stripe-best-practices: Stripe Integration Selection and Best Practices Agent Skill

Introduction

Integrating Stripe involves a vast documentation landscape: choosing between Checkout or PaymentIntent for one-time payments, deciding whether to use Connect Accounts v2 for marketplaces, selecting the right Billing API suite for subscriptions and usage-based billing, enabling automatic_tax for tax handling, and configuring keys, Webhooks, and sandboxes. Reviewing multiple documents independently often leads to selecting the wrong API or encountering pitfalls in details like tax and fulfillment. This article introduces the stripe-best-practices Skill, maintained by Stripe officially in the stripe/ai repository. It consolidates common integration scenarios into a decision routing table, accompanied by mandatory rules and topic-specific reference files, enabling coding assistants to answer step-by-step when planning, implementing, testing, or reviewing integrations.

What is this

stripe-best-practices is an Agent-facing Stripe integration guide Skill maintained by Stripe, with its source code located at https://github.com/stripe/ai/tree/main/skills/stripe-best-practices.

It covers development and testing environment planning (the trade-offs between independent sandboxes and shared test mode), API selection (Checkout Sessions, PaymentIntents, SetupIntents, etc.), Connect platforms (Accounts v2, controller properties), billing and subscriptions, tax and registration (Stripe Tax, automatic_tax, product tax codes), Treasury financial accounts, integration modalities (Checkout, Payment Element), migration from deprecated APIs, and security practices (API keys, Webhooks, OAuth, etc.). Applicable scenarios include: planning or modifying any Stripe integration, selecting a development environment, collecting payments, building marketplaces, integrating subscriptions, handling sales tax/VAT/GST, creating Connected Accounts, or auditing key and Webhook configurations.

The Skill requires the use of the latest Stripe API version; the documentation specifies the current version as 2026-09-30.endive. Unless specified otherwise by the user, the latest API version and SDK should always be used.

Core Features

Integration Routing (Selecting APIs by Scenario)

The Skill uses a table to map “what you are doing” to recommended APIs and requires reading the corresponding reference files (e.g., references/payments.md, references/connect.md) before answering or writing code:

Scenario Recommended API
One-time payments Checkout Sessions
Custom forms + embedded UI Checkout Sessions + Payment Element
Saving payment methods for later Setup Intents
Connect platforms or marketplaces Accounts v2 (/v2/core/accounts)
Usage-based billing (new integrations) Metronome
Subscriptions or recurring billing Billing APIs + Checkout Sessions
Sales tax, VAT, GST Stripe Tax + Registrations API
Embedded financial accounts / banking capabilities v2 Financial Accounts
Security (Keys, Webhooks, OAuth, etc.) See security reference

When requirements span multiple domains, the Skill points to Stripe documentation’s Integration Options, API Tour, and Go Live Checklist as supplementary entry points.

Environment and SDK Defaults

  • New integration development: Default to using independent sandboxes rather than the account-shared test mode sandbox; separate sandboxes are recommended for local and CI environments. Only use shared test mode if legacy integrations depend on it or if a feature does not yet support general sandboxes.
  • Without a Stripe account: You can install the Stripe CLI and create a sandbox test account (no registration required). Installation and creation commands are detailed in “Typical Usage” below.
  • API Keys: The default recommendation is restricted API key (RAK) (rk_ prefix) rather than secret keys (sk_).
  • SDK Versions: The documentation lists the latest versions for various languages (Ruby 20.0.0, Python 16.0.0, Node.js 23.0.0, PHP 22.0.0, Java 34.0.0, Go 87.0.0, .NET 53.0.0). Implementation should align with the official SDKs.

Critical Rules (Hard Constraints for Integration)

The Skill specifies several error-prone points that assistants must adhere to when providing solutions or code:

  1. Tax: Before enabling automatic_tax: { enabled: true } or calculating tax for custom PaymentIntents, you must read the tax reference and confirm that the user has an active registration; otherwise, Stripe will not calculate or collect taxes, but the business side might mistakenly assume tax is included.
  2. Payment Method Types: Except for Terminal in-person payments which require uploading payment_method_types: ['card_present'] on the PaymentIntent, do not include payment_method_types in any Stripe API calls; rely on dynamic payment methods or configure via payment_method_configurations and excluded_payment_method_types. If an explicit whitelist is needed for PaymentIntent/SetupIntent, use allowed_payment_method_types.
  3. Webhooks: Webhooks cannot be treated as optional; subscriptions and asynchronous payment methods depend on them. Fulfillment logic should be placed in the handlers for checkout.session.completed and checkout.session.async_payment_succeeded (combined with payment_status), rather than on the success page.
  4. Checkout Tracking: For API version 2026-03-25.dahlia and later, pass integration_identifier when creating a Checkout Session. Labels should include an 8-character random letter suffix to facilitate comparing different checkout flows in the Dashboard.
  5. Client Instantiation: Always instantiate StripeClient and call methods on the instance; do not use deprecated global/module-level key setting methods (e.g., stripe.api_key = …, Stripe.setApiKey, etc.).

Installation and Activation

Add this Skill from the official Stripe repository via the skills installation tool:

npx skills add https://github.com/stripe/ai --skill stripe-best-practices

Alternatively, provide the Skill directory link to a coding assistant that supports Agent Skills and let it install according to project conventions: https://github.com/stripe/ai/tree/main/skills/stripe-best-practices.

If the documentation does not distinguish installation differences for Cursor, Codex CLI, or Claude Code, rely on the npx skills add command and GitHub path mentioned above.

Typical Usage

1. Quickly obtain sandbox and test keys using CLI

If you do not have an account, install the CLI globally first, then create a sandbox (the Skill clarifies that a sandbox is the Stripe testing environment):

npm i -g @stripe/cli
stripe sandbox create

If the environment is created via stripe sandbox create, the Skill requires not using MCP within that flow; if you wish to use MCP later, you must first execute stripe sandbox claim. Check CLI login status with:

stripe whoami --format json

Do not use stripe config --list for authentication checks.

2. Describe your business to the assistant to follow integration routing

For example: “We want to build a SaaS monthly subscription and want to minimize maintenance for the checkout page” — The Skill will route to Billing APIs + Checkout Sessions and prompt to read the billing and payments references before writing code like checkout.sessions.create.

Another example: “The platform facilitates transactions between buyers and sellers with revenue sharing” — This routes to Accounts v2 and the Connect reference, rather than using the legacy Connect account model.

3. Checklist before going live

When boundaries are unclear, the Skill points to the Go Live Checklist. This is suitable for having the assistant verify key permissions, Webhooks, tax registration, etc., item by item when reviewing existing integrations or preparing for a production switch.

Use Cases and Notes

Who is it for

  • Teams building or revamping Stripe payment collection, subscriptions, marketplaces, tax, or Treasury capabilities who want the assistant to output API selections and code patterns consistent with current official recommendations.
  • Developers needing to audit legacy integrations (deprecated global SDK key setting, misuse of payment_method_types, success page fulfillment, missing Webhook configuration, etc.).

Limitations and Notes

  • The Skill is a decision-making and specification layer; specific parameters and examples should still be based on the references/*.md within the Skill and docs.stripe.com. Corresponding references should be read before answering integration questions.
  • Topics such as tax, Connect liability allocation, and OAuth involve compliance and account configuration. The Skill emphasizes prerequisites (such as tax registration) but cannot replace your confirmation in the Stripe Dashboard and legal processes.
  • The documentation only provides the installation method via npx skills add; do not assume other IDE plugin paths if they are not specified on the official page.

Conclusion

stripe-best-practices compresses integration choices across Stripe’s multiple product lines into executable decision routing and Critical Rules. It reduces the probability of selecting the wrong API among Checkout, PaymentIntent, Connect, Billing, and Tax, and unifies defaults for environment, keys, Webhooks, and SDK usage. If you are using an AI assistant to write or review Stripe code, you can install this Skill from the official repository and specify your business scenario (one-time/subscription/platform/tax, etc.) in your prompt, allowing the assistant to route first before writing code.

Official Address: https://github.com/stripe/ai/tree/main/skills/stripe-best-practices

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye