|< Day Day Up >|
Test Instant Payment Notification (IPN) and Payment Data Transfer (PDT) in the PayPal Sandbox .
Once you've deposited money into the Personal account in your Sandbox [Hack #87] , you'll need to configure your Sandbox Business account to use either PDT or IPN (both of which are discussed at length in Chapter 7). This hack shows how to configure PDT.
As with the live PayPal site, to use PDT with the PayPal Sandbox, you must first configure some options in your Sandbox Business account Profile.
To enable Auto Return and the PDT feature, follow these steps:
See [Hack #85] for additional PDT setup instructions and tips.
Now, when sending order information to PayPal, you can do it through a URL ( GET ) or via an HTML form ( POST ). Either way, you need to tell PayPal that the payment is going to a Sandbox account. Just add the parameter test_pdt=1 (or test_ipn=1 if you are using the IPN) to the URL (or include it as a variable in your HTML form).
When the transaction is complete, the pseudobuyer will be redirected to the URL you supplied in the ReturnURL parameter, along with several transaction parameters appended to the URL, including:
Once the Sandbox has sent you this information, you can set up your IPN or PDT logic as you need without worrying about real orders and real money being transacted. The return information from PayPal won't specify that it's a Sandbox transaction, though, so if it's important to you to know this, you can append a flag to your return URL, like this:
PayPal appends its transaction information to this URL for both PDT and IPN, preserving your test parameter and thus helping you to distinguish test transactions from real ones.
-- Rob Conery and Dave Nielsen
|< Day Day Up >|