Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add "trial_period_days" to stripe fixture #1115

Open
theodufort opened this issue Aug 17, 2023 · 1 comment
Open

Cannot add "trial_period_days" to stripe fixture #1115

theodufort opened this issue Aug 17, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@theodufort
Copy link

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 } } ] }

@theodufort theodufort added the bug Something isn't working label Aug 17, 2023
@wilmeltech
Copy link

wilmeltech commented Aug 25, 2023

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants