Reputation: 35734
The paypal adaptive payments flow for end user is a little bit odd.
Instead of working like the paypal express flow such like:
It goes like: 1. User goes through checkout process 2. User goes to paypal and payment must be taken while they are on paypal site 3. IPN gets sent to site to confirm success or failure
This is very important flaw because now there is a chance of end user not returning to site with failed payment or even worse, the end user might return to the site before the ipn is received. In which case, should the basket be emptied or not? This opens up lots of potential issues.
How can this be solved?
Upvotes: 0
Views: 267
Reputation: 902
To solve your problem once you configure the URL parameters (as mentioned below),
1) When the user returns the returnUrl endpoint, you make a call for the PaymentDetails API and check the status and proceed. 2) To handle the corner case where the user might have paid but didn't return to your site await the IPN message to proceed with your order shipment etc., 3) If the user cancels a payment they will be taken the cancelUrl endpoint and you can handle the flow accordingly 4) In case of errors (like limit exceeded, currency not supported etc.,) the Pay operation will actually throw an error and you will be able to handle this as part of the error / exception catch flow.
Please use the following parameters when making the API call
returnUrl The URL to which the sender’s browser is redirected after approving a payment on paypal.com cancelUrl The URL to which the sender’s browser is redirected if the sender cancels the approval for a payment on paypal.com. ipnNotificationUrl The URL to which all IPN messages for this payment are sent
If you are using the SDK then suggest look at the samples that are bundled as part of it.
https://www.x.com/developers/paypal/documentation-tools/paypal-sdk-index
Upvotes: 1