Users closing browser so OnApprove not firing…

MrGoldblum
Contributor
Contributor
I’m using the standard PayPal JavaScript button. This is working fine most of the time. Is there any callback to call a php page if the “onApprove” does not get to fire? Some of our buyers seem to close their browser before completing or something. So we are taking peoples money (in PayPal) - but without the OnApprove function - we aren’t getting to add their details to our DB. Thanks for any help.
Login to Me Too
1 REPLY 1

lgcorreia
New Community Member

I'm in the same situation and with the current docs I haven't figured out the proper way to handle this.
One solution would be to use webhooks, this is nodejs but it explains the gist of it https://riptutorial.com/paypal/example/1867/testing-sandbox-webhooks-with-ngrok-and-express--node-
Problem is, webhooks response time seems to be random, can be instantaneous or take hours.
So my current solution would be to continue using onApprove for when the customer stays with the window open and use the webhook as a backup to update the db in case the onApprove wasn't triggered. This might be a bit troublesome as well since it might raise a race condition between the onApprove and webhook if they're triggered at the same time.
I don't know if this is the only solution to this problem and the docs are so unorganised and outdated that I can't understand what the proper course of action should be.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.