#lory1234_api

1 messages ¡ Page 1 of 1 (latest)

terse gyroBOT
#

👋 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/1469437432607801516

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

random rampart
small crane
#

yes

random rampart
#

so you'd only like invoices generated on the 6 Feb and 10 Mar? would you want both of those invoices to bill for the same amount?

small crane
#

yes exactly

#

the invoice of 10 March should be the same amount as the 2nd phase. I dont want to make the user pay for prorations

random rampart
#

ok, something you could try would be to have a trial phase from 6 March to 10 March to bridge the gap and not generate an invoice

#

I see you already are using test clocks so you should be able to test this out and see if it gets you the results you want. I can also try it but might take me longer

small crane
#

does trial_end work if I want to charge, for example 3 days before?

random rampart
#

3 days before the end of the phase? I would try it and see. Subscription Schedules can be tricky, I always recommend people try it in test mode whenever possible

small crane
#

I tried with a trial but it charged double again

random rampart
#

hmm, I tried it out on my end. it generated a full invoice on 6 Feb, a $0 invoice on 6 Mar, and a full invoice on 10 Mar. let me reach out to my colleagues to see if they have any ideas, one moment

small crane
#

I am checking it again

random rampart
#

ok I double checked with my colleagues and unfortunately we don't think there's a way to do exactly what you want. the options you have are what I suggested, which should generate a $0 invoice on 6 March (not what you want, but the closest we've got) or canceling the subscription and re-starting it on 10 March

#

this was the phases definition I used for my test:

phases: [{
    items: [{
      price: PRICE_ID
    }],
    start_date: "now",
    end_date: new Date("Mar 06 2025 12:00").getTime() / 1000,
    proration_behavior: "none"
  },{
    items: [{
      price: PRICE_ID
    }],
    end_date: new Date("Mar 10 2025 12:00").getTime() / 1000,
    proration_behavior: "none",
    trial: true
  },{
    items: [{
      price: PRICE_ID
    }],
    end_date: new Date("Apr 06 2025 12:00").getTime() / 1000,
    proration_behavior: "none",
  }]
small crane
#

okay, thank you for your support. I was using trial_end: timestamp instead of trial and it generated a full amount invoice. I will give it a try as you suggested and check also how it behaves when the new date should be a few days earlier

#

why is it charging even though I set trial: true?

random rampart
#

taking a look now

small crane
#

oh, does that mean the user actually pays 0? Im not sure what thos brackets mean

random rampart
#

ok, so this is slightly different than the phases I set up in my example. what it looks like you have here is:

6 Feb - 10 Mar : Set as trial
10 Mar - 6 Apr : Normal
6 Apr - 6 May : Normal

What I think you want is:

6 Feb - 6 Mar: Normal
6 Mar - 10 Mar: Trial
10 Mar - 6 Apr: Normal

#

basically you're using that small middle phase to "push" the billing cycle later

small crane
#

ah I see. Since the user has paid first, I wanted to make it a trial from 6 to 10 Mar, and on 10 Mar, they can pay again

random rampart
#

right. the user won't be charged for that 6 to 10 Mar phase, but a $0 invoice will be generated. this is just a limitation of how Stripe's subscriptions work

small crane
#

isnt this possible: 6 Feb - 10 Mar : Set as trial (no invoice generation)
10 Mar - 6 Apr : Normal
6 Apr - 6 May : Normal

#

I dont want to start trial only for the difference of days which could be 1 or 2 days

random rampart
#

maybe, but the subscription is created on 6 Feb, right? so the first invoice would be generated then, since we bill ahead of time

small crane
#

and Im worried for the case when I will the offset -2 or -1 days :/

#

yes the invoice generated on 6 Feb is fine

#

whats not fine is the one generated on 6 Mar

random rampart
#

and Im worried for the case when I will the offset -2 or -1 days :/

I'm not sure what you mean by this, you mean if you need to shorten the phase? like make it end on 4 Mar, for example?

small crane
#

yes

#

For some cases I want to shorten it and for some to lengthen it

random rampart
#

for that, you can shorten the end of the phase, then use billing_cycle_anchor: 'phase_start' on the next phase to change the anchor. so your phases would look like:

6 Feb - 4 Mar : Normal
4 Mar - 4 Apr : set billing_cycle_anchor to phase_start

small crane
#

oh, no worries. Sorry for keeping you late. It was helpful to discuss this with you