Question

I'm about to integrate Paypal Express Checkout in an online food ordering system. My current view of the flow is the following:

  • SetExpressCheckout is called, and the customer is redirected to Paypal with the token.
  • Once the customer has approved the payment, he is redirected to a waiting page, while the order is being sent to the restaurant.
  • Upon reception of the restaurant response, the following happens:
    • If the order is approved, DoExpressCheckoutPayment is called and the payment is completed;
    • If the order is rejected, the payment never completes.

That makes me wonder, is it ever possible that DoExpressCheckoutPayment fails, and the funds cannot be taken for any reason? Because in my case, that would be too late to cancel the order which has already been sent to the restaurant.

Should I use PAYMENTACTION=Authorization instead, and then capture/void the authorization? As the funds can be held for 3 days, while I just need a few minutes for decision, that looks a bit overkill.

Was it helpful?

Solution

Yes, a DoExpressCheckoutPayment API call can certainly fail.
What you should do is set PAYMENTACTION=Authorization in your SetExpressCheckout and DoExpressCheckoutPayment API call, and - once the restaurant has acknowledged the order - call the DoCapture API to capture the funds from the authorization.
Funds are honoured for 3 days, and an authorization is available up to 29 days.

Also; design to fail. Keep a fallback. Just in case the DoCapture does fail. It shouldn't, but you never know. So double-check that 'PAYMENTSTATUS' is 'Completed' and 'TRANSACTIONID' is not empty in the DoCapture API response.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top