Question

i am coding a script thats needs first to verify if the payment has been made and then proceed to the registration form.. now after I integrated a payment gateway im not sure what is the best solution for the visitor to proceed to registration as a security case? using SESSIONS ? so after the payment was made successfuly, start a session that will be checked in the signup.php ? Thank you..

Was it helpful?

Solution

For paypal payments, you can use the Paypal IPN (instant payment notification) system, which signals your website as soon as the payment transaction has been successfully processed.

Basically, there is a specific server-side (i.e. PHP or asp.net) page that receives the paypal IPN message, and then can update a database or set a session variable or directly serve out files, or what have you.

See these posts for how it works:


When you have received confirmation from paypal (via IPN) that the payment went through, you can do something like this:

  • In the information sent to paypal, include data to identify the customer in your database. I usually create an encrypted item_number that includes this information. Another idea is to have a table in your database called IPN_CODES. Everytime you send a customer to paypal you can enter a bunch of information into this table (cust_id, firstname, lastname, date time, etc). As with all database tables, each entry will have a unique ID. Get that unique ID and use that as the item_number that you send to paypal.

  • When paypal sends back their IPN message, you will also receive back the item_number field, so you can de-crypt it (or look up the info in the IPN_CODES table) and parse-out the customer_id. Now you can update that customer's record in your database and mark them as paid. (Perhaps you have a boolean or INT field called is_paid)

  • When the IPN page has finished, it can end by redirecting the user to a new page (using POST or a GET string, such as http://yourdomain.com/signup.php?1273491341230346492329 - where the long number is an encoded representation of their user_id in your database.)

At the beginning of the signup.php page, you can ask for their email address, or use the GET string to check your database to confirm that this user has is_paid == 1 set.

Something like that.

If you need examples / tutorials on this type of thing, I can direct you to:

http://thenewboston.org
http://phpacademy.org

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top