> ## 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.

# 列出订阅支付

> 返回订阅的收费历史记录，适用时包含计划/阶段上下文。

> [!NOTE]
>
> **这是一个全新的 endpoint**
>
> 在 Plans 推出之前，没有支付子资源，[订阅对象](https://docs.y.uno/zh-hans/reference/subscriptions/the-subscription-object.md) 上的 `payments` 数组是一个旧版字段，始终为空。由于这里没有需要保留的既有商户集成，此 endpoint 以统一、简洁的 `data[]` 结构发布，并带有完整的计划/阶段上下文，不含任何旧版字段。

> [!NOTE]
>
> **收费上的折扣**
>
> 每一项都将 `amount` 保留为该次收费的全额价格。带有促销的收费还包含 `discount_amount` 和 `net_amount`。`net_amount` 等于 `amount` 减去 `discount_amount`：即客户为该次收费实际支付的金额。对于 100% 折扣的周期，该值为 `0`。没有促销的收费不包含这两个字段。请参阅 [订阅计划促销](https://docs.y.uno/zh-hans/docs/payment-features/subscriptions/promotions.md)。

> [!WARNING]
>
> **`offset` 必须是 `limit` 的倍数**
>
> 未对齐的 `offset` 会重复返回您已经看过的行并导致 `has_more` 出错，因此会被拒绝并返回 `400 BAD_REQUEST`，而不会被静默向下取整。

> [!WARNING]
>
> **免费周期表现为 `total: 0`，而非单独的状态**
>
> \$0 的计费周期（例如免费试用的支付）可以通过 `total == 0` 识别，没有单独的“免费”状态。


## OpenAPI

````yaml openapi/zh-hans/subscriptions/list-subscription-payments.json GET /subscriptions/{subscription_id}/payments
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}/payments:
    get:
      summary: 列出订阅支付
      description: >-
        返回订阅的扣款历史，每次计费尝试一行，当订阅关联了计划时还包括计划/阶段上下文。这是一个全新的
        endpoint（在计划功能之前没有支付子资源），因此它以单一、干净的结构发布，没有需要沿用的旧版字段。
      operationId: list-subscription-payments
      parameters:
        - name: subscription_id
          in: path
          description: 订阅的唯一标识符。
          schema:
            type: string
          required: true
        - name: limit
          in: query
          description: 返回的最大条目数。1-100，默认为 20。
          schema:
            type: integer
            default: 20
            minimum: 1
            maximum: 100
        - name: offset
          in: query
          description: >-
            要跳过的条目数。必须是 `limit` 的非负整数倍，否则返回 `400
            BAD_REQUEST`：未对齐的偏移量会重复返回您已经看到的行，并破坏 `has_more`。默认为 0。
          schema:
            type: integer
            default: 0
            minimum: 0
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Result:
                  value:
                    data:
                      - id: 00000000-0000-4000-8000-000000000010
                        payment_id: 00000000-0000-4000-8000-000000000011
                        idempotency_key: null
                        status: SUCCEEDED
                        sub_status: null
                        provider: PROVIDER_TEST
                        payment_method:
                          id: 00000000-0000-4000-8000-000000000012
                          type: CARD
                        amount:
                          currency: USD
                          value: 9.99
                        currency: USD
                        subtotal: 9.99
                        total: 9.99
                        plan_id: 00000000-0000-4000-8000-000000000001
                        line_items:
                          - type: PLAN
                            label: Intro
                            service_period:
                              start: '2024-04-01T09:00:00Z'
                              end: '2024-05-01T09:00:00Z'
                            amount:
                              currency: USD
                              value: 9.99
                        phase:
                          index: 1
                          name: Intro
                          type: TRIAL
                        phase_payment: 1
                        billing_cycle: null
                        retry:
                          count: 0
                          forced: false
                        trace_id: null
                        created_at: '2024-04-01T09:00:00.000000Z'
                        updated_at: '2024-04-01T09:00:00.000000Z'
                    pagination:
                      total: 1
                      limit: 20
                      offset: 0
                      has_more: false
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: 此订阅的每一次支付尝试，最新的在前。
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        payment_id:
                          type: string
                        idempotency_key:
                          type: string
                          nullable: true
                        status:
                          type: string
                          description: >-
                            平台词汇：SUCCEEDED、DECLINED、REJECTED、ERROR、PENDING、CREATED、CANCELED，而不是引擎内部的
                            EXECUTED。
                        sub_status:
                          type: string
                          nullable: true
                        provider:
                          type: string
                          description: 对于 $0 周期、起始行，以及在服务提供商捕获字段出现之前扣款的行，为 null。
                        payment_method:
                          type: object
                          properties:
                            id:
                              type: string
                            type:
                              type: string
                        amount:
                          type: object
                          properties:
                            currency:
                              type: string
                            value:
                              type: number
                        currency:
                          type: string
                        discount_amount:
                          type: number
                          description: 应用于此次扣款的折扣，按币种的小数位数表示。仅当该扣款有促销时出现。
                        net_amount:
                          type: number
                          description: >-
                            `amount` 减去 `discount_amount`：客户为此次扣款实际支付的金额。对于 100%
                            折扣的周期为 `0`。仅当该扣款有促销时出现。
                        subtotal:
                          type: number
                        total:
                          type: number
                        plan_id:
                          type: string
                          description: 对于原始（非计划）订阅，为 null。
                        line_items:
                          type: array
                          items:
                            type: object
                            properties:
                              type:
                                type: string
                              label:
                                type: string
                              service_period:
                                type: object
                                properties:
                                  start:
                                    type: string
                                  end:
                                    type: string
                              amount:
                                type: object
                                properties:
                                  currency:
                                    type: string
                                  value:
                                    type: number
                        phase:
                          type: object
                          description: 对于起始行和旧版（非计划）行，为 null。
                          properties:
                            index:
                              type: integer
                            name:
                              type: string
                            type:
                              type: string
                        phase_payment:
                          type: integer
                          description: 当前阶段内的 1..N。起始行上为 null。
                        billing_cycle:
                          type: integer
                          nullable: true
                          description: 0 = 起始行，null = TRIAL 阶段的行，从第一次 REGULAR 阶段的支付起为 1..。
                        retry:
                          type: object
                          properties:
                            count:
                              type: integer
                            forced:
                              type: boolean
                        trace_id:
                          type: string
                          nullable: true
                        created_at:
                          type: string
                        updated_at:
                          type: string
                  pagination:
                    type: object
                    properties:
                      total:
                        type: integer
                      limit:
                        type: integer
                      offset:
                        type: integer
                      has_more:
                        type: boolean
        '400':
          description: 请求错误。该订阅在此账户中不存在。
          content:
            application/json:
              examples:
                Not Found:
                  value:
                    code: SUBSCRIPTION_NOT_FOUND
                    messages:
                      - Subscription not found.
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: SUBSCRIPTION_NOT_FOUND
                  messages:
                    type: array
                    items:
                      type: string
                      example: Subscription not found.
      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.