示例#1
0
        public async Task <ActionResult> Purchase(long paymentId)
        {
            var payment = await _paymentAppService.GetPaymentAsync(paymentId);

            if (payment.Status != SubscriptionPaymentStatus.NotPaid)
            {
                throw new ApplicationException("This payment is processed before");
            }

            var model = new StripePurchaseViewModel
            {
                PaymentId          = payment.Id,
                Amount             = payment.Amount,
                Description        = payment.Description,
                IsRecurring        = payment.IsRecurring,
                Configuration      = _stripeConfiguration,
                UpdateSubscription = payment.EditionPaymentType == EditionPaymentType.Upgrade
            };

            var sessionId = await StripePaymentAppService.CreatePaymentSession(new StripeCreatePaymentSessionInput()
            {
                PaymentId  = paymentId,
                SuccessUrl = _webUrlService.GetSiteRootAddress().EnsureEndsWith('/') + "Stripe/GetPaymentResult",
                CancelUrl  = _webUrlService.GetSiteRootAddress().EnsureEndsWith('/') + "Stripe/PaymentCancel",
            });

            if (payment.IsRecurring && payment.EditionPaymentType == EditionPaymentType.Upgrade)
            {
                model.IsRecurring = false;
            }

            model.SessionId = sessionId;

            return(View(model));
        }
示例#2
0
        public async Task <ActionResult> GetPaymentResult(string sessionId)
        {
            var payment = await StripePaymentAppService.GetPaymentAsync(
                new StripeGetPaymentInput
            {
                StripeSessionId = sessionId
            });

            if (payment.TenantId != AbpSession.TenantId)
            {
                return(new NotFoundResult());
            }

            ViewBag.PaymentId = payment.Id;
            return(View());
        }
        public async Task <ActionResult> GetPaymentResult(string sessionId)
        {
            var payment = await StripePaymentAppService.GetPaymentAsync(
                new StripeGetPaymentInput
            {
                StripeSessionId = sessionId
            });

            using (CurrentUnitOfWork.SetTenantId(null))
            {
                var tenant = await _tenantManager.GetByIdAsync(payment.TenantId);

                await _stripeGatewayManager.UpdateCustomerDescriptionAsync(sessionId, tenant.TenancyName);
            }

            if (payment.TenantId != AbpSession.TenantId)
            {
                return(new NotFoundResult());
            }

            ViewBag.PaymentId = payment.Id;
            return(View());
        }