Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@

# Chimoney Multi-Currency Wallet Transfer Setup Guide

This guide will help you set up authentication and environment variables so you can successfully send a payout using Chimoney’s multi-currency wallet transfer endpoint.

## Prerequisites

- Chimoney developer account ([sign up here](https://sandbox.chimoney.io/auth/signup?next=/))
- Access to the Chimoney Dashboard
- Sandbox API key
- Node.js 18+
- npm
- A tool for making API requests (curl, Postman, etc.)

## Step 1: Authentication

Generate a Sandbox API key from the Chimoney dashboard.
[Watch this video](https://www.loom.com/share/436303eb69c44f0d9757ea0c655bed89?sid=b6a0f661-721c-4731-9873-ae6f2d25780) to learn how to generate your API key.


## Step 2: Environment Setup

Check your setup:

```bash
node --version
npm --version
```

Create a new project folder and install dependencies:

```bash
mkdir chimoney-demo
cd chimoney-demo
npm init -y
npm install dotenv
```

Create a `.env` file in your project root, copy your API-KEY from the Developers tab in your sandbox and replace the placeholder.

```env
CHIMONEY_API_KEY=your_sandbox_api_key_here
CHIMONEY_BASE_URL=https://api-v2-sandbox.chimoney.io
```

To authorize requests, you have to include your API key in the header; you will see how to do so in the example below.

## Step 3: Make a Test API Call

Create a file called `testConnection.js`:

```js
require('dotenv').config();

const url = `${process.env.CHIMONEY_BASE_URL}/v0.2.4/multicurrency-wallets/transfer`;
const headers = {
'Content-Type': 'application/json',
'X-API-KEY': process.env.CHIMONEY_API_KEY,
};

const body =
{
"amountToSend": "2",
"originCurrency": "USD",
"email": "[email protected]",
"phoneNumber": "+16471234567",
"destinationCurrency": "NGN",
"narration": "multi-currency transfer",
};

fetch(url, {
method: 'POST',
headers,
body: JSON.stringify(body),
})
.then(res => res.json())
.then(data => {
if (data && data.status === 'success') {
console.log('API call successful:', data.data.data[0]);
} else {
console.error('API call failed:', data);
}
})
.catch(err => console.error('Error:', err));
```

Run your test:

```bash
node testConnection.js
```

If your setup is complete, you should see a response with quote details (including the amount and currencies).

## What Success Looks Like

You should receive a 200 OK response.

```json
API call successful: {
id: 'RiDW88uCwemwZu2tRuLv',
turnOffNotification: false,
valueInUSD: '2',
wallet: true,
quote: {
expiresAt: '7/31/2025, 6:00:00 PM UTC',
expiresAtTimestamp: 1753984800000,
rate: 1480.339745,
receiver: '',
sender: 'VUla2glefVPCtwzqpwm3mD95TOM2',
originCurrency: 'USD',
originCurrencyDebitAmount: 2,
destinationCurrency: 'NGN',
destinationCurrencyCreditAmount: 2960.67949,
markups: {},
fee: 1,
fixedFees: null
},
email: '[email protected]',
swapped: true,
narration: 'multi-currency transfer',
redeemData: {},
chimoney: 2000,
issuer: 'VUla2glefVPCtwzqpwm3mD95TOM2',
issueID: 'VUla2glefVPCtwzqpwm3mD95TOM2_2_1753984331035',
type: 'chimoney',
initiatedBy: 'VUla2glefVPCtwzqpwm3mD95TOM2',
integration: { appID: 'iq6vJJQYosEQNsjbXuQR', reference: '' },
fee: 1,
personalizedMessage: 'multi-currency transfer',
chiRef: '01f41117-38ff-42c3-868d-bd9f8d6caeb6',
issueDate: '2025-07-31T17:52:11.341Z',
t_id: 235483111251582,
meta: { payer: 'VUla2glefVPCtwzqpwm3mD95TOM2', outgoingPaymentID: {} },
updatedDate: '2025-07-31T17:52:12.319Z',
paymentDate: '2025-07-31T17:52:12.319Z',
message: { mId: '', mType: 'email', status: 'sent' },
redeemLink: 'https://sandbox.chimoney.io/redeem/?chi=01f41117-38ff-42c3-868d-bd9f8d6caeb6'
}
```

If you get an error, check your API key, base URL, and request body.

## Troubleshooting

| Error | Cause | Fix |
|--------------------|-----------------------------|-------------------------------------------|
| 401 Unauthorized | Missing/invalid API key | Double-check the `X-API-KEY` header |
| 400 Bad Request | Invalid body format | Check that all required fields are present|
| Insufficient Funds | Not enough wallet balance | Try a smaller amount or add test funds |

For more help, visit the [Chimoney docs](https://chimoney.readme.io/reference/introduction) or contact their support.

## Helpful Links
- https://chimoney.readme.io/reference/post_v0-2-4-multicurrency-wallets-transfer
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@

# Tutorial: Using the Chimoney Multi-Currency Wallet Transfer API

This tutorial will walk you through making a multi-currency wallet transfer using Chimoney’s API. You’ll see how to request a quote and then execute a transfer, with code samples and explanations for each step.

---

## 1. Prerequisites

Before you start, make sure you have:
- A Chimoney Sandbox API key
- Node.js and npm installed
- The setup steps from `setup.md` completed

---

## 2. Request a Transfer Quote

First, you need to get a quote for your transfer. This tells you how much the recipient will get after conversion and fees.

**Sample code (`getQuote.js`):**


```js
require('dotenv').config();

const url = `${process.env.CHIMONEY_BASE_URL}/v0.2.4/multicurrency-wallets/transfer/quote`;
const headers = {
'Content-Type': 'application/json',
'X-API-KEY': process.env.CHIMONEY_API_KEY,
};

const body = {
amountToSend: '50.00',
originCurrency: 'USD',
destinationCurrency: 'NGN',
email: '[email protected]',
};

fetch(url, {
method: 'POST',
headers,
body: JSON.stringify(body),
})
.then(async res => {
const data = await res.json();
if (!res.ok) {
// Handle HTTP errors
console.error('Error:', res.status, data);
return;
}
if (data.status !== 'success') {
// Handle API-level errors
console.error('API error:', data);
return;
}
console.log('Quote response:', data);
})
.catch(err => console.error('Network error:', err));
```

**Expected response:**
```json
Quote response: {
status: 'success',
message: 'Quote generated successfully',
data: {
expiresAt: '7/31/2025, 7:00:00 PM UTC',
expiresAtTimestamp: 1753988400000,
rate: 1480.340184,
receiver: '',
sender: 'VUla2glefVPCtwzqpwm3mD95TOM2',
originCurrency: 'USD',
originCurrencyDebitAmount: 50,
destinationCurrency: 'NGN',
destinationCurrencyCreditAmount: 74017.0092,
markups: {},
fee: 5,
fixedFees: null
}
}
```

---

## 3. Execute the Transfer

Once you have the quote and are ready to send, make the transfer call.

**Sample code (`transfer.js`):**


```js
require('dotenv').config();

const url = `${process.env.CHIMONEY_BASE_URL}/v0.2.4/multicurrency-wallets/transfer`;
const headers = {
'Content-Type': 'application/json',
'X-API-KEY': process.env.CHIMONEY_API_KEY,
};

const body = {
amountToSend: '50.00',
originCurrency: 'USD',
destinationCurrency: 'NGN',
email: '[email protected]',
narration: 'Test transfer',
};

fetch(url, {
method: 'POST',
headers,
body: JSON.stringify(body),
})
.then(async res => {
const data = await res.json();
if (!res.ok) {
// Handle HTTP errors
console.error('Error:', res.status, data);
return;
}
if (data.status !== 'success') {
// Handle API-level errors
console.error('API error:', data);
return;
}
console.log('Transfer response:', data);
})
.catch(err => console.error('Network error:', err));
```

**Expected response:**
```json
Transfer response: {
status: 'success',
message: 'Payout to Chimoney wallets completed successfully.',
data: {
paymentLink: 'https://sandbox.chimoney.io/pay/?issueID=VUla2glefVPCtwzqpwm3mD95TOM2_50_1753985771489',
data: [ [Object], [Object] ],
chimoneys: [ [Object], [Object] ],
error: 'None',
payouts: {
'0': [Object],
'1': [Object],
issueID: 'VUla2glefVPCtwzqpwm3mD95TOM2_50_1753985771489'
}
}
}
```

---


## 4. Notes, Tips, and Error Handling

- Always check the HTTP status and the `status` field in the response.
- Handle errors gracefully in your code (see above for examples).
- Use the quote endpoint before every transfer to get up-to-date rates and fees.
- For production, switch to your live API key and endpoint.

**Common errors:**

| Error code / message | What it means | How to fix |
|--------------------------|--------------------------------------|-----------------------------------|
| 401 Unauthorized | API key missing or invalid | Check your `X-API-KEY` header |
| 400 Bad Request | Invalid request body or parameters | Check your request fields |
| Insufficient Funds | Not enough balance in your wallet | Try a smaller amount or add funds |
| Network error | Could not reach the API | Check your internet connection |

---

You’ve now seen how to request a quote and make a multi-currency wallet transfer using Chimoney’s API. For more information, see the [Chimoney API docs](https://chimoney.readme.io/reference/introduction).
Loading