#Benoît
1 messages · Page 1 of 1 (latest)
Hi 👋
Can you share the API request ID that is throwing the error?
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Hi ! I don't have a request ID yet, that's my IDE that throw me the error
Maybe that's only a problem on my IDE ? I loaded the Stripe NPM package v12.10.0
"now" or "unchanged"
That's what i see in the docs : https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_cycle_anchor
But if you are using stripe-node in TypeScript you have to understand the types
You can review them here: https://github.com/stripe/stripe-node/tree/master/types
"now" or "unchanged" are strings
I'm not sure to understand your question
I call subscriptions.update()
The error message tells you what to look at
The expected type comes from the property billing_cycle_anchor in type SubscriptionUpdateParams
Yes, and i looked. I tried a timestamp because one of your colleague suggested me to do so
Yes, what do you want to tell me ?
Sorry, i'm french, sometimes i don't understand all
I'm saying you need to look here: https://github.com/stripe/stripe-node/blob/master/types/SubscriptionsResource.d.ts#L687C67-L687C67 to determine the correct Type to cast the value to.
I looked, that's the same thing that in the docs https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_cycle_anchor
It says i must use "now" or "unchanged". But one of your colleague toldme yesterday to try with a timestamp
And that is causing a type error
Yes, that's why i asked the question in the general chan, "In the docs, i can see that a timestamp is not possible, so i don't know how to do what i'm searching for"
I'm searching for a way to update the billing cycle of my subscription, and set it whenever i want
Okay I get what you are looking for. Let me do some digging
Let's imagine my customer subscribe to a plan on august 1st, and decide to pause it on august 10th. Some months later, my customer decide to reactivate his subscription on december 25th, so i need to reset his billing cycle date to (december 25th + 20 unused days) = january 14th
Thanks !
Okay, confirmed that you can only set the biling cycle anchor to a specific date when you create a Subscription, not when you resume a Subscription
arf
From this example, what would happen to the billing cycle if i just resume the Subscription with pause_collection: '' ?
Would the next invoice happen on january 1st ?
I'm looking but we don't call out what the default value is (if not provided)
I would recommend testing this out to ensure you get the behavior you expect
I tried with a subscription that started july 27th. When i pause it today and resume it after, that's like i didn't do anything. The next invoice still remains at august 27th
Hello! Hopping in here since snufkin has to head out soon
Hello, NP !
You're using pause_collection right? pause_collection doesn't have any affect on the billing cycle at all - invoices are still generated normally, we just change what we do with them (automatically void them, keep them as draft, etc.)
Ok.
I don't know if you read our previous messages, so just in case : Let's imagine my customer subscribe to a plan on august 1st, and decide to pause it on august 10th. My customer decide to resume his subscription on december 25th, so i need to reset his billing cycle date to (december 25th + 20 unused days) = january 14th
That was my problem
And i also wonder what would be the next invoice date after my customer resume his subscription just with the pause_collection: '' param. Will it be the january 1st ?
Yeah the issue is that right now, this is not what pause_collection is meant to be used for - it doesn't do any kind of prorations when you turn it on/off. So what you'd need to do is reset the billing cycle anchor yourself on the 14th
and yes, the next invoice date after you resume would be jan 1st if you don't reset the anchor yourself
I'd love to do be able to reset the billing cycle anchor myslef on the 14th, but it would be great to be able to define it now for a future date, as i have no possibility to do the action myslef on january 14th with the billing_cycle_anchor: 'now' param
Yeah... what you could do is try using a subscription schedule to do this for you
Let me try and think through what combination of phases would work for this
I was thinking about it, but i wondered what would happened if the customer resume the subscription on december 25th, and decide to finaly cancel it on december 27th for example ? Will the schedule be canceled too ?
Yeah if the subcription is cancelled this would cancel the underlying schedule as well
Ah, that would be great !
Thinking out loud, I think you could make somethign like this work:
- You have the subscritoin that was paused on august 10th
- When the customer resumes on december 25th you calculate when you want the next billing cycle date to be and set
pause_collection.resumed_at(https://stripe.com/docs/api/subscriptions/update#update_subscription-pause_collection-resumes_at) to be that date (Jan 14th) - I believe when Jan 14th rolls around you should get a
customer.subscription.updatedwebhook event and you can see ifpause_collectionwas changed. If it was, you can reset the billing cycle anchor immediately
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You'd want to test that out fully to make sure it works, but it avoids the need for subscription schedules (which can get a bit complicated)
The idea is good, but how could i see if pause_collection was changed in the webhook payload ?
Where could i retrieve the previous state ?
With *.updated event types we set data.previous_attributes on the event (https://stripe.com/docs/api/events/object#event_object-data-previous_attributes) so that you can compare what was previously vs currently set on the event
Great, i will test this now (i already have this webhook ready to be triggered)
Would you let this PM opened for me to tell you if it worked or not ?
you can let us know here if it works 🙂
Ok. i'm studying my webhook event to check the previous state (we_1HjPaMAYYvne95SHn0XQBg6E)
Could you tell me what is the type of the webhook event payload please ? I currently use the Subscription object from the payload (from payload.data.object), but i need to target payload.data for the previous attributes
Maybe i'm not clear. From the payload object (on screenshot), what is the Stripe type of payload.data please
payout.datais a hash that has a payload.data.object (which is the Subscription object you want) and payout.data.previous_attributes if the event is for an update
Yes, i just would like to know the type of payload.data.
For example, payload.data.object is a type of Stripe.Subscription
I need to type my objects
I use this NodeJS package : https://www.npmjs.com/package/stripe
Does payout.data as a specific Stripe type, like payload.data.object ?
Ah great ! That's what i looked for !
Stripe.Event.Data.PreviousAttributes seems to be an untyped object, is that right ?
I try to autocomplete my object, but there's no object properties to be found
Yeah that one's just an empty interface https://github.com/stripe/stripe-node/blob/f646c9d91eab4a80e59cfd1de966b7bdca5926c9/types/Events.d.ts#L101
I'm assuming it's because we can't really logically give it all the object properties for every single resource that would be updated
ok