3

I am trying to integrate Paypal with one of the registration forms in my site. The flow is like this:

  1. The user visits the registration page and fills out his details, like first name, last name, username, password, age, etc.
  2. Then on clicking submit button, he navigates to the paypal site, pays some amount like 5$ and after successful payment, returns back to my site.
  3. The registration is not yet complete. I want to check whether the payment is successful or not, and if it is successful, then i have to insert the user data (filled prior to submitting the registration form) into the database.

Now my question is, how can i keep track of user data filled in the form and sent to paypal? What is my best bet?

  1. Should i use any custom hidden fields in the form to store these form values, and if so, is there any size limit?
  2. Should i store the entire form data in a session, and after succesful payment, use this session data to insert into db?

Or is there any other way of doing it?

I just want to get back all the form values after a successful payment, and only then, i can insert them into the database. I prefer sandbox testing prior to using real paypal.

shasi kanth
  • 6,987
  • 24
  • 106
  • 158

1 Answers1

3

I suggest making a registration without instant payment, but making their account inactive. This way you will get user id and put it in the custom field. Uppon a successful payment, activate user's account. Here is an example of the IPN script. https://cms.paypal.com/cms_content/US/en_US/files/developer/IPN_PHP_41.txt

You will need a business account for this to work.

  • Good idea... but this probably requires an admin panel work for my site. The admin has to manually activate the users. – shasi kanth Sep 04 '11 at 18:15
  • 1
    No, users would be activated autmatically upon payment, check this out https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro – Laurynas Tretjakovas Sep 04 '11 at 18:17
  • Can i use sandbox environment with paypal IPN? Any useful links are appreciated. – shasi kanth Sep 05 '11 at 02:58
  • You can use sandbox for testing whether your script works or not https://www.paypal.com/cgi-bin/webscr?cmd=p/sell/ipn-test-outside – Laurynas Tretjakovas Sep 05 '11 at 04:21
  • I have tested with the sandbox. But when i set the Auto Return to ON in the website payment preferences, i am not receiving any post data with IPN. In the log, i see the error as: IPN Validation Failed – shasi kanth Sep 05 '11 at 07:49
  • 1
    try using this https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNTesting to find the problem – Laurynas Tretjakovas Sep 06 '11 at 05:18
  • Well, i finally settled with PDT (Payment Data Transfer) and disabled IPN. This way, i am getting back the custom data (in cm parameter) to my return url and also i am verifying the transaction id with paypal for security. – shasi kanth Sep 07 '11 at 04:42