gullerg
gullerg

Reputation: 381

How can I set the billing_cycle_anchor when setting up a subscription using a Checkout Session?

As the title says: where can I set the billing_cycle_anchor when setting up a subscription using a Checkout Session? It's clear how this is done when setting up a subscription using the subscription API ( https://stripe.com/docs/api/subscriptions/create ); however, I cannot find any details about how to set the billing_cycle_anchor in a Checkout Session ( https://stripe.com/docs/api/checkout/sessions/create ). Does anyone know how I can do this (I'm using node.js)?

Upvotes: 10

Views: 6518

Answers (3)

R. Simon
R. Simon

Reputation: 11

As said by @xyres, feature is available now, but you cannot mix it with any trial setting at checkout.

raw: {
    message: 'You may only specify one of these parameters: billing_cycle_anchor, trial_end.',
    param: 'subscription_data[billing_cycle_anchor]',
...

I'm facing the same scenario and I will try something different: using checkout with "setup" mode, and then define a subscription to this client.

I will update here if it works.

Upvotes: 1

xyres
xyres

Reputation: 21834

This feature is now available (since 26 April, 2023). See docs.

You can set the anchor while creating the checkout session like this:

const session = await stripe.checkout.sessions.create({
    mode: 'subscription',
    subscription_data: {
        billing_cycle_anchor: 1682985600
    },
    // other data ...
});

Upvotes: 2

v3nkman
v3nkman

Reputation: 1179

billing_cycle_anchor isn't supported by Checkout when creating Subscriptions at this time. Another option would be to set the Subscription to trial for a period which would start the billing cycle at the end of the trial:

https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-trial_end

Upvotes: 5

Related Questions