Sunday, July 5, 2009

User Registration with PayPal

There has been a lot written about how to handle the IPN return from PayPal so I will not go too deeply into that process, but it seems that there has not been too much written about the initial call to PayPal and that is where I will focus.

This article summarizes how to perform a user registration process which requires payment and how to integrate that with PayPal. This sort of process would exist for instance on a web form where you want to charge for registration.

The problem I set out to solve was to create a web site where I charged some nominal fee for registration. I chose to use PayPal b/c everything had already been set up for you and I did not want to have to worry about ssl and handling credit card information. I understood how to handle things once the PayPal transaction was completed, but I could not figure out how to have a user register, do some database processing, and then if there were some problems with the registration process prevent the user from being forwarded onto PayPal and instead display an error on the registration form such as "Duplicate Email Address" or "UserName already exists". These sorts of scenarios would first require a user to correct them and only after they corrected them, to then be forwarded onto PayPal to pay for the registration.

I first tried downloading the PayPal SDK and using the BuyNowButton. It is an excellent SDK and I was very happy with it, but I could not solve the problem I set out to solve. I tried overloading the OnClick event in my own form, but no matter what it would always forward the user onto PayPal. This is not what I wanted to do. So I took a look at what they were doing and used the same concept for my needs.


The basic premise here is the following:

  1. User comes to the Register.aspx page
  2. User completes form and clicks Submit
  3. The system then performs the relevant checks to ensure that this user has a unique username and email address
  4. if the above condition is true, then forward onto PayPal, if not, then display a message to the user and allow them to correct.

The concept consists of 2 files:

  1. Register.aspx
  2. BuyNow.htm

Register.aspx


See full detail: http://www.c-sharpcorner.com/UploadFile/rogersmith/PayPalRegistration11272005230805PM/PayPalRegistration.aspx

No comments: