PHP Paypal Auth/Capture NVP Integration Troubles PHP Paypal Auth/Capture NVP Integration Troubles curl curl

PHP Paypal Auth/Capture NVP Integration Troubles


you need to learn about ignore_user_abort(true); (and possibly set_time_limit(0);), use that to avoid the problem of scripts exiting half-way through the code. second, may i suggest a database of recently confirmed tokens that is updated BEFORE the curl call, so that if a user quits, then try to press "confirm" again, you'll know it's already a confirmed token, and don't re-run the curl code, and can immediately inform the user? -- http://php.net/manual/en/function.ignore-user-abort.php

  • AND WARNING, SOME SHARED HOSTING PROVIDES DOES NOT ALLOW ignore_user_abort / set_time_limit TO BE MODIFIED AT RUNTIME


Note: Not all payments will be instant. If the buyer only has a bank account associated with their PayPal account, the transfer wont be instant. Therefore it is best practice to use IPN if want automatic notifications of all payments and related activities.

According to PayPal Official Docs:

Instant Payment Notification (IPN) is a message service that notifies you of events related to PayPal transactions. You can use IPN messages to automate back-office and administrative functions, such as fulfilling orders, tracking customers, or providing status and other transaction-related information.

As best practice set transactional script in your IPN Listener. For the integration guide you can refer here : https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNImplementation/

I have extended a PHP class for PayPal IPN Listener few months backs. Hope it may help as starting point. Feel free to fork :https://github.com/datumradix/PayPal-IPN-PHP-Class-

Edit: (PayPal Documentation is not clear at many places and seems confusing to many first time readers)

IPN can come handy as secondary mechanism to confirm if the DoCapture was successful. IPN variables like txn_type, txn_id,auth_id, auth_amount and payer_id are all notified thro IPN. Please ref here for full list: https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/

Note: We can either specify the NOTIFYURL in each call or we can setup the same from paypal back-end. For steps to setup the same from PayPal profile settings, ref :https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNSetup/