Cloud
Stripe
What is Stripe?
Stripe CLI
- Install the Stripe CLI
brew install stripe/stripe-cli/stripe
- Log in to the CLI
Log in and authenticate your Stripe user account to generate a set of restricted keys.
stripe login
Press Enter on your keyboard to complete the authentication process in your browser.
Your pairing code is: enjoy-enough-outwit-win
This pairing code verifies your authentication with Stripe.
Press Enter to open the browser or visit https://dashboard.stripe.com/stripecli/confirm_auth?t=THQdJfL3x12udFkNorJL8OF1iFlN8Az1 (^C to quit)
Optionally, if you don’t want to use a browser, use the --interactive flag to authenticate with an existing API secret key or restricted key. This is helpful when authenticating to the CLI without a browser, such as in a CI/CD pipeline.
stripe login --interactive
You can also use the --api-key flag to specify your API secret key inline each time you send a request.
stripe login --api-key sk_test_51SyUG5FKc7ywNC01ZDLZIDtrgu3pBXZ7yECfXNYrUIeYplbUoUU1I4RLs9b0Sl...4bVESaDq5v00ZiOqH8Zb
API Keys
Webhook
- Create a Stripe webhook endpoint Point it to: https://your-domain.com/api/stripe/webhook
Events:
- checkout.session.completed
- customer.subscription.created
- customer.subscription.updated
- customer.subscription.deleted
- invoice.paid
- invoice.payment_failed
If testing locally, update your Stripe CLI command:
stripe listen --forward-to http://localhost:3000/api/stripe/webhook
After that, run a test checkout.
Test Credit Card
| 卡类型 | 卡号 | 安全码 (CVV) | 有效期 |
|---|---|---|---|
| Visa | 4242424242424242 | 任意 3 位数 | 任意未来的日期 |
| Visa(借记卡) | 4000056655665556 | 任意 3 位数 | 任意未来的日期 |
| Mastercard | 5555555555554444 | 任意 3 位数 | 任意未来的日期 |
| Mastercard(以 2 开头) | 2223003122003222 | 任意 3 位数 | 任意未来的日期 |
| Mastercard(借记卡) | 5200828282828210 | 任意 3 位数 | 任意未来的日期 |
| Mastercard(预付卡) | 5105105105105100 | 任意 3 位数 | 任意未来的日期 |
| American Express | 378282246310005 | 任意 4 位数 | 任意未来的日期 |
| American Express | 371449635398431 | 任意 4 位数 | 任意未来的日期 |
| Discover | 6011111111111117 | 任意 3 位数 | 任意未来的日期 |
| Discover | 6011000990139424 | 任意 3 位数 | 任意未来的日期 |
| Discover(借记卡) | 6011981111111113 | 任意 3 位数 | 任意未来的日期 |
| Diners Club | 3056930009020004 | 任意 3 位数 | 任意未来的日期 |
| Diners Club(14 位卡号) | 36227206271667 | 任意 3 位数 | 任意未来的日期 |
| BCcard 和 DinaCard | 6555900000604105 | 任意 3 位数 | 任意未来的日期 |
| JCB | 3566002020360505 | 任意 3 位数 | 任意未来的日期 |
| 银联 | 6200000000000005 | 任意 3 位数 | 任意未来的日期 |
| 银联(借记卡) | 6200000000000047 | 任意 3 位数 | 任意未来的日期 |
| 银联(19 位卡号) | 6205500000000000004 | 任意 3 位数 | 任意未来的日期 |