Esempio n. 1
0
        public async Task InitPayment_SpecifiedRequestEncodingAndReturnType_Succeeds(
            HttpRequestEncodingType encodingType, InitPaymentResponseType responseType)
        {
            var connection = new Connection(PlatronClient.PlatronUrl, SettingsStorage.Credentials, encodingType);
            var client     = new PlatronClient(connection);
            // To find out what really happens enable proxy (thru fiddler)
            // and use custom connection over http to watch plain requests
            //.EnableProxy(new WebProxy("http://localhost:8888", false));

            var initPayment = new InitPaymentRequest(1.Rub(), "Money first");

            initPayment.InTestMode();
            initPayment.OrderId = Guid.NewGuid().ToString("N");

            switch (responseType)
            {
            case InitPaymentResponseType.RedirectLink:
                var response = await client.InitPaymentAsync(initPayment);

                Assert.NotNull(response);
                break;

            case InitPaymentResponseType.HtmlForm:
                var html = await client.InitPaymentAsHtmlAsync(initPayment);

                Assert.NotNull(html);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(responseType), responseType, null);
            }
        }
        public async Task InitPayment_InvalidMerchant_ThrowsInvalidResponse()
        {
            var initPayment = new InitPaymentRequest(1.Rur(), "sample description");
            var client = new PlatronClient("0000", "secret");

            var exception =
                await Assert.ThrowsAsync<ErrorApiException>(() => client.InitPaymentAsync(initPayment));
            Assert.Equal(ErrorCode.InvalidMerchant, exception.Error.Code);
        }
        public async Task InitPayment_InvalidSecretKey_ThrowsInvalidResponse()
        {
            var initPayment = new InitPaymentRequest(1.Rur(), "sample description");
            var client = new PlatronClient(SettingsStorage.Credentials.MerchantId, "secret");

            var exception =
                await Assert.ThrowsAsync<ErrorApiException>(() => client.InitPaymentAsync(initPayment));
            Assert.Equal(ErrorCode.InvalidSignature, exception.Error.Code);
        }
        public async Task InitPayment_PlatronNotAvailableOrNotResolvable_ThrowsServiceNotAvailable(
            string notAvailableUrl, string description)
        {
            var initPayment = new InitPaymentRequest(1.Rur(), "sample description");

            var connection = new Connection(new Uri(notAvailableUrl), new Credentials("0000", "secret"), TimeSpan.FromSeconds(5));
            var client = new PlatronClient(connection);

            await Assert.ThrowsAsync<ServiceNotAvailableApiException>(() => client.InitPaymentAsync(initPayment));
        }
Esempio n. 5
0
        public async Task InitPayment_PlatronNotAvailableOrNotResolvable_ThrowsServiceNotAvailable(
            string notAvailableUrl, string description)
        {
            var initPayment = new InitPaymentRequest(1.Rub(), "sample description");

            var connection = new Connection(new Uri(notAvailableUrl), new Credentials("0000", "secret"), TimeSpan.FromSeconds(5));
            var client     = new PlatronClient(connection);

            await Assert.ThrowsAsync <ServiceNotAvailableApiException>(() => client.InitPaymentAsync(initPayment));
        }
Esempio n. 6
0
        public async Task InitPayment_InvalidMerchant_ThrowsInvalidResponse()
        {
            var initPayment = new InitPaymentRequest(1.Rub(), "sample description");
            var client      = new PlatronClient("0000", "secret");

            var exception =
                await Assert.ThrowsAsync <ErrorApiException>(() => client.InitPaymentAsync(initPayment));

            Assert.Equal(ErrorCode.InvalidMerchant, exception.Error.Code);
        }
Esempio n. 7
0
        public async Task InitPayment_InvalidSecretKey_ThrowsInvalidResponse()
        {
            var initPayment = new InitPaymentRequest(1.Usd(), "sample description");
            var client      = new PlatronClient(SettingsStorage.Credentials.MerchantId, "secret");

            var exception =
                await Assert.ThrowsAsync <ErrorApiException>(() => client.InitPaymentAsync(initPayment));

            Assert.Equal(ErrorCode.InvalidSignature, exception.Error.Code);
        }
Esempio n. 8
0
        public async Task InitPayment_ValidMerchant_Succeeds()
        {
            var initPayment = new InitPaymentRequest(1.Rub(), "sample description");
            var client      = new PlatronClient(SettingsStorage.Credentials);

            initPayment.InTestMode();
            var response = await client.InitPaymentAsync(initPayment);

            Assert.NotNull(response);
            Assert.NotNull(response.RedirectUrl);
        }
        public async Task InitPayment_ValidMerchant_Succeeds()
        {
            var initPayment = new InitPaymentRequest(1.Usd(), "sample description");
            var client = new PlatronClient(SettingsStorage.Credentials);

            initPayment.InTestMode();
            var response = await client.InitPaymentAsync(initPayment);

            Assert.NotNull(response);
            Assert.NotNull(response.RedirectUrl);
        }
        public async Task InitPaymentAsHtml_InvalidMerchant_ReturnsHtml()
        {
            var initPayment = new InitPaymentRequest(1.Rur(), "sample description");
            initPayment.Language = PlatronLanguage.English; // doesn't work. still in russian

            var client = new PlatronClient("0000", "secret");

            initPayment.InTestMode();
            var html = await client.InitPaymentAsHtmlAsync(initPayment);

            Assert.True(html.Content.Contains("Incorrect merchant"));
        }
Esempio n. 11
0
        public async Task InitPaymentAsHtml_InvalidMerchant_ReturnsHtml()
        {
            var initPayment = new InitPaymentRequest(1.Rub(), "sample description");

            initPayment.Language = PlatronLanguage.English; // doesn't work. still in russian

            var client = new PlatronClient("0000", "secret");

            initPayment.InTestMode();
            var html = await client.InitPaymentAsHtmlAsync(initPayment);

            Assert.True(html.Content.Contains("Incorrect merchant"));
        }
        public async Task InitPaymentAsHtml_ValidMerchant_ReturnsHtml()
        {
            var initPayment = new InitPaymentRequest(1.Eur(), "sample description");
            var client = new PlatronClient(SettingsStorage.Credentials);

            initPayment.InTestMode();
            var html = await client.InitPaymentAsHtmlAsync(initPayment);

            // requestUri contains redirect uri: https://www.platron.ru/payment_params.php?customer=f00e1b48ea91013cc7a40242f218e68821586740
            Assert.NotNull(html.RequestUri);

            // and requestUri contains 'customer' which hides inside html too:
            // <input type="hidden" name="customer" value="f00e1b48ea91013cc7a40242f218e68821586740">
            var customer = html.RequestUri.Query.Split('=').Last();
            Assert.True(html.Content.Contains(customer));
        }
Esempio n. 13
0
        public async Task InitPaymentAsHtml_ValidMerchant_ReturnsHtml()
        {
            var initPayment = new InitPaymentRequest(1.Eur(), "sample description");
            var client      = new PlatronClient(SettingsStorage.Credentials);

            initPayment.InTestMode();
            var html = await client.InitPaymentAsHtmlAsync(initPayment);

            // requestUri contains redirect uri: https://www.platron.ru/payment_params.php?customer=f00e1b48ea91013cc7a40242f218e68821586740
            Assert.NotNull(html.RequestUri);

            // and requestUri contains 'customer' which hides inside html too:
            // <input type="hidden" name="customer" value="f00e1b48ea91013cc7a40242f218e68821586740">
            var customer = html.RequestUri.Query.Split('=').Last();

            Assert.True(html.Content.Contains(customer));
        }
        public void TestEmptyConstructorsUsedForMappingFromConfigFile()
        {
            _ = new PaymentRequest();
            _ = new SettleTransactionRequest();
            _ = new VoidTransactionRequest();
            _ = new RefundTransactionRequest();
            _ = new GetPaymentStatusRequest();
            _ = new OpenOrderRequest();
            _ = new InitPaymentRequest();
            _ = new Authorize3dRequest();
            _ = new Verify3dRequest();
            _ = new PayoutRequest();
            _ = new GetCardDetailsRequest();
            _ = new GetMerchantPaymentMethodsRequest();

            Assert.Pass();
        }
Esempio n. 15
0
        public async Task GettingStarted_SampleClient_Succeeds()
        {
            var credentials = new Credentials("0000", "asdffsasdfasdfasdf");
            var client = new PlatronClient(credentials);

            // ensure that your server listens on that address and accepts GET request
            var resultUrl = new Uri("https://my.server.com/platron/result");

            var request = new InitPaymentRequest(1.Rub(), "Order payment")
            {
                OrderId = "#1234567890",
                UserPhone = "+79990001112",
                ResultUrl = resultUrl
            };

            InitPaymentResponse response = await client.InitPaymentAsync(request).ConfigureAwait(false);
            await SendToUserAsync(response.RedirectUrl).ConfigureAwait(false);
        }
Esempio n. 16
0
        public async Task GettingStarted_SampleClient_Succeeds()
        {
            var credentials = new Credentials("0000", "asdffsasdfasdfasdf");
            var client      = new PlatronClient(credentials);

            // ensure that your server listens on that address and accepts GET request
            var resultUrl = new Uri("https://my.server.com/platron/result");

            var request = new InitPaymentRequest(1.Rub(), "Order payment")
            {
                OrderId   = "#1234567890",
                UserPhone = "+79990001112",
                ResultUrl = resultUrl
            };

            InitPaymentResponse response = await client.InitPaymentAsync(request).ConfigureAwait(false);

            await SendToUserAsync(response.RedirectUrl).ConfigureAwait(false);
        }
Esempio n. 17
0
        public async Task FullPayment_ManualPaymentThruBrowser_Succeeds()
        {
            var connection = new Connection(PlatronClient.PlatronUrl, SettingsStorage.Credentials,
                                            HttpRequestEncodingType.PostWithQueryString);

            var client = new PlatronClient(connection);

            var initPaymentRequest = new InitPaymentRequest(1.01.Rub(), "verifying resulturl")
            {
                ResultUrl = _server.ResultUrl,
                UserPhone = SettingsStorage.PhoneNumber,
                OrderId   = Guid.NewGuid().ToString("N"),
                NeedUserPhoneNotification = true
            };

            // enables only test systems
            //initPaymentRequest.InTestMode();

            var response = await client.InitPaymentAsync(initPaymentRequest);

            // open browser = selenium can be here ^)
            Assert.NotNull(response);
            Assert.NotNull(response.RedirectUrl);
            Browser.Open(response.RedirectUrl);

            // we have some time to manually finish payment.
            var request = _server.WaitForRequest(TimeSpan.FromMinutes(3));

            _output.WriteLine(request.Uri.AbsoluteUri);

            var resultUrl = client.ResultUrl.Parse(request.Uri);

            // to return money back - it's enough to reject payment
            // and hope that your payment service supports it.
            var resultUrlResponse = client.ResultUrl.TryReturnReject(resultUrl, "sorry, my bad...");

            _output.WriteLine(resultUrlResponse.Content);

            request.SendResponse(resultUrlResponse.Content);
        }
Esempio n. 18
0
        public async Task <InitPaymentResponse> InitPayment(
            string currency,
            string amount,
            InitPaymentPaymentOption paymentOption,
            string userTokenId          = null,
            string clientUniqueId       = null,
            string clientRequestId      = null,
            DeviceDetails deviceDetails = null,
            UrlDetails urlDetails       = null,
            string customData           = null,
            UserAddress billingAddress  = null,
            string userId                 = null,
            string rebillingType          = null,
            string authenticationTypeOnly = null,
            SubMerchant subMerchant       = null,
            Addendums addendums           = null,
            string orderId                = null)
        {
            var request = new InitPaymentRequest(merchantInfo, sessionToken, currency, amount, paymentOption)
            {
                UserTokenId            = userTokenId,
                ClientRequestId        = clientRequestId,
                ClientUniqueId         = clientUniqueId,
                DeviceDetails          = deviceDetails,
                UrlDetails             = urlDetails,
                CustomData             = customData,
                BillingAddress         = billingAddress,
                UserId                 = userId,
                RebillingType          = rebillingType,
                AuthenticationTypeOnly = authenticationTypeOnly,
                SubMerchant            = subMerchant,
                Addendums              = addendums,
                OrderId                = orderId
            };

            return(await safechargeRequestExecutor.InitPayment(request));
        }
        public void TestGetAndSetModelInitPaymentRequest()
        {
            var initPaymentPaymentOption = new InitPaymentPaymentOption
            {
                Card = new InitPaymentCard
                {
                    CardNumber      = "",
                    CardHolderName  = "",
                    ExpirationMonth = "",
                    ExpirationYear  = "",
                    CVV             = "123",
                    ThreeD          = new InitPaymentThreeD
                    {
                        Acquirer = new Acquirer {
                            Bin = null, MerchantId = null, MerchantName = null
                        },
                        MethodNotificationUrl = null
                    }
                }
            };

            _ = new InitPaymentRequest(merchantInfo, sessionToken, currency, amount, initPaymentPaymentOption)
            {
                UserTokenId     = "",
                ClientRequestId = "",
                ClientUniqueId  = "",
                DeviceDetails   = new DeviceDetails {
                },
                UrlDetails      = new UrlDetails {
                },
                CustomData      = "",
                BillingAddress  = new UserAddress {
                }
            };

            Assert.Pass();
        }
        public void TestInitPaymentSuccess()
        {
            var paymentOptionInitPayment = new InitPaymentPaymentOption
            {
                Card = new InitPaymentCard
                {
                    CardNumber      = "5111426646345761",
                    CardHolderName  = "CL-BRW1",
                    ExpirationMonth = "12",
                    ExpirationYear  = "25",
                    CVV             = "217"
                }
            };

            var request = new InitPaymentRequest(merchantInfo, sessionToken, currency, amount, paymentOptionInitPayment);

            var response = requestExecutor.InitPayment(request).GetAwaiter().GetResult();

            Assert.IsNotNull(response);
            Assert.IsEmpty(response.Reason);
            Assert.AreEqual(ResponseStatus.Success, response.Status);
            Assert.IsNull(response.GwErrorReason);
            Assert.AreNotEqual(ApiConstants.TransactionStatusError, response.TransactionStatus);
        }
Esempio n. 21
0
 public async Task <InitPaymentResponse> InitPayment(InitPaymentRequest initPaymentRequest)
 {
     return(await this.PostAsync <InitPaymentResponse, InitPaymentRequest>(initPaymentRequest));
 }
        public void Test3dSecureChallengeFlowSuccess()
        {
            var paymentOptionInitPayment = new InitPaymentPaymentOption
            {
                Card = new InitPaymentCard
                {
                    CardNumber      = "4000020951595032",
                    CardHolderName  = "CL-BRW1",
                    ExpirationMonth = "12",
                    ExpirationYear  = "25",
                    CVV             = "217",
                    ThreeD          = new InitPaymentThreeD
                    {
                        MethodNotificationUrl = "www.ThisIsAMethodNotificationURL.com",
                    }
                }
            };

            var initPaymentRequest  = new InitPaymentRequest(merchantInfo, sessionToken, "USD", "500", paymentOptionInitPayment);
            var initPaymentResponse = requestExecutor.InitPayment(initPaymentRequest).GetAwaiter().GetResult();

            var po = new PaymentOption
            {
                Card = new Card
                {
                    CardNumber      = "4000020951595032",
                    CardHolderName  = "CL-BRW1",
                    ExpirationMonth = "12",
                    ExpirationYear  = "25",
                    CVV             = "217",
                    ThreeD          = new ThreeD
                    {
                        MethodCompletionInd = "U",
                        Version             = initPaymentResponse.PaymentOption.Card.ThreeD.Version,
                        V2AdditionalParams  = new V2AdditionalParams
                        {
                            ChallengePreference = "01",
                            DeliveryEmail       = "*****@*****.**",
                            DeliveryTimeFrame   = "03",
                            GiftCardAmount      = "1",
                            GiftCardCount       = "41",
                            GiftCardCurrency    = "USD",
                            PreOrderDate        = "20220511",
                            PreOrderPurchaseInd = "02",
                            ReorderItemsInd     = "01",
                            ShipIndicator       = "06",
                            RebillExpiry        = "20200101",
                            RebillFrequency     = "13",
                            ChallengeWindowSize = "05"
                        },
                        NotificationURL = "https://3dsecuresafecharge.000webhostapp.com/3Dv2/notificationUrl.php",
                        MerchantURL     = "http://www.The-Merchant-Website-Fully-Quallified-URL.com",
                        PlatformType    = "02",
                        BrowserDetails  = new BrowserDetails
                        {
                            AcceptHeader      = "text/html,application/xhtml+xml",
                            Ip                = "192.168.1.11",
                            JavaEnabled       = "TRUE",
                            JavaScriptEnabled = "TRUE",
                            Language          = "EN",
                            ColorDepth        = "48",
                            ScreenHeight      = "400",
                            ScreenWidth       = "600",
                            TimeZone          = "0",
                            UserAgent         = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47"
                        },
                        Account = new Account
                        {
                            NameInd               = "02",
                            Age                   = "05",
                            LastChangeDate        = "20190220",
                            LastChangeInd         = "04",
                            RegistrationDate      = "20190221",
                            PasswordChangeDate    = "20190222",
                            ResetInd              = "01",
                            PurchasesCount6M      = "6",
                            AddCardAttepmts24H    = "24",
                            TransactionsCount24H  = "23",
                            TransactionsCount1Y   = "998",
                            CardSavedDate         = "20190223",
                            CardSavedInd          = "02",
                            AddressFirstUseDate   = "20190224",
                            AddressFirstUseInd    = "03",
                            SuspiciousActivityInd = "01"
                        }
                    }
                }
            };
            var paymentRequest = new PaymentRequest(merchantInfo, sessionToken, "USD", "500", po)
            {
                RelatedTransactionId = initPaymentResponse.TransactionId,
                BillingAddress       = new UserAddress
                {
                    FirstName = "John",
                    LastName  = "Smith",
                    Address   = "340689 main St.",
                    City      = "London",
                    Country   = "GB",
                    Email     = "*****@*****.**"
                },
                ShippingAddress = new UserAddress
                {
                    FirstName = "John",
                    LastName  = "Smith",
                    Address   = "340689 main St.",
                    City      = "London",
                    Country   = "GB",
                    Email     = "*****@*****.**"
                },
                DeviceDetails = new DeviceDetails {
                    IpAddress = "93.146.254.172"
                }
            };
            var paymentResponse = requestExecutor.Payment(paymentRequest).GetAwaiter().GetResult();

            var acsUrl = paymentResponse.PaymentOption.Card.ThreeD.AcsUrl;
            var cReq   = paymentResponse.PaymentOption.Card.ThreeD.CReq;
            var url    = $"https://3dsecuresafecharge.000webhostapp.com/3Dv2/showUrl.php?acsUrl={acsUrl}&creq={cReq}";

            var paymentOptionC = new PaymentOption
            {
                Card = new Card
                {
                    CardNumber      = "4000020951595032",
                    CardHolderName  = "CL-BRW1",
                    ExpirationMonth = "12",
                    ExpirationYear  = "25",
                    CVV             = "217",
                }
            };
            var liabilityShiftRequest = new PaymentRequest(merchantInfo, sessionToken, currency, amount, paymentOptionC)
            {
                RelatedTransactionId = paymentResponse.TransactionId,
                TransactionType      = ApiConstants.TransactionTypeAuth,
                BillingAddress       = new UserAddress
                {
                    FirstName = "John",
                    LastName  = "Smith",
                    Address   = "340689 main St.",
                    City      = "London",
                    Country   = "GB",
                    Email     = "*****@*****.**"
                },
                DeviceDetails = new DeviceDetails {
                    IpAddress = "93.146.254.172"
                }
            };
            var liabilityShiftResponse = requestExecutor.Payment(liabilityShiftRequest).GetAwaiter().GetResult();

            Assert.IsNotNull(liabilityShiftResponse);
            Assert.IsEmpty(liabilityShiftResponse.Reason);
            Assert.AreEqual(ResponseStatus.Success, liabilityShiftResponse.Status);
            Assert.IsNull(liabilityShiftResponse.GwErrorReason);
            Assert.AreNotEqual(ApiConstants.TransactionStatusError, liabilityShiftResponse.TransactionStatus);
        }
        public void Test3dSecureFrictionlessFlowSuccess()
        {
            var paymentOptionInitPayment = new InitPaymentPaymentOption
            {
                Card = new InitPaymentCard
                {
                    CardNumber      = "4000027891380961",
                    CardHolderName  = "FL-BRW1",
                    ExpirationMonth = "12",
                    ExpirationYear  = "25",
                    CVV             = "217"
                }
            };

            var initPaymentRequest = new InitPaymentRequest(merchantInfo, sessionToken, currency, amount, paymentOptionInitPayment);

            var initPaymentResponse = requestExecutor.InitPayment(initPaymentRequest).GetAwaiter().GetResult();

            var po = new PaymentOption
            {
                Card = new Card
                {
                    CardNumber      = "4000027891380961",
                    CardHolderName  = "FL-BRW1",
                    ExpirationMonth = "12",
                    ExpirationYear  = "25",
                    CVV             = "217",
                    ThreeD          = new ThreeD
                    {
                        MethodCompletionInd = "U",
                        Version             = initPaymentResponse.PaymentOption.Card.ThreeD.Version,
                        NotificationURL     = "http://wwww.Test-Notification-URL-After-The-Challange-Is-Complete-Which-Recieves-The-CRes-Message.com",
                        MerchantURL         = "http://www.The-Merchant-Website-Fully-Quallified-URL.com",
                        PlatformType        = "02",
                        V2AdditionalParams  = new V2AdditionalParams
                        {
                            ChallengePreference = "01",
                            DeliveryEmail       = "*****@*****.**",
                            DeliveryTimeFrame   = "03",
                            GiftCardAmount      = "1",
                            GiftCardCount       = "41",
                            GiftCardCurrency    = "USD",
                            PreOrderDate        = "20220511",
                            PreOrderPurchaseInd = "02",
                            ReorderItemsInd     = "02",
                            ShipIndicator       = "06",
                            RebillExpiry        = "20200101",
                            RebillFrequency     = "13",
                            ChallengeWindowSize = "05"
                        },
                        BrowserDetails = new BrowserDetails
                        {
                            AcceptHeader      = "text/html,application/xhtml+xml",
                            Ip                = "192.168.1.11",
                            JavaEnabled       = "TRUE",
                            JavaScriptEnabled = "TRUE",
                            Language          = "EN",
                            ColorDepth        = "48",
                            ScreenHeight      = "400",
                            ScreenWidth       = "600",
                            TimeZone          = "0",
                            UserAgent         = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47"
                        },
                        Account = new Account
                        {
                            Age                   = "05",
                            LastChangeDate        = "20190220",
                            LastChangeInd         = "04",
                            RegistrationDate      = "20190221",
                            PasswordChangeDate    = "20190222",
                            ResetInd              = "01",
                            PurchasesCount6M      = "6",
                            AddCardAttepmts24H    = "24",
                            TransactionsCount24H  = "23",
                            TransactionsCount1Y   = "998",
                            CardSavedDate         = "20190223",
                            CardSavedInd          = "02",
                            AddressFirstUseDate   = "20190224",
                            AddressFirstUseInd    = "03",
                            NameInd               = "02",
                            SuspiciousActivityInd = "01"
                        }
                    }
                }
            };
            var paymentRequest = new PaymentRequest(merchantInfo, sessionToken, currency, amount, po)
            {
                RelatedTransactionId = initPaymentResponse.TransactionId,
                BillingAddress       = new UserAddress
                {
                    FirstName = "John",
                    LastName  = "Smith",
                    Address   = "340689 main St.",
                    City      = "London",
                    Country   = "GB",
                    Email     = "*****@*****.**"
                },
                ShippingAddress = new UserAddress
                {
                    FirstName = "John",
                    LastName  = "Smith",
                    Address   = "340689 main St.",
                    City      = "London",
                    Country   = "GB",
                    Email     = "*****@*****.**"
                },
                DeviceDetails = new DeviceDetails {
                    IpAddress = "93.146.254.172"
                }
            };
            var paymentResponse = requestExecutor.Payment(paymentRequest).GetAwaiter().GetResult();

            Assert.IsNotNull(paymentResponse);
            Assert.IsEmpty(paymentResponse.Reason);
            Assert.AreEqual(ResponseStatus.Success, paymentResponse.Status);
            Assert.IsNull(paymentResponse.GwErrorReason);
            Assert.AreNotEqual(ApiConstants.TransactionStatusError, paymentResponse.TransactionStatus);
        }
        public void TestRecurringWith3dSecureSuccess()
        {
            var paymentOptionInitPayment = new InitPaymentPaymentOption
            {
                Card = new InitPaymentCard
                {
                    CardNumber      = "4000020951595032",
                    CardHolderName  = "FL-BRW1",
                    ExpirationMonth = "12",
                    ExpirationYear  = "25",
                    CVV             = "217",
                    ThreeD          = new InitPaymentThreeD
                    {
                        MethodNotificationUrl = "www.ThisIsAMethodNotificationURL.com",
                    }
                }
            };

            var initPaymentRequest = new InitPaymentRequest(merchantInfo, sessionToken, "USD", "500", paymentOptionInitPayment)
            {
                UserTokenId = "recurringUser"
            };

            var initPaymentResponse = requestExecutor.InitPayment(initPaymentRequest).GetAwaiter().GetResult();

            var po = new PaymentOption
            {
                Card = new Card
                {
                    CardNumber      = "4000020951595032",
                    CardHolderName  = "FL-BRW1",
                    ExpirationMonth = "12",
                    ExpirationYear  = "25",
                    CVV             = "217",
                    ThreeD          = new ThreeD
                    {
                        MethodCompletionInd = "U",
                        Version             = initPaymentResponse.PaymentOption.Card.ThreeD.Version,
                        V2AdditionalParams  = new V2AdditionalParams
                        {
                            RebillExpiry    = "20200101",
                            RebillFrequency = "13"
                        },
                        NotificationURL = "http://wwww.Test-Notification-URL-After-The-Challange-Is-Complete-Which-Recieves-The-CRes-Message.com",
                        MerchantURL     = "http://www.The-Merchant-Website-Fully-Quallified-URL.com",
                        PlatformType    = "02",
                        BrowserDetails  = new BrowserDetails
                        {
                            AcceptHeader      = "text/html,application/xhtml+xml",
                            Ip                = "192.168.1.11",
                            JavaEnabled       = "TRUE",
                            JavaScriptEnabled = "TRUE",
                            Language          = "EN",
                            ColorDepth        = "48",
                            ScreenHeight      = "400",
                            ScreenWidth       = "600",
                            TimeZone          = "0",
                            UserAgent         = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47"
                        }
                    }
                }
            };
            var paymentRequest = new PaymentRequest(merchantInfo, sessionToken, "USD", "500", po)
            {
                RelatedTransactionId = initPaymentResponse.TransactionId,
                UserTokenId          = "recurringUser",
                IsRebilling          = 0,
                RebillingType        = "RECURRING",
                BillingAddress       = new UserAddress
                {
                    FirstName = "John",
                    LastName  = "Smith",
                    Address   = "340689 main St.",
                    City      = "London",
                    Country   = "GB",
                    Email     = "*****@*****.**"
                },
                ShippingAddress = new UserAddress
                {
                    FirstName = "John",
                    LastName  = "Smith",
                    Address   = "340689 main St.",
                    City      = "London",
                    Country   = "GB",
                    Email     = "*****@*****.**"
                },
                DeviceDetails = new DeviceDetails {
                    IpAddress = "93.146.254.172"
                }
            };
            var paymentResponse = requestExecutor.Payment(paymentRequest).GetAwaiter().GetResult();

            Assert.IsNotNull(paymentResponse);
            Assert.IsEmpty(paymentResponse.Reason);
            Assert.AreEqual(ResponseStatus.Success, paymentResponse.Status);
            Assert.IsNull(paymentResponse.GwErrorReason);
            Assert.AreNotEqual(ApiConstants.TransactionStatusError, paymentResponse.TransactionStatus);

            var getSessionTokenRequest = new GetSessionTokenRequest(merchantInfo);

            var getSessionTokenResponse = requestExecutor.GetSessionToken(getSessionTokenRequest).GetAwaiter().GetResult();

            sessionToken = getSessionTokenResponse.SessionToken;

            var recurringRequest = new PaymentRequest(merchantInfo, sessionToken, "USD", "10", new PaymentOption {
                UserPaymentOptionId = paymentResponse.PaymentOption.UserPaymentOptionId
            })
            {
                RelatedTransactionId = paymentResponse.TransactionId,
                IsRebilling          = 1,
                UserTokenId          = "recurringUser",
                BillingAddress       = new UserAddress
                {
                    FirstName = "John",
                    LastName  = "Smith",
                    Address   = "340689 main St.",
                    City      = "London",
                    Country   = "GB",
                    Email     = "*****@*****.**"
                },
                DeviceDetails = new DeviceDetails {
                    IpAddress = "93.146.254.172"
                }
            };
            var recurringResponse = requestExecutor.Payment(recurringRequest).GetAwaiter().GetResult();

            Assert.IsNotNull(recurringResponse);
            Assert.IsEmpty(recurringResponse.Reason);
            Assert.AreEqual(ResponseStatus.Success, recurringResponse.Status);
            Assert.IsNull(recurringResponse.GwErrorReason);
            Assert.AreNotEqual(ApiConstants.TransactionStatusError, recurringResponse.TransactionStatus);
        }
        public void Test3dSecureV1FallbackFlowSuccess()
        {
            var paymentOptionInitPayment = new InitPaymentPaymentOption
            {
                Card = new InitPaymentCard
                {
                    CardNumber      = "4012001037490014",
                    CardHolderName  = "john smith",
                    ExpirationMonth = "12",
                    ExpirationYear  = "25",
                    CVV             = "217",
                    ThreeD          = new InitPaymentThreeD
                    {
                        MethodNotificationUrl = "www.ThisIsAMethodNotificationURL.com",
                    }
                }
            };

            var initPaymentRequest = new InitPaymentRequest(merchantInfo, sessionToken, currency, amount, paymentOptionInitPayment);

            var initPaymentResponse = requestExecutor.InitPayment(initPaymentRequest).GetAwaiter().GetResult();

            var po = new PaymentOption
            {
                Card = new Card
                {
                    CardNumber      = "4012001037490014",
                    CardHolderName  = "asd asdas",
                    ExpirationMonth = "12",
                    ExpirationYear  = "25",
                    CVV             = "217",
                    ThreeD          = new ThreeD
                    {
                    }
                }
            };
            var paymentRequest = new PaymentRequest(merchantInfo, sessionToken, currency, amount, po)
            {
                RelatedTransactionId = initPaymentResponse.TransactionId,
                BillingAddress       = new UserAddress
                {
                    FirstName = "John",
                    LastName  = "Smith",
                    Address   = "340689 main St.",
                    City      = "London",
                    Country   = "GB",
                    Email     = "*****@*****.**"
                },
                ShippingAddress = new UserAddress
                {
                    FirstName = "John",
                    LastName  = "Smith",
                    Address   = "340689 main St.",
                    City      = "London",
                    Country   = "GB",
                    Email     = "*****@*****.**"
                },
                DeviceDetails = new DeviceDetails {
                    IpAddress = "93.146.254.172"
                }
            };
            var paymentResponse = requestExecutor.Payment(paymentRequest).GetAwaiter().GetResult();

            var acsUrl    = paymentResponse.PaymentOption.Card.ThreeD.AcsUrl;
            var paRequest = paymentResponse.PaymentOption.Card.ThreeD.PaRequest;

            var paResponse = ""; // result from paRequest

            po.Card.ThreeD.PaResponse = paResponse;

            var liabilityShiftRequest = new PaymentRequest(merchantInfo, sessionToken, currency, amount, po)
            {
                BillingAddress = new UserAddress
                {
                    FirstName = "John",
                    LastName  = "Smith",
                    Address   = "340689 main St.",
                    City      = "London",
                    Country   = "GB",
                    Email     = "*****@*****.**"
                },
                DeviceDetails = new DeviceDetails {
                    IpAddress = "93.146.254.172"
                }
            };
            var liabilityShiftResponse = requestExecutor.Payment(liabilityShiftRequest).GetAwaiter().GetResult();

            Assert.IsNotNull(liabilityShiftResponse);
            Assert.IsEmpty(liabilityShiftResponse.Reason);
            Assert.AreEqual(ResponseStatus.Success, liabilityShiftResponse.Status);
            Assert.IsNull(liabilityShiftResponse.GwErrorReason);
            Assert.AreNotEqual(ApiConstants.TransactionStatusError, liabilityShiftResponse.TransactionStatus);
        }
        public async Task InitPayment_SpecifiedRequestEncodingAndReturnType_Succeeds(
            HttpRequestEncodingType encodingType, InitPaymentResponseType responseType)
        {
            var connection = new Connection(PlatronClient.PlatronUrl, SettingsStorage.Credentials, encodingType);
            var client = new PlatronClient(connection);
            // To find out what really happens enable proxy (thru fiddler)
            // and use custom connection over http to watch plain requests
            //.EnableProxy(new WebProxy("http://localhost:8888", false));

            var initPayment = new InitPaymentRequest(1.Rur(), "Money first");
            initPayment.InTestMode();
            initPayment.OrderId = Guid.NewGuid().ToString("N");

            switch (responseType)
            {
                case InitPaymentResponseType.RedirectLink:
                    var response = await client.InitPaymentAsync(initPayment);
                    Assert.NotNull(response);
                    break;
                case InitPaymentResponseType.HtmlForm:
                    var html = await client.InitPaymentAsHtmlAsync(initPayment);
                    Assert.NotNull(html);
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(responseType), responseType, null);
            }
        }