Open theodufort opened 10 months ago
@theodufort Hey, I was just facing the same problem. Looks like the trial period days field is a little hidden.
let checkoutSession = await stripe.checkout.sessions.create({ customer: customer.id, success_url:"https://mycompany.com", line_items: [{price: priceId}], allow_promotion_codes: true. mode: "subscription", **subscription_data: {trial_period_days: 7}** });
The trial_period_days is hidden in the subscription_data field indicated in the API docs here: https://stripe.com/docs/api/checkout/sessions/create.
Hope that helps!
The more information we have the easier it is for us to help. Feel free to remove any sections that might not apply
Issue
The "trial_period_days" parameters is not recognized
Expected Behavior
Add 3 days of trial to a subscription.
Steps to reproduce
Clone https://github.com/vercel/nextjs-subscription-payments and run the fixtures file.
Traceback
Request failed, status=400, body={ "error": { "code": "parameter_unknown", "doc_url": "https://stripe.com/docs/error-codes/parameter-unknown", "message": "Received unknown parameters: trial_from_plan, trial_period_days", "param": "trial_from_plan", "request_log_url": "https://dashboard.stripe.com/test/logs/req_sTomyrSioWuJtM?t=1692280729", "type": "invalid_request_error" } }
Environment
Stripe CLI 1.17
I cant seem to add a 3 day trial period to my plans. Here is my fixtures file:
{ "_meta": { "template_version": 0 }, "fixtures": [ { "name": "prod_retail", "path": "/v1/products", "method": "post", "params": { "name": "Retail Trader", "description": "For casual scanning.", "metadata": { "max_number_strat": 1, "max_number_substrat": 1, "max_weekly_scans": 1 } } }, { "name": "price_retail_month", "path": "/v1/prices", "method": "post", "params": { "product": "${prod_retail:id}", "currency": "usd", "billing_scheme": "per_unit", "unit_amount": 1000, "recurring": { "interval": "month", "interval_count": 1 }, "trial_from_plan": true, "trial_period_days": 3 } }, { "name": "price_retail_year", "path": "/v1/prices", "method": "post", "params": { "product": "${prod_retail:id}", "currency": "usd", "billing_scheme": "per_unit", "unit_amount": 10000, "recurring": { "interval": "year", "interval_count": 1 }, "trial_from_plan": true, "trial_period_days": 3 } }, { "name": "prod_next_level_retail", "path": "/v1/products", "method": "post", "params": { "name": "Next Level Retail Trader", "description": "Things are starting to get serious.", "metadata": { "max_number_strat": 3, "max_number_substrat": 3, "max_weekly_scans": 2 } } }, { "name": "price_next_level_retail_month", "path": "/v1/prices", "method": "post", "params": { "product": "${prod_next_level_retail:id}", "currency": "usd", "billing_scheme": "per_unit", "unit_amount": 3000, "recurring": { "interval": "month", "interval_count": 1 }, "trial_from_plan": true, "trial_period_days": 3 } }, { "name": "price_next_level_retail_year", "path": "/v1/prices", "method": "post", "params": { "product": "${prod_next_level_retail:id}", "currency": "usd", "billing_scheme": "per_unit", "unit_amount": 30000, "recurring": { "interval": "year", "interval_count": 1 }, "trial_from_plan": true, "trial_period_days": 3 } }, { "name": "prod_market_insider", "path": "/v1/products", "method": "post", "params": { "name": "Market Insider", "description": "You have broken the code of the market...", "metadata": { "max_number_strat": 10, "max_number_substrat": 10, "max_weekly_scans": 5 } } }, { "name": "price_market_insider_month", "path": "/v1/prices", "method": "post", "params": { "product": "${prod_market_insider:id}", "currency": "usd", "billing_scheme": "per_unit", "unit_amount": 5000, "recurring": { "interval": "month", "interval_count": 1 }, "trial_from_plan": true, "trial_period_days": 3 } }, { "name": "price_market_insider_year", "path": "/v1/prices", "method": "post", "params": { "product": "${prod_market_insider:id}", "currency": "usd", "billing_scheme": "per_unit", "unit_amount": 50000, "recurring": { "interval": "year", "interval_count": 1 }, "trial_from_plan": true, "trial_period_days": 3 } } ] }