Search code examples
payment-gatewaygoogle-checkout

Implementing Google Checkout - (similar to paypal express checkout)


I am trying to integrate Google Checkout to my asp.net MVC(C#) application. I am trying to implement Google Checkout similar to PayPal Express Checkout. i.e.

  1. Shop the Products
  2. Get the Authorization token(by sign in to Google Checkout) and redirect to my site
  3. Process(Charge) the Customer's Account from my site using the token got from the previous step.

This will avoid the use of Notification process. Is it possible to implement the same using Google Checkout? Please suggest


Solution

  • I finally solved this by using the ParameterizedUrl of Google CheckOut. I have done this as below:

    GCheckout.Checkout.ShoppingCartItem shoppingCartItem = new GCheckout.Checkout.ShoppingCartItem();
        shoppingCartItem.Description = "Google Checkout Item";
        shoppingCartItem.Name = "Google Checkout Item";
        decimal _price = 0M;
        decimal.TryParse(amt, out _price);
        shoppingCartItem.Price = _price;
        shoppingCartItem.Quantity = 1;
        shoppingCartItem.MerchantItemID = "1";
    
        string returnURL = "http://localhost:50241/GCheckout/Success";
        string trackURL = "http://localhost:50241/GCheckout/Track";
    
        GCheckout.Checkout.CheckoutShoppingCartRequest checkoutShoppingCartRequest = new GCheckout.Checkout.CheckoutShoppingCartRequest(ConfigurationManager.AppSettings["GoogleMerchantID"], ConfigurationManager.AppSettings["GoogleMerchantKey"], EnvironmentType.Sandbox, "USD", 30, false);
        checkoutShoppingCartRequest.ContinueShoppingUrl = returnURL;
        ParameterizedUrl trackingUrl = new ParameterizedUrl(trackURL + "?mid=123");
        trackingUrl.AddParameter("oid", UrlParameterType.OrderID);
        trackingUrl.AddParameter("ot", UrlParameterType.OrderTotal);
        trackingUrl.AddParameter("zp", UrlParameterType.ShippingPostalCode);
        checkoutShoppingCartRequest.ParameterizedUrls.AddUrl(trackingUrl);
    
        checkoutShoppingCartRequest.AddItem(shoppingCartItem);
    
        GCheckout.Checkout.MerchantCode merchantCode = new GCheckout.Checkout.MerchantCode();
    
        GCheckoutResponse response = checkoutShoppingCartRequest.Send();
        if (response != null)
        {
              Response.Redirect(response.RedirectUrl, true);
        }