> ## Documentation Index
> Fetch the complete documentation index at: https://docs.waffo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 更新状态

> 激活或停用订阅商品

激活或停用订阅商品。

```
POST /v1/actions/subscription-product/update-status
```

**认证方式：** API Key

## 请求体

| 字段       | 类型     | 必需 | 说明                    |
| -------- | ------ | -- | --------------------- |
| `id`     | string | 是  | 商品 ID（`PROD_xxx` 格式）  |
| `status` | string | 是  | `active` 或 `inactive` |

## 请求示例

<CodeGroup>
  ```typescript SDK theme={"system"}
  import { ProductVersionStatus } from "@waffo/pancake-ts";

  await client.subscriptionProducts.updateStatus({
    id: "PROD_3F7H2J5L8N1Q4S6U",
    status: ProductVersionStatus.Inactive,
  });
  ```

  ```typescript TypeScript (fetch) theme={"system"}
  // Uses callApi() helper from authentication.mdx
  const result = await callApi("POST", "/v1/actions/subscription-product/update-status", {
    id: "PROD_3F7H2J5L8N1Q4S6U",
    status: "inactive",
  });
  console.log(result.data);
  ```

  ```java Java theme={"system"}
  // Uses callApi() helper from authentication.mdx
  String body = """
      {"id":"PROD_3F7H2J5L8N1Q4S6U","status":"inactive"}""";

  String response = callApi("POST", "/v1/actions/subscription-product/update-status", body);
  System.out.println(response);
  ```

  ```python Python theme={"system"}
  # Uses call_api() helper from authentication.mdx
  result = call_api("POST", "/v1/actions/subscription-product/update-status", {
      "id": "PROD_3F7H2J5L8N1Q4S6U",
      "status": "inactive",
  })
  print(result["data"])
  ```

  ```go Go theme={"system"}
  // Uses callAPI() helper from authentication.mdx
  body := map[string]interface{}{
      "id":     "PROD_3F7H2J5L8N1Q4S6U",
      "status": "inactive",
  }
  result, err := callAPI("POST", "/v1/actions/subscription-product/update-status", body)
  if err != nil {
      log.Fatal(err)
  }
  fmt.Println(string(result))
  ```

  ```rust Rust theme={"system"}
  // Uses call_api() helper from authentication.mdx
  let body = serde_json::json!({
      "id": "PROD_3F7H2J5L8N1Q4S6U",
      "status": "inactive"
  });
  let result = call_api("POST", "/v1/actions/subscription-product/update-status", &body).await?;
  println!("{}", result);
  ```

  ```c C theme={"system"}
  /* Uses call_api() helper from authentication.mdx */
  const char *body = "{\"id\":\"PROD_3F7H2J5L8N1Q4S6U\",\"status\":\"inactive\"}";
  char *response = call_api("POST", "/v1/actions/subscription-product/update-status", body);
  printf("%s\n", response);
  free(response);
  ```

  ```cpp C++ theme={"system"}
  // Uses callApi() helper from authentication.mdx
  std::string body = R"({"id":"PROD_3F7H2J5L8N1Q4S6U","status":"inactive"})";
  std::string response = callApi("POST", "/v1/actions/subscription-product/update-status", body);
  std::cout << response << std::endl;
  ```

  ```bash cURL theme={"system"}
  MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
  TIMESTAMP=$(date +%s)
  BODY='{"id":"PROD_3F7H2J5L8N1Q4S6U","status":"inactive"}'
  BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
  CANONICAL_REQUEST="POST
  /v1/actions/subscription-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/subscription-product/update-status" \
    -H "Content-Type: application/json" \
    -H "X-Merchant-Id: $MERCHANT_ID" \
    -H "X-Timestamp: $TIMESTAMP" \
    -H "X-Signature: $SIGNATURE" \
    -d "$BODY"
  ```

  ```bash wget theme={"system"}
  MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
  TIMESTAMP=$(date +%s)
  BODY='{"id":"PROD_3F7H2J5L8N1Q4S6U","status":"inactive"}'
  BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
  CANONICAL_REQUEST="POST
  /v1/actions/subscription-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/subscription-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"
  ```
</CodeGroup>

## 成功响应 (200)

```json theme={"system"}
{
  "data": {
    "product": {
      "id": "PROD_3F7H2J5L8N1Q4S6U",
      "storeId": "STO_2D5F8G3H1K4M6N9P",
      "name": "Pro Plan",
      "description": "Full access to all Pro features.",
      "billingPeriod": "monthly",
      "prices": {
        "USD": { "amount": "29.00", "taxCategory": "saas" },
        "EUR": { "amount": "27.00", "taxCategory": "saas" }
      },
      "media": [],
      "successUrl": "https://example.com/welcome",
      "metadata": { "trialDays": 14 },
      "status": "inactive",
      "createdAt": "2026-03-30T10:30:00.000Z",
      "updatedAt": "2026-03-30T13:00:00.000Z"
    }
  }
}
```

## 响应字段

与 [创建订阅商品响应](/api-reference/endpoints/subscription-products/create-product#response-fields) 相同。

<Note>
  停用订阅商品会阻止**新注册**，但**不会**取消现有活跃订阅。订阅者继续其当前计费周期不受影响。
</Note>

## 错误响应

> **重试策略**：4xx 一律不要重试 — 修正请求后重发。5xx 指数退避重试（起步 5s，最多 3 次）。

| 状态码 | `errors[0].message`                                          | 含义                              | 推荐处理                                 |
| --- | ------------------------------------------------------------ | ------------------------------- | ------------------------------------ |
| 400 | `Missing header: x-context-merchant-id`                      | 商户上下文 header 未透传                | 修正 SDK 配置                            |
| 400 | `Missing or invalid header: x-context-environment`           | 环境 header 缺失或不是 `test` / `prod` | 把 `X-Environment` 设为 `test` 或 `prod` |
| 400 | `Missing required field: id`                                 | 请求体缺少 `id`                      | 补齐 `id` 后重发                          |
| 400 | `Expected format: PROD_xxx, got "X"`                         | `id` 不是合法 Short ID              | 使用 `PROD_` 前缀的 Short ID              |
| 400 | `Invalid or missing status (must be 'active' or 'inactive')` | `status` 缺失或不在允许集合              | 改为 `active` 或 `inactive`             |
| 400 | 消息包含 `has no version`                                        | 目标环境（`test` 或 `prod`）尚无版本       | 先在该环境创建版本（从 test 发布，或在 test 创建）      |
| 401 | `Unauthorized`                                               | 认证失败                            | 检查 API Key、时间戳与签名                    |
| 404 | `Product not found` / `Current version not found`            | product ID 不存在（或当前版本缺失）         | 确认 product ID                        |
| 500 | `Internal server error`                                      | 瞬时下游故障                          | 指数退避重试（起步 5s，最多 3 次）                 |
