ReactJS + Stripe: Trial days not working as expected
P粉773659687
P粉773659687 2024-04-01 14:55:33
0
1
367

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粉773659687
P粉773659687

reply all(1)
P粉492959599

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!