#mtanzi-subscriptions

1 messages ยท Page 1 of 1 (latest)

unborn saffron
#

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

real jungle
unborn saffron
#

yeah I just tested it with Test Clocks and a final invoice is generated

unborn saffron
real jungle
#

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

unborn saffron
#

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

real jungle
#

no because that's a comulative sum that can change untill the end

unborn saffron
#

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

real jungle
#

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

unborn saffron
#

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)

real jungle
#

I see, ok it makes sense! I would just need to invert the calls ๐Ÿ™‚