Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you connect a Paypal IPN confirmation to a user?

I wanted to use Paypal's IPN service to verify payments for a recurring subscription charge for my website. How do you tie the IPN confirmations to a user in your site?

The IPN confirmation message has a name, email, paypal ID, recurring payment ID, but it seems to not give a unique identifier since I don't know where the paypal ID or recurring payment id comes from and it may not be trivial to uniquely match up the name/email that a user has on their paypal account (or entered there) with the name/email I have for them on my site (there may be many John Smith's and the person may choose to use a different email.)

1) When I send the initial payment request to Paypal, I can attach a unique UUID in the URL I ask them to send back to me, so if I save that unique ID for that user I can match that payment confirmation to the user who initiated it. Am I making that harder than it is? Is there an easier way?

2) Also, for a recurring/subscription charge, does paypal always use the URL I specified with the initial payment initiation? Does anyone have practical experience using the recurring Paypal payments with IPN's, does it reuse that unique URL? Or do I have to associate the Paypal ID's with the user after the first recurring payment is received?

like image 546
MikeN Avatar asked Feb 19 '09 21:02

MikeN


2 Answers

Attaching unique data to the payment request is pretty much the accepted way to do it.

I don't have any experience with recurring charges.

like image 136
greyfade Avatar answered Oct 08 '22 11:10

greyfade


I recently also set up some reoccurring payments with Paypal.

I actually wanted people to register as members after paying for the subscription, if they wanted to. As having to sign up as a member could add some friction to the sale process. So I don't send any user info along with the Subscribe button.

What my IPN script does is generate a unique activation code tied to the Paypal subscriptionID in the Activations table, then it sends this code to whoever paid for the subscription, with instructions on how to activate.

At the point of activation, you need to register or login. At this point the userID is added to the relevant row in the Activations table.

When the EndOfTerm IPN notification comes in the IPN script looks up the userID from the Activations table based on the SubscriberID given in the IPN. Then I can do whatever I need to do to that user to disable their subscription.

At all time the URL of the IPN script remains the same.

like image 38
Iain M Norman Avatar answered Oct 08 '22 13:10

Iain M Norman