#tomkcey-subscription
1 messages ยท Page 1 of 1 (latest)
Hello ๐
Give me a moment to catch up here
can you share the example request IDs for these?
I'm not sure what you mean. I'm pinging my own test environment, test mode in Stripe Dashboard.
So the request that you're making to subscription cancel API, should have a request ID.
You'll find it here
https://dashboard.stripe.com/test/logs
That's from the /test/logs page.
The previous one was from the specific customer's.
There should be request IDs for these
Should look like req_xxxxxx
DELETE /v1/subscriptions/sub_1L3iLEBcZkr7pv9q4eHljcV7
Status
200 OK
ID
req_4CfmSBSiceEne9
Thanks! looking
But, do you know how to cancel a subscription and charge any amount accrued during the current cycle immediately?
That's essentially the question. I'm not sure why we're looking at logs.
You said with invoice_now it isn't generating a final invoice right?
It should for accrued amount during the current cycle
It's generating an invoice and paying it but it sets the amount to 0$. In my retrieveUpcoming (basically my tests), I'm setting the accrued usage to equivalent of 5000$.
I thought I'd see an invoice with 5000$ on it. Is that "hidden" or somesuch?
Hmm let me get some more eyes on this as I'm not sure
๐ stepping in here as @digital agate needs to step away. Give me a moment to catch up
Okay so you are using metered pricing
And want to cancel mid-cycle
But still charge for whatever usage they have accrued
But you aren't seeing the invoice collect the un-invoiced metered-usage?
When you set invoice_now?
That should be happening afaik
Let me look at your example above
Oh wait
On that example you didn't pass invoice_now
Doh
Ignore me
I was looking at the wrong request
You did pass invoice_now
Looking more
I tried many things, I usually pass invoice_now=true, but I did try without.
I tried with prorate, which I'm not exactly sure what it does, and without.
In any case, it generates an invoice and gets it to the paid state, but the invoice is of 0$, while it should be whatever amount I set it to (usually my tests will do 5000$, but sometimes I double-click my request and it sends for 10 000$)
Ah okay wait
Are you actually creating usage here?
Or just previewing as-if you created usage
I'm creating usage.
Which Sub is that for?
Another, the one you're looking at I canceled. But that shouldn't be important?
How do we end a subscription and charge all pending usage immediately as a final invoice?
When you set invoice_now: true that is the expected behavior. We state this in the API ref: https://stripe.com/docs/api/subscriptions/cancel#cancel_subscription-invoice_now
Will generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items.
So if you aren't seeing that happen I do need to look at the specific Sub that has usage added
I'll create a new one then... although it will be the exact same as the one you're looking at anyway.
So, before cancel, with one usage posted.
Just added a card before making the transaction
After cancel. Now it seems to have actually created an invoice for 5K$, not sure why, but it's still open. I need it to confirm it's paid.
Here are some screenshots
Not sure how to express myself differently.
I want that invoice to be paid immediately
Sure so you just have to trigger payment on it
But you were saying that the invoice was generated as $0 before
That is completely different
You pay the invoice after it is created when you cancel the Sub
https://stripe.com/docs/api/subscriptions/cancel By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed.
We state that it is expected that this invoice won't be paid via the cancellation
It was. You can go see all the other logs I gave you. Not sure why I'm being depicted as a liar here.
Thanks for the help.
I am in no way attempting to depict you as a liar. I don't see any usage on the previous sub when a $0 invoice was generated after cancellation. If you have a specific Subscription that had usage that I can look at then I'd be happy to. But your most recent test shows that it seems to be working as expected.
So, here, tried to use pay
It's giving me a 0$ invoice, AND erroring on the pay
Okay, please provide the request ID or the Subscription ID
It's right there in the screenshot...
req_5p0zVTAowQQ4sS
Okay I think I see the issue. You are setting a timestamp for your usage record and that timestamp appears to be after your cancellation occurs.
Can you try with a usage_record that uses timestamp: now
Honestly that feels like a bug to me
We shouldn't be letting you set a usage record in the future?
I'm not mistaken right... your timestamp you are setting is 1647909287 which correlates to 12:39:10PM EST (your local) and you are creating that record at 12:36:44PM EST
It was exactly that.
As in that fixed it?
Yes my invoice is 10k and it's paid.
Okay well I'll need to dig into why you were able to set a future timestamp (I don't think you should have been able to) and file a ticket internally if it is a bug.
Oh wait
I think I might know
Okay not a bug. Just an edge case here
Reporting usage outside the current billing interval results in an error. Stripe leaves a 5 minute window in the default aggregation mode (aggregate_usage=sum) after the period ends to allow for clock drift. For all other aggregation modes the timestamp must be within the current period.
I forgot about this caveat
So if you had attempted to set the timestamp more than 5 mins, you would have seen an error
Yes, exactly. It did occur. After which I kept my timestamps rather near the current time, but in the future.
In my actual program's flow, this isn't going to be a problem though. It's just the way I set up my tests.
Thanks for the help.