public static bool OnPaymentProcessed(Payment payment) { bool success = true; foreach (ICardPaymentProcessor processor in CardPaymentProcessors) { PaymentProcessorResult result = processor.ProcessPayment(payment); if (result == PaymentProcessorResult.Succeeded) { return(true); } if (result == PaymentProcessorResult.Failed) { success = false; } } return(success); }
public static void OnPaymentCommited(Payment payment) { bool processingFailed = false; foreach (ICardPaymentProcessor processor in CardPaymentProcessors) { PaymentProcessorResult result = processor.PaymentCommited(payment); if (result == PaymentProcessorResult.Succeeded) { return; } if (result == PaymentProcessorResult.Failed) { processingFailed = true; } } if (processingFailed) { throw new ApplicationException("Payment completion failed!"); } }