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.
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



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
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
sir , i need c# code can u send me on my id
————————————————-thanks
sir , i need c# code can u send me on my email id plz
Short and sweet – straight to the point explanation.
Thanks Jacob.
Sir, I require the C# code of this particular explanation. Will it b feasible for u to send it in my email id plz?
Sure Zinnia,
mean while i am in process of creating a ftp for all the code.
Thanks
rajat
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
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
How can add my product cost will go on your paypal site
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.
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
nice and simple explaination thanx a lot!!!!!
I think you can help me.
surely if its possible i will help please goahead.
Thanks
sounds good
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
Good Post…………
very nice site thanks
Hi,
Can I have the C# code for the same please.
Thanks,
Anusha
can i have sample code in C#
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.
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………………………….
me to have the same doubt. i wanna hide my pay pall business id .. help me….
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?
Nice article Rajat.can u please send code for my email id(vgunarakes@gmail.com
).
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.
i need paypall integration c# code pls send me the code
I hope you got , I sent a mail.