Simplest PayPal Integration with asp.net in 5 steps

Hello friends,
In Today’ Scenario PayPal is well known name, so its not need any introduction.
I know after reading title you are excited to know how to integrate PayPal in your website. First thing I declare here there different technique, different ways of using PayPal so it’s up to you what way you like to integrate. I am using here with simplest way. Just follows the steps.
Step 1: PayPal provide lot of thing for developer to integrate PayPal in developer web site. Here our first step is to create a developer account on PayPal so we can test it.
For that just login on PayPal Site  https://developer.paypal.com

Just create your account over here create a buyer and seller account for testing.
PayPal provide Sandbox site for testing.

A buyer account use for buy something from your site (On Sandbox)
And Seller account use for Sell Something to your buyers on your site means your shops account (for testing on Sandbox)

Step 2:- Once you have done with creating Sandbox work then here we take a task suppose I am a bike seller and I am selling bikes online then I have following page to show bikes
From here user can buy any bike on my site.
And he can do payment by paypal. For this we used PayPal image which you can get by https://www.paypal.com/en_US/i/btn/x-click-but01.gif
You can find much option as your requirement.

product

Here we did code for each image button for this I have made a session which keep bike information with name, price and description.

Public Class pub_clsCommon
Public Const _strBikeSession As String = “BIKESESSION”
End Class
_
Public Class pub_clsBikeInfo
Public lngId As Integer
Public strBikeName As String
Public strBikePrice As Decimal
Public strBikeDescription As String
End Class

Step 3:-
On button click we fill this session as shown below.
Private Sub imgBike5_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgBike5.Click
Try
clsSession = New pub_clsBikeInfo
clsSession.lngId = 5
clsSession.strBikeName = “Harley Davidson Model#005”
clsSession.strBikePrice = Me.lblPrice5.Text
clsSession.strBikeDescription = Me.lblDescription5.Text
Session(pub_clsCommon._strBikeSession) = clsSession
Response.Redirect(“PayPalIntegration.aspx”)
Catch ex As Exception
Throw ex
End Try
End Sub ‘imgBike5_Click

Once this done we go for Second page which is PayPalIntegration.aspx.
Step4:-The payPalIntegration.aspx is the main page from this page we interact with PayPal.
On this form we are using Action =”https://www.sandbox.paypal.com/cgi-bin/webscr”

which is basically paypal sandbox address and it’s for testing basically.

We have to send some require fields which are necessary for PayPal as hidden variables.
These hidden fields are like
1) Business: – in this yours PayPal business id save like “xyz@xyz.com”
2)cmd :- in this we put value “_cart”
3)Currency_code:- like USD Or other
4)Item_Name_N :- Where n is Item number sequence like 1,2,3. This will keep Item Name
5)Item_description_N :- where n is the item number Sequence like 1,2,3.This will keep Item Description
6)Amount_N :- Where n is the item number Sequence like 1,2,3. This will keep item amount
Similarly we can assign shipping, notes and other variables if required.

Step 5:- once we done with this fields we just post this form after updating item description, name, and amount as our need.
In this way we can use paypal integration in simplest manner.

You can see test code at http://indiandotnetWithPayPalIntegration.tk

and also download code from
https://skydrive.live.com/embed?cid=1EDA2012469FF8AD&resid=1EDA2012469FF8AD%21244&authkey=ALELSIiAsy9lJiQ
For more detail you can visit  https://developer.paypal.com

I hope you understand the basic. I will come up with further operation in coming up session till then
Thanks a lot
Enjoy coding
Enjoy programming 🙂

Yours truly, Host
Rajat Jaiswal

49 thoughts on “Simplest PayPal Integration with asp.net in 5 steps

  1. hi,
    i have read the article and i felt very much convinced to understand what Mr. Rajat Jaiswal tried to explain. But I actually want to know how paypal Transfer our money to our bank account?? of course i know all that to add bank acc, and than withdraw money.. etc.. i m interested to know is there any third party which will perform this kind of money transfers… ?

    Thanks,
    Madhu L. Chande

  2. Nice article Rajat….I have a query on this….how to connect the payment record in PayPal and the customer record in the ASP .NET app’s DB?

    Thanks

    Sandeep

  3. sir , i need c# code can u send me on my id
    ————————————————-thanks

  4. Sir, I require the C# code of this particular explanation. Will it b feasible for u to send it in my email id plz?

  5. Sir ,Could you tell me how can we get the confirmation from paypal sandbox that transaction we made is successful and can we get transaction id & necessary detail if possible on our asp.net website page?Pls do help.I’m gonna to integrate paypal.

    Thanks in Advance Sir

  6. Hi,
    I am prabhu from Banagalore.I need to integrate payapal in my site for receiving money from customers using dotnet. Here i have some doubts.
    1.Is it possible to do receive money from customer without navigationg to paypal site?
    2.Is it compulsory to customer have a paypal account?
    3.How to do Recurring paypal services?
    I think you can help me.

    1. Hi Prabhu,
      Happy morning.
      here is your doubt solution.
      1) Yes it is possible for this you have to use express checkout APIs provided by Paypal
      2) No Customer can make payment via credit card also.
      3) there is API helpbook provided by paypal.

      if you have any other doubt feel free to contact.

      Thanks
      Rajat Jaiswal

  7. Hi Rajat great work you are the correct person who clear my doughs.am developing a website we have payment gateway i want to keep track of payment details and also want to give discount to the customer based on the discount voucher and coupons hope you will help me my frontend is asp.net and back end sql server 2005 .thanks in advance

  8. How to connect this hidden variables to paypal 1) Business: – in this yours PayPal business id save like “xyz@xyz.com”
    2)cmd :- in this we put value “_cart”
    3)Currency_code:- like USD Or other
    4)Item_Name_N :- Where n is Item number sequence like 1,2,3. This will keep Item Name
    5)Item_description_N :- where n is the item number Sequence like 1,2,3.This will keep Item Description
    6)Amount_N :- Where n is the item number Sequence like 1,2,3. This will keep item amount
    Similarly we can assign shipping, notes and other variables if required.

  9. Hi Rajat,

    I implemented ur code.when i click on paypal button it is redirecting to paypal sandbox site.Then i am logging with my sandbox account.and then i entered my buyer account.Now when i click on send money tab.The email filed is empty.How can i populate the emaild field with seller maild id? it is must .right?

  10. hello sir, nice post with good explanation
    but how do i interate my cart items with paypal(as in a cart there is more then 1 item).
    waiting for reply sir.

    as i am begginer to asp.net

    thank you in advance.

  11. hi rajat !!!
    nice post i have successfully integrated website standard payment services with my website which is a recurring payment procedure. but it is not possible for subscription payments to use credit or debit card without having a paypal account..

    as per client requirement now we are needed to move on to website payment pro integration.
    i m new to this and know nothing abt it. i hv tried to go through devoloper guide but all the information was smoky . i am a .net devoloper . plz help

  12. Please can you send me the code?
    I tried the link above to your skydrive
    but for somereason i cannotdownload the file:-(

    Thank You

  13. Nice article i need help to integrate recurring payment in paypal with asp.net. I have used cmd=_s-xclick&business and also set perameter like P3,T3 and A3 but its showing me error page on paypal i don’t understand why this showing error can you help me on this

  14. Hello Sir, Nice Article..
    can you please send me C# code of this paypal integration?
    & please give me more detail of express checkout API ?

  15. Hello used your code but i m getting below error:
    This recipient is currently unable to receive money.

  16. Hello sir,
    I am making a website for Toll collection.Now ,what I want is that the user should pay for the retrieved price for a particular toll and vehicle type.The amount to be paid can be through session variable.
    Can you suggest something?I mean how should I modify the amount and type of button?
    Waiting for an early response!

Leave a reply to Pragati Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.