I’m setting up a payment gateway for my software product which users can buy off the web and use. I’m using paypal website payments standard to get started.
There’s a basic issue troubling me. The workflow for my user is:
Login to my product site (free license for a trial period) -> Pay to extend license
Now suppose a user – xyz@abc.com registers on my site and logs in. I then show him the buy now button (paypal’s). He clicks on it, gets redirected to paypal, pays, gets redirected back to my site. In the background, I set up paypal’s IPN feature and get notified of this transaction and its details. Now – how do I link this purchase with my user? How do I know that xyz@abc.com made the payment.
Note: I’m not using autoreturn + PDT method because of its basic flaw – if user closes browser after payment but before returning to the autoreturn page, my post payment logic never runs. Using IPN guarantees running of post payment logic but how do I link the payment with the username on my site that initiated and completed the payment?
For your user payment you create a unique ID that you send for the payment, and you get it back on IPN.
The code to use for place it on PayPal:”invoice“
Here are the codes:
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables
Look at table 4.
invoice ->
Passthrough variable you can use to identify your invoice number for this purchase.
Here is a code for IPN https://www.paypal.com/us/cgi-bin/webscr?cmd=p/pdn/ipn-codesamples-pop-outside
on the if (strResponse == “VERIFIED”){… you can get the invoice… just by reading the Request.Form[“invoice”]
Ps You can use both PDT and IPN and you can merge the results from both.