What is the best practice to handle http code 502 while creating payment

Dear Team,

We noticed sometimes payment API returned http code 502 while creating payment;
In this situation, both the customer and our application didn’t know the payment result, the customer usually thought the payment is failed, so he paid it again, it might turn out that he paid twice finally.

May I know your suggestion on how our application should handle http code 502 from payment API? we want to ensure the customer make the payment only once.

Thanks in advance.
Best Regards,

In this case you can retry the payment with the same idempotency_key. If the customer was already charged it will just return the payment response. If they weren’t charged we would then process the payment. :slight_smile:

1 Like

Hi Bryan,

Thanks for the feedback, we will improve the application based on your advice.

Meanwhile, we are interested in the cause of the http code 502, we understood that it’s the standard code for something abnormal in API proxy, but could we know the the root cause of it? such as, whether it was caused by API QPS limitation, etc.

Below are two of the payments with this issue, if any other info is required, please let us know.

Thanks in advance.

  • Feb 15th, Payment ID: X3WgOJcJhJTKmsQnQG4DRRXydvXZY

  • Feb 22nd, Payment ID: lwnC17tnr5H0izu6libNcc1ShfCZY

I took a look at your API logs and I don’t see any 5xx errors being returned from Square for those payments. :slight_smile:

I checked API log just now, I can’t find 5xx errors neither, but I can’t find the log for the two payments as well, did you find them? in that case, could you please share the timestamp of the API request in the API log?

No, I didn’t find the logs. :slight_smile:

but the payments exist if you query them in DB or through API explorer, right?

Yes, these are successful payments that have been refunded. :slight_smile: