Beispiel #1
0
        private SetExpressCheckoutRequestDetailsType SetupExpressCheckoutReqDetailsType(ICart cart, IPayment payment, string orderNumber)
        {
            var setExpressChkOutReqDetails = _payPalApiHelper.CreateExpressCheckoutReqDetailsType(payment, _paymentMethodConfiguration);

            // This key is sent to PayPal using https so it is not likely it will come from other because
            // only PayPal knows this key to send back to us
            var acceptSecurityKey = Utilities.GetAcceptUrlHashValue(orderNumber);
            var cancelSecurityKey = Utilities.GetCancelUrlHashValue(orderNumber);

            _acceptUrl = UriSupport.AbsoluteUrlBySettings(_paymentMethodConfiguration.SuccessUrl);
            _cancelUrl = UriSupport.AbsoluteUrlBySettings(_paymentMethodConfiguration.CancelUrl);

            var acceptUrl = UriSupport.AddQueryString(_acceptUrl, "accept", "true");

            acceptUrl = UriSupport.AddQueryString(acceptUrl, "hash", acceptSecurityKey);

            var cancelUrl = UriSupport.AddQueryString(_cancelUrl, "accept", "false");

            cancelUrl = UriSupport.AddQueryString(cancelUrl, "hash", cancelSecurityKey);

            setExpressChkOutReqDetails.CancelURL      = cancelUrl;
            setExpressChkOutReqDetails.ReturnURL      = acceptUrl;
            setExpressChkOutReqDetails.PaymentDetails = new List <PaymentDetailsType> {
                _payPalApiHelper.GetPaymentDetailsType(payment, cart, orderNumber, _acceptUrl)
            };

            setExpressChkOutReqDetails.BillingAddress = AddressHandling.ToAddressType(payment.BillingAddress);

            return(setExpressChkOutReqDetails);
        }
        public void UpdateOrderAddress_ShouldUpdateCorrectly()
        {
            var orderAddress  = CreateOrderAddress();
            var paypalAddress = AddressHandling.ToAddressType(orderAddress);

            paypalAddress.Street1 = "Street1";
            AddressHandling.UpdateOrderAddress(orderAddress, CustomerAddressTypeEnum.Billing, paypalAddress, "*****@*****.**");

            Assert.Equal("Street1", orderAddress.Line1);
            Assert.Equal("*****@*****.**", orderAddress.Email);
        }
        public void ToAddressType_ShouldConvertCorrectly()
        {
            var orderAddress = CreateOrderAddress();
            var result       = AddressHandling.ToAddressType(orderAddress);

            Assert.Equal("Los Angeles", result.CityName);
            Assert.Equal(CountryCodeType.US, result.Country);
            Assert.Equal("FakeAddress", result.Street1);
            Assert.Equal("", result.Street2);
            Assert.Equal("90001", result.PostalCode);
            Assert.Equal("99999999", result.Phone);
            Assert.Equal("John Doe", result.Name);
            Assert.Equal("CA", result.StateOrProvince);
        }