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

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# 取消订阅

> 立即取消订阅，或将取消安排在将来的某个日期或计费周期。

使用空请求体（或完全不带请求体）调用此 endpoint 会立即取消订阅，
将其 `status` 更改为 `CANCELED`。此行为保持不变，并且仍是最终操作：立即取消后，
将无法撤销。

您可以从 `CREATED`、`ACTIVE`、`TRIALING`、`PAST_DUE` 和 `PAUSED` 状态取消订阅。`COMPLETED` 和
`CANCELED` 是终态，因此从这两种状态取消会返回 `400 INVALID_STATE`，包括对已取消的订阅
再次执行取消。请参阅 [订阅状态](https://docs.y.uno/zh-hans/reference/subscriptions/status-subscriptions.md)。

## 立即取消时的退款

> [!NOTE]
>
> **仅限已加入允许名单的组织**
>
> 退款报价按组织启用，与预定取消相互独立。如果您的调用
> 返回 `400` `"Refund quote is not enabled for this organization."`，请联系您的 Yuno 代表
> 为您启用该功能。

在立即取消（不带 `schedule`）时一并发送 `refund` 模式，即可让 Yuno 计算
当前计费周期的退款报价。Yuno 只 **计算** 报价，从不转移资金。
响应中的 `refund.execution` 始终为 `"MERCHANT"`：您需要以报价金额为输入，
通过您自己的支付通道自行执行退款。

```json Cancel with a prorated refund theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "refund": "PRORATED"
}
```

| 值 | 行为 |
| - | - |
| `NONE`（默认值） | 不计算退款。与不带 `refund` 键相同。 |
| `PRORATED` | 按日历天数退还当前周期中未使用的部分。 |
| `FULL` | 退还当前周期收取的全部金额。 |
| `CUSTOM` | 退还商户提供的金额，上限为该周期收取的金额。 |

`refund` 不能与 `schedule` 组合使用：同时发送两者，或将 `refund` 与
`"schedule": null` 一起发送，都会在写入任何内容之前被驳回并返回 `400`。`refund: NONE` 或完全省略
`refund` 时，仍可与 `schedule` 正常配合使用。

### 退款基准

所有退款模式都基于相同的基准计算：**订阅上最近一次已捕获的
支付**，而不是订阅自身的标价，也不是估算值。对于
应用了促销的周期，这些金额是扣除折扣后的实付净额，`basis.charged_amount`
会显示该金额。如果当前周期没有任何已捕获的支付（支付已拒绝、支付仍待处理，
或存在空缺），`PRORATED`、`FULL` 和 `CUSTOM` 都会返回 `400 REFUND_NOT_AVAILABLE`，但真正的
`$0` 阶段（未收取任何费用的试用或促销阶段）或完全由
促销覆盖的周期除外，这种情况会返回 `200` 及 `amount: 0.00`。此时没有可退款的金额，但这并不是
错误。

`PAST_DUE` 订阅在进行中的周期内没有已捕获的支付，因此适用相同规则：
`refund: NONE`（或不带 `refund`）仍会正常取消，但任何其他模式都会返回
`400 REFUND_NOT_AVAILABLE`，并带有 `current_status: "PAST_DUE"`。

### PRORATED

退还当前周期中未使用的天数，按日历日期计算，从不按小时或
分钟计算：

* `period_start`：最近一次已捕获的支付的收费日期。
* `period_end`：当前周期自然结束的日期；如果订阅设有 `availability.finish_at` 且该日期更早，
  则以该时间为上限。
* `unused_days = period_days − used_days`，其中 `used_days` 将您取消的当天计为完整的
  已使用天：在 30 天周期的第 10 天任何时间取消，仍计为已使用 10 天。
* `amount = charged_amount × unused_days / period_days`，按该币种的最小
  单位以 `HALF_UP` 方式舍入。

例如，一个 30 天的周期收取了 `$30.00`，在第 10 天取消：已使用 10 天，未使用 20 天，
`amount = 30.00 × 20/30 = 20.00`。

```json Cancel with a prorated refund — response theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "refund": {
    "mode": "PRORATED",
    "amount": { "value": 20.00, "currency": "USD" },
    "unused_days": 20,
    "period_days": 30,
    "basis": {
      "billing_cycle": 4,
      "charged_amount": { "value": 30.00, "currency": "USD" },
      "payment_id": "<example>",
      "charged_at": "<example>"
    },
    "execution": "MERCHANT",
    "quoted_at": "<example>"
  }
}
```

按小时或分钟计费的订阅没有有意义的“天”的概念，因此 `PRORATED`
在这种情况下会返回 `400` `"proration is not available for sub-daily cadences"`。`FULL` 和 `CUSTOM`
不受影响：两者在小于一天的计费节奏上仍然有效。

### FULL

退还当前周期的全部 `basis.charged_amount`：`amount` 始终与
`basis.charged_amount` 完全相等，并且 `unused_days` 等于 `period_days`（整个周期都被视为
未使用）。

### CUSTOM

`CUSTOM` 退款按以下顺序从两个来源之一获取金额：

1. 取消请求中的 `refund_amount`（如果您发送了）。
2. 否则使用订阅上配置的 `refund_rule`。

如果两者都不存在，取消会被驳回并返回 `400` `BAD_REQUEST`：
`"refund: CUSTOM requires refund_amount or a configured refund_rule."`。`CUSTOM` 从不回退到
计算得出的金额。`refund_rule` 可在 [创建](https://docs.y.uno/zh-hans/reference/subscriptions/create-subscription.md#setting-a-refund-rule)
或 [更新](https://docs.y.uno/zh-hans/reference/subscriptions/update-subscription.md#setting-a-refund-rule) 时设置，并在
[订阅对象](https://docs.y.uno/zh-hans/reference/subscriptions/the-subscription-object.md) 中说明。

```json Cancel G — the request's refund_amount wins over the configured refund_rule theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "refund": "CUSTOM",
  "refund_amount": { "value": 5000, "currency": "COP" }
}
// refund.amount.value: 5000 — the configured refund_rule (a FIXED rule for 10000) is not used
```

```json Cancel H — no refund_amount sent, the configured refund_rule wins theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "refund": "CUSTOM"
}
// refund.amount.value: 10000 — the subscription's stored FIXED refund_rule
```

> [!NOTE]
>
> **可用性**
>
> 已配置的 `refund_rule` 仅适用于已启用该功能的组织；请联系 Yuno。对于
> 尚未启用的组织，`CUSTOM` 的行为与现在完全相同：请求中的 `refund_amount`
> 为必填项，并且该组织从一开始就无法配置
> `refund_rule`。

将 `refund_amount` 与 `"refund": "CUSTOM"` 一起发送，即可退还指定金额，而不是
计算得出或基于规则的金额：

```json Cancel with a custom refund amount theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "refund": "CUSTOM",
  "refund_amount": { "value": 5.00, "currency": "USD" }
}
```

响应中的 `amount` 原样返回您的 `refund_amount`，不会重新计算或再次
舍入。`refund_amount.value` 必须大于 `0`，且不得超过当前周期的
收取金额，并且 `refund_amount.currency` 必须与订阅自身的币种一致。

### 读取退款对象

当 `refund` 为 `NONE` 或被省略时，`refund` 为 `null`。否则：

| 字段 | 描述 |
| - | - |
| `mode` | `PRORATED`、`FULL` 或 `CUSTOM`：返回所请求的模式。 |
| `amount` | 计算得出（或 `CUSTOM` 原样返回）的退款金额。 |
| `unused_days` / `period_days` | 计算金额所依据的天数输入。对于 `FULL`，`unused_days` 等于 `period_days`：整个周期都计为未使用。 |
| `basis.billing_cycle` | 计算退款所依据的计费周期。 |
| `basis.charged_amount` | 该周期实际收取的金额，即退款的上限。 |
| `basis.payment_id` | 已捕获支付自身的 id。对于没有可引用支付的 `$0` 阶段报价，为 `null`。 |
| `basis.charged_at` | 该支付被捕获的时间。对于没有可引用支付的 `$0` 阶段报价，为 `null`。 |
| `execution` | 始终为 `"MERCHANT"`：Yuno 计算报价，由您执行退款。 |
| `quoted_at` | 计算此报价的时间。 |

### `refund` 出现的位置

* **取消操作的 `200` 响应** 始终携带 `refund` 键：未计算报价时为 `null`，
  否则为该对象。
* **`GET /v1/subscriptions/{id}`** 和 **`GET /v1/subscriptions?merchant_reference=...`** 在存在报价后
  也会携带 *最近一次计算的* `refund`：带退款报价的取消会将其持久保存，因此
  之后通过这两种方式读取该订阅时，都会持续显示该报价。
* **`GET /v1/subscriptions`**（分页列表）的任何条目中 **都不** 携带 `refund`，无论
  该订阅是否带报价取消：列表项是比完整订阅对象更小的摘要结构，
  而 `refund` 不在其包含的字段中。
* **`subscription.cancel` webhook** 仅在实际计算了报价时才携带 `refund`
  （`PRORATED`/`FULL`/`CUSTOM`）；对于 `NONE`/不带 refund 的取消，该字段不存在，而不是 `null`。

## 改为预定取消

> [!NOTE]
>
> **仅限已加入允许名单的组织**
>
> 预定取消按组织启用。如果您的调用返回 `400` `"Scheduled
>   cancellation is not enabled for this organization."`，请联系您的 Yuno 代表为您启用该
> 功能。

发送 `schedule` 对象可推迟取消，而不是立即应用。订阅
保持当前状态（计费照常进行），直到预定时间触发。

```json Schedule after 3 more billing cycles theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "schedule": {
    "after_cycles": 3
  }
}
```

```json Schedule for a specific date theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "schedule": {
    "at": "2026-11-01T00:00:00Z"
  }
}
```

`schedule` 只能包含以下其中一项：

| 字段 | 类型 | 规则 |
| - | - | - |
| `after_cycles` | integer | 1 到 60，并且不能超过订阅剩余的计费周期数（当计划设有总数时，为 `billing_cycles.total − billing_cycles.current`）。 |
| `at` | Timestamp | 带 UTC 偏移量的 ISO-8601 格式，必须是将来的时间，并且如果订阅设有 `availability.finish_at`，则必须早于该时间。 |

同时发送两者或两者都不发送会返回 `400`。

以 `frequency.execution: MERCHANT` 计费的 `PIX_AUTOMATIC` 订阅无法预定
取消：请在其他支付方式类型上以 `at` 或 `after_cycles` 进行预定，或者改为
立即取消。

### 重试进行期间的行为

> [!NOTE]
>
> **`past_due_behavior` 会在 `cancel_scheduled` 中返回，尚待产品确认**
>
> 引擎目前会将为该预定解析出的 `past_due_behavior`（显式值，
> 或默认值 `EXHAUST_RETRIES`）写入每个响应的 `cancel_scheduled.past_due_behavior` 字段。
> 在产品确认其为预期的对外契约之前，请将该返回值视为临时性的，
> 它可能会发生变化。

`past_due_behavior` 控制当预定取消本应触发时订阅处于 `PAST_DUE` 状态的情况下，
预定取消如何处理：

| 值 | 行为 |
| - | - |
| `EXHAUST_RETRIES`（默认值） | 预定取消会等待：进行中周期的重试继续执行，只有当订阅离开 `PAST_DUE` 状态（已恢复或重试已用尽）时，取消才会触发。 |
| `SKIP_RETRIES` | 预定取消立即触发，不等待未完成的重试结束。 |

```json Schedule and skip retries if PAST_DUE when it fires theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "schedule": {
    "after_cycles": 1,
    "past_due_behavior": "SKIP_RETRIES"
  }
}
```

无论 `past_due_behavior` 如何设置，取消 `PAST_DUE` 订阅（无论是立即取消，还是
因预定到期而取消）都不会出错，并且始终会停止该周期的重试。请参阅
[订阅状态](https://docs.y.uno/zh-hans/reference/subscriptions/status-subscriptions.md) 和
[重试](https://docs.y.uno/zh-hans/docs/payment-features/subscriptions/retries.md)。

> [!NOTE]
>
> 退款处理仅适用于 **立即** 取消，请参阅
> [立即取消时的退款](#refund-on-immediate-cancel)。预定取消不支持退款处理：
> `schedule` 请求不能同时携带 `refund` 模式。

## 撤销预定取消

发送 `"schedule": null` 可清除待处理的预定。除此之外订阅不受影响：不会
变更状态，也不会收费。

```json Undo a scheduled cancellation theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "schedule": null
}
```

在没有任何预定时发送 `"schedule": null` 是空操作：返回 `200`，`cancel_scheduled` 保持
`null`，并且不发送 webhook。清除预定时，会改为触发
`subscription.cancel_schedule_canceled`。

## 读取结果

响应携带的 [订阅](https://docs.y.uno/zh-hans/reference/subscriptions/the-subscription-object.md)
结构与其他所有订阅 endpoint 相同。此处有四个相关字段：

* `cancel_scheduled`：没有待处理的取消时为 `null`，否则包含预定的 `mode`、
  `after_cycles`/`at`、`requested_at` 和 `past_due_behavior`。
* `retries.stopped`、`retries.attempts_made`、`retries.outcome`、`retries.next_retry_at`：只要
  订阅处于 `PAST_DUE` 状态或有待处理的 `cancel_scheduled`，就会填充这些字段；否则省略。
* `unpaid_cycle`：当前计费周期处于 `PAST_DUE` 状态且尚未结清时出现。
* `refund`：未计算退款报价时为 `null`（在非取消的读取中则不存在），否则包含
  报价金额及其基准。请参阅 [立即取消时的退款](#refund-on-immediate-cancel)。

> [!NOTE]
>
> **取消后 `retries` 和 `unpaid_cycle` 是否持久保留，尚待产品确认**
>
> 这两个字段都是根据请求时订阅的实时状态计算的。对于 `GET
>   /v1/subscriptions/{id}`，如果在订阅进入 `CANCELED` 之后发出，它是继续显示进行中周期的
> 重试快照和未付周期，还是在进入终态后将其省略，目前
> 尚未确认为稳定的契约；在依赖此行为之前，请通过实际响应进行验证。

请参阅 [订阅对象](https://docs.y.uno/zh-hans/reference/subscriptions/the-subscription-object.md)
了解完整的字段参考。

## 对已暂停的订阅预定取消

已暂停的订阅仍然可以预定取消。订阅处于 `PAUSED` 状态时，`schedule.after_cycles` 会被驳回，
因为暂停会冻结计费时钟，没有可供计数的周期
边界：

```json 400 — after_cycles on a paused subscription theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "code": "BAD_REQUEST",
  "messages": [
    "schedule.after_cycles cannot be resolved while the subscription is paused; use schedule.at instead."
  ]
}
```

`schedule.at` 没有此限制：它不需要周期时钟，因此在
`PAUSED` 订阅上会被正常接受。请参阅 [暂停订阅](https://docs.y.uno/zh-hans/reference/subscriptions/pause-subscription.md)。

## Webhooks

* `subscription.cancel_scheduled`：通过此 endpoint 预定取消时发送。
* `subscription.cancel_schedule_canceled`：通过 `"schedule": null` 撤销待处理的预定取消时
  发送。

立即取消（空请求体，或预定到期）仍会像以前一样发出 `subscription.cancel`；
预定功能仅针对预定和撤销操作本身发出其自身的事件。
`subscription.cancel` 的 payload 也会携带 `refund`，遵循与取消响应
相同的规则：仅在实际计算了报价时出现（`PRORATED`/`FULL`/`CUSTOM`），对于
`NONE`/不带 refund 的取消则不存在。

## 错误

| HTTP | `code` | 触发条件 |
| - | - | - |
| `400` | `BAD_REQUEST` | 存在无法识别的顶层键，或 `schedule` 中存在无法识别的键。 |
| `400` | `BAD_REQUEST` | `schedule` 同时携带 `at` 和 `after_cycles`，或两者都不携带。 |
| `400` | `BAD_REQUEST` | `after_cycles` 不是 1 到 60 之间的整数，或超过剩余的计费周期数。 |
| `400` | `BAD_REQUEST` | 订阅处于 `PAUSED` 状态时发送了 `after_cycles`：`"schedule.after_cycles cannot be resolved while the subscription is paused; use schedule.at instead."` |
| `400` | `BAD_REQUEST` | `at` 不是带 UTC 偏移量的 ISO-8601 日期时间，不是将来的时间，或等于或晚于 `availability.finish_at`。 |
| `400` | `BAD_REQUEST` | `past_due_behavior` 不是 `EXHAUST_RETRIES` 或 `SKIP_RETRIES`。 |
| `400` | `BAD_REQUEST` | 该组织未启用预定取消。 |
| `400` | `BAD_REQUEST` | 以 `frequency.execution: MERCHANT` 计费的 `PIX_AUTOMATIC` 订阅无法预定取消。 |
| `400` | `BAD_REQUEST` | `refund` 不是 `NONE`、`PRORATED`、`FULL`、`CUSTOM` 之一。 |
| `400` | `BAD_REQUEST` | `refund`（`NONE` 以外的任何模式）与 `schedule` 组合使用，包括 `"schedule": null`。 |
| `400` | `BAD_REQUEST` | 该组织未启用退款报价（`refund: NONE`/不带 refund 时从不受限制）。 |
| `400` | `BAD_REQUEST` | 发送了 `refund_amount`，但未使用 `refund: CUSTOM`。 |
| `400` | `BAD_REQUEST` | 发送了 `refund: CUSTOM`，但既没有 `refund_amount`，订阅上也没有配置 `refund_rule`：`"refund: CUSTOM requires refund_amount or a configured refund_rule."` |
| `400` | `BAD_REQUEST` | `refund_amount.value` 缺失、不大于 `0`，或超过当前周期的收取金额（上限）。 |
| `400` | `BAD_REQUEST` | `refund_amount.currency` 缺失或与订阅自身的币种不一致。 |
| `400` | `BAD_REQUEST` | 在小于一天（`HOUR`/`MINUTE`）的计费节奏上使用 `refund: PRORATED`。 |
| `400` | `REFUND_NOT_AVAILABLE` | `refund` 不是 `NONE`，且当前计费周期没有可供退款的已捕获支付（包括所有 `PAST_DUE` 情况）。携带 `current_status`。 |
| `400` | `INVALID_STATE` | 订阅的状态不支持取消（`COMPLETED` 或已 `CANCELED`）。 |


## OpenAPI

````yaml openapi/zh-hans/subscriptions/cancel-subscription.json POST /subscriptions/{subscription_id}/cancel
openapi: 3.1.0
info:
  title: subscription
  version: 1.0.2
servers:
  - url: https://api-sandbox.y.uno/v1
    description: Sandbox
  - url: https://api.y.uno/v1
    description: Production (US)
security:
  - sec0: []
    sec1: []
paths:
  /subscriptions/{subscription_id}/cancel:
    post:
      summary: 取消订阅
      operationId: cancel-subscription
      parameters:
        - name: subscription_id
          in: path
          description: 订阅的唯一标识符。
          schema:
            type: string
          required: true
      requestBody:
        required: false
        content:
          application/json:
            examples:
              IMMEDIATE (empty body):
                value: {}
              SCHEDULE AFTER 3 CYCLES:
                value:
                  schedule:
                    after_cycles: 3
              SCHEDULE AT A DATE:
                value:
                  schedule:
                    at: '2026-11-01T00:00:00Z'
              SCHEDULE AND SKIP RETRIES IF PAST_DUE:
                value:
                  schedule:
                    after_cycles: 1
                    past_due_behavior: SKIP_RETRIES
              UNDO A PENDING SCHEDULE:
                value:
                  schedule: null
              CANCEL WITH A PRORATED REFUND:
                value:
                  refund: PRORATED
              CANCEL WITH A CUSTOM REFUND AMOUNT:
                value:
                  refund: CUSTOM
                  refund_amount:
                    value: 5
                    currency: USD
              CANCEL WITH CUSTOM REFUND (RULE RESOLVES IT):
                value:
                  refund: CUSTOM
            schema:
              type: object
              properties:
                refund:
                  type: string
                  description: >-
                    NONE（默认）、PRORATED、FULL 或 CUSTOM。在立即取消时，为当前计费周期计算退款报价。不能与
                    schedule 同时使用。
                  example: PRORATED
                refund_amount:
                  type: object
                  description: 当 refund 为 CUSTOM 时必填，且仅在此时允许使用。不得超过当前周期的已扣款金额。
                  properties:
                    value:
                      type: number
                      example: 5
                    currency:
                      type: string
                      description: 必须与订阅自身的币种一致。
                      example: USD
                schedule:
                  type:
                    - object
                    - 'null'
                  properties:
                    after_cycles:
                      type: integer
                      description: 再经过这么多个计费周期后取消。1-60，以剩余周期数为上限。after_cycles/at 必须且只能提供其一。
                      example: 3
                    at:
                      type: string
                      description: >-
                        在此 ISO-8601 日期时间取消（必须带 UTC 偏移）。必须晚于当前时间，且早于
                        availability.finish_at。after_cycles/at 必须且只能提供其一。
                      example: '2026-11-01T00:00:00Z'
                    past_due_behavior:
                      type: string
                      description: >-
                        EXHAUST_RETRIES（默认）会等待当前周期的重试完成后再触发；SKIP_RETRIES
                        会立即触发，即使订阅处于 PAST_DUE 状态。
                      example: EXHAUST_RETRIES
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                CANCEL SUBSCRIPTION:
                  value:
                    id: 7304911d-5df9-429e-8488-ad41abea1a4c
                    name: sub_001
                    description: streaming service
                    account_id: 2404911d-5df9-429e-8488-ad41abea1a4b
                    merchant_reference: 001_marzo_23
                    status: CANCELED
                    subscription_plan_id: 1904911d-5df9-429e-8488-ad41abea1a4d
                    amount:
                      currency: USD
                      value: 12100
                    frequency:
                      type: MONTH
                      value: 1
                    billing_cycles:
                      total: 10
                      current: 2
                      next_at: '2023-02-16T20:00:00.786342Z'
                    customer_payer:
                      id: 3t04911d-5df9-429e-8488-ad41abea1a2c
                    payment_method:
                      type: CARD
                      token: 9104911d-5df9-429e-8488-ad41abea1a4b
                      vaulted_token: 6104911d-5df9-429e-8488-ad41abea1a4b
                      card:
                        verify: false
                        card_data:
                          number: '4507990000000010'
                          expiration_month: 10
                          expiration_year: 2025
                          security_code: 123
                          holder_name: JOHN DOE
                    availability:
                      start_at: '2024-01-16T00:00:00.786342Z'
                      finish_at: '2024-05-26T20:00:00.786342Z'
                    metadata:
                      - key: sub_ext_id
                        value: AA001
                    payments:
                      - 5104911d-5df9-229e-8468-bd41abea1a4s
                    created_at: '2023-12-16T20:46:54.786342Z'
                    updated_at: '2023-12-16T21:00:54.786342Z'
                    country: US
                    retries:
                      retry_on_decline: false
                      amount: 6
                      strategy: DEFAULT
                      schedule: null
                      stop_on_hard_decline: null
                      cancel_on_exhausted_retries: null
                    additional_data: null
                    trial_period:
                      billing_cycles: 1
                      amount:
                        value: 0
                        currency: USD
                    initial_payment_validation: false
                    reason: null
                    subscription_agreement_id: null
                    soft_descriptor: ACME SUBSCRIPTION
                    renewal_notification_days: null
                    cancellation_time: '2026-10-23T08:53:58.316841Z'
                    cancellation_source: MERCHANT
                    ending_time: null
                    pending_plan_change: null
                    current_period_start: '2026-10-23T00:00:00Z'
                    current_period_end: '2026-11-23T00:00:00Z'
                    refund: null
                CANCELLATION SCHEDULED:
                  value:
                    id: 7304911d-5df9-429e-8488-ad41abea1a4c
                    name: sub_001
                    description: streaming service
                    account_id: 2404911d-5df9-429e-8488-ad41abea1a4b
                    merchant_reference: 001_marzo_23
                    status: ACTIVE
                    subscription_plan_id: 1904911d-5df9-429e-8488-ad41abea1a4d
                    amount:
                      currency: USD
                      value: 12100
                    frequency:
                      type: MONTH
                      value: 1
                    billing_cycles:
                      total: 10
                      current: 2
                      next_at: '2023-02-16T20:00:00.786342Z'
                    customer_payer:
                      id: 3t04911d-5df9-429e-8488-ad41abea1a2c
                    retries:
                      retry_on_decline: true
                      amount: 4
                      strategy: SMART
                    cancel_scheduled:
                      mode: AFTER_CYCLES
                      after_cycles: 3
                      at: '2024-03-16T20:00:00.786342Z'
                      requested_at: '2023-12-16T21:00:54.786342Z'
                      past_due_behavior: EXHAUST_RETRIES
                    created_at: '2023-12-16T20:46:54.786342Z'
                    updated_at: '2023-12-16T21:00:54.786342Z'
                    country: US
                    payment_method:
                      type: CARD
                      vaulted_token: 6477c344-6c33-47d7-880c-867da866eeaf
                      card:
                        installments: 3
                        network_transaction_id: null
                        usage: USED
                    availability:
                      start_at: '2030-01-01T00:00:00Z'
                      finish_at: null
                    metadata:
                      - key: plan
                        value: gold
                    additional_data: null
                    trial_period:
                      billing_cycles: 1
                      amount:
                        value: 0
                        currency: USD
                    initial_payment_validation: false
                    reason: null
                    subscription_agreement_id: null
                    soft_descriptor: ACME SUBSCRIPTION
                    renewal_notification_days: null
                    cancellation_time: '2026-10-23T08:53:58.316841Z'
                    cancellation_source: MERCHANT
                    ending_time: null
                    pending_plan_change: null
                    current_period_start: '2026-10-23T00:00:00Z'
                    current_period_end: '2026-11-23T00:00:00Z'
                    refund: null
                CANCELED FROM PAST_DUE (RETRIES STOPPED, UNPAID CYCLE):
                  value:
                    id: 7304911d-5df9-429e-8488-ad41abea1a4c
                    name: sub_001
                    description: streaming service
                    account_id: 2404911d-5df9-429e-8488-ad41abea1a4b
                    merchant_reference: 001_marzo_23
                    status: CANCELED
                    subscription_plan_id: 1904911d-5df9-429e-8488-ad41abea1a4d
                    amount:
                      currency: USD
                      value: 12100
                    billing_cycles:
                      total: 10
                      current: 2
                      next_at: '2023-02-16T20:00:00.786342Z'
                    customer_payer:
                      id: 3t04911d-5df9-429e-8488-ad41abea1a2c
                    retries:
                      retry_on_decline: true
                      amount: 4
                      strategy: SMART
                      stopped: true
                      attempts_made: 2
                      outcome: ABANDONED
                    unpaid_cycle:
                      cycle_number: 2
                      amount:
                        currency: USD
                        value: 12100
                      attempts: 2
                      last_failure_code: DECLINED_BY_BANK
                    cancel_scheduled: null
                    created_at: '2023-12-16T20:46:54.786342Z'
                    updated_at: '2023-12-16T21:00:54.786342Z'
                    country: US
                    frequency:
                      type: MONTH
                      value: 1
                    payment_method:
                      type: CARD
                      vaulted_token: 6477c344-6c33-47d7-880c-867da866eeaf
                      card:
                        installments: 3
                        network_transaction_id: null
                        usage: USED
                    availability:
                      start_at: '2030-01-01T00:00:00Z'
                      finish_at: null
                    metadata:
                      - key: plan
                        value: gold
                    additional_data: null
                    trial_period:
                      billing_cycles: 1
                      amount:
                        value: 0
                        currency: USD
                    initial_payment_validation: false
                    reason: null
                    subscription_agreement_id: null
                    soft_descriptor: ACME SUBSCRIPTION
                    renewal_notification_days: null
                    cancellation_time: '2026-10-23T08:53:58.316841Z'
                    cancellation_source: MERCHANT
                    ending_time: null
                    pending_plan_change: null
                    current_period_start: '2026-10-23T00:00:00Z'
                    current_period_end: '2026-11-23T00:00:00Z'
                    refund: null
                CANCELED WITH A PRORATED REFUND QUOTE:
                  value:
                    id: 7304911d-5df9-429e-8488-ad41abea1a4c
                    name: sub_001
                    description: streaming service
                    account_id: 2404911d-5df9-429e-8488-ad41abea1a4b
                    merchant_reference: 001_marzo_23
                    status: CANCELED
                    subscription_plan_id: 1904911d-5df9-429e-8488-ad41abea1a4d
                    amount:
                      currency: USD
                      value: 12100
                    billing_cycles:
                      total: 10
                      current: 4
                      next_at: '2023-02-16T20:00:00.786342Z'
                    customer_payer:
                      id: 3t04911d-5df9-429e-8488-ad41abea1a2c
                    refund:
                      mode: PRORATED
                      amount:
                        value: 20
                        currency: USD
                      unused_days: 20
                      period_days: 30
                      basis:
                        billing_cycle: 4
                        charged_amount:
                          value: 30
                          currency: USD
                        payment_id: 9104911d-5df9-429e-8488-ad41abea1a5e
                        charged_at: '2023-11-16T20:00:00.786342Z'
                      execution: MERCHANT
                      quoted_at: '2023-12-16T21:00:54.786342Z'
                    created_at: '2023-12-16T20:46:54.786342Z'
                    updated_at: '2023-12-16T21:00:54.786342Z'
                    country: US
                    frequency:
                      type: MONTH
                      value: 1
                    payment_method:
                      type: CARD
                      vaulted_token: 6477c344-6c33-47d7-880c-867da866eeaf
                      card:
                        installments: 3
                        network_transaction_id: null
                        usage: USED
                    availability:
                      start_at: '2030-01-01T00:00:00Z'
                      finish_at: null
                    retries:
                      retry_on_decline: false
                      amount: 6
                      strategy: DEFAULT
                      schedule: null
                      stop_on_hard_decline: null
                      cancel_on_exhausted_retries: null
                    metadata:
                      - key: plan
                        value: gold
                    additional_data: null
                    trial_period:
                      billing_cycles: 1
                      amount:
                        value: 0
                        currency: USD
                    initial_payment_validation: false
                    reason: null
                    subscription_agreement_id: null
                    soft_descriptor: ACME SUBSCRIPTION
                    renewal_notification_days: null
                    cancellation_time: '2026-10-23T08:53:58.316841Z'
                    cancellation_source: MERCHANT
                    ending_time: null
                    pending_plan_change: null
                    current_period_start: '2026-10-23T00:00:00Z'
                    current_period_end: '2026-11-23T00:00:00Z'
                CANCELED WITH A CUSTOM REFUND - THE REQUEST AMOUNT WINS:
                  value:
                    id: 7304911d-5df9-429e-8488-ad41abea1a4c
                    name: SUB-108B merchant precedence subject G
                    account_id: 2404911d-5df9-429e-8488-ad41abea1a4b
                    country: CO
                    description: null
                    merchant_reference: pa-sub108bg-1789488892790-438550
                    status: CANCELED
                    amount:
                      currency: COP
                      value: 45000
                    frequency:
                      type: MINUTES
                      value: 1
                    billing_cycles:
                      total: null
                      current: 4
                      paid: 3
                      next_at: '2026-09-15T16:17:57.79Z'
                    customer_payer:
                      id: 3t04911d-5df9-429e-8488-ad41abea1a2c
                    payment_method:
                      type: CARD
                      vaulted_token: 6104911d-5df9-429e-8488-ad41abea1a4b
                      card:
                        installments: null
                        network_transaction_id: '615803391389209'
                        usage: USED
                    availability:
                      start_at: '2026-09-15T16:14:57.79Z'
                      finish_at: null
                    retries:
                      retry_on_decline: false
                      amount: 6
                      strategy: SMART
                      schedule: null
                      stop_on_hard_decline: null
                      cancel_on_exhausted_retries: null
                    metadata: null
                    additional_data: null
                    trial_period:
                      billing_cycles: 1
                      amount:
                        value: 0
                        currency: ''
                    initial_payment_validation: false
                    reason: null
                    subscription_agreement_id: null
                    soft_descriptor: null
                    renewal_notification_days: null
                    cancellation_time: '2026-09-15T16:17:20.597473Z'
                    cancellation_source: MERCHANT
                    ending_time: null
                    created_at: '2026-09-15T16:14:53.58767Z'
                    updated_at: '2026-09-15T16:17:20.597473Z'
                    pending_plan_change: null
                    current_period_start: '2026-09-15T16:16:57.79Z'
                    current_period_end: '2026-09-15T16:17:57.79Z'
                    refund_rule:
                      type: FIXED
                      amount:
                        currency: COP
                        value: 10000
                    refund:
                      mode: CUSTOM
                      amount:
                        currency: COP
                        value: 5000
                      unused_days: 0
                      period_days: 0
                      basis:
                        billing_cycle: 3
                        charged_amount:
                          currency: COP
                          value: 45000
                        payment_id: 857de7e6-47eb-49be-99ee-7e1239c4e154
                        charged_at: '2026-09-15T16:16:57.804759Z'
                      execution: MERCHANT
                      quoted_at: '2026-09-15T16:17:20.59332Z'
                CANCELED WITH A CUSTOM REFUND - THE CONFIGURED RULE WINS:
                  value:
                    id: 7304911d-5df9-429e-8488-ad41abea1a4c
                    name: SUB-108B merchant precedence subject H
                    account_id: 2404911d-5df9-429e-8488-ad41abea1a4b
                    country: CO
                    description: null
                    merchant_reference: pa-sub108bh-1789488893775-983485
                    status: CANCELED
                    amount:
                      currency: COP
                      value: 45000
                    frequency:
                      type: MINUTES
                      value: 1
                    billing_cycles:
                      total: null
                      current: 4
                      paid: 3
                      next_at: '2026-09-15T16:17:58.775Z'
                    customer_payer:
                      id: 3t04911d-5df9-429e-8488-ad41abea1a2c
                    payment_method:
                      type: CARD
                      vaulted_token: 6104911d-5df9-429e-8488-ad41abea1a4b
                      card:
                        installments: null
                        network_transaction_id: '615803391389209'
                        usage: USED
                    availability:
                      start_at: '2026-09-15T16:14:58.775Z'
                      finish_at: null
                    retries:
                      retry_on_decline: false
                      amount: 6
                      strategy: SMART
                      schedule: null
                      stop_on_hard_decline: null
                      cancel_on_exhausted_retries: null
                    metadata: null
                    additional_data: null
                    trial_period:
                      billing_cycles: 1
                      amount:
                        value: 0
                        currency: ''
                    initial_payment_validation: false
                    reason: null
                    subscription_agreement_id: null
                    soft_descriptor: null
                    renewal_notification_days: null
                    cancellation_time: '2026-09-15T16:17:21.838701Z'
                    cancellation_source: MERCHANT
                    ending_time: null
                    created_at: '2026-09-15T16:14:54.30455Z'
                    updated_at: '2026-09-15T16:17:21.838701Z'
                    pending_plan_change: null
                    current_period_start: '2026-09-15T16:16:58.775Z'
                    current_period_end: '2026-09-15T16:17:58.775Z'
                    refund_rule:
                      type: FIXED
                      amount:
                        currency: COP
                        value: 10000
                    refund:
                      mode: CUSTOM
                      amount:
                        currency: COP
                        value: 10000
                      unused_days: 0
                      period_days: 0
                      basis:
                        billing_cycle: 3
                        charged_amount:
                          currency: COP
                          value: 45000
                        payment_id: a35cb164-e68f-45f0-954e-1fe34e4203eb
                        charged_at: '2026-09-15T16:16:58.790108Z'
                      execution: MERCHANT
                      quoted_at: '2026-09-15T16:17:21.837768Z'
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: 7304911d-5df9-429e-8488-ad41abea1a4c
                  name:
                    type: string
                    example: sub_001
                  description:
                    type: string
                    example: streaming service
                    nullable: true
                  account_id:
                    type: string
                    example: 2404911d-5df9-429e-8488-ad41abea1a4b
                  merchant_reference:
                    type: string
                    example: 001_marzo_23
                  status:
                    type: string
                    example: CANCELED
                  subscription_plan_id:
                    type: string
                    example: 1904911d-5df9-429e-8488-ad41abea1a4d
                  amount:
                    type: object
                    properties:
                      currency:
                        type: string
                        example: USD
                      value:
                        type: number
                        example: 12100
                        default: 0
                  frequency:
                    type: object
                    properties:
                      type:
                        type: string
                        example: MONTH
                      value:
                        type: integer
                        example: 1
                        default: 0
                      monthly_billing_day:
                        type: integer
                        nullable: true
                        description: >-
                          在 MONTH 频率的订阅上，计费所锚定的每月日期。由
                          RESTART（在更新、计划变更、恢复或重新激活时）设置，或通过发送更新订阅自己的
                          frequency.monthly_billing_day
                          设置。只有在写入之后才会出现；在此之前以及在所有其他频率类型上，该字段不存在（而不是 null）。
                        example: 15
                  billing_cycles:
                    type: object
                    properties:
                      total:
                        type: integer
                        example: 10
                        default: 0
                        nullable: true
                      current:
                        type: integer
                        example: 2
                        default: 0
                      next_at:
                        type: string
                        example: '2023-02-16T20:00:00.786342Z'
                      scheduling_date:
                        type: string
                        description: >-
                          扣款指令交给 Pix 通道的时间，即 `next_at` 减去四天。仅出现在由 Yuno 执行的
                          `PIX_AUTOMATIC` 订阅上，并且仅在该组织启用了四天预约提前期时出现；否则该字段不存在（而不是
                          `null`）。只读。请参阅 [Pix
                          Automático](/zh-hans/docs/payment-features/subscriptions/pix-automatico#the-scheduling-date)。
                        example: '2026-11-27T00:00:00Z'
                      paid:
                        type: integer
                        description: 到目前为止已支付的周期数。与 `current` 不同，`current` 是正在计费的周期。
                  customer_payer:
                    type: object
                    properties:
                      id:
                        type: string
                        example: 3t04911d-5df9-429e-8488-ad41abea1a2c
                  payment_method:
                    type: object
                    properties:
                      type:
                        type: string
                        example: CARD
                      token:
                        type: string
                        example: 9104911d-5df9-429e-8488-ad41abea1a4b
                      vaulted_token:
                        type: string
                        example: 6104911d-5df9-429e-8488-ad41abea1a4b
                      card:
                        type: object
                        properties:
                          verify:
                            type: boolean
                            example: false
                            default: true
                          card_data:
                            type: object
                            properties:
                              number:
                                type: string
                                example: '4507990000000010'
                              expiration_month:
                                type: integer
                                example: 10
                                default: 0
                              expiration_year:
                                type: integer
                                example: 2025
                                default: 0
                              security_code:
                                type: integer
                                example: 123
                                default: 0
                              holder_name:
                                type: string
                                example: JOHN DOE
                          installments:
                            type: integer
                            nullable: true
                          network_transaction_id:
                            type: string
                            nullable: true
                          usage:
                            type: string
                            example: FIRST
                        nullable: true
                    description: 订阅扣款所使用的支付方式。是单个对象，而不是列表。
                  availability:
                    type: object
                    properties:
                      start_at:
                        type: string
                        example: '2024-01-16T00:00:00.786342Z'
                      finish_at:
                        type: string
                        example: '2024-05-26T20:00:00.786342Z'
                        nullable: true
                  metadata:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                          example: sub_ext_id
                        value:
                          type: string
                          example: AA001
                    nullable: true
                  payments:
                    type: array
                    items:
                      type: string
                      example: 5104911d-5df9-229e-8468-bd41abea1a4s
                    description: 由该订阅创建的支付 ID 列表。当订阅没有支付时，响应中会省略该字段。
                  retries:
                    type: object
                    properties:
                      retry_on_decline:
                        type: boolean
                      amount:
                        type: integer
                      strategy:
                        type: string
                      stopped:
                        type: boolean
                        description: 仅当订阅处于 PAST_DUE 状态或有待处理的 cancel_scheduled 时出现。
                      attempts_made:
                        type: integer
                        description: 仅当订阅处于 PAST_DUE 状态或有待处理的 cancel_scheduled 时出现。
                      outcome:
                        type: string
                        description: >-
                          RECOVERED、EXHAUSTED 或 ABANDONED。仅当订阅处于 PAST_DUE
                          状态或有待处理的 cancel_scheduled 时出现。
                      next_retry_at:
                        type: string
                        description: 仅当订阅处于 PAST_DUE 状态或有待处理的 cancel_scheduled 时出现。
                      schedule:
                        type: array
                        nullable: true
                        description: >-
                          每次尝试的计划，仅当 `strategy` 为 `CUSTOM_SCHEDULE` 时设置；否则为
                          `null`。
                        items:
                          type: object
                      stop_on_hard_decline:
                        type: boolean
                        nullable: true
                        description: 为 true 时，硬拒绝会停止当前计费周期的重试。
                      cancel_on_exhausted_retries:
                        type: boolean
                        nullable: true
                        description: >-
                          为 true 时，一个周期的重试结束后仍没有支付成功，订阅就会被取消，同时
                          `cancellation_source` 设置为 `RETRIES_EXHAUSTED`。
                      profile:
                        type: string
                        description: >-
                          订阅遵循的固定重试阶梯，用来替代可配置的计划。始终为
                          `PIX_AUTOMATIC`。该字段和下面三个字段仅出现在由 Yuno 执行的
                          `PIX_AUTOMATIC` 订阅上；在所有其他支付方式上，它们不存在（而不是 `null`）。请参阅
                          [Pix
                          Automático](/zh-hans/docs/payment-features/subscriptions/pix-automatico#the-retry-ladder)。
                        example: PIX_AUTOMATIC
                      max_attempts:
                        type: integer
                        description: Pix 阶梯执行的重试次数。始终为 3，与这些订阅所报告的 `amount` 一致。
                        example: 3
                      min_gap_hours:
                        type: integer
                        description: >-
                          始终为
                          24，即阶梯各扣款日期（`D`、`D+1`、`D+2`、`D+3`）之间的间隔，而不是各发出尝试之间的间隔。
                        example: 24
                      until:
                        type: string
                        description: >-
                          阶梯停止的时间，即 `billing_cycles.next_at` 加 7 天。每次续订时随
                          `next_at` 一起变动。
                  unpaid_cycle:
                    type: object
                    description: 仅当当前计费周期处于 PAST_DUE 状态且尚未结清时出现。
                    properties:
                      cycle_number:
                        type: integer
                      amount:
                        type: object
                        properties:
                          currency:
                            type: string
                          value:
                            type: number
                      attempts:
                        type: integer
                      last_failure_code:
                        type: string
                  cancel_scheduled:
                    type:
                      - object
                      - 'null'
                    description: 没有待处理的取消时为 null。
                    properties:
                      mode:
                        type: string
                        example: AFTER_CYCLES
                      after_cycles:
                        type: integer
                        example: 3
                      at:
                        type: string
                      requested_at:
                        type: string
                      past_due_behavior:
                        type: string
                        example: EXHAUST_RETRIES
                  refund:
                    type:
                      - object
                      - 'null'
                    description: 当 refund 为 NONE 或被省略时为 null。出现在取消响应中，计算完成后的每次后续读取中也会出现。
                    properties:
                      mode:
                        type: string
                        example: PRORATED
                      amount:
                        type: object
                        properties:
                          currency:
                            type: string
                            example: USD
                          value:
                            type: number
                            example: 20
                      unused_days:
                        type: integer
                        example: 20
                      period_days:
                        type: integer
                        example: 30
                      basis:
                        type: object
                        properties:
                          billing_cycle:
                            type: integer
                            example: 4
                          charged_amount:
                            type: object
                            properties:
                              currency:
                                type: string
                                example: USD
                              value:
                                type: number
                                example: 30
                          payment_id:
                            type: string
                            description: 对于没有已捕获支付的 $0 阶段报价，为 null。
                          charged_at:
                            type: string
                            description: 对于没有已捕获支付的 $0 阶段报价，为 null。
                      execution:
                        type: string
                        example: MERCHANT
                      quoted_at:
                        type: string
                  created_at:
                    type: string
                    example: '2023-12-16T20:46:54.786342Z'
                  updated_at:
                    type: string
                    example: '2023-12-16T21:00:54.786342Z'
                  country:
                    type: string
                    description: 订阅所在国家/地区（ISO 3166-1 alpha-2）。
                    example: US
                  soft_descriptor:
                    type: string
                    description: 账单描述符。
                    example: ACME SUBSCRIPTION
                    nullable: true
                  current_period_start:
                    type: string
                    nullable: true
                    description: >-
                      订阅当前所处计费周期的开始时间，比 `current_period_end`
                      早一个计费间隔。在试用期或任何其他计划阶段内，它遵循该阶段的计费间隔。处于终态的订阅（`CANCELED` 或
                      `COMPLETED`）保留其最后的时间窗口，而不会变为 null。仅对没有周期性计费间隔的订阅为 Null。始终与
                      current_period_end 一起返回。
                    example: '2023-01-16T20:00:00.912480Z'
                  current_period_end:
                    type: string
                    nullable: true
                    description: >-
                      订阅当前所处计费周期的结束时间。等于 billing_cycles.next_at。始终与
                      current_period_start 一起返回。
                    example: '2023-02-16T20:00:00.786342Z'
                  billing_date:
                    type: object
                    nullable: true
                    description: 仅出现在按固定日期（而不是按频率）计费的订阅上；与 `frequency` 互斥。
                    properties:
                      type:
                        type: string
                        example: DAY
                      day:
                        type: integer
                        example: 2
                  trial_period:
                    type: object
                    description: 试用期。
                    properties:
                      billing_cycles:
                        type: integer
                        example: 1
                        default: 0
                      amount:
                        type: object
                        properties:
                          value:
                            type: number
                            example: 0
                            default: 0
                          currency:
                            type: string
                            example: USD
                  additional_data:
                    type: object
                    nullable: true
                    description: >-
                      创建时发送的可选订单补充数据，原样回显。完整结构请参阅[订阅对象](/zh-hans/reference/subscriptions/the-subscription-object)。
                  initial_payment_validation:
                    type: boolean
                    description: 订阅是否等待首次支付成功后才激活。默认为 `false`。
                    example: false
                  reason:
                    type: string
                    nullable: true
                    description: 订阅当前状态的自由格式原因（如果有记录）；否则为 `null`。
                    example: merchant request
                  renewal_notification_days:
                    type: integer
                    nullable: true
                    description: >-
                      在下一个计费日期之前多少天发送 `subscription.close_to_renewal`
                      webhook。`null` 表示不发送续订通知。
                    example: 3
                  subscription_agreement_id:
                    type: string
                    description: 订阅协议 ID。
                    example: sa_6af2dfcd-44c0-4f16-a331-8bed3ed9c9fa
                    nullable: true
                  cancellation_time:
                    type: string
                    nullable: true
                    description: 订阅被取消的时间。仅在订阅达到 `CANCELED` 后设置；否则为 `null`。
                    example: '2023-12-16T20:46:54.786342Z'
                  cancellation_source:
                    type: string
                    nullable: true
                    description: >-
                      触发取消的原因：`MERCHANT`、`SYSTEM`、`PLAN_CHANGE` 或
                      `RETRIES_EXHAUSTED`。仅在订阅达到 `CANCELED` 后设置；否则为
                      `null`。请将其视为开放式字段，并妥善处理无法识别的值。
                    example: MERCHANT
                  ending_time:
                    type: string
                    nullable: true
                    description: 订阅完成或过期的时间。仅在订阅达到 `COMPLETED` 后设置；否则为 `null`。
                    example: '2024-12-16T20:46:54.786342Z'
                  plan_id:
                    type: string
                    description: 仅当订阅关联了计划时出现。
                    example: 00000000-0000-4000-8000-000000000001
                  plan_assigned_at:
                    type: string
                    description: 仅出现在关联了计划的订阅上。计划被附加的时间，即从计划创建订阅时、迁移到计划时或计划变更时。
                    example: '2023-12-16T20:46:54.786342Z'
                  previous_subscription_id:
                    type: string
                    description: 仅当该订阅由计划变更（将现有订阅切换到另一个计划）创建时出现。
                    nullable: true
                  phases:
                    type: array
                    description: >-
                      所关联计划的阶段定义，与计划声明的一致，包括终止的 `REGULAR`
                      阶段。仅出现在其计划包含阶段的、关联了计划的订阅上。这是计划自己的阶梯，而不是该订阅者的快照：要查看创建时为该订阅固定下来的内容，请使用
                      `billing_phases`。
                    items:
                      type: object
                      properties:
                        order:
                          type: integer
                        name:
                          type: string
                        type:
                          type: string
                          description: '`TRIAL` 或 `REGULAR`。'
                        duration:
                          type: object
                          nullable: true
                          description: 阶段持续多长时间。在终止的 `REGULAR` 阶段上为 `null`，该阶段一直持续到订阅结束。
                          properties:
                            type:
                              type: string
                            value:
                              type: integer
                        frequency:
                          type: object
                          nullable: true
                          description: 阶段的计费频率。在终止的 `REGULAR` 阶段上为 `null`，该阶段按计划自身的频率计费。
                          properties:
                            type:
                              type: string
                            value:
                              type: integer
                        amount:
                          type: object
                          nullable: true
                          description: 阶段价格。在终止的 `REGULAR` 阶段上为 `null`，其价格在每次计费时由计划确定。
                          properties:
                            currency:
                              type: string
                            value:
                              type: number
                        total_payments:
                          type: integer
                          nullable: true
                        country_prices:
                          type: array
                          description: 按国家/地区覆盖的阶段价格，阶段没有覆盖时为空。
                          items:
                            type: object
                            properties:
                              country:
                                type: string
                              amount:
                                type: object
                                properties:
                                  currency:
                                    type: string
                                  value:
                                    type: number
                  current_phase:
                    type: string
                    description: 仅出现在关联了计划的订阅上。
                    example: REGULAR
                  current_phase_end:
                    type: string
                    nullable: true
                    description: >-
                      由 `current_phase`
                      指定的阶段移交给下一个阶段的时间，对于处于试用期的订阅，即切换到常规价格的时间。它是该阶段所涵盖的最后一个计费周期的结束时间，因此在试用期的最后一个周期，它等于
                      `current_period_end`。对于没有计划的订阅以及已离开阶段阶梯的订阅，为 Null。
                    example: '2023-03-16T20:00:00.786342Z'
                  billing_phases:
                    type: array
                    description: >-
                      仅出现在其计划包含阶段的、关联了计划的订阅上。只包含前面的 TRIAL 阶段，在创建时生成快照；终止的
                      REGULAR 阶段从不包含在内，因为它的价格没有被固定，而是在每次计费时由计划确定。`current_phase:
                      "REGULAR"` 表示阶梯已经用完。
                    items:
                      type: object
                      properties:
                        order:
                          type: integer
                        type:
                          type: string
                          description: 始终为 TRIAL，终止的 REGULAR 阶段从不出现在该数组中。
                        name:
                          type: string
                        amount:
                          type: object
                          properties:
                            currency:
                              type: string
                            value:
                              type: number
                        frequency:
                          type: object
                          properties:
                            type:
                              type: string
                            value:
                              type: integer
                        start_cycle:
                          type: integer
                        end_cycle:
                          type: integer
                  pending_plan_change:
                    type: object
                    nullable: true
                    description: >-
                      计划在下一个计费周期生效的变更，没有待处理的变更时为 null。使用更新订阅上的 `plan_change`
                      块可以预定一个变更。
                    properties:
                      plan_id:
                        type: string
                        description: 目标计划的标识符。
                        example: 1904911d-5df9-429e-8488-ad41abea1a4d
                      plan_name:
                        type: string
                        description: 目标计划的名称。
                        example: Pro
                      direction:
                        type: string
                        enum:
                          - UPGRADE
                          - DOWNGRADE
                        description: 目标计划是升级还是降级。仅供参考。
                        example: UPGRADE
                      effective:
                        type: string
                        enum:
                          - NEXT_BILLING_CYCLE
                        description: 变更生效的时间。
                        example: NEXT_BILLING_CYCLE
                      phases_behavior:
                        type: string
                        enum:
                          - START_FROM_REGULAR
                          - HONOR_PHASES
                        description: 目标计划包含阶段时会发生什么。
                        example: START_FROM_REGULAR
                      applies_at:
                        type: string
                        description: 变更将在其上生效的计费事件，即订阅的下一个计费日期。
                        example: '2023-02-16T20:00:00.786342Z'
                      requested_at:
                        type: string
                        description: 变更被预定的时间。
                        example: '2023-01-20T10:12:31.786342Z'
                  refund_rule:
                    type: object
                    description: >-
                      已存储的退款规则，当取消请求没有自带 refund_amount 时，用它来确定 CUSTOM
                      取消的退款。仅在配置了规则时出现；否则该字段被省略（而不是 null）。适用于已启用该功能的组织；请联系 Yuno。
                    properties:
                      type:
                        type: string
                        enum:
                          - PERCENT
                          - FIXED
                        description: PERCENT 将退款确定为已扣款金额的百分比；FIXED 将其确定为固定金额。
                        example: FIXED
                      percent:
                        type: number
                        description: 当 type 为 PERCENT 时必填，且仅在此时允许（0-100）。
                        example: 50
                      amount:
                        type: object
                        description: 当 type 为 FIXED 时必填，且仅在此时允许。
                        properties:
                          value:
                            type: number
                            example: 10000
                          currency:
                            type: string
                            description: 必须与订阅自身的币种一致。
                            example: COP
                  pause_until:
                    type: string
                    description: >-
                      订阅预定自动恢复的时间。仅出现在当前带有时长（暂停时发送了 pause_cycles 或
                      pause_until）而处于暂停状态的订阅上；在所有其他读取中，该字段不存在（而不是 null）。
                    example: '2026-10-15T15:54:22.780166Z'
        '400':
          description: '400'
          content:
            application/json:
              examples:
                INVALID_STATE:
                  value:
                    code: INVALID_STATE
                    messages:
                      - >-
                        The subscription state does not support the action
                        requested.
                UNKNOWN KEY:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - 'unknown field: reason'
                SCHEDULE MUST CARRY EXACTLY ONE OF at OR after_cycles:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - schedule must carry exactly one of at or after_cycles
                at NOT IN THE FUTURE:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - schedule.at must be in the future
                ORGANIZATION NOT ENABLED:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - >-
                        Scheduled cancellation is not enabled for this
                        organization.
                REFUND NOT COMBINABLE WITH SCHEDULE:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - refund cannot be combined with schedule (v1)
                REFUND QUOTING NOT ENABLED FOR THIS ORGANIZATION:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - Refund quote is not enabled for this organization.
                REFUND_AMOUNT EXCEEDS THE CHARGED AMOUNT:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - refund_amount must not exceed the charged amount
                REFUND_AMOUNT CURRENCY MISMATCH:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - >-
                        refund_amount.currency must match the subscription's
                        currency (USD)
                PRORATED NOT AVAILABLE ON A SUB-DAILY CADENCE:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - proration is not available for sub-daily cadences
                REFUND NOT AVAILABLE:
                  value:
                    code: REFUND_NOT_AVAILABLE
                    messages:
                      - >-
                        No charged payment exists for the current cycle
                        (subscription is PAST_DUE). Only refund: NONE is valid.
                    current_status: PAST_DUE
                SUBSCRIPTION NOT FOUND:
                  value:
                    code: SUBSCRIPTION_NOT_FOUND
                    messages:
                      - Subscription not found.
                  summary: >-
                    No subscription resolves for the subscription_id on this
                    account. Returned as 400, not 404.
                REFUND CUSTOM REQUIRES A SOURCE:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - >-
                        refund: CUSTOM requires refund_amount or a configured
                        refund_rule.
                  summary: >-
                    Neither refund_amount on the request nor a stored
                    refund_rule resolves the CUSTOM refund.
      deprecated: false
components:
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: public-api-key
      x-default: <Your public-api-key>
    sec1:
      type: apiKey
      in: header
      name: private-secret-key
      x-default: <Your private-secret-key>

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.