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

# Apple Pay 集成

> 比较四种 Apple Pay 集成方式，以及每种方式对运行环境、前端改造和 Token 处理的不同要求。

本页比较四种 Apple Pay 集成方式，以及每种方式对运行环境、前端改造和 Token 处理的不同要求。Waffo 支持通过托管收银台或 Merchant 自建 Apple Pay 前端完成支付。

## 选择集成方式

| 方式                            | 适用场景                                       | Merchant 侧要求                                                                                                  |
| ----------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
| 直接外跳 Waffo 收银台                | 网站、H5 或 App 可以跳转到独立支付页面                    | 创建订单后，使用 [`orderAction.webUrl`](/docs/api-reference/order-create/create-new-order#response-data) 在顶层页面打开 Waffo 收银台 |
| App WebView 加载 Waffo 收银台      | 希望用户留在 Merchant App 内完成支付                  | 创建订单时传 [`userTerminal=APP`](/docs/api-reference/order-create/create-new-order#body-user-info)，并允许 WebView 打开外部页面   |
| iframe 加载 Waffo Apple Pay 收银台 | 适用于网页和 H5；Merchant 希望将用户保留在当前页，不跳转到新页面     | 必须使用 Waffo 前端 SDK，并提前完成域名验证和报备                                                                                |
| Merchant 直接集成 Apple Pay       | Merchant 需要完全控制 Apple Pay 按钮、支付页和 Token 处理 | 自行完成 Apple Pay 前端、Merchant 账号、证书、域名验证、Token 解密和合规工作                                                           |

## 方式一：直接外跳 Waffo 收银台

调用 [`/api/v1/order/create`](/docs/api-reference/order-create/create-new-order) 创建订单，解析响应中的 [`orderAction`](/docs/api-reference/order-create/create-new-order#response-data)，然后在浏览器顶层页面打开 [`orderAction.webUrl`](/docs/api-reference/order-create/create-new-order#response-data)。

这种方式由 Waffo 收银台展示 Apple Pay。你不需要在 Merchant 页面内集成 Apple Pay JS，也不需要处理 Apple Pay Token。支付结果应以 Webhook 或 [`/api/v1/order/inquiry`](/docs/api-reference/order-inquiry/order-inquiry) 查询结果为准。

## 方式二：通过 App WebView 加载 Waffo 收银台

在 App 中使用 WebView 打开 [`orderAction.webUrl`](/docs/api-reference/order-create/create-new-order#response-data)。创建订单时传 [`userTerminal=APP`](/docs/api-reference/order-create/create-new-order#body-user-info)，以获取适合 App 端的跳转链接。

## 方式三：通过 iframe 加载 Waffo Apple Pay 收银台

<Warning>
  iframe 方式必须使用 Waffo 前端 SDK `@waffo/payment-sdk`，并在接入前联系 Waffo 技术支持完成 Apple Pay 域名验证和报备。不要直接用普通 `<iframe>` 加载 [`orderAction.webUrl`](/docs/api-reference/order-create/create-new-order#response-data)。
</Warning>

前端 SDK 负责在 Merchant 页面内渲染和管理收银台 iframe。接入时还需要满足收银台 iframe 的 `allow="payment"`、Referrer Policy 和自适应布局要求。参见 [前端 SDK 使用说明](/docs/zh/developer-docs/integration/elements/usage#嵌入式收银台-renderiframe)和 [iframe 嵌入注意事项](/docs/zh/developer-docs/integration/checkout/steps#iframe-嵌入注意事项)。

在域名验证和报备完成前，不要上线 iframe Apple Pay。否则 Apple Pay 按钮可能无法显示，或支付授权无法继续。

## 方式四：Merchant 直接集成 Apple Pay

完整的准备、解密和透传格式参见 [Merchant 直接集成 Apple Pay](/docs/zh/developer-docs/integration/apple-pay/merchant-direct-integration)。
