跳转到主要内容
本页是 取消订阅(Merchant API Key) 同一端点的 customer-token 调用视图。行为、请求体、响应结构完全一致 — 只有认证方式和调用方位置不同。
POST /v1/actions/subscription-order/cancel-order
认证方式: Session Token — 见 Customer Endpoints(customer 或 buyer 角色)
orderId 必须属于该 session token 所绑定的 customer。为某 buyer mint 的 token 不能取消另一 buyer 的订阅。

取消行为

当前状态操作结果状态
pending立即取消canceled
active在周期结束时取消(通过 PSP)canceling → 周期结束时变为 canceled

请求体

字段类型必需说明
orderIdstring订阅订单 ID(Short ID 格式 ORD_xxx

请求示例

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

const client = new WaffoPancake({
  sessionToken: window.WAFFO_SESSION_TOKEN, // 由商户 portal 注入
  environment: "prod",
});

const result = await client.orders.cancelSubscription({
  orderId: "ORD_2aUyqjCzEIiEcYMKj7TZtw",
});

console.log(result.orderId); // "ORD_2aUyqjCzEIiEcYMKj7TZtw"
console.log(result.status);  // "canceling" 或 "canceled"

成功响应 (200)

{
  "data": {
    "orderId": "ORD_2aUyqjCzEIiEcYMKj7TZtw",
    "status": "canceling"
  }
}

响应字段

字段类型说明
orderIdstring订单 ID(Short ID)
statusstring新的订单状态(cancelingcanceled

错误响应

重试策略:4xx 一律不要重试 — 修正请求后重发。5xx 指数退避重试(起步 5s,最多 3 次)。
状态码errors[0].message含义推荐处理
400Missing required field: orderId请求体未提供 orderId修正请求体后重新提交
400Expected format: ORD_xxx, got "..."orderId Short ID 解码失败修正 orderId 格式后重新提交
400Subscription cannot be canceled, current status: X订单状态非 pendingactive(如已 canceledcancelingexpired该订阅已不可取消
401Authentication failedSession token 无效、过期或格式错误通过 Issue Session Token 重新签发
403Order does not belong to userToken 绑定的 buyer 不是订单所有者为正确的 buyer mint 一个 token
404Order not found订单不存在验证 order ID
500Internal server error服务端意外失败指数退避重试(起步 5s,最多 3 次)
502Failed to cancel subscription本地更新或 PSP 取消失败指数退避重试(起步 5s,最多 3 次)