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

# 二维码与即时支付

> 将 Pix 二维码支付与订阅注册相结合，实现自动定期扣款

在**二维码与即时支付**流程中，Yuno 会展示一个二维码，只需一个无缝步骤，即可立即向客户收款，并为其注册所有后续定期支付。客户扫描二维码后，其银行应用会处理第一期款项，同时获取客户对后续自动扣款的同意，无需任何额外批准或手动输入。

完成首次扫码和支付后，每个**后续请求**都由商户通过 Yuno 发送，并由客户的银行根据原始同意自动验证，确保转账快速可靠，且无需客户再次参与。该流程将注册和支付合并为一次用户操作，从而简化订阅管理。

## 第 1 步：首次支付与创建订阅

要启动该流程，您必须先发起一笔标准的 [Pix 支付](https://docs.y.uno/zh-hans/reference/payments/create-payment.md#/)，同时设置订阅。这会生成一个二维码或重定向页面，供客户授权该定期扣款。支付完成后，订阅即被创建，并返回 `subscription_code`。

您可以在订阅 payload 中定义频率、可用时间范围以及金额类型（固定或可变）。

| 订阅字段 | 描述 |
| :- | :- |
| 频率 | 定义订阅扣款的发生频率（每周、每月、每季度、每半年或每年），并指定下一个账单周期需要收取的金额。 |
| 可用时间 | 订阅的开始日期和结束日期。 |
| 金额 | 定义订阅后续支付所使用的金额。可以是设定了最低金额的 `FIXED`，也可以是未为后续支付设定金额的 `VARIABLE`。 |

请注意，创建订阅时定义的信息会限制后续支付可使用的日期和金额。

```json Example theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "amount": {
    "value": "100",
    "currency": "BRL"
  },
	"payment_method": {
        "type": "PIX_AUTOMATIC"
	},
	"subscription": {
    "frequency": {
      "type": "MONTH",
      "value": 1
    },
    "availability": {
      "start_at": "2025-05-23T20:17:30.277678Z",
      "finish_at": "2027-05-23T20:17:30.277678Z"
    },
    "amount": {
      "value": "100",
      "currency": "BRL",
      "type": "FIXED"
    }
  }
}
```

首次支付确认后，客户即拥有一个有效订阅，您可以开始安排后续扣款。

## 第 2 步：后续支付

根据中央银行的规定，支付必须在**计划账单日期前 10 至 2 天的时间窗口内**创建。在[创建支付](https://docs.y.uno/zh-hans/reference/payments/create-payment.md#/)时，使用 `subscription.id` 标识该定期扣款。

| 后续支付字段 | |
| :- | :- |
| `subscription.id` | 在第一步中获得的订阅 ID（在该步骤中以 `subscription_code` 返回）。 |
| `billing_date` | 通过指定 `billing_date` 对象，商户可以定义订阅确切账单日期的计算逻辑。 |

```json Example theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
"workflow": "DIRECT",
"amount": {
  "value": "100",
  "currency": "BRL"
},
"payment_method": {
  "type": "PIX_AUTOMATIC",
},
"subscription": {
  "id": "cab9f0fe-2428-419b-8f9d-4b5efee8c1c8",
  "billing_date": {
    "type": "DAY",
    "day": 14
  }
}
```

如果定期支付失败，可以通过新的支付请求进行重试。**重试**必须在原始账单日期后的 **7 天内**进行，且每个周期**最多 3 次尝试**。


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