Reputation: 333
I'm using IPN from paypal to get information about transactions based on reference transaction id. The first time we try to create a paypal account for the customer after redirected from paypal dialog, it looks like ipn tooks couple of minutes to gave us the results we needed. Also for recurring payments based on reference transaction id, it tooks a couple of minutes up to hours until the payment gets confirmed by ipn.
We use angular in frontend and the verification process is completed. But the ipn notification in our django backend will be received after a few minutes which is way too long.
For the ux it is very bad and other websites also handle this in a few seconds. Is it only because of sandbox?
greetings and thanks for help
Upvotes: 0
Views: 235
Reputation: 30359
IPN is a very old, asynchronous technology. There is no latency guarantee, and no reason to be relying on IPN notifications with current PayPal Checkout integrations.
Instead, follow the PayPal Checkout integration guide and make 2 routes on your server, one for 'Create Order' and one for 'Capture Order' (see the optional step 5 in 'Add and modify the code'). Both of these routes should return only JSON data (no HTML or text). Inside the 2nd route, when the capture API is successful you should store its resulting payment details in your database (particularly purchase_units[0].payments.captures[0].id
, which is the PayPal transaction ID) and perform any necessary business logic (such as sending confirmation emails or reserving product) immediately before forwarding your return JSON to the frontend caller.
Pair those 2 routes with the frontend approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
Upvotes: 1