Simple Paypal IPN examples?

dot picture dot · Mar 25, 2009 · Viewed 34.6k times · Source

I would like to have a text input form with a submit button that goes to paypal, upon payment the contents of the form should go in a mysql database..

This sounds trivial, but I'm having such a hard time with paypal's IPN.

Can anyone point in me in the right direction?

Thanks!

Answer

Mr. Shiny and New 安宇 picture Mr. Shiny and New 安宇 · Mar 25, 2009

PayPal has some sample code on their website. However the bigger problem you'll face is that the user will probably want a real-time response. This is usually done by processing the PDT data that is submitted to your site when the user clicks the link to return to your site. At some point later PayPal will post to your IPN url similar data. You need to avoid processing the data twice.

Also the data in question is only PayPal's data about the transaction. It does not contain arbitrary data. You should probably record the customer's order before sending them to paypal, or else look for a pass-through variable. For example, when creating a billing agreement, there is a variable called custom which is passed back to you as you created it. You can store an order id or whatever you want in that variable. Be careful to validate its contents to make sure it's still correct for the transaction details.