Following up on a previous question about add-on licenses, if a customer purchase add-on license for their Edition (let's say we also charge for "Additional Users") and we add those as addition features in Stripe, when the Webhook receives notice of a successful payment from Stripe, will there be a reflection in the invoice in the ASP.Net Zero's portal for:
- The initial purchase, which would be a pro-rated monthly rate on the day that the add-on was purchased;
- During monthly recurring payments, will there be a line on the invoice for both the Edition and the Additional Users, or whatever else was paid for by the customer?
I'm working on requirements and trying to see whether we need to modify the code that creates invoices or not.
Thanks in advance for a reply.
-Eric
2 Answer(s)
-
0
Hi @eric_pulaski
Current Implementation
1. Initial Payment (One time/First Purchase)
For initial payments (non recurring), ASP.NET Zero does support multiple line items. Looking at StripePaymentAppService.cs:
sessionCreateOptions.LineItems = payment.SubscriptionPaymentProducts .Select(p => new SessionLineItemOptions { Quantity = p.Count, PriceData = new SessionLineItemPriceDataOptions { UnitAmount = _stripeGatewayManager.ConvertToStripePrice(p.Amount), Currency = AbpZeroTemplateConsts.Currency, ProductData = new SessionLineItemPriceDataProductDataOptions { Description = p.Description, Name = AbpZeroTemplateConsts.ProductName } } }).ToList();All items in
SubscriptionPaymentProductsare sent to Stripe and stored in theAppSubscriptionPaymentProductstable. The invoice display (via InvoiceAppService.cs) pulls these products and shows them asItems:Items = payment.SubscriptionPaymentProducts,Initial purchases with multiple products WILL be reflected in the invoice.
2. Recurring Payments (Subscription Cycle)
For recurring subscription cycle payments, there's a limitation. Looking at TenantManager.cs:
var payment = new SubscriptionPayment { ... SubscriptionPaymentProducts = { new SubscriptionPaymentProduct( $"Extend subscription {Convert.ToInt32(paymentPeriodType)} days for {editionDisplayName}", editionItem.Amount, 1, totalAmount: editionItem.Amount ) } };The current implementation only processes the first item (
editionItem = eventData.Items.FirstOrDefault()) from the Stripe invoice and creates a singleSubscriptionPaymentProduct. Other line items (like "Additional Users") from Stripe are ignored.While StripeGatewayManager.cs correctly reads all line items from Stripe:
foreach (var i in invoice.Lines.Data) { var item = new RecurringPaymentLineItem { Product = i.Pricing?.PriceDetails?.Product, PlanId = i.Pricing?.PriceDetails?.Price, PlanType = await GetPlanTypeByIdAsync(i.Pricing?.PriceDetails?.Price), Amount = ConvertFromStripePrice(i.Amount) }; items.Add(item); }Only the Edition line item is processed for recurring payments. Add on features like "Additional Users" are NOT reflected in the ASP.NET Zero invoice.
Yes, code modifications will be required to fully support add on products in recurring payment invoices. Specifically:
Modify
TenantManager.HandleEvent(RecurringPaymentSucceedEventData)to iterate through ALL items ineventData.Itemsand create multipleSubscriptionPaymentProductentries (not just the first Edition item).Add a PlanType for add on features (currently it only recognizes
PaymentConsts.EditionSubscriptionPlan).Consider how to handle feature provisioning the current implementation only updates the tenant's edition, but add on features may need separate handling.
Please feel free to contact us if you need any further information.
Thank you
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Just the info I needed. Thanks.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)