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

# Collect and Pay Out in Local Currency

> Collect a bank transfer in local currency through a virtual account, settle it as a stablecoin, and pay it out to a local bank account with Withdraw Fiat.

> [!NOTE]
>
> In a nutshell\\
>
> Your customer pays into a virtual account by bank transfer. Blockradar settles
> the payment as a stablecoin in your wallet and sends `onramp.success`. Your
> webhook handler then pays the amount out in local currency with Withdraw Fiat.
> Neither your customer nor the recipient ever has to see or hold the
> stablecoin.

This guide uses Naira (NGN) as the example: an NGN virtual account that settles
in USDC on Base, and an NGN payout to a Nigerian bank account. The same flow
works for any currency that supports both
[deposits and payouts](https://docs.blockradar.co/en/use-cases/supported-fiat-currencies.md).

## Prerequisites

* **Compliance approval** for the corridors you use, both the deposit side and
  the payout side. See the
  [FAQ](https://docs.blockradar.co/en/introduction/faq.md) for what business verification involves.
* **Virtual accounts enabled** for your account. See the
  [Virtual Accounts prerequisites](https://docs.blockradar.co/en/use-cases/virtual-accounts.md#prerequisites).
* **A webhook endpoint** that verifies signatures. See
  [Webhooks](https://docs.blockradar.co/en/utilities/webhooks.md).

## How it works

**1. Create a virtual account**

Create a virtual account on your wallet with NGN as the currency and USDC
as the destination asset. Follow [Steps 1 to 3 of Virtual
Accounts](https://docs.blockradar.co/en/use-cases/virtual-accounts.md#step-1-discover-options).

**2. Your customer pays by bank transfer**

Share the account number with your customer. When their transfer arrives,
Blockradar sends `onramp.processing`, then settles the USDC to your wallet
and sends `onramp.success`.

**3. Pay out on onramp.success**

Your webhook handler finds the Withdraw Fiat asset for the settled
stablecoin, then gets a rate, quotes and executes an NGN payout. Follow
[Steps 1 to 7 of Withdraw Fiat](https://docs.blockradar.co/en/use-cases/withdraw-fiat.md#step-1-get-supported-assets).

**4. Confirm the payout**

Withdraw Fiat sends its own webhooks as the payout progresses. See
[Withdraw Fiat webhooks](https://docs.blockradar.co/en/use-cases/withdraw-fiat.md#webhooks).

## The onramp.success webhook

The fields you need for the payout are `toCurrency` (the stablecoin that
settled), `toAmount` (how much settled) and `wallet.id` (where it settled):

```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"
    }
  }
}
```

Use `data.id` to process each event once. The same event can be delivered more
than once.

## Start the payout from the 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
}
```

## If the virtual account settles in cNGN

A virtual account can settle in cNGN instead of USDC, if its discovery options
offer it. cNGN pays out to NGN only. To pay cNGN out in another currency, swap
it to USDC first. See
[Swap Before Paying Out](https://docs.blockradar.co/en/use-cases/withdraw-fiat.md#swap-before-paying-out).

## See also

* [Virtual Accounts](https://docs.blockradar.co/en/use-cases/virtual-accounts.md)
* [Withdraw Fiat](https://docs.blockradar.co/en/use-cases/withdraw-fiat.md)
* [Supported Fiat Currencies](https://docs.blockradar.co/en/use-cases/supported-fiat-currencies.md)
* [Customer fiat flows](https://docs.blockradar.co/en/guides/customer-fiat-flows.md)


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