bar1024
bar1024

Reputation: 231

PHP/MySQL PayPal IPN with multiple custom variables

Am I correct in my understanding that I can only pass-through one custom variable from a form I create to PayPal using IPN?

I have my IPN script up and running with no issues. However, upon payment notification I need to store information input by the user from a form on my site into a MySQL database.

In this specific case its for a sports league registration form. The user fills out info regarding their team (i.e. Team name, League, ect..) then pays the league fee via PayPal. Upon verification I'd like to store their team name, the league they're signing up for and other info I need to collect in my database. But since I can only pass-through one custom variable from my form through the PayPal IPN process, I'm a bit stumped.

I've read other posts about storing the info immediately in the database, then marking it 'paid' upon verification. However, how could I accomplish this since when the user clicks Pay Now, the form action performed is the PayPal payment process (as opposed to an insert statement I create). Where would I perform a database INSERT with the posted form information?

Tips or advice would be appreciated!

Upvotes: 1

Views: 766

Answers (1)

Pekka
Pekka

Reputation: 449783

However, how could I accomplish this since when the user clicks Pay Now, the form action performed is the PayPal payment process (as opposed to an insert statement I create). Where would I perform a database INSERT with the posted form information?

Perform the INSERT before sending the customer to PayPal. Before that, define a unique random key for the transaction. Put that key

  1. into the database record that's being inserted and
  2. pass it to PayPal's IPN.

Once notification comes back from PayPal, you can use the key to identify the record (with all the info already in it) and mark it paid.

Upvotes: 1

Related Questions