コード例 #1
0
ファイル: PaymentBl.cs プロジェクト: meowzrin/paymentApi
        public async Task <PaymentResponse> processData(PaymentData paymentInfo)
        {
            int retryAttempts = 0;

            PaymentResponse response = new PaymentResponse();

            if (paymentInfo.amount < 20)
            {
                response = _cheapPaymentGateway.processPayment(paymentInfo);
            }
            else if (paymentInfo.amount > 20 && paymentInfo.amount < 500)
            {
                response = _cheapPaymentGateway.processPayment(paymentInfo);
                if (response.Status == "Fail")
                {
                    response = _expensivePaymentGateway.processPayment(paymentInfo);
                }
            }
            else
            {
                response = _expensivePaymentGateway.processPayment(paymentInfo);
                while (response.Status == "Fail" && retryAttempts <= 3)
                {
                    response = _expensivePaymentGateway.processPayment(paymentInfo);
                    retryAttempts++;
                }
            }
            return(response);
        }