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

# 以本地货币收款和付款

> 通过虚拟账户以本地货币接收银行转账，将其结算为稳定币，再通过法币提现支付到本地银行账户。

> [!NOTE]
>
> 简而言之\\
>
> 您的客户通过银行转账向虚拟账户付款。Blockradar 将这笔款项以稳定币结算到您的钱包，并发送 `onramp.success`。随后，您的 Webhook 处理程序通过法币提现以本地货币付出这笔金额。您的客户和收款方都无需看到或持有稳定币。

本指南以奈拉（NGN）为例：一个结算为 Base 上 USDC 的 NGN 虚拟账户，以及一笔支付到尼日利亚银行账户的 NGN 付款。同样的流程适用于任何同时支持[存款和付款](https://docs.blockradar.co/zh/use-cases/supported-fiat-currencies.md)的币种。

## 前提条件

* 您所使用通道的**合规审批**，包括存款端和付款端。企业验证的具体内容请参阅[常见问题](https://docs.blockradar.co/zh/introduction/faq.md)。
* 您的账户已**启用虚拟账户**。请参阅[虚拟账户的前提条件](https://docs.blockradar.co/zh/use-cases/virtual-accounts.md#前提条件)。
* 一个会验证签名的 **Webhook 端点**。请参阅 [Webhooks](https://docs.blockradar.co/zh/utilities/webhooks.md)。

## 工作原理

**1. 创建虚拟账户**

在您的钱包上创建一个虚拟账户，币种为 NGN，目标资产为 USDC。请按照[虚拟账户的步骤 1 至 3](https://docs.blockradar.co/zh/use-cases/virtual-accounts.md#步骤-1：发现选项)操作。

**2. 客户通过银行转账付款**

将账号分享给您的客户。转账到账后，Blockradar 会发送 `onramp.processing`，然后将 USDC 结算到您的钱包并发送 `onramp.success`。

**3. 收到 onramp.success 后付款**

您的 Webhook 处理程序找到与已结算稳定币对应的法币提现资产，然后获取汇率、报价并执行 NGN 付款。请按照[法币提现的步骤 1 至 7](https://docs.blockradar.co/zh/use-cases/withdraw-fiat.md#步骤-1：获取受支持的资产)操作。

**4. 确认付款**

付款过程中，法币提现会发送自己的 Webhook。请参阅[法币提现 Webhooks](https://docs.blockradar.co/zh/use-cases/withdraw-fiat.md#webhooks)。

## onramp.success Webhook

付款需要的字段是 `toCurrency`（结算的稳定币）、`toAmount`（结算金额）和 `wallet.id`（结算到的钱包）：

```json theme={null}
{
  "event": "onramp.success",
  "data": {
    "id": "0198f02a-9201-7000-8000-000000000002",
    "reference": "provider-payment-001",
    "type": "ONRAMP",
    "status": "SUCCESS",
    "currency": "NGN",
    "amount": "150000",
    "toCurrency": "USDC",
    "toAmount": "100",
    "virtualAccount": {
      "id": "0198f020-0000-7000-8000-000000000004",
      "accountNumber": "1234567890",
      "bankName": "Example Bank"
    },
    "paymentOrder": null,
    "wallet": {
      "id": "0198f020-0000-7000-8000-000000000005",
      "name": "Base Wallet"
    }
  }
}
```

请使用 `data.id` 确保每个事件只处理一次。同一事件可能会被多次投递。

## 从 Webhook 发起付款

```javascript theme={null}
// Call this from your webhook endpoint after verifying the signature
async function onOnrampSuccess(event) {
  if (event.event !== "onramp.success") return;

  const { wallet, toCurrency, toAmount } = event.data;
  const assets = await fetch(
    `https://api.blockradar.co/v2/wallets/${wallet.id}/withdraw/fiat/assets`,
    { headers: { "x-api-key": process.env.BLOCKRADAR_API_KEY } },
  ).then((r) => r.json());
  const assetId = assets.data?.find((a) => a.asset?.symbol === toCurrency)?.id;

  // Continue with Steps 2 to 7 of Withdraw Fiat, using wallet.id, assetId,
  // currency NGN and an amount no larger than toAmount
}
```

## 如果虚拟账户结算为 cNGN

如果虚拟账户的发现选项提供 cNGN，它也可以结算为 cNGN 而不是 USDC。cNGN 只能付出为 NGN。要将 cNGN 以其他币种付出，请先将其兑换为 USDC。请参阅[先兑换再提现](https://docs.blockradar.co/zh/use-cases/withdraw-fiat.md#先兑换再提现)。

## 另请参阅

* [虚拟账户](https://docs.blockradar.co/zh/use-cases/virtual-accounts.md)
* [法币提现](https://docs.blockradar.co/zh/use-cases/withdraw-fiat.md)
* [受支持的法币](https://docs.blockradar.co/zh/use-cases/supported-fiat-currencies.md)
* [客户法币流程](https://docs.blockradar.co/zh/guides/customer-fiat-flows.md)


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