#edutomesco
1 messages · Page 1 of 1 (latest)
Hi
Can you give a concrete example please of this ?
yes
I have a product that have 5 prices of yearly recurrence. This 5 prices represent 5 services on my company that are metered prices with layers. The first layer is the quantity is included on your subscription and it costs 0€. The second layer is all the overage that the user consumes that is not included on the subscription and so it would be charge the next billing cycle that extra amount. But with the annual plans what happens is that I don't want to wait one year to charge this extra amount I want to control that monthly, and so I would like to every month passed on an annual subscription to emit an invoice to the customer to liquidate this overage used.
The reason the interval is anual is because one of the price is a licensed that is a fixed price the user should pay in the case of annual subscriptions annually
More clear?
I'm thinking on create a worker on my service to control when the subscription change of month and emit an invoice manually for all the overage the user did.
Hi?
Sorry for my late reply, I think you can refer to this:
https://stripe.com/docs/billing/invoices/subscription#generating-invoices
Otherwise, you can create multiple subscription for the same customer, each Subscription represent a Layer, (one annual subscription, one monthly...)
I can't do that because I used the checkout of Stripe
I'm struggling to understand the use case you describe. Can you share an existing sub_xxx that demonstrates the behaviour?
sub_1MnzULG1fQyuUuzXngkGkfTV
But with the annual plans what happens is that I don't want to wait one year to charge this extra amount I want to control that monthly
That's just not possible unfortunately
and so I would like to every month passed on an annual subscription to emit an invoice to the customer to liquidate this overage used.
Why not just use a monthly price?
The reason the interval is anual is because one of the price is a licensed that is a fixed price the user should pay in the case of annual subscriptions annually
Then this is something you'd need to account for in your integration. Perhaps you prevent cancellations until after annual period is over
exactly if user cancels you have access since the finalitzation of your subscription because you already paid
can you propose me a better design?
or how people manage this use case?
because I need one compact invoice with all the services (prices) that we offer
Business model don't allow me to emit two different invoices with different prices
Then just prevent them from being able to cancel the subscription until a specific date (i.e. don't allow for it in your UI)
But I don't unserstand why this can help me?
because I need to charge the licensed prices just ones per year
Well then have 2 Subscriptions: one with the annual price, and the other with the recurring monthly prices
If you need them on one Invoice, then you'll need to use your own Invoicing service
but I'm using the checkout of stripe I think I can't achieve that
There's no way to do what you're describing with a single Subscription
True, Checkout can't really support super complex, niche use cases like that
and about this?
Use pending_invoice_item_interval to specify an interval for how often to bill for any pending invoice items. This is equivalent to having Stripe create a one-off invoice for the subscription on a recurring basis.
this could handle it?
Maybe that will work, have you tried it? Your use case is very specific, it's hard for me to fully recommend something as I don't have all the context you do
I didn't try it
But this is to put prices to execute on different interval isn't it?
No, you'd need to manually add the invoice items to each Invoice not the Subscription
I mean what is considered a pending invoice item?
don't understand
But this is an attribute that you set in the susbcription
Read the documentation:
These one-off items are added to the next invoice created for this customer. To make sure this is added to a specific subscription, use the optional subscription parameter to apply it to that subscription.
So you'd need to add them ~every month I imagine if your Subscription is annual
That doesn't add it to the Subscription, it just means to allow apply/charge for those pending items on invoice related to that subscription
but how this invoice is trigger?
I mean I need to do something apart from specify this when I create the subscription?
Because you'd specify pending_invoice_item_interval: https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_invoice_item_interval
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
The best option is you to just try this out, and use billing clocks to see if this works as you need
Okey, but I dont need to manually create any invoice no?
No, you'd need to manually create the Invoice Item every month though to reflect the monthly charge you want
but how I know when I need to create this invoice?
I mean I need a webhook or something like this no?
because its tottally async
You'd create it via a job or a queue I guess, at whatever timestamp you want to generate the monthly invoice
In general, when a customer incurs overage charges for a metered price during the middle of a subscription period, a pending invoice item is created for the overage amount, and this item is added to the next invoice that is generated for the subscription, according to the specified pending_invoice_item_interval. The exact amount of the pending invoice item will depend on the pricing and metered usage for the specific price in question.
but reading this it suggests I do not need to create any invoice
I mean
how I know when it's the next month if I put an interval of "month"
You don't create an Invoice no, you'd create an Invoice Item every month (if that's the interval you want), which would be invoiced according to the pending_invoice_item_interval field on the Subscription
As stated, you need to programmatically create these Invoice Items on the 1st of every month, for example (or whenever you want to bill the user)
and how I can do that?
I don't exactly understand
So then why it's used ending_invoice_item_interval
if I need to control myself the first of each month
Because otherwise, we'll only generated an Invoice for those pending items according to the default billing cycle for the Subscription. Which, in your case, would be yearly
This is what that parameter exists, so you can charge for one-off items related to the Subscription of a different interval
But you need to create the Invoice Items yourself
Okey so then I need to put all the prices that I want to charge on this invoiceitem object?
But for me the difficult thing is to know when I should put this? I need to know the change of month and that is sync with the stripe
Yes, correct
I don't understand the question
I can execute this in a cron for example every two hours
Honestly, my original recommendation would be to just try this out and see how it works, and whether it's a good fit for you
so first it's better to try just setting the parameter
Create your Subscription with your annual Price, set pending_invoice_item_interval: 'monthly'
monthly it's month isn't it?
Then try adding Invoice Items, passing the subscription parameter and see what happens
You'll need to do this with a test clock so you can jump forward to the billing intervals as needed
but how can I specified this customer and subscirption on test clock
if I can put code to create it?
You'd create the clock and then create a new Customer and Subscription: https://stripe.com/docs/billing/testing/test-clocks#how-to-use-test-clocks