Recently I have worked on shopping cart using Google checkout.This is quite easy to work with Google checkout rather than Paypal or others. However, I will be describing here in brief:
Steps:
1.Shopping cart account in Google
2.Downloading GCheckout.dll and installing in VS.
3.Working with GCheckout Button.
Here I will be describing in details.
1.Shopping cart account in Google
Generally for this you will have to have a google account. And using this account you can create shopping cart account. So if you have account then do the following.
a. log in to Google.
b. visit https://sandbox.google.com/checkout/main
c. Here you will find a control panel having 'Edit Payment Method'. Here you will put your credit card info to which customer will pay you. And also some other info you have to pay like country, city, shipping address etc.
d. Then go to main panel and collect Merchant ID, Merchant Key which will be used in your website for accessing the shopping cart account. Generally
these keys will be generated by Google.
2.GCheckout.dll
a.You can make a Google search and download this dll. For Asp.net developer, there is a .NET version of GCheckout. You have to download that. After downloading this dll you have to Add reference to this dll and in this way, the dll will be copied to website Bin directory.
b. Add reference: Solution Explorer>Website Name>Add Reference>browse the dll
3.Working With GCheckout Button
To work with GCheckout Button you have to do the following:
a.Toolbox>Choose Item>browse dll.
This way new controls (dll) will be shown up in toolbox (GCheckoutButton,GCheckoutDonateButton);
b. Now drag and drop the control to the .aspx page and you will see automatically the following code will be generated.
i. in directive section:
< %@ Register Assembly="GCheckout" Namespace="GCheckout.Checkout" TagPrefix="cc1" % / >
ii.in page body:
< cc1:GCheckoutButton ID="MyGCheckoutButton" runat="server"
onclick="MyGCheckoutButton_Click" / >
Here, we see that this button is clicked and handler is generated to handle the event.
c. Web configuration section:
You have to put the following configuration in app setting.
< appSettings >
< add key="GoogleMerchantID" value="XXXXXXXXXX" />
< add key="GoogleMerchantKey" value="YYYYYYYYYY" />
< add key="GoogleEnvironment" value="Sandbox" />
< /appSettings>
The Merchant ID and Merchant Keys will have to be inserted in the above section to make the system works.
d. Coding in the Button event handler function.
You have to put the following code in the function:
CheckoutShoppingCartRequest chkoutShoppingCartReq = MyGCheckoutButton.CreateRequest();
chkoutShoppingCartReq.AddItem("Business Plan: Plan No"+Session["PlanID"], "Business Plan Consultancy Fee", decimal.Parse(Session["PlanCost"].ToString()), 1);
GCheckoutResponse obtainedResponse = chkoutShoppingCartReq.Send();
Response.Redirect(obtainedResponse.RedirectUrl, true);
Here obtainedResponse.RedirectUrl is the URL to which website will be redirected for payment.
e.When you will be working in the Setting in Merchant Account you have to generally set the thank you page (for payment) as the redirect URL so that after successful payment, the user can be acknowledged that his/her payment is received successfully and he/she is free to go.
This is the way..Google Checkout works.
Thanks. Masud (13-11-2009)
No comments:
Post a Comment