#peter_api

1 messages · Page 1 of 1 (latest)

gentle cairnBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1395518657546682509

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

tall citrus
#

Hi there

#

So you're trying to sort of restart the subscription in the same state it was paused in in terms of days into the billing cycle, etc

lone junco
#

Yeah!

#

FWIW, if the person "paused" longer than a cycle, like for 41 days on Jan 1 and billing_cycle_anchor = Jan 2, I’m assuming it’d be similar to stopping 10 days, like resumes_at = Feb 11 and next invoice on Feb 12

tall citrus
#

And the person has paid the previous invoice, is that right? Do you want to offer a "put my subscription on hold" functionality? Like if I am going on vacation for a 3 weeks tomorrow (I wish) and I've just paid my HBO streaming subscription or something like that, I would ideally like to pause it and then still have 29/30 days of service remaining and be invoiced again at that time?

lone junco
#

yup

#

great example!

tall citrus
#

I wonder if just using a trial period will be the easiest thing

lone junco
#

Can a trial period be added to an active subscription?

#

Oh I just tested from my REPL and am seeing something promising:

s4 = stripe.Subscription.modify(sub_id, expand=['items.data.price'], trial_end=s3.created + 86400 * 3)

print(_d(s3.billing_cycle_anchor))
# 2025-07-17 15:38:56 -04:00

print(_d(s4.billing_cycle_anchor))
# 2025-07-20 15:38:56 -04:00
tall citrus
#

Yep

#

I can't recommend it enough

#

Especially for this kind of thing

lone junco
#

yup, have been test clocking this particular sub

#

Are there any weird edge cases, like if the trial is too close to now? I am seeing “Can be at most two years from billing_cycle_anchor.”

tall citrus
#

nothing that is top of mind, but that's why I'd recommend using test clocks to work through a simulation and make sure you're getting the behavior you want

#

but then you have to keep the state of when you want that Subscription to resume

lone junco
#

ok, thx for the help. It seems like if I go the trialing route, then it’s pretty good at handling tracking time remaining on current cycle and I’ll just need to do some extra work to understand when a particular case of trialing is a "paused" state

#

hrm, resume seems like I’m still limited to "now" or "unchanged" for billing_cycle_anchor

tall citrus
#

yeah, that would be like if you tied that API call to a customer coming to your website and saying "I want to resume service" or scheduling that ahead of time

lone junco
#

got it, thx again!