Trial_period_days: 7 doesn't seem to be recognized in my node function. Any idea why this happens? Am I missing a variable? Publishing to this point will result in integration errors...
const subscription = await stripe.subscriptions.create({ customer: customer.id, items: [{ price: "price_1KZ3nTGxUje7SlyIDUfIXkr3" }], payment_settings: { payment_method_options: { card: { request_three_d_secure: "any", }, }, payment_method_types: ["card"], save_default_payment_method: "on_subscription", }, trial_period_days: 7, expand: ["latest_invoice.payment_intent"], });
P粉4929595992024-04-02 10:00:24
When you create a subscription that includes a trial or a 100% coupon, there is no need to pay the invoice immediately. Therefore, there is no PaymentIntent and no client_secret. This is why your PaymentIntent validation fails. Instead, the subscription creates a SetupIntent to collect the payment method for future use. You can access the SetupIntent's client secret via the pending_setup_intent.client_secret
property (you need to extend the pending_setup_intent
property when creating the subscription). You then need to confirm the SetupIntent on the frontend. To better understand how SetupIntents work, you can follow this guide: https:// stripe.com/docs/ payments/save-and-reuse?platform=web.