#Vinz

1 messages ยท Page 1 of 1 (latest)

sullen yarrowBOT
wanton sable
#

Hello ๐Ÿ‘‹
Not sure I understand, can you elaborate?

lean dagger
#

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

sullen yarrowBOT
wanton sable
#

What are you seeing in your testing?

lean dagger
#

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

wanton sable
#

what I want is when trialing, go to yearly price at the end of current perdio
Hmm... that one is tricky ๐Ÿค”

lean dagger
#

all upcoming_invoice will be correct you think

#

?

#

I already use schedules to cancel subscription at period_end

lean dagger
#

it's working pretty well

#

or let me change the timezone.now(), I work with testing clock

wanton sable
lean dagger
#

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

wanton sable
#

yeah since its trialing, there's nothing to prorate right?

lean dagger
#

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 ?

keen pilot
#

Hi ๐Ÿ‘‹

Stepping in as @wanton sable had to go. That looks good but I would test it out thoroughly to be sure

lean dagger
#

no it does not work, current_period_start is updated to now

#

hi @keen pilot anyway

keen pilot
#

proration_date changes when prorations are calculated. What are you trying to do here?

lean dagger
#

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

keen pilot
#

If you want to change it to a yearly subscription at the end of the trial, why don't you create it that way?

lean dagger
#

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

keen pilot
#

Ah, okay