创建支持多币种定价的一次性购买产品。
POST /v1/actions/onetime-product/create-product
认证方式: API Key
请求体
| 字段 | 类型 | 必需 | 说明 |
|---|
storeId | string | 是 | 门店 ID(Short ID 格式 STO_xxx) |
name | string | 是 | 产品名称 |
description | string | 否 | 产品描述(支持 Markdown) |
prices | object | 是 | 多币种定价映射(见下方) |
media | array | 否 | 产品图片/视频(见下方) |
successUrl | string | 否 | 购买成功后的重定向 URL |
metadata | object | 否 | 自定义键值数据(最多 50 个键) |
价格对象格式
价格是 ISO 4217 货币代码到价格配置对象的映射。至少需要一种货币。
{
"USD": {
"amount": "29.00",
"taxIncluded": false,
"taxCategory": "saas"
},
"EUR": {
"amount": "27.00",
"taxIncluded": true,
"taxCategory": "saas"
}
}
| 字段 | 类型 | 说明 |
|---|
amount | string | 显示格式的价格字符串(如 “29.00” = $29.00) |
taxIncluded | boolean | 金额是否已含税 |
taxCategory | string | 用于税额计算的税收类别 |
支持的 taxCategory 值:
| 值 | 说明 |
|---|
digital_goods | 通用数字商品 |
saas | 软件即服务 |
software | 可下载软件 |
ebook | 电子书 |
online_course | 在线课程和教育 |
consulting | 咨询服务 |
professional_service | 专业服务 |
媒体项格式
{
"type": "image",
"url": "https://example.com/product.png",
"alt": "Product screenshot",
"thumbnail": "https://example.com/product-thumb.png"
}
| 字段 | 类型 | 说明 |
|---|
type | string | image 或 video |
url | string | 媒体 URL |
alt | string | 无障碍替代文本 |
thumbnail | string | 缩略图 URL(图片可选,视频推荐) |
请求示例
import { WaffoPancake, TaxCategory } from "@waffo/pancake-ts";
const client = new WaffoPancake({
merchantId: process.env.WAFFO_MERCHANT_ID!,
privateKey: process.env.WAFFO_PRIVATE_KEY!,
});
const { product } = await client.onetimeProducts.create({
storeId: "STO_2aUyqjCzEIiEcYMKj7TZtw",
name: "Premium Template Pack",
description: "50 premium design templates for your next project.",
prices: {
USD: { amount: "49.00", taxIncluded: false, taxCategory: TaxCategory.DigitalGoods },
EUR: { amount: "45.00", taxIncluded: true, taxCategory: TaxCategory.DigitalGoods },
},
media: [
{ type: "image", url: "https://example.com/templates-preview.png", alt: "Template preview" },
],
successUrl: "https://example.com/thank-you",
metadata: { category: "design", fileCount: "50" },
});
成功响应 (200)
{
"data": {
"id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
"storeId": "STO_2aUyqjCzEIiEcYMKj7TZtw",
"prodVersionId": null,
"testVersionId": "PROD_7dG4hJkLmNpQrStUvWxYz1",
"prodStatus": "inactive",
"testStatus": "active",
"createdAt": "2026-01-15T10:30:00.000Z",
"updatedAt": "2026-01-15T10:30:00.000Z",
"version": {
"id": "PROD_7dG4hJkLmNpQrStUvWxYz1",
"productId": "PROD_3kF9mNpQrStUvWxYz1A2bC",
"versionNumber": 1,
"name": "Premium Template Pack",
"description": "50 premium design templates for your next project.",
"prices": {
"USD": { "amount": "49.00", "taxIncluded": false, "taxCategory": "digital_goods" },
"EUR": { "amount": "45.00", "taxIncluded": true, "taxCategory": "digital_goods" }
},
"media": [
{ "type": "image", "url": "https://example.com/templates-preview.png", "alt": "Template preview" }
],
"successUrl": "https://example.com/thank-you",
"metadata": { "category": "design", "fileCount": "50" },
"createdAt": "2026-01-15T10:30:00.000Z"
}
}
}
响应字段
| 字段 | 类型 | 说明 |
|---|
id | string | 产品 ID(PROD_xxx) |
storeId | string | 门店 ID(STO_xxx) |
prodVersionId | string | null | 生产环境活跃版本 ID(PROD_xxx),未发布时为 null |
testVersionId | string | null | 测试环境活跃版本 ID(PROD_xxx),不在测试环境时为 null |
prodStatus | string | 生产状态:active 或 inactive |
testStatus | string | 测试状态:active 或 inactive |
createdAt | string | 创建时间戳(ISO 8601) |
updatedAt | string | 最后更新时间戳(ISO 8601) |
version | object | 当前环境中创建或活跃的版本 |
版本对象:
| 字段 | 类型 | 说明 |
|---|
id | string | 版本 ID(PROD_xxx) |
productId | string | 父产品 ID(PROD_xxx) |
versionNumber | integer | 递增版本号(从 1 开始) |
name | string | 该版本的产品名称 |
description | string | null | 该版本的产品描述 |
prices | object | 多币种定价映射 |
media | array | 该版本的媒体项 |
successUrl | string | null | 该版本的成功重定向 URL |
metadata | object | null | 该版本的自定义元数据 |
createdAt | string | 版本创建时间戳(ISO 8601) |
在测试环境中创建(默认),testStatus 为 active,prodStatus 为 inactive。在生产环境中创建时,值相反。
错误响应
| 状态码 | 错误 | 说明 |
|---|
| 400 | Missing required field: storeId | 未提供 storeId |
| 400 | Missing required field: name | 未提供 name |
| 400 | Prices must not be empty | prices 缺失或为空对象 |
| 404 | Store not found | 门店不存在或不可访问 |