Well, from taking a look at the code, I decided that this feature needs to be built. So here is how I am proceeding:
1. Created an additional constructor for PaymentService that takes in an IPaymentProvider :
public PaymentService(IPaymentProvider customPaymentProvider)
{
_paymentProviderCollection = new PaymentProviderCollection();
_paymentProviderCollection.Add(customPaymentProvider);
}
2. Created an overload of the OrderController.Charge Method that takes a IPaymentProvider as a parameter. It just passes the IPaymentProvider when creating a the PaymentService.
public static Transaction Charge(Order order, IPaymentProvider customPaymentProvider, string userName)
{
[... code ...]
PaymentService paymentService = new PaymentService(customPaymentProvider);
[... code ...]
}
3. Modify the CheckOut.aspx.cs btnProcessOrder_Click to call the new overloaded OrderController.Charge method:
transaction =
OrderController.Charge(order, new FreePaymentProvider(), GetUserName());
Well, off to go and test it out to see if it works...
Alex