#nadiya_api

1 messages Β· Page 1 of 1 (latest)

kindred pelicanBOT
#

πŸ‘‹ 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/1339388368118747136

πŸ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

drifting goblet
#
return [
            {
                // Phase 1: From schedule start until the fixed billing day.
                end_date: nextBillingDateUnix,
                items: [{ price: stripePriceId, metadata }],
                collection_method: "send_invoice",
                invoice_settings: {
                    days_until_due: 3,
                },
                proration_behavior: "none",
                metadata,
            },
            {
                // Phase 2: Begins automatically at the previous phase's end_date.
                items: [{ price: stripePriceId, metadata }],
                proration_behavior: "none",
                metadata,
            },
        ];

this is how i create each phase.
what did i miss?

marsh flicker
#

Hi hi! Let me mull this over for a sec. πŸ™‚

#

proration_behavior: "none" makes the current period free.

drifting goblet
#

but its not free for the subscription i created

marsh flicker
#

Hm lolz

#

Ok so the goal is:

A user starts a subscription any day of the month by paying for a full month. On the 25th, they'll be re-billed for the upcoming month, and again every 25th until hopefully the heat death of the universe

Is that right?

drifting goblet
#

yes correct

marsh flicker
#

Ok. Let me figure out how to do this. πŸ˜‚

drifting goblet
#

yes please!

marsh flicker
#

I believe this will do what you want:

return [
            {
                // Phase 1: From schedule start until the fixed billing day.
                billing_cycle_anchor: "automatic",
                end_date: aVariableThatDefinitelyContainsTheUnixTimestampOfTheNext25thOfTheMonth,
                items: [{ price: stripePriceId, metadata }],
                collection_method: "send_invoice",
                invoice_settings: {
                    days_until_due: 3,
                },
                metadata,
            },
            {
                // Phase 2: Begins automatically at the previous phase's end_date.
                billing_cycle_anchor: "phase_start",
                items: [{ price: stripePriceId, metadata }],
                metadata,
            },
        ];

drifting goblet
#

no proration_behavior?
if we don't specify this, shouldn't it create proration automatically (create_prorations)?
we're charging the full amount, not the proated amount

marsh flicker
#

It won't create prorations, but also the first Invoice's billing_cycle_anchor is whatever datetime it was created.

#

Is it acceptable to wait for the second invoice on the 25th for the 'correct' anchor?

marsh flicker
drifting goblet
marsh flicker
#

It would show as the 13th to the 13th.

drifting goblet
#

oh! thats' what its showing now

#

though, i guess it'll be fine on Feb 25

marsh flicker
#

Yes but ... I hear you.

#

Lemme give it another look.

drifting goblet
#

but the invoice generated to the customer will show as Feb 13 - Mar 13, which is misleading

marsh flicker
#

Agreed.

#

it should show Feb 13 to Feb 24

#

(or 25 whatever πŸ˜‚)

drifting goblet
#

yes right

marsh flicker
#

Oooo

#

Gimme a sec, I might have something.

drifting goblet
#

sure

marsh flicker
#

'Might' is carrying a lot there πŸ˜‚

drifting goblet
#

πŸ˜†

marsh flicker
#

Ok so I have an answer and it's a funny one. πŸ˜‚

drifting goblet
#

oh cool!

marsh flicker
#

You actually want to create a Subscription (directly), with the following:

{
  "customer": customerId,

  "items": [ { "price": stripePriceId, metadata } ],
  "collection_method": "send_invoice",
  "days_until_due": 3,
  
  "backdate_start_date": thePrevious25th,
  "billing_cycle_anchor": theNext25th,
}
drifting goblet
#

oh wow! i tried a lot with subscription first, and i moved to subscription schedule later when i can't find any solution

#

btw, does this work if i subscribe on 27th?

marsh flicker
#

First invoice would be Feb 25 to Mar 25

kindred pelicanBOT
drifting goblet
#

how about not adding proration amount?
"backdate_start_date
timestamp
For new subscriptions, a past timestamp to backdate the subscription’s start date to. If set, the first invoice will contain a proration for the timespan between the start date and the current time. Can be combined with trials and the billing cycle anchor."

marsh flicker
#

It doesn't do any proration - or rather, the whole amount is kinda a proration. Β―_(ツ)_/Β―

#

Give it a go; I think you'll find it does what you're looking for. πŸ™‚

#

jack_stripe is here if you need anything further; I have to go play some Minecraft now. πŸ€ͺ Have a good one!

kindred pelicanBOT
bitter shell
#

Hi @drifting goblet I'm taking over tihs thread, give me a sec to catch up

drifting goblet
#

sorry, is there any way to do the same with schedules?
i do have other plan (with different requirements, and i'd used schedule for both code (like a re-usable one),

also, i've used schedules so that i can create two phase in which the first phase (one iteration ) will use collection_method: "send_invoice", and the rest will charge automatically

bitter shell
#

No, there's no backdate param available in subscription schedules API

drifting goblet
#

its fine to start from the current day, but it should end on the next 25th. (without showing them wrong period for the first phase in the invoice. ie, if today is 13th , the, it should show Feb 13 - Feb 25 (not Feb 13- Mar 13)