Home > Asp.net > Simplest PayPal Integration with asp.net in 5 steps

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 http://IndianDotnetWithPayPalIntegration.tk

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

Categories: Asp.net Tags: , ,
  1. Madhu
    August 6, 2009 at 2:18 pm | #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. Sandeep
    March 30, 2010 at 9:39 pm | #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. abhishek
    April 3, 2010 at 5:15 pm | #3

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

  4. Mayank Pundir
    May 11, 2010 at 5:59 am | #4

    sir , i need c# code can u send me on my email id plz

  5. June 26, 2010 at 3:30 pm | #5

    Short and sweet – straight to the point explanation.

  6. Zinnia Sarkar
    August 1, 2010 at 2:46 pm | #7

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

    • August 1, 2010 at 5:51 pm | #8

      Sure Zinnia,
      mean while i am in process of creating a ftp for all the code.

      Thanks
      rajat

  7. Amit
    August 23, 2010 at 7:32 am | #9

    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

    • September 28, 2010 at 6:02 am | #10

      Hi Amit,

      Paypal give us acknowledge facility by which we can determine last transaction status.
      you can use express checkout API for this.

      Thanks
      Rajat Jaiswal

  8. August 26, 2010 at 7:59 am | #11

    How can add my product cost will go on your paypal site

  9. prabhu
    September 28, 2010 at 5:48 am | #12

    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.

    • September 28, 2010 at 6:01 am | #13

      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

  10. October 22, 2010 at 5:36 am | #14

    nice and simple explaination thanx a lot!!!!!

  11. January 9, 2011 at 5:53 pm | #15

    I think you can help me.

  12. krishiv
    February 10, 2011 at 12:38 pm | #17

    sounds good

  13. tafazzulhussain07@gmail.com
    April 5, 2011 at 4:49 pm | #18

    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

  14. nichole
    May 18, 2011 at 6:44 am | #19

    Good Post…………

  15. jay
    May 29, 2011 at 7:57 pm | #20

    very nice site thanks

  16. Anusha Rahul
    September 19, 2011 at 8:08 am | #21

    Hi,

    Can I have the C# code for the same please.

    Thanks,
    Anusha

  17. hetal
    October 3, 2011 at 3:12 am | #22

    can i have sample code in C#

  18. vadivukarasi
    November 14, 2011 at 12:28 pm | #23

    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.

  19. December 27, 2011 at 1:03 pm | #24

    Hi Rajat Jaiswal, you have written a good post in VB but can you send me the code on mmazeemahmad@gmail.com you have used in C# language, i am very grateful to you upon this act………………………….

  20. praveen
    January 3, 2012 at 1:55 pm | #25

    me to have the same doubt. i wanna hide my pay pall business id .. help me….

  21. MuraliKrishna
    March 13, 2012 at 5:14 am | #26

    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?

  22. guna
    March 17, 2012 at 12:52 pm | #27

    Nice article Rajat.can u please send code for my email id(vgunarakes@gmail.com
    ).

  23. Hardik Modi
    April 13, 2012 at 9:13 am | #28

    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.

  24. lakshman
    May 10, 2012 at 3:30 pm | #29

    i need paypall integration c# code pls send me the code

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 38 other followers