更新一次性产品的内容。如果内容有变更,会自动创建新的不可变版本。如果内容与当前版本完全相同,则不会创建新版本。
POST /v1/actions/onetime-product/update-product
认证方式: API Key
使用更新状态端点来变更产品状态(active/inactive)。本端点仅用于内容更新。
请求体
| 字段 | 类型 | 必需 | 说明 |
|---|
id | string | 是 | 产品 ID(Short ID 格式 PROD_xxx) |
name | string | 是 | 更新后的产品名称 |
description | string | 否 | 更新后的描述 |
prices | object | 是 | 更新后的多币种定价映射 |
media | array | 否 | 更新后的媒体项 |
successUrl | string | 否 | 更新后的重定向 URL |
metadata | object | 否 | 更新后的自定义元数据 |
prices 和 media 的对象格式见创建产品。
请求示例
const { product } = await client.onetimeProducts.update({
id: "PROD_3kF9mNpQrStUvWxYz1A2bC",
name: "Premium Template Pack v2",
description: "75 premium design templates — expanded collection.",
prices: {
USD: { amount: "59.00", taxIncluded: false, taxCategory: TaxCategory.DigitalGoods },
EUR: { amount: "55.00", taxIncluded: true, taxCategory: TaxCategory.DigitalGoods },
},
successUrl: "https://example.com/thank-you",
});
响应字段
与创建产品响应相同。
产品版本是不可变的。现有订单保留其原始版本。新购买始终使用最新版本。如果提交的内容与当前版本完全相同,不会创建新版本,返回现有版本。
错误响应
| 状态码 | 错误 | 说明 |
|---|
| 400 | Missing required field: id | 未提供 id |
| 400 | Missing required field: name | 未提供 name |
| 400 | Prices must not be empty | prices 缺失或为空对象 |
| 400 | No version in current environment | 产品在当前环境(测试/生产)中没有版本 |
| 404 | Product not found | 产品不存在或不可访问 |