Пример #1
0
 public PoliApiController(
     IOnlinePaymentManager onlinePaymentManager,
     IStartPaymentStrategy <PoliPayment, StartPoliPaymentResponse> startPaymentStrategy,
     ICompletePaymentStrategy <string, PoliCompleteResponse, PoliPayment> completeStrategy)
 {
     _onlinePaymentManager = onlinePaymentManager;
     _startPaymentStrategy = startPaymentStrategy;
     _completeStrategy     = completeStrategy;
 }
Пример #2
0
 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;
 }
Пример #3
0
        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);
        }