示例#1
0
        public async Task PaymentProcess()
        {
            bool IsPaymentSuccess = false;

            if (paymentDTO.IsCheapPayment)
            {
                IsPaymentSuccess = paymentGateway.CheapPaymentService();
            }
            else if (paymentDTO.IsExpensivePayment)
            {
                IsPaymentSuccess = paymentGateway.ExpensivePaymentService(); // to check expensive payment service is available or not.
                if (!IsPaymentSuccess)
                {
                    IsPaymentSuccess = paymentGateway.CheapPaymentService();
                }
            }
            else if (paymentDTO.IsPremiumPayment)
            {
                IsPaymentSuccess = Retry.Do(paymentGateway.PremiumPaymentService, TimeSpan.FromSeconds(1));
            }

            if (IsPaymentSuccess)
            {
                paymentDTO.PaymentState = "Processed";
            }
            else
            {
                paymentDTO.PaymentState = "Failed";
            }

            paymentDTO.IsSuccess = true;
        }