> ## 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：创建结账会话，由 SDK 显示按钮和支付表单，并处理一次性支付。

本指南介绍如何使用 SDK 将 Google Pay™ 与 Yuno 集成。采用此方式时，Yuno 的 SDK 管理完整的 Google Pay 体验：显示 Google Pay 按钮、展示支付表单并处理支付令牌。您无需直接与 Google Pay API 集成。

> [!NOTE]
>
> 在实施之前，请查看 [Google Pay 要求](https://docs.y.uno/zh-hans/docs/wallets/google-pay#requirements)，并确保 Google Pay 在您的运营国家/地区可用。

## 集成流程

1. 在 Yuno 中创建结账会话。
2. 在您的应用（Web、Android 或 iOS）中初始化 Yuno 的 SDK。
3. SDK 显示 Google Pay 按钮并处理支付表单。
4. 客户通过 Google Pay 授权支付。
5. Yuno 接收支付令牌，并通过您配置的服务提供商处理交易。
6. 通过 [webhooks](https://docs.y.uno/zh-hans/docs/webhooks.md) 监控支付状态。

## 要求

* 拥有 API 凭证的 Yuno 账户（[Dashboard](https://dashboard.y.uno/)）
* 在 Yuno Dashboard 中配置的支持 Google Pay 的支付服务提供商连接
* 包含 Google Pay 支付方式的路由规则
* 在您的应用中集成的 Yuno SDK（[Web](https://docs.y.uno/docs/sdks/resources/references/web.md)、[Android](https://docs.y.uno/docs/sdks/resources/references/android.md) 或 [iOS](https://docs.y.uno/docs/sdks/resources/references/ios.md)）

## 集成步骤

### 第 1 步：创建结账会话

使用[创建结账会话](https://docs.y.uno/zh-hans/reference/checkout-sessions/create-checkout-session.md) endpoint 启动支付会话：

```json theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "country": "US",
  "customer_id": "customer-uuid",
  "merchant_order_id": "order-123",
  "payment_description": "Google Pay payment",
  "amount": {
    "currency": "USD",
    "value": 5000
  }
}
```

响应会返回一个 `checkout_session` ID，用于初始化 SDK。

### 第 2 步：初始化 SDK

使用结账会话初始化 Yuno 的 SDK。SDK 会根据您的 Dashboard 配置，自动检测可用的支付方式，包括 Google Pay。

请参阅您所用平台的 SDK 文档：

* [Web SDK 集成](https://docs.y.uno/docs/sdks/full-checkout/web-payments)
* [Android SDK 集成](https://docs.y.uno/docs/sdks/full-checkout/android-payments)
* [iOS SDK 集成](https://docs.y.uno/docs/sdks/full-checkout/ios-payments)

### 第 3 步：客户完成支付

其余工作由 SDK 处理。当客户选择 Google Pay 时：

1. Google Pay 支付表单出现，显示客户已保存的卡。
2. 客户选择一张卡并授权支付。
3. SDK 将加密的支付令牌发送给 Yuno。
4. Yuno 通过您配置的服务提供商处理支付。

### 第 4 步：处理响应

SDK 返回支付结果。您也可以通过 [webhooks](https://docs.y.uno/zh-hans/docs/webhooks.md) 监控支付状态，以获得异步确认。

## 请求联系信息

您可以直接在 [Checkout Builder](https://docs.y.uno/zh-hans/docs/using-yuno/dashboard-overview/checkout-builder.md#required-fields) 中配置 Google Pay 支付表单向客户请求哪些字段。可用字段包括：

* Email
* 电话
* 持卡人姓名
* 账单地址
* 收货地址

当其中任一字段在 Checkout Builder 中被启用为必填字段时，Google Pay 支付表单会提示客户在完成支付前提供该信息。

> [!NOTE]
>
> 此项以前在连接层级配置。现在它统一在 Checkout Builder 的 Required Fields 下，与 Apple Pay 的方式相同。

> [!NOTE]
>
> 对于 Google Pay，持卡人姓名默认处于禁用状态；而对于卡，它默认处于启用状态。如果您的集成需要，请在 Checkout Builder 中启用它。

| 平台 | 最低版本 |
| - | - |
| Web | 1.8.0 |
| Android | 2.16.0 |

### Google Pay 无法提供的信息

某些服务提供商需要 Google Pay 表单无法返回的字段，例如证件号码（比如巴西的 CPF），或分开发送的名字和姓氏。Google Pay 只会在地址中以一个完整姓名的形式返回姓名。下表显示当您的账户启用钱包信息表单时，每个字段的来源：

| 在 Checkout Builder 中设为必填的字段 | 来源 |
| - | - |
| 持卡人姓名、email、电话、账单地址、收货地址 | Google Pay 表单 |
| 名字、姓氏 | Google Pay 表单打开前的简短表单 |
| 证件 | Google Pay 表单打开前的简短表单 |

当其中某个字段为必填，而您没有在结账会话的 `customer` 对象中发送它时，Web SDK 会照常显示 Google Pay 按钮。客户点击该按钮后，一个简短表单只会询问缺失的字段，其下方显示 Google Pay 按钮。该按钮会打开 Google Pay 表单，这些值会随支付一起发送。如果您已经发送了这些值，客户只需轻点一次即可支付，与以前相同。Yuno 绝不会替换您或钱包发送的值。

如果没有该表单，Google Pay 表单仍会提供持卡人姓名、email、电话和地址，但不会收集名字、姓氏和证件：请在创建结账会话时在 `customer` 中发送它们。

| 平台 | 可用性 |
| - | - |
| Web 1.11.61 及更高版本（Full checkout，包括托管支付链接） | 按账户启用。请联系您的 Yuno 客户经理。 |
| Yuno SDK for Web 2.9.0 及更高版本（[`paymentMethodList`](https://docs.y.uno/zh-hans/docs/yuno-sdk/features/payment-methods-list) 中的钱包按钮） | 默认开启。如需关闭，请让您的客户经理将 `wallet_missing_details_enabled` 设置为 `false`。 |
| iOS、Android | 不可用 |

## 使用 SDK 工作流创建支付

如果您在使用 SDK checkout 流程时需要直接调用支付 API，请将 `workflow` 设置为 `SDK_CHECKOUT` 并包含结账会话：

```json theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "account_id": "your-account-id",
  "description": "Google Pay via SDK",
  "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"
  },
  "workflow": "SDK_CHECKOUT"
}
```

> [!WARNING]
>
> 集成 Google Pay 等钱包时，即使使用 SDK 工作流，`payment_method.type` 字段也是必填的。请将其设置为 `GOOGLE_PAY`。

## 启用和测试 Google Pay

要在 sandbox 中测试 Google Pay：

1. 将 [Yuno 的 SDK](https://docs.y.uno/docs/sdks/full-checkout/android-payments) 集成到您的应用中。
2. 创建一个 Google 测试账户并登录 [Google Pay Business Console](https://pay.google.com/business/console)。
3. 在 Google Pay Business Console 中，前往 API 部分并选择 **Create a Pass** 以启用 **Demo mode**。

![](https://mintcdn.com/yuno-3979e326/MTlogjS0_SlxtlJG/images/reference/google-pay-sdk-integration/image1.png?fit=max\&auto=format\&n=MTlogjS0_SlxtlJG\&q=85\&s=90097bd7c2ba76e08eaa63d6f551bde6)

4. 在您的测试设备上下载 [Google Wallet App](https://play.google.com/store/apps/details?id=com.google.android.apps.walletnfcrel\&hl=en\&gl=US)。
5. 完整运行一遍支付流程，以验证集成是否正常工作。

## 上线

测试完成后，申请 [Google Production Access](https://developers.google.com/pay/api/web/guides/test-and-deploy/request-prod-access) 并联系您的技术客户经理。Yuno 团队会在上线前验证您的配置。

## 后续步骤

* [定期支付](https://docs.y.uno/zh-hans/docs/wallets/google-pay/sdk-integration/recurring-payments.md)。使用 vault 令牌进行的客户发起交易和商户发起交易。
* [快捷 checkout](https://docs.y.uno/zh-hans/docs/wallets/google-pay/sdk-integration/express-checkout.md)。Google Pay 表单上的订单明细、配送方式和收货地址更新（Android 和 Web）。

## 相关文档

* [Google Pay 概览](https://docs.y.uno/zh-hans/docs/wallets/google-pay)
* [Google Pay Direct 集成](https://docs.y.uno/zh-hans/docs/wallets/google-pay/google-pay-direct-integration.md)
* [通过服务提供商集成 Google Pay](https://docs.y.uno/zh-hans/docs/wallets/google-pay/integration-via-provider-google-pay.md)
* [Google Pay 与 PIX](https://docs.y.uno/zh-hans/docs/wallets/google-pay/google-pay-with-pix.md)


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