コード例 #1
0
        /// <summary>
        /// Helper method to retry payment with cheap gateway, if model matches business requirements
        /// </summary>
        /// <param name="paymentModel"></param>
        /// <returns></returns>
        private PaymentResult RetryWithCheapPaymentGateway(PaymentModel paymentModel)
        {
            var expensiveGatewayResponse = _expensivePaymentGateway.BankTransfer(paymentModel);

            if (expensiveGatewayResponse.StatusCode == _config.ThirdPartyErrorResponse)
            {
                // Service is unavailable. Retry with cheap gateway
                var thirdPartyResponse = _cheapPaymentGateway.BankTransfer(paymentModel);

                return(thirdPartyResponse);
            }
            else
            {
                return(expensiveGatewayResponse);
            }
        }