#jbuck94-checkout-billing-anchor
1 messages ยท Page 1 of 1 (latest)
Hi ๐ you're correct that it is not possible to specify a Subscription's billing cycle anchor when using a Checkout Session.
The closest option is to add a trial period to the Subscription via subscription_data.trial_end or subscription_data.trial_period_days that will push back the billing cycle anchor to the end of the trial period, but this could look odd to your customers.
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-trial_end
The other option is to use a Checkout Session in setup mode to collect your customer's payment method information, and then use the created payment method to create a Subscription from you server where you can control the billing_cycle_anchor and backdate_start_date values directly:
https://stripe.com/docs/api/subscriptions/create#create_subscription-backdate_start_date
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Ah ok - didnt realize there was a setup mode. What webhook events will i receive around the setup that I would listen for to start a subscription
This guide walks through the process of saving payment method information for future use in more detail, but you can listen for checkout.session.completed to be notified when a Checkout Session is completed:
https://stripe.com/docs/payments/save-and-reuse?platform=checkout
when creating the subscription - what field to i pass the setup_intent to?
Hi ๐ What are you trying to do with the Setup Intent?
See above. Trying to use the setup intent to collect payment info - then intialize a subscription from my backend
Ahh I see here - i have to fetch the setupIntent, then get its payment_method_id
https://stripe.com/docs/payments/save-and-reuse?platform=checkout#retrieve-setup-intent
Alternatively you can set the Payment Method as the default_payment_method in invoice_settings
https://stripe.com/docs/api/customers/update?lang=node#update_customer-invoice_settings-default_payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
This would automatically use that payment method when a subscription for that customer is created
Is it "more correct" to set it as the default payment method of the customer, or the subscription?
Or - doesnt completing the checkout session attach the payment method to the customer already?
It depends on the behavior you want. You can specify it on the subscription and the PM will get used for all recurring charges on that Subscription, or you can specify it on the Customer. You are right, the PM will get associated with the customer. If they do not already have a PM specified as the default it may set that too but I would want to test that first.