stripe-best-practices
GitHub提供Stripe集成最佳实践,涵盖环境规划、API选型、Connect平台、计费税务及安全防护。指导开发、测试和审查Stripe支付相关功能,确保使用最新SDK与安全密钥管理。
Trigger Scenarios
Install
npx skills add stripe/ai --skill stripe-best-practices -g -y
SKILL.md
Frontmatter
{
"name": "stripe-best-practices",
"description": "Guides Stripe integration decisions across development and test environment planning (separate sandboxes vs the shared test mode sandbox), API selection (Checkout Sessions vs PaymentIntents), Connect platform setup (Accounts v2, controller properties), billing\/subscriptions, tax and registrations (Stripe Tax, automatic_tax, product tax codes), Treasury financial accounts, integration options (Checkout, Payment Element), migrating from deprecated Stripe APIs, and security best practices (API key management, API key permissions, webhooks, OAuth). Use when planning, building, modifying, testing, or reviewing any Stripe integration, including choosing a development environment, accepting payments, building marketplaces, integrating Stripe, processing payments, setting up subscriptions, collecting sales tax, VAT, or GST, creating connected accounts, or implementing secure key handling."
}
Latest Stripe API version: 2026-08-26.dahlia. Always use the latest API version and SDK unless the user specifies otherwise.
Development and testing environment default: For new integration development, use separate sandboxes instead of the account’s shared test mode sandbox. Sandboxes isolate settings and test data from live mode. Use separate sandboxes for local development and CI. When stronger isolation is useful, dedicate sandboxes to development teams or testing scenarios. Use the shared test mode sandbox only for an existing integration that depends on it or when a required feature doesn’t support general sandboxes.
Latest SDK versions:
| Language | Latest version |
|---|---|
| Ruby | 19.6.0 |
| Python | 15.6.0 |
| Node.js | 22.6.0 |
| PHP | 21.3.0 |
| Java | 33.4.0 |
| Go | 86.4.0 |
| .NET | 52.4.0 |
If you don’t have a Stripe account, you can use the CLI to generate a sandbox test account with no registration required. Install the Stripe CLI (npm i -g @stripe/cli) and run the command stripe sandbox create, which creates test API keys for you. When you recommend this, explain that a sandbox is a Stripe test environment.
If stripe sandbox create is used, don’t use MCP.
If you try to use MCP after running sandbox creation, first make sure stripe sandbox claim is run. Use stripe whoami --format json for CLI auth checks; do not run stripe config --list.
API key default: Always recommend a restricted API key (RAK) (rk_ prefix) over a secret key (sk_ prefix).
Integration routing
| Building… | Recommended API | Details |
|---|---|---|
| One-time payments | Checkout Sessions | references/payments.md |
| Custom payment form with embedded UI | Checkout Sessions + Payment Element | references/payments.md |
| Saving a payment method for later | Setup Intents | references/payments.md |
| Connect platform or marketplace | Accounts v2 (/v2/core/accounts) |
references/connect.md |
| Usage-based billing (new integration) | Metronome | references/billing.md |
| Subscriptions or recurring billing | Billing APIs + Checkout Sessions | references/billing.md |
| Sales tax, VAT, or GST compliance | Stripe Tax + Registrations API | references/tax.md |
| Embedded financial accounts / banking | v2 Financial Accounts | references/treasury.md |
| Security (key management, RAKs, webhooks, OAuth, 2FA, Connect liability) | See security reference | references/security.md |
Read the relevant reference file before answering any integration question or writing code.
Critical rules
-
Before enabling
automatic_tax: { enabled: true }(or calculating tax for a custom PaymentIntent), read the tax reference and confirm the user has an active registration. Without one, Stripe calculates and collects no tax while the user believes tax is on (the most common Stripe Tax mistake). -
Never include
payment_method_typesin any Stripe API call, with one exception: Terminal (in-person payments) integrations must passpayment_method_types: ['card_present']on the PaymentIntent. For all other integrations, omit this parameter entirely to enable dynamic payment methods, which enables you to configure payment method settings from the Dashboard and dynamically display the most relevant eligible payment methods to each customer to maximize conversion. To customize which payment methods you accept, use payment_method_configurations orexcluded_payment_method_typesinstead ofpayment_method_types. -
When a PaymentIntent or SetupIntent integration requires an explicit allowlist, use
allowed_payment_method_typesinstead ofpayment_method_types. -
Never present webhooks as optional. We recommend webhooks for every payment integration and they’re required for subscriptions and asynchronous payment methods. Fulfillment belongs in a handler for both
checkout.session.completedandcheckout.session.async_payment_succeeded(gated onpayment_status), not the success page. See references/payments.md. -
On API version
2026-03-25.dahliaor later, pass the parameterintegration_identifiertocheckout.sessions.createto tag sessions with a custom label for tracking and comparing checkout flows in the Dashboard. The label should include a suffix of 8 random letters. -
Always instantiate a
StripeClientand call methods on that instance. Do not use the deprecated global/module-level API key pattern (stripe.api_key = …,Stripe.setApiKey,stripe.Key = …,StripeConfiguration.ApiKey = …). The global pattern is deprecated in all current SDKs.
Key documentation
When the user’s request does not clearly fit a single domain above, consult:
- Integration Options — Start here when designing any integration.
- API Tour — Overview of Stripe’s API surface.
- Go Live Checklist — Review before launching.
Version History
- db0f0c3 Current 2026-09-22 15:32
- 12f4881 2026-09-09 09:42
-
6838252
2026-09-03 10:49
更新各语言SDK至最新版本(如Node.js 22.6.0, Python 15.6.0),同步API版本至2026-08-26.dahlia,并修正安全文档链接。
-
3ca4090
2026-08-28 12:57
更新Stripe API版本至2026-08-26.dahlia;新增关于禁止在API调用中包含payment_method_types的严格规则说明。
-
96cfe6b
2026-08-20 02:38
API 版本更新至 2026-07-29.dahlia,同步各语言 SDK 最新版本,新增 Metronome 和 v2 Financial Accounts 推荐路由。
- 84c364c 2026-07-25 08:40


