跳转到主要内容
激活或停用商品。活跃商品可被购买;停用商品在收银台页面中隐藏。
POST /v1/actions/onetime-product/update-status
认证方式: API Key

请求体

字段类型必需说明
idstring商品 ID(Short ID 格式 PROD_xxx
statusstringactiveinactive

请求示例

import { ProductVersionStatus } from "@waffo/pancake-ts";

const { product } = await client.onetimeProducts.updateStatus({
  id: "PROD_3kF9mNpQrStUvWxYz1A2bC",
  status: ProductVersionStatus.Inactive,
});
// Uses callApi() helper from authentication.mdx
const result = await callApi("POST", "/v1/actions/onetime-product/update-status", {
  id: "PROD_3kF9mNpQrStUvWxYz1A2bC",
  status: "inactive",
});
console.log(result.data.product.status); // => "inactive"
// Uses callApi() helper from authentication.mdx
String body = """
    {"id":"PROD_3kF9mNpQrStUvWxYz1A2bC","status":"inactive"}""";

String response = callApi("POST", "/v1/actions/onetime-product/update-status", body);
System.out.println(response);
# Uses call_api() helper from authentication.mdx
result = call_api("POST", "/v1/actions/onetime-product/update-status", {
    "id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
    "status": "inactive",
})
print(result["data"]["product"]["status"])  # => "inactive"
// Uses callAPI() helper from authentication.mdx
body := map[string]interface{}{
    "id":     "PROD_3kF9mNpQrStUvWxYz1A2bC",
    "status": "inactive",
}
result, err := callAPI("POST", "/v1/actions/onetime-product/update-status", 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",
    "status": "inactive"
});
let result = call_api("POST", "/v1/actions/onetime-product/update-status", &body).await?;
println!("{}", result);
/* Uses call_api() helper from authentication.mdx */
const char *body = "{\"id\":\"PROD_3kF9mNpQrStUvWxYz1A2bC\",\"status\":\"inactive\"}";
char *response = call_api("POST", "/v1/actions/onetime-product/update-status", body);
printf("%s\n", response);
free(response);
// Uses callApi() helper from authentication.mdx
std::string body = R"({"id":"PROD_3kF9mNpQrStUvWxYz1A2bC","status":"inactive"})";
std::string response = callApi("POST", "/v1/actions/onetime-product/update-status", body);
std::cout << response << std::endl;
MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
TIMESTAMP=$(date +%s)
BODY='{"id":"PROD_3kF9mNpQrStUvWxYz1A2bC","status":"inactive"}'
BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
CANONICAL_REQUEST="POST
/v1/actions/onetime-product/update-status
$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-status" \
  -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","status":"inactive"}'
BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
CANONICAL_REQUEST="POST
/v1/actions/onetime-product/update-status
$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-status" \
  --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",
      "description": "50 premium design templates for your next project.",
      "prices": {
        "USD": { "amount": "49.00", "taxCategory": "digital_goods" },
        "EUR": { "amount": "45.00", "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" },
      "status": "inactive",
      "createdAt": "2026-01-15T10:30:00.000Z",
      "updatedAt": "2026-01-15T13:00:00.000Z"
    }
  }
}

响应字段

创建商品响应 相同。
将商品设为 inactive 会在收银台页面中隐藏该商品,但不影响现有订单。已购买的客户仍保留访问权限。

错误响应

重试策略:4xx 一律不要重试 — 修正请求后重发。5xx 指数退避重试(起步 5s,最多 3 次)。
状态码errors[0].message含义推荐处理
400Missing required field: id未提供 id修正请求体后重发
400Invalid ID format提供的 Short ID 无法解码修正 id 格式后重发
400Invalid or missing status (must be 'active' or 'inactive')status 不是 activeinactive使用 activeinactive 后重发
400Product X has no version in environment Y商品在目标环境尚无版本(例如 prod 尚未发布即尝试切换状态)先通过 Publish Product 将商品发布到目标环境
404Product not found商品不存在或不可访问验证 id 是否属于当前商户
500Internal server error服务端意外失败指数退避重试(起步 5s,最多 3 次)