#Benoît

1 messages · Page 1 of 1 (latest)

regal spokeBOT
cyan latch
odd adder
#

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

cyan latch
#

Oh this looks like a TypeScript error

#

What is the type expected here?

odd adder
#

"now" or "unchanged"

cyan latch
#

But if you are using stripe-node in TypeScript you have to understand the types

odd adder
#

"now" or "unchanged" are strings

#

I'm not sure to understand your question

#

I call subscriptions.update()

cyan latch
#

The error message tells you what to look at

#

The expected type comes from the property billing_cycle_anchor in type SubscriptionUpdateParams

odd adder
#

Yes, and i looked. I tried a timestamp because one of your colleague suggested me to do so

odd adder
#

Sorry, i'm french, sometimes i don't understand all

cyan latch
odd adder
cyan latch
#

And that is causing a type error

odd adder
#

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

cyan latch
#

Okay I get what you are looking for. Let me do some digging

odd adder
#

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 !

cyan latch
#

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

odd adder
#

arf

odd adder
#

Would the next invoice happen on january 1st ?

cyan latch
#

I'm looking but we don't call out what the default value is (if not provided)

odd adder
#

ok

#

thank you

cyan latch
#

I would recommend testing this out to ensure you get the behavior you expect

regal spokeBOT
odd adder
#

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

quaint ocean
#

Hello! Hopping in here since snufkin has to head out soon

odd adder
#

Hello, NP !

quaint ocean
#

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

odd adder
#

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 ?

quaint ocean
#

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

odd adder
#

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

quaint ocean
#

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

odd adder
#

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 ?

quaint ocean
#

Yeah if the subcription is cancelled this would cancel the underlying schedule as well

odd adder
#

Ah, that would be great !

quaint ocean
#

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.updated webhook event and you can see if pause_collection was changed. If it was, you can reset the billing cycle anchor immediately
#

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)

odd adder
#

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 ?

quaint ocean
odd adder
#

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 ?

quaint ocean
#

you can let us know here if it works 🙂

odd adder
#

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

quaint ocean
#

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

odd adder
#

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

#

Does payout.data as a specific Stripe type, like payload.data.object ?

quaint ocean
#

that's our typescript definition for Event in our node library

odd adder
#

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

quaint ocean
#

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

odd adder
#

ok