示例#1
0
        public async Task <PaymentResponse> DoPaymentAsync(Payment payment)
        {
            // send the payment request through _paymentGatewayProxy
            payment.MerchantId = merchantIdGuid;
            //payment.RequestId = Guid.NewGuid().ToString();
            var response = await _paymentGatewayProxy.CreatePaymentAsync(payment);

            if (response != null && string.IsNullOrEmpty(response.ErrorCode))
            {
                for (int i = 0; i < 3; i++)
                {
                    await Task.Delay(1000);

                    var paymentStatus = await _paymentGatewayProcessorProxy.GetPaymentStatusAsync(response.PaymentRequestId);

                    if (paymentStatus != null && string.IsNullOrEmpty(paymentStatus.ErrorCode))
                    {
                        response.CreatedAt     = paymentStatus.CreatedAt;
                        response.UpdatedAt     = paymentStatus.UpdatedAt;
                        response.TransactionId = paymentStatus.TransactionId;
                        response.Status        = paymentStatus.Status;
                        if (response.Status != "Scheduled")
                        {
                            break;
                        }
                    }
                }
            }

            return(response);
        }
        [ProducesResponseType(typeof(PaymentStatusModel), 200)] // OK
        public async Task <IActionResult> GetByPaymentGuidId(Guid paymentRequestId)
        {
            var response = await _paymentGatewayProcessorProxy.GetPaymentStatusAsync(paymentRequestId);

            return(Ok(_mapper.Map <PaymentStatusModel>(response)));
        }