Sunday, January 27, 2008

Internet payment services for .NET applications

You have put lots and lots of effort to bring your application online. Then comes the main picture, let us collect some money through your application/site. A number of companies and websites do the processing through internet payment services like






Let us see how we can integrate paypal (which is used more comparatively to other inernet payment services) into our application. The visitor, instead of paying the client directly, pays PayPal using credit card or bank account. The client then uses its PayPal account to get the money received from the customers.

Creating a new PayPal account is free, the fees involved when receiving money can be checked at Display Fees

PayPal Links & Resources:

Website Payments Standard Integration Guide

PayPal Developer Network

PayPal Developers - Forum

Creating PayPal Account:

1. Go to PayPal
2. Click Sign Up link.
3. PayPal supports 3 types of account: Personal, Premier and Business account. Choose your country from the pull down menu, and click Continue.
4. Fill in all the requested information and you'll get an email to confirm the details you have entered from PayPal.

Integrating PayPal and Application:

1. To accept payments we need to include 2 elements to the user interface part of the site.
2. Add to Cart buttons for each product and a View Cart button on the page.
3. For example we have a product Ultimate Doll with cost of $16:

PS: your_email_address - Should the registeration email ID of your PayPal account.

4. The View Cart button:

Open your main page (master page - may be Main.Master) in source view and add the following javascript function under head element.

5. In the Main.Master where you have Search, Reset (buttons for products), just add the below code below the Search button.

6. Next to add PayPal Add to Cart in Product.aspx:

7. Add these below code under PopulateControls method in Product.aspx.cs

//Create the "Add to Cart" PayPal link

string link="JavaScript: OpenPayPalWindow(\""
+ "?cmd=_cart " + //open shopping cart command
"&" + //your PayPal account
"&item_name=" + pd.Name + //product name
"&amount=" + String.Format("{0:0.00}", pd.Price) + // product price
"¤cy=USD" + //currency
"&add=1" + //quantity to add to the shopping cart
"&" + //return address
"&\")"; //cancel return address)

//Encode link characters to be included in HTML file
string encodedLink= Server.HtmlEncode(link);
// Then link to the HTML Server control add to cart image
addToCartLink.HRef= encodedLink;

PS: Be sure with the email id, as that should be correct in order to get money into your account.

Hope the above few lines definitely are, an initiative for including internet payment services in our .NET applications.


Aarthi said...

Grt info karthick..I have no coding knowledge..learning slowly...hope you dont remove this that anytime i want I can come back and refer here...:)

Karthick said...

Aarthi: Sure and thanks for your comment :)

Aarthi said...

Hey I have tagged u...and hav a surprise award for u too...take it up..:)

Karthick said...

Aarthi: Whats that award? Couldn't find in your blog?