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 my 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. 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¤cy=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 += "¤cy=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 Butonsprotected 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:
No comments:
Post a Comment