private async Task <string> DoPayment(PaymentRequest request) { Console.WriteLine("Call to payment API has started..."); //if() if (checkAvailability()) { Console.WriteLine("Payment is successfully completed"); // Logic to consume external service provider for payments goes here.. return("Ok"); } else { return(await _cheapPaymentGateway.ProcessCheapPaymentAsync(request)); } }
public async Task <bool> PaymentGatewaySelectorLAsync(PaymentRequest payment) { if (payment.Amount > 20 && payment.Amount < 500) { var check = await _expensivePayment.ProcessExpensivePaymentAsync(payment); if (check == "Ok") { return(true); } else { return(false); } } else if (payment.Amount < 20) { var check = await _cheapPayment.ProcessCheapPaymentAsync(payment); if (check == "Ok") { return(true); } else { return(false); } } else if (payment.Amount > 500) { var check = await _expensivePayment.ProcessPremiumPaymentAsync(payment); if (check == "Ok") { return(true); } else { return(false); } } return(false); }