Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 6556 |  Welcome, Guest!   Register  Login
Home > Articles > ASP.NET > Online Payments Using PayPal- Integration with ASP.NET

Online Payments Using PayPal- Integration with ASP.NET

11 vote(s)
Rating: 4.82 out of 5
Article posted by BangaruBabu on 6/22/2010 | Views: 25144 | Category: ASP.NET | Level: Beginner red flag


Abstarct: In this article I am going to explain Step by Step Procedure, about integrating PayPal account with asp.net.
Case Study: If any of the web application need to collect money from their customers, the best and ideal solution is to open a Paypal Merchant account by using valid email id and respective Credit card which belongs to their individual accounts.
PayPal is an e-commerce business which allows payments and money transfers via Internet. It is an alternative to traditional paper methods such as checks and money orders

Download


 Download source code for Online Payments Using PayPal- Integration with ASP.NET


Abstarct: In this article I am going to explain Step by Step Procedure, about integrating PayPal account with asp.net.

Case Study: If any of the web application need to collect money from their customers, the best and ideal solution is to open a Paypal Merchant account by using valid email id and respective Credit card which belongs to their individual accounts.

PayPal is an e-commerce business which allows payments and money transfers via Internet. It is an alternative to traditional paper methods such as checks and money orders.

Here I don’t want to give more explanation on Paypal accounting standards and money transfers, why because it is a self explanatory resource which is available @ www.paypal.com for more information.

Even we can integrate any web application not only PayPal, we had also third party vendors like CCAvenue (http://www.ccavenue.com/), PayByWeb (http://www.paybyweb.com/), ABC Payments (http://www.abcpayments.com/),EBS(www.ebs.in),Web link India (www.weblinkindia.net),Times Of Money(http://www.timesofmoney.com/direcpay/jsp/home.jsp) ,Pro Pay(www.propay.com) ,World Pay (www.worldpay.com) ,Data Cash(www.datcash.com).e.t.c. But in my real application I used PayPal API for receiving Money from Customers.

Hands on Experiment:

In this  experiment I will give total explanation and step by step procedure about integrating Paypal to asp.net website –which I did in my initial stages of development career. At that time the word online payments hampers my Head Like anything, after a long research on Google and Paypal website-I decided my self, we can integrate Paypal just like a kids Play.

 Steps to integrate Paypal API to ASP.NET:

Step-1) Create Paypal Merchant Account @ www.paypal.com using valid Mail Account

Step-2) Provide Debit or Credit Card No and Its Type.

Step-3) Develop ASP.NET Page According To Your Requirement

Step-4) Integrate API by Passing Website Variables as a Input to PayPal Account Using our Mail Account writing customized Business logic

 

Step-1) Create Paypal Merchant Account @ www.paypal.com using valid Mail Account :

Open www.payapal.com and register with valid Credentials as depicted below, here I used bangarubau.p@gmail.com mail account for receiving amounts, keep remember that this id will use full @ the time of integrating api with Business logic and registered with Business name as BangaruBabu’s Digital Shoppy. When the time I redirected from ASP.NET Page to PayPal Account Business Name will be displayed @ the top of the Paypal web page by using Mail Account I created.



After creating Account, the account internals will be created to Individual



In The above screen @ right hand side in Notifications option, I marked as red circle, in that link provide bank credit and debit card numbers. Left hand side Green Circle indicates money payments and Receivables information was provided. Black Color circle link indicates account status Verification option.

 Step-2) Provide Debit or Credit Card No and Its Type

 

Step-3) Develop ASP.NET Page According To Requirement

I considered online shopping Scenario by displaying electronic Gadgets on Asp.Net Web Page. In this Step I designed a Page by Using Three Images (Xbox, Bluetooth Headset,) three Labels to display the Currency on Web Page to the respective Electronic Gadgets and three Image Buttons.


Step-4) Integrate API by Passing Website Variables as an Input to PayPal Account using our Mail Account writing customized Business logic.

Before going to write Business logic we just discuss Paypal API Link and its Parameters

Paypal API

https://www.paypal.com/cgi-bin/webscr?cmd=_cart&business=mailid@server.com&businessname &item_name=Welcome Back&amount=10&currency=USD&add=5

 

The above mentioned URL is a Constructive link to get the values from the website to Paypal Gateway. In the URL bold Letters indicates predefined parameters .Following are the some of the Parameter values and their descriptions




Now add Class [RedirectToPaypal.cs] File in App_Code Folder. Write One Static Method by taking only two [as per as your requirement you can take n-no of parameters to the function with predefined variable names mentioned in the above table] dynamic parameters. Here I am using single item Transaction for Shopping Scenario. Write Method as Follows in C# Language to construct a link.

public static string  getItemNameAndCost(string itemName, string itemCost)


    {

        //Converting String Money Value Into Decimal



       decimal price = Convert.ToDecimal(itemCost);



        //declaring empty String



       string returnURL = "";



       returnURL +="https://www.paypal.com/xclick/business=bangarubabu.p@gmail.com";



        //PassingItem Name as dynamic



       returnURL +="&item_name="+itemName;



        //AssigningName as Statically to Parameter



       returnURL += "&first_name"+ "Raghunadh Babu";



       //AssigningCity as Statically to Parameter



       returnURL += "&city"+ "Hyderabad";



       //Assigning State as Statically to Parameter



       returnURL += "&state"+ "Andhra Pradesh";



       //Assigning Country as Statically to Parameter



       returnURL += "&country" + "India";



        //Passing Amount as Dynamic



       returnURL += "&amount=" + price;



       //Passing Currency as your



       returnURL += "&currency=USD";



       //retturn Url if Customer wants To return to Previous Page



       returnURL += "&return=http://bangarubabupureti.spaces.live.com";



       //retturn Url if Customer Wants To Cancel the Transaction



       returnURL += "&cancel_return=http://bangarubabupureti.spaces.live.com";



       return returnURL;



    }



 



Write Code Under Image Butons



protected void ImageButton1_Click(object sender, ImageClickEventArgs e)



    {



        string iName="XBox";



        string responseURL = RedirectToPaypal.getItemNameAndCost(iName,
lblxbox.Text);





        Response.Redirect(responseURL);      



    }



    protected void ImageButton4_Click(object sender, ImageClickEventArgs e)

  {



        string iName = "Philips Mobile";



        string responseURL = RedirectToPaypal.getItemNameAndCost(iName,
lblphone.Text);



        Response.Redirect(responseURL);


     }



    protected void ImageButton5_Click(object sender, ImageClickEventArgs e)


    {

        string iName = "BlueTooth HeadSet";


        string responseURL = RedirectToPaypal.getItemNameAndCost(iName,

lblbluetooth.Text);





        Response.Redirect(responseURL);     



    }

Now run and Click On shop Now Paypal Button under Xbox, it will automatically Redirects to Paypal Web Site with your given input, the customer will pay according to your Specifications in the Website


Here I used only _xclick command, if you want to add shopping cart or donations or subscriptions, you can customize application according to your requirement.

 

My Reference:

http://www.payapal.com

 

Conclusion:

In this article I covered all the aspects of the online Payment using PAYPAL gateway except Shopping Cart, even it is very easy. For more information check http://www.payapal.com.

I hope this article definitely helps.


If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

Experience:3 year(s)
Home page:http://bangarubabupureti.spaces.live.com
Member since:Wednesday, May 12, 2010
Level:Starter
Status: [Member]
Biography:Microsoft Technology Enthusiast
 Responses
Posted by: Parasu | Posted on: 24 Jun 2010 02:39:57 AM

Babu,

Excellent article, but im not able to view the images that you added in this article.

Posted by: Kullayappa | Posted on: 24 Jun 2010 04:43:34 AM

Its very clear to understand for beginners and the way u have presented is good

Posted by: Kullayappa | Posted on: 24 Jun 2010 04:48:32 AM

Good

Posted by: Vuyiswamb | Posted on: 25 Jun 2010 07:15:01 PM

Very nice Article with good info on it. but you did not show all the info. A newbie can follow article. give your readers more , screenshots and namespaces to use. but it is a good article after all. Keep up the good work.

Thank you for posting at dotnetfunda

Vuyiswa Maseko

Posted by: Akiii | Posted on: 12 Aug 2011 03:29:05 AM | Points: 25

good article...
keep posting..

Thanks and Regards
Akiii

Posted by: Hareesh | Posted on: 17 Feb 2012 05:58:25 AM | Points: 25

hi
Really very good article. you give a very good example with paypal


thanks®ards
Hareesh.A

Posted by: Prasuna | Posted on: 21 Apr 2012 03:39:37 AM | Points: 25

Hi,

Thank you for posting this article..its nice., but the thing here is if we get the error how come it should be displayed in our website. i mean to say is if the cardno is not valid or if the user is not genuine and will they reply us the result for cancelling the transaction. ie., why it is cancelled, the reason in query string will be passed to our url. here returncancel is for what exactly..

If you provide us the possibilities of error regarding payment.. with coding..it will be better to understand.

Thanks in advance.

Posted by: Arshesander | Posted on: 25 Apr 2012 05:48:57 AM | Points: 25

hello, can anybody show how to put the logo of business in paying paypal?

>> Write Response - Respond to this post and get points
Related Posts

To generate Edit, Delete, Update and Select buttons automatically in the GridView, we can follow this approach.

This is my first article on asp.net and I will try to explain the basics of asp.net page life cycle and easy understanding of its usage. Page life cycle depends on whether it is requested for the first time or it is after postback(page request of itself) and finalize to the web server. When a web page is requested to web server, it goes through a series of sequence of steps/events (like initialization, instantiating controls, restoring and maintaining state, running event handler code, and rendering) before it returned back to the web browser.

This article will compare four important architecture presentation patterns i.e. MVP(SC),MVP(PV),PM,MVVM and MVC. Many developers are confused around what is the difference between these patterns and when should we use what. This article will first kick start with a background and explain different types of presentation patterns. We will then move ahead discussing about the state , logic and synchronization issues. Finally we will go in detail of each pattern and conclude how they differ from each other.

In this article, I am going to describe how to send email with attachment in ASP.NET. I am going to use System.IO, System.Net and System.Net.Mail namespaces in this article.

In scenario where a page has multiple buttons and the need is to avoid validation on clicking of certain button, we can follow this approach.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2012 8:12:59 AM