New to the community? Welcome! Please read our Community Rules and Guidelines
We implemented payment via PayPal some time ago, it works fine, but sometimes it takes too long (2+ hours) to confirm payment (and so process the order). I want to make sure we are doing it right and there is no faster way to do this.
Here are the steps in our implementation:
- user choses to pay via PayPal
- we send request to PayPal API to create order, and if success - send user to PayPal checkout pages
- after payment is done, user returned by return URL to our website
- here we send request to PayPal API to capture the order (and set state on our side to `paid, not confirmed`)
- then we also have webhook listener that listens to:
The main questions is: are we doing it right, should we wait first for `CHECKOUT.ORDER.APPROVED` and then for `PAYMENT.CAPTURE.COMPLETED` to be sure that payment was completed, or we can confirm payment on our side right away when one of those are received?
Or maybe we can rely on some other notification instead of `PAYMENT.CAPTURE.COMPLETED`, that can be received faster, and guarantee that payment completed and money will be received?
Thanks for the question! In this case, you are using the correct webhook in `PAYMENT.CAPTURE.COMPLETED'. This is the one webhook that tells you whether or not the payment has been completely captured.
While this is a reliable webhook, it may not be sent as quickly as the response you may get for the capture. If you are doing this capture, then you can check the status in the response. If it says "completed", no need to wait for the webhook as the payment capture completed right away. That can be one way to expedite instead of waiting for the webhook.
Hope that helps!
@MTS-Aaron , thanks for your response.
So when user returned by return URL from PayPal to our website, we can send capture request, and if response is COMPLETED, we can confirm payment right away?
But does it also mean that when we receive CHECKOUT.ORDER.APPROVED notification with status APPROVED , we also can make capture request, and if response status is COMPLETED then we can confirm payment as well (not waiting forPAYMENT.CAPTURE.COMPLETED)? I'm specifying this, because sometimes users pay and don't return to our website, then we rely on notifications to proceed with payment confirmation.
If I'm understanding your question correctly, you are right that when you see that COMPLETED webhook, the captured funds have completed movement from the buyer to the seller.
Additionally, if you receive the Checkout.Order.Approved webhook with status Approved, you can definitely also make that capture request if the customer didn't get redirected back to your site automatically.
I hope that helps!
Hi @MTS-Aaron ,
thanks for your answer again.
Sorry for more questions, but I want specify and summarise once again if I understand all this correctly:
1. If user returned to our website after payment by return URL, at this point we can make capture request, and if received response status is COMPLETED, we can confirm payment on our side, and no need to wait on any notifications.
2. If we receive PAYMENT.CAPTURE.COMPLETED notification with status COMPLETED, it means that we can for sure confirm payment on our side.
3. If we receive CHECKOUT.ORDER.APPROVED notification, with status APPROVED, we can do the same as in p. 1 - make checkout request and if response status is COMPLETED - confirm payment. And question - is it ok to make capture request on each CHECKOUT.ORDER.APPROVED notification with APPROVED status?
4. What if we receive CHECKOUT.ORDER.APPROVED notification (so same as in p.3), but with status COMPLETED? Does it also mean that we can confirm payment right away, w/o making capture request (that we do in p.3, when status is APPROVED)? Or we still should make capture request in this case?
And if you have some link to documentation that explains this, please share.
Happy to help with this!
Here are the docs I was able to find on this, but they don't outline your specific corner cases/inquiries.
I hope that helps!