【问题标题】:Implementing Google Checkout - (similar to paypal express checkout)实施 Google Checkout -(类似于 paypal express checkout)
【发布时间】:2013-02-19 09:33:33
【问题描述】:
我正在尝试将 Google Checkout 集成到我的 asp.net MVC(C#) 应用程序中。我正在尝试实现类似于 PayPal Express Checkout 的 Google Checkout。即
- 购买产品
- 获取授权令牌(通过登录 Google Checkout)并重定向到我的网站
- 使用从上一步获得的令牌从我的站点处理(收费)客户的帐户。
这将避免使用通知过程。是否可以使用 Google Checkout 实现相同的功能?请推荐
【问题讨论】:
标签:
payment-gateway
google-checkout
【解决方案1】:
就像任何 API 一样,您必须相应地实施。
- Google Checkout/电子钱包中没有(自动)重定向会以某种方式为您提供订单数据
- 与 Google Checkout API 的数据交换实际上是通过通知而不是(浏览器/客户端)结帐流程的一部分(单独的过程 - 在 Paypal 中,这类似于
IPN)
从技术上讲,您可以使用Notification History API 和charge 那些Chargeable 为您的订单“投票”。
【解决方案2】:
我终于通过使用 Google CheckOut 的 ParameterizedUrl 解决了这个问题。我这样做如下:
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);
}