upgrade-stripe
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseThe latest Stripe API version is 2026-02-25.clover - use this version when upgrading unless the user specifies a different target version.
最新的Stripe API版本是2026-02-25.clover——除非用户指定了不同的目标版本,否则升级时请使用此版本。
Upgrading Stripe Versions
Stripe版本升级
This guide covers upgrading Stripe API versions, server-side SDKs, Stripe.js, and mobile SDKs.
本指南涵盖Stripe API版本、服务器端SDK、Stripe.js及移动端SDK的升级方法。
Understanding Stripe API Versioning
理解Stripe API版本控制
Stripe uses date-based API versions (e.g., , , ). Your account's API version determines request/response behavior.
2026-02-25.clover2025-08-27.basil2024-12-18.acaciaStripe采用基于日期的API版本(例如、、)。您账户的API版本决定了请求/响应的行为。
2026-02-25.clover2025-08-27.basil2024-12-18.acaciaTypes of Changes
变更类型
Backward-Compatible Changes (do not require code updates):
- New API resources
- New optional request parameters
- New properties in existing responses
- Changes to opaque string lengths (e.g., object IDs)
- New webhook event types
Breaking Changes (require code updates):
- Field renames or removals
- Behavioral modifications
- Removed endpoints or parameters
Review the API Changelog for all changes between versions.
向后兼容变更(无需修改代码):
- 新增API资源
- 新增可选请求参数
- 现有响应中新增属性
- 不透明字符串长度变更(例如对象ID)
- 新增Webhook事件类型
破坏性变更(需要修改代码):
- 字段重命名或移除
- 行为修改
- 端点或参数移除
查看API变更日志了解版本间的所有变更。
Server-Side SDK Versioning
服务器端SDK版本控制
See SDK Version Management for details.
详情请参阅SDK版本管理。
Dynamically-Typed Languages (Ruby, Python, PHP, Node.js)
动态类型语言(Ruby、Python、PHP、Node.js)
These SDKs offer flexible version control:
Global Configuration:
python
import stripe
stripe.api_version = '2026-02-25.clover'ruby
Stripe.api_version = '2026-02-25.clover'javascript
const stripe = require('stripe')('sk_test_xxx', {
apiVersion: '2026-02-25.clover'
});Per-Request Override:
python
stripe.Customer.create(
email="customer@example.com",
stripe_version='2026-02-25.clover'
)这些SDK提供灵活的版本控制:
全局配置:
python
import stripe
stripe.api_version = '2026-02-25.clover'ruby
Stripe.api_version = '2026-02-25.clover'javascript
const stripe = require('stripe')('sk_test_xxx', {
apiVersion: '2026-02-25.clover'
});单请求覆盖:
python
stripe.Customer.create(
email="customer@example.com",
stripe_version='2026-02-25.clover'
)Strongly-Typed Languages (Java, Go, .NET)
强类型语言(Java、Go、.NET)
These use a fixed API version matching the SDK release date. Do not set a different API version for strongly-typed languages because response objects might not match the strong types in the SDK. Instead, update the SDK to target a new API version.
这些语言使用与SDK发布日期匹配的固定API版本。请勿为强类型语言设置不同的API版本,否则响应对象可能与SDK中的强类型不匹配。应通过升级SDK来适配新的API版本。
Best Practice
最佳实践
Always specify the API version you're integrating against in your code instead of relying on your account's default API version:
javascript
// Good: Explicit version
const stripe = require('stripe')('sk_test_xxx', {
apiVersion: '2026-02-25.clover'
});
// Avoid: Relying on account default
const stripe = require('stripe')('sk_test_xxx');请始终在代码中指定您集成所使用的API版本,而非依赖账户的默认API版本:
javascript
// 推荐:显式指定版本
const stripe = require('stripe')('sk_test_xxx', {
apiVersion: '2026-02-25.clover'
});
// 避免:依赖账户默认版本
const stripe = require('stripe')('sk_test_xxx');Stripe.js Versioning
Stripe.js版本控制
See Stripe.js Versioning for details.
Stripe.js uses an evergreen model with major releases (Acacia, Basil, Clover) on a biannual basis.
详情请参阅Stripe.js版本控制。
Stripe.js采用常青模型,每半年发布一次主要版本(Acacia、Basil、Clover)。
Loading Versioned Stripe.js
加载指定版本的Stripe.js
Via Script Tag:
html
<script src="https://js.stripe.com/clover/stripe.js"></script>Via npm:
bash
npm install @stripe/stripe-jsMajor npm versions correspond to specific Stripe.js versions.
通过Script标签:
html
<script src="https://js.stripe.com/clover/stripe.js"></script>通过npm:
bash
npm install @stripe/stripe-jsnpm的主要版本对应特定的Stripe.js版本。
API Version Pairing
API版本配对
Each Stripe.js version automatically pairs with its corresponding API version. For instance:
- Clover Stripe.js uses API
2026-02-25.clover - Acacia Stripe.js uses API
2024-12-18.acacia
You cannot override this association.
每个Stripe.js版本会自动与对应的API版本配对。例如:
- Clover版本的Stripe.js使用API
2026-02-25.clover - Acacia版本的Stripe.js使用API
2024-12-18.acacia
您无法覆盖此关联关系。
Migrating from v3
从v3版本迁移
- Identify your current API version in code
- Review the changelog for relevant changes
- Consider gradually updating your API version before switching Stripe.js versions
- Stripe continues supporting v3 indefinitely
- 在代码中确认当前使用的API版本
- 查看变更日志了解相关变更
- 考虑在切换Stripe.js版本前逐步升级API版本
- Stripe会无限期支持v3版本
Mobile SDK Versioning
移动端SDK版本控制
See Mobile SDK Versioning for details.
详情请参阅移动端SDK版本控制。
iOS and Android SDKs
iOS和Android SDK
Both platforms follow semantic versioning (MAJOR.MINOR.PATCH):
- MAJOR: Breaking API changes
- MINOR: New functionality (backward-compatible)
- PATCH: Bug fixes (backward-compatible)
New features and fixes release only on the latest major version. Upgrade regularly to access improvements.
两个平台均遵循语义化版本控制(MAJOR.MINOR.PATCH):
- MAJOR:破坏性API变更
- MINOR:新增功能(向后兼容)
- PATCH:Bug修复(向后兼容)
新功能和修复仅在最新的主要版本中发布。请定期升级以获取改进。
React Native SDK
React Native SDK
Uses a different model (0.x.y schema):
- Minor version changes (x): Breaking changes AND new features
- Patch updates (y): Critical bug fixes only
采用不同的版本模型(0.x.y格式):
- 次要版本变更(x):包含破坏性变更和新功能
- 补丁更新(y):仅包含关键Bug修复
Backend Compatibility
后端兼容性
All mobile SDKs work with any Stripe API version you use on your backend unless documentation specifies otherwise.
除非文档另有说明,所有移动端SDK均可与您后端使用的任意Stripe API版本兼容。
Upgrade Checklist
升级检查清单
- Review the API Changelog for changes between your current and target versions
- Check Upgrades Guide for migration guidance
- Update server-side SDK package version (e.g., ,
npm update stripe)pip install --upgrade stripe - Update the parameter in your Stripe client initialization
apiVersion - Test your integration against the new API version using the header
Stripe-Version - Update webhook handlers to handle new event structures
- Update Stripe.js script tag or npm package version if needed
- Update mobile SDK versions in your package manager if needed
- Store Stripe object IDs in databases that accommodate up to 255 characters (case-sensitive collation)
Testing API Version Changes
测试API版本变更
Use the header to test your code against a new version without changing your default:
Stripe-Versionbash
curl https://api.stripe.com/v1/customers \
-u sk_test_xxx: \
-H "Stripe-Version: 2026-02-25.clover"Or in code:
javascript
const stripe = require('stripe')('sk_test_xxx', {
apiVersion: '2026-02-25.clover' // Test with new version
});使用标头测试代码在新版本下的表现,无需修改默认版本:
Stripe-Versionbash
curl https://api.stripe.com/v1/customers \
-u sk_test_xxx: \
-H "Stripe-Version: 2026-02-25.clover"或在代码中:
javascript
const stripe = require('stripe')('sk_test_xxx', {
apiVersion: '2026-02-25.clover' // 使用新版本测试
});Important Notes
重要提示
- Your webhook listener should handle unfamiliar event types gracefully
- Test webhooks with the new version structure before upgrading
- Breaking changes are tagged by affected product areas (Payments, Billing, Connect, etc.)
- Multiple API versions coexist simultaneously, enabling staged adoption
- 您的Webhook监听器应能优雅处理不熟悉的事件类型
- 在升级前测试新版本结构下的Webhook
- 破坏性变更会按受影响的产品领域(支付、账单、Connect等)标记
- 多个API版本可同时存在,支持分阶段升级