cancel
Showing results for 
Search instead for 
Did you mean: 

PayPal C# API - ExecutePayment Randomly Fails

Member

PayPal C# API - ExecutePayment Randomly Fails

I am having an issue with ExecutePayment call failing randomly - this results in the payment not going through.

Here is the process flow:

  1. User Clicks to Pay via PayPal
  2. User is redirected to PayPal after creating a 'approval_url' by calling payment.Create(apiContext);
  3. User confirms with payment with PayPal and is redirected back to our site.
  4. We then process the order after validating the PaymentID passed back by PayPal matches the original PaymentID and then call 'payment.Execute(apiContext, paymentExecution);' This call also let's us update the invoice # and etc.

The issue is on some random occasions the payment.Execute() call will throw an error of "The remote server returned an error: (400) Bad Request."

When this error occurs, the payment.Execute() call never goes through which then causes the payment not to go through. but since we have already processed the order based on the initial approval and are using payment.Execute to update the order invoice#, it results in the transaction not going through but the order being processed, we then have to reverse the order.

I am wondering what are some best practice tips for dealing with this situation.

The reason I am doing the second call of payment.Execute() is it seems like that's the only way to do it, how can I have the first call finalize the payment without relying on the second call and use the second call just for updating the invoice number and description.

 

Here are some Debug ID's: 87a80d2969ede,  b7480c0696509

3 REPLIES
Moderator

Re: PayPal C# API - ExecutePayment Randomly Fails

Hi, the DebugID shows a "The instrument presented was declined by the bank". In these situations, when the card used by the buyers is declined by their own bank (for any reason we are not able to know for privacy laws), you should eventually implement a procedure in your script that handle these errors and maybe returns a message to the customer. If no errors then update the invoice # and register the order in your own integration/DB, if any error show a message to the buyer about the payment declined.

The payment with REST needs 2 steps, creation and execution. You can't complete the payment only with the first one I am afraid.

Member

Re: PayPal C# API - ExecutePayment Randomly Fails

Hi Andre,

 

Thank you for the reply.

 

We were hoping to first get the customer's approval --> process the order --> finally execute payment with updated invoice #.  But now we can't process the order until we execute the payment to make sure that it went through. Now when we execute the payment, then we can't update it anymore... What do you think we can do in this scenario? We are now avoiding putting an invoice # on the orders and just using an auto gen data. Just wanted to see how others were handling this scenario. 

Highlighted
Contributor

Re: PayPal C# API - ExecutePayment Randomly Fails

I had the same problem, 400 Bad Request.

I opened a new Question here:

https://www.paypal-community.com/t5/REST-APIs/400-Bad-Request/m-p/1649271#M1737

 

I have to ask to check the DebugIds every time in this forum?

or there is another way to check what happened for the specific case?

Why the API Calls list page does not offer any info apart from OK/Fail ?