#mtanzi-subscriptions
1 messages ยท Page 1 of 1 (latest)
hi! I'd need to test it but I think you can just add invoice items to the subscription normally and there's a final invoice at the end of the period
here is an example of event that is sent when a subscription is finally cancelled, the only invoice id I see is the latest_invoice
https://dashboard.stripe.com/test/events/evt_1L5ryUJfYi7qv89iuAfkOguJ
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
yeah I just tested it with Test Clocks and a final invoice is generated
yep but to be clear I mean
- create subscription date X, next billing is in a month on Y
- at X+5 days set cancel_at_period_end: true
- at x+7, create a pending invoice item (https://stripe.com/docs/billing/invoices/subscription#adding-upcoming-invoice-items)
- on Y, we create an invoice that charges for the outstanding pending item, and the subscription is cancelled
at x+7, create a pending invoice item
the first 2 steps are correct, then from X+5 to Y the user uses the app and when the subscription cancelled event comes at Y I want to create an invoice to charge "somthing" that is calculated at the end of the period
can you calculate it before then?
it would be much easier
then it would just work the way I say, you fire off an API request at any point during the period and forget about it
no because that's a comulative sum that can change untill the end
then I'd say your options are
1 - set up a cron job or something else to remind your system to calculate+send the API request e.g. an hour before the subscription is going to end
2 - if it really has to be after the end of the period, you'd have to create a one-off invoice(https://stripe.com/docs/invoicing/integration) for the amount
I think that creating a one off incoice for that amount is ok ๐ ,
what is the best way to do that since the subscription at that point will be cancelled, can you create an invoice without subscription?
here is an example of empty invoice and that fails..
i = Stripe::Invoice.create(customer: 'cus_LnlcXZSPBiQJeu')
Stripe::InvalidRequestError: Nothing to invoice for customer
What I was thinking doing is to create an empty invoice, then attache the lineitem and then close the invoice
you can't do that
you have to create the item first, then the invoice, that's how the Invoicing API works unfortunately (see the guide I linked which describes how to create the invoice item and then the invoice, which 'sucks in' the pending items)
I see, ok it makes sense! I would just need to invert the calls ๐