Esempio n. 1
0
        public FormRequest CreateFormRequest(string shoppingCartId, double price, Customer customer, PaymentType paymentType, IReturnUrlProvider returnUrlProvider)
        {
            var shop = WSPayConfiguration.RegularShop;
            var formattedPriceForRegularForm = WSPayHelpers.FormatAmountForRegularShopForm(price);

            return(new FormRequest
            {
                Url = WSPayConfiguration.FormUrl.ToString(),
                ShopId = shop.ShopId,
                ShoppingCartID = shoppingCartId,
                Amount = formattedPriceForRegularForm,
                Signature = signatureFactory.GenerateFormRequestSignature(shop, shoppingCartId, price),
                CustomerFirstName = customer?.FirstName,
                CustomerSurname = customer?.LastName,
                CustomerEmail = customer?.Email,
                CustomerAddress = customer?.Address,
                CustomerPhone = customer?.Phone,
                IsTokenRequest = paymentType.IsNewTokenRequest,
                Token = paymentType.Token,
                TokenNumber = paymentType.TokenNumber,
                FormattedDateTime = timeProvider.Get().ToString("yyyyMMddHHmmss"),
                ReturnUrl = returnUrlProvider.GetReturnUrl(),
                CancelUrl = returnUrlProvider.GetCancelUrl(shoppingCartId),
                ErrorUrl = returnUrlProvider.GetErrorUrl()
            });
        }
Esempio n. 2
0
        public ChangeTransactionStatusRequest CreateChangeTransactionStatusRequest(Shop shop, string wsPayOrderId, string stan, string approvalCode, double price)
        {
            var formattedPrice = WSPayHelpers.FormatPrice(price);
            var signature      =
                signatureFactory.GenerateChangeTransactionStatusSignature(shop, wsPayOrderId, stan,
                                                                          approvalCode, price);

            return(new ChangeTransactionStatusRequest
            {
                WSPayOrderId = wsPayOrderId,
                ShopId = shop.ShopId,
                Amount = formattedPrice,
                Stan = stan,
                ApprovalCode = approvalCode,
                Signature = signature
            });
        }
Esempio n. 3
0
        public ProcessPaymentRequest CreateProcessPaymentRequest(string shoppingCartId, double price, string token, string tokenNumber)
        {
            var shop = WSPayConfiguration.TokenShop;

            var formattedPrice = WSPayHelpers.FormatPrice(price);
            var signature      = signatureFactory.GenerateFormRequestSignature(WSPayConfiguration.TokenShop, shoppingCartId,
                                                                               price);

            return(new ProcessPaymentRequest
            {
                ShopId = shop.ShopId,
                ShoppingCartId = shoppingCartId,
                TotalAmount = formattedPrice,
                Signature = signature,
                Token = token,
                TokenNumber = tokenNumber,
                DateTime = timeProvider.Get().ToString("yyyyMMddHHmmss")
            });
        }
        public void FormatPrice()
        {
            var actual = WSPayHelpers.FormatPrice(15.25);

            actual.Should().Be("1525");
        }
        public void FormatAmountForRegularShopForm_Rounded()
        {
            var actual = WSPayHelpers.FormatAmountForRegularShopForm(15);

            actual.Should().Be("15,00");
        }
        public void FormatAmountForRegularShopForm_WithRounding()
        {
            var actual = WSPayHelpers.FormatAmountForRegularShopForm(15.257);

            actual.Should().Be("15,26");
        }
        public void FormatAmountForRegularShopForm()
        {
            var actual = WSPayHelpers.FormatAmountForRegularShopForm(15.25);

            actual.Should().Be("15,25");
        }
        public void FormatPrice_WithRounding()
        {
            var actual = WSPayHelpers.FormatPrice(15.257);

            actual.Should().Be("1526");
        }