Z Zise Developers

取消申请(唯一的自助止损路径

POST /v1/cards/applications/{id}/cancel scope: cards:write
代会员调用 · 必带 x-on-behalf-of x-idempotency-key 动钱 · 按阶段把开卡费与邮费退回该会员的可用余额
这个端点会动钱

失败处置见下方响应表。超时(504)用同一把幂等键重试——我方可能已经处理完;业务失败要换新键,同键会原样返回那次失败。

在这一条之前,一张走不下去的申请单你只能等它自己失败 ——补件过期转 failed、或上游拒批。这中间用户的钱一直冻着,而你没有任何办法把它退回去。

不需要强认证:取消是止损动作,钱是往用户账上退的方向。在他最想撤销的那一刻拦一道验证,是把工具变成障碍。(注销卡片刚好相反 —— 那一步不可逆,要强认证。)

退款分两项下发refunded_issue / refunded_shipping)。开卡费与邮费的退款比例按阶段各算各的,合成一个数你就对不出账。金额是最小单位整数串。

⚠ 先调 cancel-preview。这一条不会因为「退得太少」而拒绝执行。

reason 只进我方留痕,不影响退款比例(那是按阶段算的)。

前置条件

  • 这一单还在可取消的阶段(见 cancel-previewcancellable

路径参数

字段类型必填说明
id string 必填
字段类型必填说明
x-idempotency-key string 必填
x-on-behalf-of string 必填

请求体

这个 operation 还没有在 spec 里声明请求体字段。

响应

200已取消
{
  "stage": "submitted",
  "refunded_issue": "20000000",
  "refunded_shipping": "0"
}
400state_invalid —— 这一档不许取消了(已经开出卡、或已经在退款中), 或者另一路刚好把这一单推进了一档(这种情况重试一次可能就成了, 先重看 cancel-preview)· idempotency_key_required
404not_found
请求
curl -X POST 'https://api.zise.com/v1/cards/applications/{id}/cancel' \
  -H 'x-auth-token: Bearer $TOKEN' \
  -H 'x-on-behalf-of: $MEMBER_ID' \
  -H 'x-idempotency-key: $IDEMPOTENCY_KEY' \
  -H 'content-type: application/json' \
  -d '{
    "reason": "user_changed_mind"
  }'
const res = await fetch("https://api.zise.com/v1/cards/applications/{id}/cancel", {
  method: "POST",
  headers: {
    "x-auth-token": "Bearer $TOKEN",
    "x-on-behalf-of": "$MEMBER_ID",
    "x-idempotency-key": "$IDEMPOTENCY_KEY",
    "content-type": "application/json",
  },
  body: JSON.stringify({
    "reason": "user_changed_mind"
  }),
});
// 金额按字符串读,别让它变成 number
const data = await res.json();
import requests

res = requests.post(
    "https://api.zise.com/v1/cards/applications/{id}/cancel",
    headers={
        "x-auth-token": "Bearer $TOKEN",
        "x-on-behalf-of": "$MEMBER_ID",
        "x-idempotency-key": "$IDEMPOTENCY_KEY",
        "content-type": "application/json",
    },
    json={
      "reason": "user_changed_mind"
    },
)
# 金额用 Decimal(str(...)),不要 float
data = res.json()
req, _ := http.NewRequest("POST", "https://api.zise.com/v1/cards/applications/{id}/cancel",
    strings.NewReader(`{
  "reason": "user_changed_mind"
}`))
req.Header.Set("x-auth-token", "Bearer $TOKEN")
req.Header.Set("x-on-behalf-of", "$MEMBER_ID")
req.Header.Set("x-idempotency-key", "$IDEMPOTENCY_KEY")
req.Header.Set("content-type", "application/json")
res, err := http.DefaultClient.Do(req)
// 金额字段用 string 接,不要 float64
HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://api.zise.com/v1/cards/applications/{id}/cancel"))
    .header("x-auth-token", "Bearer $TOKEN")
    .header("x-on-behalf-of", "$MEMBER_ID")
    .header("x-idempotency-key", "$IDEMPOTENCY_KEY")
    .header("content-type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("""
{
  "reason": "user_changed_mind"
}
"""))
    .build();
// 金额字段用 String / BigDecimal,不要 double
$ch = curl_init('https://api.zise.com/v1/cards/applications/{id}/cancel');
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    'x-auth-token: Bearer $TOKEN',
    'x-on-behalf-of: $MEMBER_ID',
    'x-idempotency-key: $IDEMPOTENCY_KEY',
    'content-type: application/json',
  ],
  CURLOPT_POSTFIELDS => <<<'JSON'
{
  "reason": "user_changed_mind"
}
JSON,
]);
$res = curl_exec($ch);
// 金额用 bcmath / 字符串,不要 floatval
200
{
  "stage": "submitted",
  "refunded_issue": "20000000",
  "refunded_shipping": "0"
}