示例#1
0
        public TransactionResult ProcessTransaction(TransactionRequest request)
        {
            var stripeSettings = DependencyResolver.Resolve <StripeSettings>();

            if (request.RequestType == TransactionRequestType.Payment)
            {
                if (stripeSettings.UseRedirectionFlow)
                {
                    return(StripeHelper.CreateSessionRedirect(request, stripeSettings, _logger, false));
                }
                return(StripeHelper.ProcessPayment(request, stripeSettings, _logger));
            }
            if (request.RequestType == TransactionRequestType.Refund)
            {
                return(StripeHelper.ProcessRefund(request, stripeSettings, _logger));
            }
            if (request.RequestType == TransactionRequestType.Void)
            {
                return(StripeHelper.ProcessVoid(request, stripeSettings, _logger));
            }
            if (request.RequestType == TransactionRequestType.Capture)
            {
                return(StripeHelper.ProcessCapture(request, stripeSettings, _logger));
            }
            if (request.RequestType == TransactionRequestType.SubscriptionCreate)
            {
                if (stripeSettings.UseRedirectionFlow)
                {
                    return(StripeHelper.CreateSessionRedirect(request, stripeSettings, _logger, true));
                }
                return(StripeHelper.CreateSubscription(request, stripeSettings, _logger));
            }
            if (request.RequestType == TransactionRequestType.SubscriptionCancel)
            {
                return(StripeHelper.StopSubscription(request, stripeSettings, _logger));
            }
            return(null);
        }