Ejemplo n.º 1
0
        public void RegisterPayment()
        {
            var appSettings = ConfigurationManager.AppSettings;
            var client      = new NetaxeptServiceClient(new ClientConnection(appSettings["Netaxept:MerchantId"], appSettings["Netaxept:Token"], false));

            var paymentRequest = CreatePaymentRequest();
            var transactionId  = client.Register(paymentRequest);

            Assert.NotEmpty(transactionId);
        }
Ejemplo n.º 2
0
        public void RegisterPayment_Invalid_PhoneNumber()
        {
            var appSettings = ConfigurationManager.AppSettings;
            var client      = new NetaxeptServiceClient(new ClientConnection(appSettings["Netaxept:MerchantId"], appSettings["Netaxept:Token"], false));

            var paymentRequest = CreatePaymentRequest();

            paymentRequest.CustomerPhoneNumber = "1";

            Exception ex = Assert.Throws <ValidationException>(() => client.Register(paymentRequest));

            Assert.Equal("Invalid phonenumber, e.g. +4712345678, +469876543", ex.Message);
        }
Ejemplo n.º 3
0
        public async void CanProcessAuthorize()
        {
            var appSettings = ConfigurationManager.AppSettings;

            var merchantId   = appSettings["Netaxept:MerchantId"];
            var token        = appSettings["Netaxept:Token"];
            var isProduction = false;

            var client = new NetaxeptServiceClient(new ClientConnection(merchantId, token, isProduction));

            var paymentRequest = CreatePaymentRequest();
            var transactionId  = client.Register(paymentRequest);

            var redirectUrl = TerminalHelper.GetRedirectUrl(merchantId, transactionId, isProduction);

            var browserFetcher = new BrowserFetcher();
            var launchOptions  = new LaunchOptions {
                Headless = true
            };
            await browserFetcher.DownloadAsync();

            using (var browser = await Puppeteer.LaunchAsync(launchOptions))
                using (var page = await browser.NewPageAsync())
                {
                    await page.GoToAsync(redirectUrl);
                    await ExecuteCustomerPaymentAutomation(page, "#Visa", "4925000000000004", DateTime.UtcNow.AddYears(1), "123");

                    // For some reason, page.WaitForNavigationAsync doesn't work
                    // 5 seconds seems enough time for Nets to process
                    await page.WaitForTimeoutAsync(5000);

                    Assert.StartsWith(paymentRequest.SuccessUrl, page.Url);
                }

            var processResult = client.Authorize(transactionId);

            Assert.Equal("OK", processResult.ResponseCode);

            var paymentResult = client.Query(transactionId);

            Assert.True(paymentResult.Authorized);
        }