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

# Network Token Authentication

> 使用卡组织通行密钥对存储卡支付进行认证，提高批准率并将欺诈责任转移给发卡机构

Network Token Authentication（NTA）是 Yuno 的统一解决方案，通过 **Network Token Passkeys**（卡组织在其令牌化服务之上提供的、基于通行密钥的认证体验）对银行卡支付进行认证。它将各卡组织的通行密钥集成整合到单一 Yuno 产品下，无论底层卡组织是哪家，都能为商户提供一致的流程、配置入口和购物者体验。

NTA 的目的很简单：让商户无需集成特定卡组织的 SDK，即可将存储卡支付转变为经过认证、基于通行密钥的交易。Yuno 负责处理加密、重定向以及特定卡组织的底层对接，而商户通过路由规则控制支付何时进入通行密钥流程。

## 产品解决的问题

存储卡支付传统上依赖已存储的 PAN，最多再加上一次静态 CVC 重新输入。这通常会导致：

* **批准率低**：发卡机构将未经认证的存储卡交易视为较高风险。
* **摩擦大**：备用方案通常需要完整的 3DS 挑战。

Network Token Passkeys 可同时解决这两个问题。交易以带有密文（cryptogram）的网络令牌形式提交，购物者使用设备通行密钥（生物识别或一次性密码）向卡组织完成一次认证。由此产生的交易既经过令牌化又经过认证，并在适用时实现责任转移。

## 对商户的好处

* **更高的授权批准率**：经过通行密钥认证的交易带有强认证信号，会获得发卡机构的认可。
* **责任转移**：对于经过认证的交易，欺诈责任转移至发卡机构，降低拒付风险敞口。
* **SCA 合规**：满足强客户认证（SCA）要求，购物者体验比单独使用 3DS 更轻便。
* **更顺畅的重复购买体验**：通行密钥注册后，在同一设备上的后续购买将无摩擦且更快速。
* **减少因摩擦导致的流失**：通行密钥步骤由卡组织托管并针对移动端优化，可降低放弃率。
* **一次集成覆盖所有卡组织**：随着 Yuno 接入新的卡组织，商户会自动获得这些新的卡组织集成。
* **由商户通过路由控制**：使用标准 Yuno 路由规则，精确决定何时应用 NTA（例如按国家/地区、金额、支付方式、BIN）。

## 支持的卡品牌

| 卡品牌 | 通行密钥产品 | 状态 |
| - | - | - |
| Mastercard | Secure Card on File (SCOF) | 已支持 |

随着其他卡组织的通行密钥集成实现产品化，将陆续添加更多卡组织。面向商户的流程在各卡品牌之间保持一致。

## Yuno 中的工作原理

Network Token Authentication **按商户选择启用**，完全由路由配置驱动。支付创建调用无需任何更改；通行密钥流程会根据该笔交易的路由规则触发。

### 设置步骤

在触发通行密钥流程之前，请完成以下设置：

1. **接入 Network Tokens**：为您的账户启用 [Network Tokens](https://docs.y.uno/zh-hans/docs/security-and-compliance/network-tokens.md)。
2. **创建 Network Token Authentication 连接**：在 Yuno Dashboard 中，创建一个类型为 **Network Token Authentication** 的专用连接。
3. **加载 3DS 信息**：确保处理授权的支付服务提供商连接已加载其 3DS 凭证或配置。
4. **配置路由**：在路由配置中，将 NTA 连接设置为在支付服务提供商步骤**之前**运行的步骤。

### 运行时行为

1. 创建支付时，Yuno 会在将交易发送给收单机构**之前**评估路由规则。
2. 如果路由包含 Network Token Authentication 步骤，Yuno 会与相应卡组织触发通行密钥流程。
3. 否则，支付将按标准银行卡授权继续处理。

Yuno 负责路由评估、通行密钥触发、重定向处理以及返回认证结果。

## 集成

触发 NTA 时，Yuno 会将其作为标准的 `REDIRECT_URL` 继续操作（continue action）返回。这与基于重定向的 APM 所使用的模式一致，无需编写特定卡组织的 frontend 代码。

### 初始化 Yuno

```js theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const yuno = await Yuno.initialize(PUBLIC_API_KEY)
```

### 启动支付客户端

```js theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const apiClientPayment = await yuno.apiClientPayment({
  country_code: "US",
  checkout_session: "<CHECKOUT_SESSION>",
})
```

### 生成一次性令牌

```js theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const oneTimeToken = await apiClientPayment.generateToken({
  checkout_session: "<CHECKOUT_SESSION>",
  payment_method: {
    type: "CARD",
    vaulted_token: "<VAULTED_TOKEN>",
    card: { detail: { security_code: "123" } },
  },
})
```

### 创建支付

从您的 backend 调用 Yuno 的 [Create Payment](https://docs.y.uno/zh-hans/reference/payments/create-payment.md) endpoint，并将 `payment_method.token` 设置为一次性令牌。如果触发了 NTA，响应中会包含 `sdk_action_required: true`。

### 获取继续操作

```js theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const data = await apiClientPayment.getContinuePaymentAction({
  checkoutSession: "<CHECKOUT_SESSION>",
})
```

`data.action` 将为 `REDIRECT_URL`，`data.redirect` 包含由卡组织托管的认证 URL：

```json theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "action": "REDIRECT_URL",
  "redirect": {
    "init_url": "https://...",
    "success_url": "https://...",
    "error_url": "https://..."
  }
}
```

### 重定向购物者

使用整页浏览器重定向将购物者发送到 `redirect.init_url`。

```js theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
if (data.action === "REDIRECT_URL") {
  window.location.href = data.redirect.init_url
}
```

认证完成后，卡组织会将购物者重定向回您的网站。使用 [Yuno Webhooks](https://docs.y.uno/zh-hans/docs/webhooks/configure-webhooks.md) 或 [Retrieve Payment by ID](https://docs.y.uno/reference/payments/retrieve-payment-by-id) 读取最终状态。

## 何时触发认证

**仅**在以下情况下运行 NTA：

1. 商户已接入 Network Tokens。
2. 存在 NTA 连接，且支付服务提供商连接上已配置 3DS 信息。
3. NTA 连接在路由中正确放置于支付步骤之前。

## 处理最终状态

该流程是异步的。通过 webhook 等待结果，或轮询支付状态。终态为标准 Yuno 状态（`SUCCEEDED`、`DECLINED`、`CANCELLED`、`EXPIRED`）。


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