public GoogleCheckoutRedirect RequestCheckout(ShoppingCart shoppingCart, CheckoutOptions options = null, IEnumerable<ShippingMethod> shippingMethods = null) { if (shoppingCart == null) throw new ArgumentNullException("shoppingCart"); _logger.Log("RequestCheckout.Request", shoppingCart); var request = _requestBuilder.CreateRequest(shoppingCart); if (options != null) _requestBuilder.AddOptions(request, options); if (shippingMethods != null) _requestBuilder.AddShippingMethods(request, shippingMethods); var response = request.Send(); _logger.Log("RequestCheckout.Response", response); var redirect = new GoogleCheckoutRedirect { GoogleResponse = response.ResponseXml, RedirectUrl = response.RedirectUrl, Status = response.IsGood ? PaymentStatus.Pending : PaymentStatus.Failed }; if (!response.IsGood) { redirect.IsSystemFailure = true; redirect.FailureMessage = response.ErrorMessage; } return redirect; }
public CheckoutShoppingCartRequest CreateRequest(ShoppingCart shoppingCart) { var request = new CheckoutShoppingCartRequest(_configuration.MerchantId, _configuration.MerchantKey, _configuration.EnvironmentType, "GBP", 0); foreach (var item in shoppingCart.Items) request.AddItem(item.Name, item.Description, item.MerchantItemId, item.UnitPriceExTax, item.Quantity); foreach (var discount in shoppingCart.Discounts) request.AddItem(discount.Name, discount.Description, -Math.Abs(discount.AmountExTax), discount.Quantity ?? 1); // TODO: Support different tax rates request.AddWorldAreaTaxRule(.2d, true); return request; }