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

# 定期支付

> 使用 Yuno SDK 设置 Google Pay 订阅：先进行一笔客户发起的交易，将令牌存入 vault，然后基于存入 vault 的令牌进行商户发起的扣款。

Google Pay 定期支付遵循与卡相同的两个步骤：先进行一笔客户发起的交易（CIT），将支付工具存入 vault，然后基于由此得到的 `vaulted_token` 进行商户发起的交易（MIT）。完整的 `reason` 和 `usage` 对照表请参阅[存储凭证](https://docs.y.uno/zh-hans/docs/payment-features/stored-credentials.md#wallet-originated-tokens-apple-pay-and-google-pay)。

## 客户发起的交易（CIT）

在 CIT 中，请发送 `vault_on_success: true`，并将 `stored_credentials` 放在 `detail.wallet` 下，因为此时支付方式仍然是钱包：

```json theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "account_id": "your-account-id",
  "description": "Google Pay recurring setup",
  "merchant_order_id": "order-123",
  "country": "US",
  "amount": {
    "currency": "USD",
    "value": 5000
  },
  "checkout": {
    "session": "checkout-session-id"
  },
  "customer_payer": {
    "id": "customer-uuid",
    "email": "customer@example.com"
  },
  "payment_method": {
    "type": "GOOGLE_PAY",
    "token": "one-time-token-from-the-sdk",
    "vault_on_success": true,
    "detail": {
      "wallet": {
        "stored_credentials": {
          "reason": "SUBSCRIPTION",
          "usage": "FIRST"
        }
      }
    }
  },
  "workflow": "SDK_CHECKOUT"
}
```

CIT 的关键参数如下：

* **`vault_on_success: true`**：将解密后的卡存入 vault，作为一条 `CARD` 记录（带有 `parent_payment_method_type: GOOGLE_PAY`），并在支付响应中返回其 `vaulted_token`。`customer_payer.id` 必须引用一个已存在的客户（请先使用[创建客户](https://docs.y.uno/reference/customers/create-customer.md)创建）。缺少该参数时，支付仍会成功，但不会存入任何内容：响应会带有空的 `vaulted_token`，且不会返回错误。
* **`detail.wallet.stored_credentials.usage: "FIRST"`**：表示这是定期系列中的第一笔交易。Yuno 会将服务提供商返回的 `network_transaction_id` 存储在已保存的记录中。

> [!WARNING]
>
> 不要在 CIT 中将 `stored_credentials` 放在 `detail.card` 下。对于钱包支付，该字段不会被验证，且可能被丢弃，这会导致已保存的记录没有存储凭证标志，也没有 `network_transaction_id`。

> [!NOTE]
>
> `vaulted_token` 仅在 CIT 支付响应中返回。通过钱包存入 vault 的支付工具有意不包含在[检索已注册的支付方式](https://docs.y.uno/reference/payment-methods-direct-workflow/retrieve-enrolled-payment-methods-api.md)中，因此请在 CIT 成功时在您这一侧存储该令牌。

## 商户发起的交易（MIT）

后续扣款将 `vaulted_token` 作为已存储的卡使用。不需要 Google Pay 令牌，也不需要结账会话：

```json theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "account_id": "your-account-id",
  "description": "Google Pay recurring payment",
  "merchant_order_id": "order-124",
  "country": "US",
  "amount": {
    "currency": "USD",
    "value": 5000
  },
  "customer_payer": {
    "id": "customer-uuid"
  },
  "payment_method": {
    "type": "CARD",
    "vaulted_token": "vaulted-token-from-the-cit-response",
    "detail": {
      "card": {
        "stored_credentials": {
          "reason": "SUBSCRIPTION",
          "usage": "USED"
        }
      }
    }
  },
  "workflow": "DIRECT"
}
```

MIT 的关键参数如下：

* **`vaulted_token`**：CIT 响应中返回的令牌。
* **`detail.card.stored_credentials.usage: "USED"`**：表示这是该系列中的后续交易。Yuno 会自动附加来自 CIT 的 `network_transaction_id`。

## 相关文档

* [设置和一次性支付](https://docs.y.uno/zh-hans/docs/wallets/google-pay/google-pay-sdk-integration.md)
* [存储凭证](https://docs.y.uno/zh-hans/docs/payment-features/stored-credentials.md)


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