简体   繁体   中英

Stripe: Set billing_cycle_anchor on existing subscription product via Stripe Checkout

I'm trying to create a simple subscription in Stripe with billing_cycle_anchor set to a specific date.

I've run into two issues:

1: When using Stripe Checkout with a subscription product made on the dashboard

stripe.checkout.sessions.create

( https://stripe.com/docs/billing/quickstart#add-trial )

I cannot pass billing_cycle_anchor as a parameter, I get error

Received unknown parameter: subscription_data[billing_cycle_anchor]

I'm confused by this as in https://stripe.com/docs/api/subscriptions/object It lists 'trial_end' as a parameter and I can successfully use this. While this suits my purpose technically, the Checkout displays text about a Trial and it's not a trial, I just need the subscription to not start until a certain date.

In the Stripe documentation for billing_cycle_anchor, instead of going straight to the checkout with a pre-made product, they create a subscrition billing_cycle_anchor like so:

const subscription = await stripe.subscriptions.create({
  customer: 'cus_4fdAW5ftNQow1a',
  items: [
    {
      price: 'price_CBb6IXqvTLXp3f',
    },
  ],
  billing_cycle_anchor: 1611008505,
});

But I haven't been able to adapt this to my needs as it won't work without the customer parameter, and I don't want to link this to an existing customer, I want to create a new one (or use their existing account if one exists, but this isn't linked to any sort of a database, I just need a basic button).

I'm confused as to why I can't create a subscription without passing in a parameter for customer, and just create a new one at checkout.

Basically all I need is a way for customers to buy a subscription that has a specific start date. This can't be done with no-code via the Stripe Dashboard so I'm trying to hack it together.

I'm trying to do this using Node and JS. It works with trial_end but not billing_cycle_anchor

Thanks:)

With Checkout, the trial is the way to accomplish this. If you were to use a custom flow with the Payment Element, you could utilize Subscription Schedules to just start a subscription in the future .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM