Exemple #1
0
        public async Task <BankPaymentResponse> ProcessPayment(BankPaymentRequest requestModel)
        {
            using var request = new HttpRequestMessage
                  {
                      RequestUri = new Uri($"{_acquiringBankSettings.ApiUrl}/api/payment"),
                      Method     = HttpMethod.Post,
                      Content    = requestModel.ToStringContent()
                  };

            var response = await _httpClient.SendAsync(request);

            if (!response.IsSuccessStatusCode)
            {
                return(new BankPaymentResponse
                {
                    PaymentIdentifier = Guid.NewGuid().ToString(),
                    PaymentStatus = PaymentStatus.Failed
                });
            }

            var responseContent = await response.Content.ReadAsStringAsync();

            return(responseContent.FromJson <BankPaymentResponse>());
        }
        public async Task <BankPaymentResponse> ProcessPayment(BankPaymentRequest requestModel)
        {
            using var request = new HttpRequestMessage
                  {
                      RequestUri = new Uri($"{_acquiringBankSettings.ApiUrl}/api/payment"),
                      Method     = HttpMethod.Post,
                      Content    = requestModel.ToStringContent()
                  };

            var response = await _httpClient.SendAsync(request);

            if (!response.IsSuccessStatusCode)
            {
                _logger.Error($"acquring bank payment failed. error: {response.ReasonPhrase}");
                return(new BankPaymentResponse
                {
                    PaymentStatus = PaymentStatus.Failed
                });
            }

            var responseContent = await response.Content.ReadAsStringAsync();

            return(responseContent.FromJson <BankPaymentResponse>());
        }