Skip to content

Commit 00ab2d4

Browse files
authored
feat: add stripe-cli fixtures for creating products and prices (vercel#58)
This closes vercel#26
1 parent 23c4b0d commit 00ab2d4

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ For example, you can create business models with different pricing tiers, e.g.:
9292
- Price 1: 20 USD per month
9393
- Price 2: 200 USD per year
9494

95+
#### Generate test data with the Stripe CLI
96+
97+
The [Stripe CLI](https://stripe.com/docs/stripe-cli#install) `fixtures` command executes a series of API requests defined in a JSON file. To speed up the setup, we have added a [fixtures file](fixtures/stripe-fixtures.json) to bootstrap test product and pricing data in your Stripe account. Simply run `stripe fixtures fixtures/stripe-fixtures.json`.
98+
99+
**Important:** Be sure to start the webhook forwarding (see below) so that the products created by the fixtures command above are imported into your database.
100+
95101
### Configure the Stripe customer portal
96102

97103
1. Set your custom branding in the [settings](https://dashboard.stripe.com/settings/branding)

fixtures/stripe-fixtures.json

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"_meta": {
3+
"template_version": 0
4+
},
5+
"fixtures": [
6+
{
7+
"name": "prod_hobby",
8+
"path": "/v1/products",
9+
"method": "post",
10+
"params": {
11+
"name": "Hobby",
12+
"description": "Hobby product description"
13+
}
14+
},
15+
{
16+
"name": "price_hobby_month",
17+
"path": "/v1/prices",
18+
"method": "post",
19+
"params": {
20+
"product": "${prod_hobby:id}",
21+
"currency": "usd",
22+
"billing_scheme": "per_unit",
23+
"unit_amount": 1000,
24+
"recurring": {
25+
"interval": "month",
26+
"interval_count": 1
27+
}
28+
}
29+
},
30+
{
31+
"name": "price_hobby_year",
32+
"path": "/v1/prices",
33+
"method": "post",
34+
"params": {
35+
"product": "${prod_hobby:id}",
36+
"currency": "usd",
37+
"billing_scheme": "per_unit",
38+
"unit_amount": 10000,
39+
"recurring": {
40+
"interval": "year",
41+
"interval_count": 1
42+
}
43+
}
44+
},
45+
{
46+
"name": "prod_freelancer",
47+
"path": "/v1/products",
48+
"method": "post",
49+
"params": {
50+
"name": "Freelancer",
51+
"description": "Freelancer product description"
52+
}
53+
},
54+
{
55+
"name": "price_freelancer_month",
56+
"path": "/v1/prices",
57+
"method": "post",
58+
"params": {
59+
"product": "${prod_freelancer:id}",
60+
"currency": "usd",
61+
"billing_scheme": "per_unit",
62+
"unit_amount": 2000,
63+
"recurring": {
64+
"interval": "month",
65+
"interval_count": 1
66+
}
67+
}
68+
},
69+
{
70+
"name": "price_freelancer_year",
71+
"path": "/v1/prices",
72+
"method": "post",
73+
"params": {
74+
"product": "${prod_freelancer:id}",
75+
"currency": "usd",
76+
"billing_scheme": "per_unit",
77+
"unit_amount": 20000,
78+
"recurring": {
79+
"interval": "year",
80+
"interval_count": 1
81+
}
82+
}
83+
}
84+
]
85+
}

0 commit comments

Comments
 (0)