POST /v1/actions/onetime-product/update-product
使用 更新状态 端点更改商品状态(
active/inactive)。此端点仅用于内容更新。请求体
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
id | string | 是 | 商品 ID(Short ID 格式 PROD_xxx) |
name | string | 否 | 更新后的商品名称(≤ 64 字符) |
description | string | null | 否 | 更新后的描述(传 null 或 "" 清空) |
prices | object | 否 | 更新后的多币种定价映射 |
media | array | 否 | 更新后的媒体项 |
successUrl | string | null | 否 | 更新后的跳转 URL(≤ 512 字符,必须为合法 http(s) URL;传 null 或 "" 清空) |
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",
});
// Uses callApi() helper from authentication.mdx
const result = await callApi("POST", "/v1/actions/onetime-product/update-product", {
id: "PROD_3kF9mNpQrStUvWxYz1A2bC",
name: "Premium Template Pack v2",
description: "75 premium design templates — expanded collection.",
prices: {
USD: { amount: "59.00", taxIncluded: false, taxCategory: "digital_goods" },
EUR: { amount: "55.00", taxIncluded: true, taxCategory: "digital_goods" },
},
successUrl: "https://example.com/thank-you",
});
console.log(result.data.product.name); // => "Premium Template Pack v2"
// Uses callApi() helper from authentication.mdx
String body = """
{
"id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
"name": "Premium Template Pack v2",
"description": "75 premium design templates — expanded collection.",
"prices": {
"USD": { "amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods" },
"EUR": { "amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods" }
},
"successUrl": "https://example.com/thank-you"
}""";
String response = callApi("POST", "/v1/actions/onetime-product/update-product", body);
System.out.println(response);
# Uses call_api() helper from authentication.mdx
result = call_api("POST", "/v1/actions/onetime-product/update-product", {
"id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
"name": "Premium Template Pack v2",
"description": "75 premium design templates — expanded collection.",
"prices": {
"USD": {"amount": "59.00", "taxIncluded": False, "taxCategory": "digital_goods"},
"EUR": {"amount": "55.00", "taxIncluded": True, "taxCategory": "digital_goods"},
},
"successUrl": "https://example.com/thank-you",
})
print(result["data"]["product"]["name"]) # => "Premium Template Pack v2"
// Uses callAPI() helper from authentication.mdx
body := map[string]interface{}{
"id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
"name": "Premium Template Pack v2",
"description": "75 premium design templates — expanded collection.",
"prices": map[string]interface{}{
"USD": map[string]interface{}{"amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods"},
"EUR": map[string]interface{}{"amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods"},
},
"successUrl": "https://example.com/thank-you",
}
result, err := callAPI("POST", "/v1/actions/onetime-product/update-product", body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(result))
// Uses call_api() helper from authentication.mdx
let body = serde_json::json!({
"id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
"name": "Premium Template Pack v2",
"description": "75 premium design templates — expanded collection.",
"prices": {
"USD": { "amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods" },
"EUR": { "amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods" }
},
"successUrl": "https://example.com/thank-you"
});
let result = call_api("POST", "/v1/actions/onetime-product/update-product", &body).await?;
println!("{}", result);
/* Uses call_api() helper from authentication.mdx */
const char *body =
"{\"id\":\"PROD_3kF9mNpQrStUvWxYz1A2bC\","
"\"name\":\"Premium Template Pack v2\","
"\"description\":\"75 premium design templates — expanded collection.\","
"\"prices\":{\"USD\":{\"amount\":\"59.00\",\"taxIncluded\":false,\"taxCategory\":\"digital_goods\"},"
"\"EUR\":{\"amount\":\"55.00\",\"taxIncluded\":true,\"taxCategory\":\"digital_goods\"}},"
"\"successUrl\":\"https://example.com/thank-you\"}";
char *response = call_api("POST", "/v1/actions/onetime-product/update-product", body);
printf("%s\n", response);
free(response);
// Uses callApi() helper from authentication.mdx
std::string body = R"({
"id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
"name": "Premium Template Pack v2",
"description": "75 premium design templates — expanded collection.",
"prices": {
"USD": { "amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods" },
"EUR": { "amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods" }
},
"successUrl": "https://example.com/thank-you"
})";
std::string response = callApi("POST", "/v1/actions/onetime-product/update-product", body);
std::cout << response << std::endl;
MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
TIMESTAMP=$(date +%s)
BODY='{
"id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
"name": "Premium Template Pack v2",
"description": "75 premium design templates — expanded collection.",
"prices": {
"USD": { "amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods" },
"EUR": { "amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods" }
},
"successUrl": "https://example.com/thank-you"
}'
BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
CANONICAL_REQUEST="POST
/v1/actions/onetime-product/update-product
$TIMESTAMP
$BODY_HASH"
SIGNATURE=$(echo -n "$CANONICAL_REQUEST" | openssl dgst -sha256 -sign private_key.pem | base64 -w 0)
curl -X POST "https://api.waffo.ai/v1/actions/onetime-product/update-product" \
-H "Content-Type: application/json" \
-H "X-Merchant-Id: $MERCHANT_ID" \
-H "X-Timestamp: $TIMESTAMP" \
-H "X-Signature: $SIGNATURE" \
-d "$BODY"
MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
TIMESTAMP=$(date +%s)
BODY='{
"id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
"name": "Premium Template Pack v2",
"description": "75 premium design templates — expanded collection.",
"prices": {
"USD": { "amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods" },
"EUR": { "amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods" }
},
"successUrl": "https://example.com/thank-you"
}'
BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
CANONICAL_REQUEST="POST
/v1/actions/onetime-product/update-product
$TIMESTAMP
$BODY_HASH"
SIGNATURE=$(echo -n "$CANONICAL_REQUEST" | openssl dgst -sha256 -sign private_key.pem | base64 -w 0)
wget -qO- "https://api.waffo.ai/v1/actions/onetime-product/update-product" \
--header="Content-Type: application/json" \
--header="X-Merchant-Id: $MERCHANT_ID" \
--header="X-Timestamp: $TIMESTAMP" \
--header="X-Signature: $SIGNATURE" \
--post-data="$BODY"
成功响应 (200)
{
"data": {
"product": {
"id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
"storeId": "STO_2aUyqjCzEIiEcYMKj7TZtw",
"name": "Premium Template Pack v2",
"description": "75 premium design templates — expanded collection.",
"prices": {
"USD": { "amount": "59.00", "taxCategory": "digital_goods" },
"EUR": { "amount": "55.00", "taxCategory": "digital_goods" }
},
"media": [],
"successUrl": "https://example.com/thank-you",
"metadata": {},
"status": "active",
"createdAt": "2026-01-15T10:30:00.000Z",
"updatedAt": "2026-01-15T11:00:00.000Z"
}
}
}
响应字段
与 创建商品响应 相同。商品版本是不可变的。现有订单保留其原始版本。新购买始终使用最新版本。如果提交的内容与当前版本一致,则不会创建新版本,返回现有版本。
错误响应
重试策略:4xx 一律不要重试 — 修正请求后重发。5xx 指数退避重试(起步 5s,最多 3 次)。
| 状态码 | errors[0].message | 含义 | 推荐处理 |
|---|---|---|---|
| 400 | Missing required field: id | 未提供 id | 修正请求体后重发 |
| 400 | Invalid ID format | 提供的 Short ID 无法解码 | 修正 id 格式后重发 |
| 400 | Invalid currency code | 货币代码必须为 3 位大写字母(ISO 4217,如 USD、EUR、JPY) | 使用合法 ISO 4217 代码后重发 |
| 400 | Invalid amount | 金额必须为正数字符串(如 "9.99"、"100") | 使用正数字符串后重发 |
| 400 | Product X has no version in environment Y | 商品在目标环境尚无版本(例如 prod 尚未发布即尝试更新) | 先通过 Publish Product 将商品发布到目标环境 |
| 404 | Product not found | 商品不存在或不可访问 | 验证 id 是否属于当前商户 |
| 500 | Internal server error | 服务端意外失败 | 指数退避重试(起步 5s,最多 3 次) |