public SetExpressCheckoutRequestDetailsType GetSetExpressCheckoutRequestDetails(IList <ShoppingCartItem> cart)
        {
            var setExpressCheckoutRequestDetailsType =
                new SetExpressCheckoutRequestDetailsType
            {
                ReturnURL          = _payPalUrlService.GetReturnURL(),
                CancelURL          = _payPalUrlService.GetCancelURL(),
                ReqConfirmShipping = _payPalShippingService.GetRequireConfirmedShippingAddress(cart),
                NoShipping         = _payPalShippingService.GetNoShipping(cart),
                LocaleCode         = _payPalExpressCheckoutPaymentSettings.LocaleCode,
                cppheaderimage     = _payPalExpressCheckoutPaymentSettings.LogoImageURL,
                cppcartbordercolor = _payPalExpressCheckoutPaymentSettings.CartBorderColor,
                PaymentDetails     = _payPalOrderService.GetPaymentDetails(cart),
                BuyerEmail         = _payPalOrderService.GetBuyerEmail(),
                MaxAmount          = _payPalOrderService.GetMaxAmount(cart)
            };

            return(setExpressCheckoutRequestDetailsType);
        }
コード例 #2
0
        public SetExpressCheckoutReq GetSetExpressCheckoutRequest(CartModel cart)
        {
            List <ShippingOptionType> flatRateShippingOptions =
                cart.PotentiallyAvailableShippingMethods.OrderBy(x => x.GetShippingTotal(cart))
                .Select(x => new ShippingOptionType
            {
                ShippingOptionAmount    = x.GetShippingTotal(cart).GetAmountType(),
                ShippingOptionName      = x.DisplayName,
                ShippingOptionIsDefault = cart.ShippingMethod == x ? "true" : "false",
            }).ToList();

            if (flatRateShippingOptions.Any() && flatRateShippingOptions.All(type => type.ShippingOptionIsDefault != "true"))
            {
                flatRateShippingOptions[0].ShippingOptionIsDefault = "true";
            }
            var setExpressCheckoutRequestDetailsType = new SetExpressCheckoutRequestDetailsType
            {
                ReturnURL               = _payPalUrlService.GetReturnURL(),
                CancelURL               = _payPalUrlService.GetCancelURL(),
                ReqConfirmShipping      = _payPalShippingService.GetRequireConfirmedShippingAddress(),
                NoShipping              = _payPalShippingService.GetNoShipping(cart),
                LocaleCode              = _payPalExpressCheckoutSettings.LocaleCode,
                cppHeaderImage          = _payPalExpressCheckoutSettings.LogoImageURL,
                cppCartBorderColor      = _payPalExpressCheckoutSettings.CartBorderColor,
                PaymentDetails          = _payPalOrderService.GetPaymentDetails(cart),
                BuyerEmail              = _payPalOrderService.GetBuyerEmail(cart),
                MaxAmount               = _payPalOrderService.GetMaxAmount(cart),
                InvoiceID               = cart.CartGuid.ToString(),
                Custom                  = cart.CartGuid.ToString(),
                CallbackURL             = _payPalUrlService.GetCallbackUrl(),
                CallbackTimeout         = "6",
                FlatRateShippingOptions = flatRateShippingOptions,
            };
            var setExpressCheckoutRequestType = new SetExpressCheckoutRequestType
            {
                SetExpressCheckoutRequestDetails = setExpressCheckoutRequestDetailsType,
            };

            return(new SetExpressCheckoutReq {
                SetExpressCheckoutRequest = setExpressCheckoutRequestType
            });
        }