public Payment ProcessPayment(Payment payment) { _repository.CreatePayment(payment); PaymentState paymentResponse; if (payment.Amount < Constants.CheapAmountUpperBound) { paymentResponse = _cheapPaymentGateway.Charge(payment); } else if (payment.Amount >= Constants.CheapAmountUpperBound && payment.Amount <= Constants.ExpensiveAmountUpperBound) { paymentResponse = _expensivePaymentGateway.Charge(payment); if (paymentResponse.Status != PaymentStatusTypes.Processed) { paymentResponse = _cheapPaymentGateway.Charge(payment); } } else if (payment.Amount > Constants.ExpensiveAmountUpperBound) { int count = 0; do { paymentResponse = _premiumPaymentService.Charge(payment); count++; }while( count < Constants.PremiumPaymentServiceCount && paymentResponse.Status != PaymentStatusTypes.Processed ); } return(payment); }