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

# 欺诈

> 将 Web 欺诈集成（yuno.mountFraud + yuno.executeFraudCheck）迁移到统一 SDK。

在 Web 上，欺诈筛查有两个旧版入口点：

* `yuno.mountFraud(...)`：UI 模式。渲染欺诈组件，并通过自己的 `yunoCreatePayment` 创建支付。
* `yuno.executeFraudCheck(...)`：Headless。返回设备指纹标识符；没有 UI。

在统一 API 中，欺诈筛查在令牌化期间**自动在 `Transaction` 内运行**（您无需接入任何内容）。独立的 headless 检查移到 `SdkPayments` 上的一个顶层方法（不在 `Transaction` 上，因为它是查询，而不是交易）。UI 变体被移除：它的职责由 `Transaction` 承担。

## 开始之前

* 加载统一 SDK 包而不是旧版包，并按照代码对照所示进行初始化：`window.Yuno.initialize(...)` 变为 `SdkPayments.initialize(...)`。您的公共 API 密钥以及您的 backend 创建的结账会话保持不变（[开始之前](https://docs.y.uno/zh-hans/docs/yuno-sdk/get-started.md#before-you-begin)）。
* 如果您要用 `Transaction` 替换 `mountFraud`，请决定由谁创建支付。结账会话的 `workflow` 必须与该决定一致：

| 由谁创建支付 | 在 Fraud UI 中您使用的是 | 在统一 API 中 | 会话 `workflow` |
| - | - | - | - |
| 您的 backend | `mountFraud` 中的 `yunoCreatePayment` | 覆盖 `createPayment` | 默认（`SDK_CHECKOUT`） |
| SDK | 无对应项：`mountFraud` 通过 `yunoCreatePayment` 创建支付 | 不覆盖 | `SDK_SEAMLESS` |

> [!WARNING]
>
> 使用默认 workflow 的会话如果没有覆盖 `createPayment`，最终会以 `INTERNAL_ERROR` 结束：backend 会拒绝 SDK 创建支付。请参阅 [`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment)。

## 代码对照

### Headless 欺诈检查

```typescript Before. executeFraudCheck theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const yuno = await window.Yuno.initialize('your-public-api-key')

const result = await yuno.executeFraudCheck({
    checkoutSession: 'session-from-backend',
    countryCode: 'CO',
    paymentType: 'CARD',
    deviceFingerprints: [],
})

if (result.status === 'success') {
    console.log('fingerprints:', result.deviceFingerprints)
} else {
    console.error('fraud check failed:', result.error)
}
```

```typescript After. sdkPayments.antifraud theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const sdkPayments = await SdkPayments.initialize('your-public-api-key')

const result = await sdkPayments.antifraud({
    checkoutSession: 'session-from-backend',
    countryCode: 'CO',
    paymentType: 'CARD',
})

if (result.status === 'success') {
    for (const fp of result.deviceFingerprints) {
        console.log('fingerprint:', fp.providerId, fp.sessionId)
    }
} else {
    console.error('fraud check failed:', result.error)
}
```

### 欺诈 UI

```typescript Before. mountFraud (UI) theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
await yuno.mountFraud({
    checkoutSession: 'session-from-backend',
    language: 'en',
    deviceFingerprints: [],
    type: 'CARD',
    yunoCreatePayment: async (oneTimeToken, info) => {
        await myBackend.pay(oneTimeToken)
        yuno.continuePayment()
    },
    yunoError: (msg) => console.error(msg),
})
```

```typescript After. Normal Transaction, fraud is automatic theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const transaction = sdkPayments.transaction({
    checkoutSession: 'session-from-backend',
    countryCode: 'CO',
    elementSelector: '#root',
    deviceFingerprints: [],            // optional: inject your own
    createPayment: async (token) => {
        await myBackend.pay(token.token)
    },
    showLoading: (isLoading) => mySpinner.toggle(isLoading),
    onStatus: (result) => console.log('done:', result.status),
})

await transaction.start({ paymentMethod: { type: 'CARD' } })
```

## 变更内容

按您编辑代码的顺序分组。**重命名**：作用相同，名称变化。**移动**：值相同，归属对象变化。**移除**：无需调用任何内容。**新增**：没有旧版对应项。最后一列是重命名之外您唯一需要做的事。

### 初始化和配置

| 欺诈 | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `window.Yuno.initialize(publicApiKey)` | `SdkPayments.initialize(publicApiKey)` | 重命名 | 全局对象是 `window.SdkPayments`。与之前一样，对它使用 `await`：它会解析为 `SdkPayments` 实例。 |
| `executeFraudCheck` 的 `checkoutSession`、`countryCode` 参数 | `sdkPayments.antifraud` 的相同参数 | 移动 | |
| `executeFraudCheck.paymentType`（内部默认为 `CARD`） | `antifraud.paymentType?` | 移动 | 默认值相同。 |
| `executeFraudCheck.deviceFingerprints?` | `antifraud.deviceFingerprints?` | 移动 | 结构相同（`ExternalProviderId[]`）。 |
| 与支付数据一起传给 `mountFraud` 的 `deviceFingerprints?: ExternalProviderId[]` | `TransactionConfig` 中的 `deviceFingerprints?: ExternalProviderId[]` | 移动 | 可选：注入您自己的值。 |
| `mountFraud` 中的 `checkoutSession`、`language`、`type` | 交易配置中的 `checkoutSession`、`language`；`type` 变为 `start()` 上的 `paymentMethod.type` | 移动 | |

### Callback

| 欺诈 | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `mountFraud` 中的 `yunoCreatePayment(oneTimeToken, info)` | 交易配置中的 `createPayment(token)` | 重命名 | 支付创建不再与欺诈功能绑定：它由 `createPayment` 负责（或由 SDK 托管，请参阅“开始之前”）。基于 Promise，只有一个参数。创建支付后 resolve：resolve 即相当于以前的 `yuno.continuePayment()`。请参阅 [`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment)。 |
| `mountFraud` 中的 `yunoError(msg)` | *（已移除）* | 移除 | 交易改为通过 `onStatus` 报告其结果。 |
| *（无）* | `showLoading(isLoading)` | 新增 | 可选。欺诈组件已不存在，如果您需要自定义 UI 反馈，请使用它。请参阅 [`showLoading`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-loading)。 |
| *（无）* | `onStatus(result)` | 新增 | 交易在此报告其最终状态。请参阅 [`Status`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-receive#status)。 |

### 入口点

| 欺诈 | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `yuno.executeFraudCheck({...})` | `sdkPayments.antifraud({...})` | 重命名 | `SdkPayments` 上的顶层方法，不在 `Transaction` 上：它是独立的查询，不属于交易生命周期。如果您需要在创建结账会话之前进行预筛查，请使用它。 |
| `ExecuteFraudCheckReturn`（`status`、`deviceFingerprints`、`error`） | `FraudResult` 可辨识联合类型 | 重命名 | 该 Promise 永远不会被拒绝。`status: 'success'` → 存在 `deviceFingerprints`（`{ providerId: string; sessionId: string }[]`）；`status: 'error'` → 存在 `error: Error`。在 v1 中，`error` 始终与 `deviceFingerprints` 一起作为可选字段；相比之下，新结构强制您先检查 `status` 再读取任一字段（TS 会收窄类型）：不再有可选字段。 |
| `yuno.mountFraud({...})` | *（已移除）* | 移除 | 没有直接替代项：由普通的 `sdkPayments.transaction(config).start({ paymentMethod })` 取而代之。该组件的职责现在属于 `Transaction`：在普通流程中，欺诈信号会在令牌化期间自动收集，支付创建则移到 `createPayment`（请参阅“Callback”）。 |
| `yunoCreatePayment` 中的 `yuno.continuePayment()` | *（已移除）* | 移除 | 删除该调用：resolve `createPayment` 即可继续流程。 |

## 相关内容

* [`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment)。用于普通 `Transaction` 流程中的手动支付创建。


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