예제 #1
0
        public void QueryPayment()
        {
            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);

            var result = client.Query(transactionId);

            Assert.NotNull(result);
        }
예제 #2
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);
        }
        public PaymentResult QueryTransaction(Guid paymentMethodId, string transactionId)
        {
            try
            {
                var paymentMethodDto = PaymentManager.GetPaymentMethod(paymentMethodId);
                var merchantId       = paymentMethodDto.GetParameter(NetaxeptConstants.MerchantIdField, string.Empty);
                var token            = paymentMethodDto.GetParameter(NetaxeptConstants.TokenField, string.Empty);
                var isProduction     = bool.Parse(paymentMethodDto.GetParameter(NetaxeptConstants.IsProductionField, "false"));

                var connection = new ClientConnection(merchantId, token, isProduction);
                var client     = new NetaxeptServiceClient(connection);
                return(client.Query(transactionId));
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
            }

            return(null);
        }