public PoliApiController( IOnlinePaymentManager onlinePaymentManager, IStartPaymentStrategy <PoliPayment, StartPoliPaymentResponse> startPaymentStrategy, ICompletePaymentStrategy <string, PoliCompleteResponse, PoliPayment> completeStrategy) { _onlinePaymentManager = onlinePaymentManager; _startPaymentStrategy = startPaymentStrategy; _completeStrategy = completeStrategy; }
public PayPalApiController( IOnlinePaymentManager onlinePaymentManager, IStartPaymentStrategy <PayPalPayment, StartPayPalPaymentResponse> startPaymentStrategy, IPaymentStepStrategy <string, PayPalConfirmResponse> confirmStrategy, ICompletePaymentStrategy <string, PayPalCompleteResponse, PayPalPayment> completeStrategy) { _onlinePaymentManager = onlinePaymentManager; _startPaymentStrategy = startPaymentStrategy; _confirmStrategy = confirmStrategy; _completeStrategy = completeStrategy; }
public TResponse Begin <TPayment, TResponse>( TPayment payment, IStartPaymentStrategy <TPayment, TResponse> paymentStrategy, IResponseCreator <TResponse> responseCreator) where TPayment : OnlinePayment where TResponse : IStartOnlinePaymentResponse { if (!IsItemValidToPurchase(payment)) { var errorResponse = responseCreator.Create(); errorResponse.AddError("Invalid item being paid for"); return(errorResponse); } var populatedOnlinePayment = GetPopulatedPayment(payment); var response = paymentStrategy.StartPayment(populatedOnlinePayment); _repository.Create(populatedOnlinePayment); return(response); }