#tomkcey-subscription

1 messages ยท Page 1 of 1 (latest)

digital agate
#

Hello ๐Ÿ‘‹
Give me a moment to catch up here

#

can you share the example request IDs for these?

bold summit
#

I'm not sure what you mean. I'm pinging my own test environment, test mode in Stripe Dashboard.

digital agate
bold summit
#

That's from the /test/logs page.

#

The previous one was from the specific customer's.

digital agate
#

There should be request IDs for these
Should look like req_xxxxxx

bold summit
#
DELETE /v1/subscriptions/sub_1L3iLEBcZkr7pv9q4eHljcV7
Status
200 OK
ID
req_4CfmSBSiceEne9
digital agate
#

Thanks! looking

bold summit
#

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.

digital agate
#

You said with invoice_now it isn't generating a final invoice right?
It should for accrued amount during the current cycle

bold summit
#

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?

digital agate
#

Hmm let me get some more eyes on this as I'm not sure

mystic mason
#

๐Ÿ‘‹ 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

bold summit
#

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$)

mystic mason
#

Ah okay wait

#

Are you actually creating usage here?

#

Or just previewing as-if you created usage

bold summit
#

I'm creating usage.

mystic mason
#

Which Sub is that for?

bold summit
#

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?

mystic mason
bold summit
#

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

mystic mason
#

Looks good to me ๐Ÿ™‚

#

That's what you want, right?

bold summit
#

Not sure how to express myself differently.
I want that invoice to be paid immediately

mystic mason
#

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

bold summit
#

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.

mystic mason
#

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.

bold summit
#

So, here, tried to use pay
It's giving me a 0$ invoice, AND erroring on the pay

mystic mason
#

Okay, please provide the request ID or the Subscription ID

bold summit
#

It's right there in the screenshot...

req_5p0zVTAowQQ4sS

mystic mason
#

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

bold summit
#

It was exactly that.

mystic mason
#

As in that fixed it?

bold summit
#

Yes my invoice is 10k and it's paid.

mystic mason
#

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

bold summit
#

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.