#Vinz
1 messages ยท Page 1 of 1 (latest)
Hello ๐
Not sure I understand, can you elaborate?
I have a trialing subscription
monthly
while trialing, user can upgrade to yearly at any time.
My code looks like that :
def update_stripe_subscription(self):
if self.items_no_proration:
stripe.Subscription.modify(
self.subscription.stripe_id,
proration_behavior='none',
items=self.items_no_proration
)
if self.items_proration:
stripe.Subscription.modify(
self.subscription.stripe_id,
proration_behavior='always_invoice',
proration_date=int(time.time()),
items=self.items_proration
)
here all items are in items_proration
for quantity upgrade it makes sense to have proration_date=int(time.time()). But for interval upgrade it is more tricky
hum, maybe I should write proration_date=subscription.current_period_end
I give it a try
What are you seeing in your testing?
hum, it is tricky
I've not managed yet
what I want is when trialing, go to yearly price at the end of current perdio
when not trialing, go to yearly price now
when not trialing, go to yearly price now
That should be quite straightforward.
Have you had a chance to look at these docs?
https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing
what I want is when trialing, go to yearly price at the end of current perdio
Hmm... that one is tricky ๐ค
You may need to use a Subscription Schedule for that
https://stripe.com/docs/billing/subscriptions/subscription-schedules
all upcoming_invoice will be correct you think
?
I already use schedules to cancel subscription at period_end
Yep, for that, no problem
it's working pretty well
or let me change the timezone.now(), I work with testing clock
I already use schedules to cancel subscription at period_end
You may not need a schedule for cancelling ๐
https://stripe.com/docs/billing/subscriptions/cancel#cancel-at-end-of-cycle
all upcoming_invoice will be correct you think
From trial to yearly change? I believe so. Would recommend giving it a try to be 100% certain..
well, let me dig further, my problem is that
if self.items_proration:
stripe.Subscription.modify(
self.subscription.stripe_id,
proration_behavior='always_invoice',
proration_date=int(time.time()),
items=self.items_proration
)
has modified my subscription.current_period_start to int(time.time())
which is normal
Would you have an advise to avoid this behaviour
since it is a trial my first idea could be good
yeah since its trialing, there's nothing to prorate right?
yep
I should go for
def update_stripe_subscription(self):
if self.items_proration: # upgrading
prorate_date = self.subscription.current_period_start if self.subscription.status == 'trialing' else timezone.now()
stripe.Subscription.modify(
self.subscription.stripe_id,
proration_behavior='always_invoice',
proration_date=prorate_date.timestamp(),
items=self.items_proration
)
right ?
Hi ๐
Stepping in as @wanton sable had to go. That looks good but I would test it out thoroughly to be sure
proration_date changes when prorations are calculated. What are you trying to do here?
I try to make subscription anually at the end of trialing
I'll dig into schedule
or at least change it without updating current_period_start
et without having a zero invoice
If you want to change it to a yearly subscription at the end of the trial, why don't you create it that way?
well, I try to imagine people liking the concept and before end of subscription
switch to yearly
exactly as on pycharm, 30 days trial and have to choose a price before end, year or month
Ah, okay