示例#1
0
 public void AddOptions(CheckoutShoppingCartRequest request, CheckoutOptions options)
 {
     request.EditCartUrl             = options.EditCartUrl;
     request.ContinueShoppingUrl     = options.ContinueShoppingUrl;
     request.RequestBuyerPhoneNumber = options.RequestBuyerPhoneNumber;
     request.AnalyticsData           = options.AnalyticsData;
 }
 public void AddOptions(CheckoutShoppingCartRequest request, CheckoutOptions options)
 {
     request.EditCartUrl = options.EditCartUrl;
     request.ContinueShoppingUrl = options.ContinueShoppingUrl;
     request.RequestBuyerPhoneNumber = options.RequestBuyerPhoneNumber;
     request.AnalyticsData = options.AnalyticsData;
 }
示例#3
0
        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;
        }
示例#4
0
        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);
        }