Paypal Integration With Asp.Net using Website Payment Method
-->
Nowadays PayPal is the most popular payment gateway worldwide because it is totally free to integrate and PayPal does not charge anything for opening an account, you will pay PayPal when you get paid. And the amount is also lower than other payment gateways.
How to integrate with PayPal in Asp.net?, is common question ask by different developers around the world. When you visit official website of PayPal for help, no doubt they (PayPal) are trying to help visitors to learn techniques and method to integrate it with their application but for newly person who haven't experience with integration unable to understand the way of success.
There are four methods to integrate PayPal like:
· Website Payments Standard (HTML)
· Postpayment Processing
o AutoReturn
o Payment Data Transfer (PDT)
o Instant Payment Notification (IPN)
· PayPal API
o Express Checkout
o Direct Payment (Website Payments Pro)
· Payflow Gateway
But newly person's first choice is "PayPal API" for integration which is wrong. It seems quite easy with other version but after integration when you test your application using Sandbox test account, it show you version errors and the most common error is display like "Total Order is missing", in fact you already pass total order amount in session as per of description.
If you are new to PayPal, first learn all of the options that you have with the Website Payments Standard. Then, if you need to add some basic post-payment processing, use Auto-Return or PDT. If not solve your issue then IPN is a more robust option you have.
Next level would involve the PayPal API and implementing the Express Checkout, which is the most flexible PayPal integration solution. And finally, if you long for the ability to directly process credit cards on your website, you’ll pay a monthly fee to PayPal and implement Direct Payment (called Website Payments Pro).
The last item from classification is Payflow Gateway, a different beast. It is a solution aimed specifically at those businesses that have/want an Internet Merchant Account (IMA) and just need the payment gateway.
Lets start PayPal integration with Asp.net application using Website Payment Method. First follow to set up a new Test account as there are two reasons to test your application before live your application.
If you are new to PayPal, first learn all of the options that you have with the Website Payments Standard. Then, if you need to add some basic post-payment processing, use Auto-Return or PDT. If not solve your issue then IPN is a more robust option you have.
Next level would involve the PayPal API and implementing the Express Checkout, which is the most flexible PayPal integration solution. And finally, if you long for the ability to directly process credit cards on your website, you’ll pay a monthly fee to PayPal and implement Direct Payment (called Website Payments Pro).
The last item from classification is Payflow Gateway, a different beast. It is a solution aimed specifically at those businesses that have/want an Internet Merchant Account (IMA) and just need the payment gateway.
Lets start PayPal integration with Asp.net application using Website Payment Method. First follow to set up a new Test account as there are two reasons to test your application before live your application.
· You don’t want to test and play with real money
· You want to have access to different types of PayPal accounts
o Personal Account – Most people have these; just an account that allows you to use PayPal when paying for stuff on-line. Theoretically, you can use a Personal account to accept money; just know that you’ll be severely constrained – there is a $500 receiving limit per month, and you are only able to accept one time payments using the Website Payments Standard (HTML). The big advantage of a Personal account is that you don’t need to pay any transaction fee when receiving money. If you receive more than $500 in one month, you’ll be prompted to either upgrade to a Premier/Business account or reject the payment.
o Premier Account – Step up from a personal account; for anyone who wants to run a personal on-line business. This type of account has all of the integration options. However, most people skip directly from Personal to Business account as Premier account has the same transaction fees (in most cases, 2.9% + $0.30 per transaction) while lacking reporting, multi-user access, and other advanced merchant services of the Business account.
o Business Account – It has all of the features of the Premier account plus a few more (ability to operate under your business’s name is one of them). If you are developing a website that needs to accept payments in 99% of situations, you’ll go with this type of account.
To start, visit the PayPal Sandbox and sign-up for a new account. The process is straightforward, and most developers should have no trouble finishing it. However, here are the pictures that will help you navigate through the process:
· Go-to Here
· Signing up for a Sandbox account
· After setting up test account, let's start website payment method (HTML)
Parameter
|
Description
|
cmd
|
The parameter is obligatory. It must have the _xclick value for an unencrypted request.
|
business
|
The parameter is obligatory and represents the seller's e-mail.
|
item_number
|
This parameter is an item identifier. This value will not be shown to the user; however, it will be passed to your script at the time of transaction confirmation. If you plan to use PayPal to pay for goods in a cart, then you can pass the cart's identifier in this parameter.
|
item_name
|
This is a name of the item that will be shown to the user.
|
no_shipping
|
Prompt customer for shipping address.
Default or 0: customer is prompted to include a shipping address. 1: customer is not asked for a shipping address. 2: customer must provide a shipping address. |
return
|
This is the URL where user will be redirected after the payment is successfully performed. If this parameter is not passed, the buyer remains on the PayPal site.
|
rm
|
This parameter determines the way information about successful transaction will be passed to the script that is specified in the return parameter. "1" means that no parameters will be passed. "2" means that the POST method will be used. "0" means that the GET method will be used. The parameter is "0" by default.
|
cancel_return
|
This is the URL where the user will be redirected when he cancels the payment. If the parameter is not passed, the buyer remains on the PayPal site.
|
notify_url
|
This is the URL where PayPal will pass information about the transaction (IPN). If the parameter is not passed, the value from the account settings will be used. If this value is not defined in the account settings, then IPN will not be used.
|
custom
|
This field does not take part in the shopping process, it will be simply passed to IPN script at the time of transaction confirmation.
|
invoice
|
This parameter is used to pass the invoice number. The parameter is not obligatory, but being passed it must be unique for every transaction.
|
amount
|
This parameter represents an amount of payment. If the parameter is not passed, the user will be allowed to enter the amount (this is used for donations).
|
currency_code
|
This parameter represents a currency code. Possible values are "USD","EUR","GBP","YEN","CAD" etc. It is "USD" by default.
|
There are two type of integration techniques under Website Payment Method.
· Passing the Aggregate Cart Amount to PayPal
· Passing Individual Items to PayPal
A. Passing the Aggregate Cart Amount to PayPal
You may aggregate your entire shopping cart and pass the total amount into PayPal's Buy Now Button code (that is, you will need to post a single name for the entire cart and the total price of the cart's contents as though it were a purchase of a single item).
One drawback of this method is that your buyers will not be able to see the individual items appearing in their carts. In addition, you cannot change PayPal variable names, nor can you add your own variable names.
The code for your PayPal post requires the following 4 hidden variables and an image as the form submit:
Required Variables
| |
Name
|
Value
|
business
|
Email address on your PayPal account
|
item_name
|
Name of the item (or a name for the shopping cart)
|
currency_code
|
Defines the currency in which the monetary variables (amount, shipping, shipping2, handling, tax) are denoted. Possible values are "USD", "EUR", "GBP", "CAD", "JPY".
|
amount
|
Price of the item (the total price of all items in the shopping cart)
|
image
|
The image for the button your buyer will press to initiate the PayPal payment process. You can substitute your own image by replacing the src with the URL of your image
|
This means that the minimum required code for your post to PayPal will look like this:
PayPal offers additional variables to customize your form post. All of the available variables are listed below (variable names must be in lower case):
Available Variables
| |
Name
|
Value
|
business
|
Email address on your PayPal account
|
quantity
|
Number of items. This will multiply the amount if greater than one
|
item_name
|
Name of the item (or a name for the shopping cart). Must be alpha-numeric, with a 127character limit
|
item_number
|
Optional pass-through variable for you to track payments. Must be alpha-numeric, with a 127 character limit
|
amount
|
Price of the item (the total price of all items in the shopping cart)
|
shipping
|
The cost of shipping the item
|
shipping2
|
The cost of shipping each additional item
|
handling
|
The cost of handling
|
tax
|
Transaction-based tax value. If present, the value passed here will override any profile tax settings you may have (regardless of the buyer's location).
|
no_shipping
|
Shipping address. If set to "1," your customer will not be asked for a shipping address. This is optional; if omitted or set to "0," your customer will be prompted to include a shipping address
|
cn
|
Optional label that will appear above the note field (maximum 40 characters)
|
no_note
|
Including a note with payment. If set to "1," your customer will not be prompted to include a note. This is optional; if omitted or set to "0," your customer will be prompted to include a note.
|
on0
|
First option field name. 64 character limit
|
os0
|
First set of option value(s). 200 character limit. "on0" must be defined for "os0" to be recognized.
|
on1
|
Second option field name. 64 character limit
|
os1
|
Second set of option value(s). 200 character limit. "on1" must be defined for "os1" to be recognized.
|
custom
|
Optional pass-through variable that will never be presented to your customer. Can be used to track inventory
|
invoice
|
Optional pass-through variable that will never be presented to your customer. Can be used to track invoice numbers
|
notify_url
|
Only used with IPN. An internet URL where IPN form posts will be sent
|
return
|
An internet URL where your customer will be returned after completing payment
|
cancel_return
|
An internet URL where your customer will be returned after cancelling payment
|
image_url
|
The internet URL of the 150 X 50 pixel image you would like to use as your logo
|
cs
|
Sets the background color of your payment pages. If set to "1," the background color will be black. This is optional; if omitted or set to "0," the background color will be white
|
PayPal allows you to post extended variables if you change this "cmd" input:
To
By making the above change to the "cmd" input, you can also use the variables below:
Extended Variables
| |
Name
|
Value
|
email
|
Customer's email address
|
first_name
|
Customer's first name. Must be alpha-numeric, with a 32 character limit
|
last_name
|
Customer's last name. Must be alpha-numeric, with a 64 character limit
|
address1
|
First line of customer's address. Must be alpha-numeric, with a 100 character limit
|
address2
|
Second line of customer's address. Must be alpha-numeric, with a 100 character limit
|
city
|
City of customer's address. Must be alpha-numeric, with a 100 character limit
|
state
|
State of customer's address. Must be official 2 letter abbreviation
|
zip
|
Zip code of customer's address
|
night_phone_a
|
Area code of customer's night telephone number
|
night_phone_b
|
First three digits of customer's night telephone number
|
day_phone_a
|
Area code of customer's daytime telephone number
|
day_phone_b
|
First three digits of customer's daytime telephone number
|
Note: To specify shipping & handling amounts that differ from the default shipping amounts set in your Profile, please go to your Profile, edit your Shipping Calculations, and click the "allow transaction-based shipping override" checkbox.
B. Passing Individual Items to PayPal
If your custom or third party shopping cart can be configured to pass individual items to PayPal, information about the items will be included in the buyers' and sellers' History logs and notifications. To include information about the items, you will post HTML form elements to a new version of PayPal's Shopping Cart flow. This process is much like the one described in Section #1 "Passing Aggregate Cart Amount to PayPal" with the following exceptions:
· Set the "cmd" variable to "_cart"
o
o (Replace above required HTML line with below line)
o
· Add a new variable called "upload"
o
· Define item details
For each of the following item-specific parameters, define a new set of values that correspond to each item that was purchased via your custom cart. Append "_x" to the variable name, where x is the item number, starting with 1 and increasing by one for each item that is added.
Name
|
Value
|
item_name_x
|
(Required for item #x) Name of item #x in the cart. Must be alpha-numeric, with a 127 character limit
|
item_number_x
|
Optional pass-through variable associated with item #x in the cart. Must be alpha-numeric, with a 127 character limit
|
amount_x
|
(Required for item #x) Price of the item #x
|
shipping_x
|
The cost of shipping the first piece (quantity of 1) of item #x
|
shipping2_x
|
The cost of shipping each additional piece (quantity of 2 or above) of item #x
|
handling_x
|
The cost of handling for item #x
|
on0_x
|
First option field name for item #x. 64 character limit
|
os0_x
|
First set of option value(s) for item #x. 200 character limit. "on0_x" must be defined in order for "os0_x" to be recognized.
|
on1_x
|
Second option field name for item #x. 64 character limit
|
os1_x
|
Second set of option value(s) for item #x. 200 character limit. "on1_x" must be defined in order for "os1_x" to be recognized.
|
No comments:
Post a Comment
Comment Here