How to Preview the Order summary for Cart items in Paypal website using c#


Today i want to demonstrate how to show the cart items in order summary for the Paypal Website using Asp.net C# code with real time images and Code snippets.With this Article you can Know what are the parameters/Arguments you need to Club/append to the Uniform Resource Locator(URL)(i.e. when you redirect to Paypal website).

when you are working in any e-Commerce website you will come across a situation
to use any one of the Payment Gateways to send money for the Purchased Item(by single click) or Multiple Items send to PayPal(cart Items).Here if you Observe my Previous line/statement i am referring one Singular(every single click of an item redirection to Paypal website) and Plural things(cart Items sent to Paypal at a time)(These are two different/discrepant things in English Language) similar to that here in Paypal.The customer who will buy the items will have final view or having mini preview statement/order summary before Purchasing the item or items.In that statement/order Summary Customer will know/preview about What are the items, Prices, taxes ,shipping charges and currency of various Countries that you need to pay for that Cart Items.

For working out these details using Asp.net Code . So there are some parameters/Arguments that are append to the URL(Paypal website ).

See the Below code for every Single click of a Button redirect to Paypal Website on a Grid View of a button are a button



returnURL += ConfigurationManager.AppSettings["PayPalSubmitUrl"].ToString();
//Passing Item Name as dynamic
returnURL += "&cmd=_click";
returnURL += "&upload=" + value;
returnURL = returnURL + "&business="+ ConfigurationManager.AppSettings["paypalemail"].ToString();
System.Collections.Generic.List lst = (System.Collections.Generic.List)Session["shipcdcollection"];

returnURL += "&item_name_"+i+"=" + lst[0].Item;
returnURL += "&amount_"+i+"=" + lst[0].Price;
returnURL += "&custom=" + lst[0].CartID;
returnURL += "&quantity_" + i + "=" + lst[0].Quantity;




In the WebConfig file the following Settings You need to do this...

Webconfig.cs



add key="PayPalSubmitUrl" value="https://www.sandbox.paypal.com/cgi-bin/webscr?"



Here what i am doing is i have taken the Collection List i.e cart item and Upload those values to the Paypal website(cart item as an arguments/Parameters that are club/append to the Paypal website url).

Parameters that are club/append with the Url are

1)cmd=_click: This Argument will tells us redirect to a single Click or an item to Paypal website.
2)Upload= value what are the values You are going to Upload to the website.
3)business = Email id of the Vendor.
4)item_name = The description of the Item
5)amount = The Price of the Item
6)Custom = The CartId/Order Id which you will have for further reference
7)quantity = the Quantity of an Item
8)Currency = country currency code will be available like for an Ex: USD(American dollar).
9)Notify_Url = Redirect to the specified Page after sucess/Failure of the Transaction
10)Cancel_return = Redirect to the Specified Page when you click Cancel and Return the page

These all arguments/parameters club/append to the Url i.e. Paypal website.

Note : Here we do n't need to Loop the Items Because cart Collection will have only one item so that is the reason i specified only Lst[0].CartId e.t.c.....

The important thing you need to Observe if you send an Argument/Parameter i.e. Cmd=_click.That will redirect the single click of an Item to Paypal website.

But our Article and our aim is about to redirect Pay pal website to view the Cart Items(Multiple Items).For that you need to work out the following code.



string returnURL = "";
returnURL += ConfigurationManager.AppSettings["PayPalSubmitUrl"].ToString();
//Passing Item Name as dynamic
returnURL += "&cmd=_cart";
returnURL += "&upload=" + value;
returnURL = returnURL + "&business="+ ConfigurationManager.AppSettings["paypalemail"].ToString();
System.Collections.Generic.List lst = (System.Collections.Generic.List)Session["shipcdcollection"];
foreach (CartDetails cd in lst)
{
i++;
returnURL += "&item_name_"+i+"=" + cd.Item;
returnURL += "&amount_"+i+"=" + cd.Price;
returnURL += "&custom=" + cd.CartID;
returnURL += "&quantity_" + i + "=" + cd.Quantity;
}
returnURL += "&return=" + ConfigurationManager.AppSettings["FailedURL"].ToString();
//retturn Url if Customer Wants To Cancel the Transaction
returnURL += "notify_url=" + Server.UrlEncode(ConfigurationManager.AppSettings["SuccessURL"].ToString());
returnURL += "&cancel_return=" +ConfigurationManager.AppSettings["FailedURL"].ToString();
return returnURL;



Parameters that are clubbed/append with the Url are

1)cmd=_cart: This Argument will preview Cart items in Paypal website.
2)Upload= value what are the values You are going to Upload to the Paypal website.
3)business = Email id of the Vendor.
4)item_name = The description of the Item
5)amount = The Price of the Item
6)Custom = The CartId/Order Id which you will have for further reference
7)quantity = the Quantity of an Item
8)Currency = country currency code will be available like USD(American dollar).
9)Notify_Url = Redirect to the specified Page after sucess/Failure of the Transaction
10)Cancel_return = Redirect to the Specified Page when you click Cancel and Return the page

Basic Arguments/Paremeters are Mentioned here.

Note : Here we need to Loop the Items Because cart Collection will have Multiple items

Here You need to observe Carefully that argument/Parameter cmd=_Cart.This is the one that will redirect to pay pal with a preview of Cart items.

Let us see the below screen shot..

Click the Below Link if you are Unable to see the Image...

Paypalwebsite

Here in the above image you can clearly see the Description of Items , the Price of each Item , the quantity of the each item ,the Currency of the each item ,the total Amount of each item,Total Amount(Grand Total) of all items which you are going purchase with that if you want to include shipping Charges ,Taxes and shipping Address for that Purchased Items you can append those arguments in the Paypal website and that also can be viewed by the end user(Customer) in this Mini order statement Preview.


Article by srirama
A Good advice from parent to a Child , Master to a Student , Scholar to an Ignorant is like a doctor prescribed pill it is bitter to take but when they take it will do all good for them --- Bhushan

Follow srirama or read 74 articles authored by srirama

Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: