Base solution for your next web application
Open Closed

Stripe integration question - do invoices pick up all line items from Stripe, or only the Edition? #12616


User avatar
0
eric_pulaski created

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:

  1. The initial purchase, which would be a pro-rated monthly rate on the day that the add-on was purchased;
  2. 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

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

2 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    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 SubscriptionPaymentProducts are sent to Stripe and stored in the AppSubscriptionPaymentProducts table. The invoice display (via InvoiceAppService.cs) pulls these products and shows them as Items:

    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 single SubscriptionPaymentProduct. 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:

    1. Modify TenantManager.HandleEvent(RecurringPaymentSucceedEventData) to iterate through ALL items in eventData.Items and create multiple SubscriptionPaymentProduct entries (not just the first Edition item).

    2. Add a PlanType for add on features (currently it only recognizes PaymentConsts.EditionSubscriptionPlan).

    3. 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 supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    eric_pulaski created

    Just the info I needed. Thanks.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)