Getting Started
Quickstart

Quickstart

Get started with Fiatsend in minutes - Learn how to create payment orders and integrate with the SDKs

This guide will walk you through creating your first payment order and integrating with the Fiatsend SDks.

Quick Integration (5 minutes)

Step 1: Install the SDK

npm install @fiatsend/sdk

Step 2: Initialize the SDK

import Fiatsend from "@fiatsend/sdk";
 
const fiatsend = new Fiatsend({
  apiKey: "your-api-key",
  environment: "testnet" // or "mainnet"
});

Step 3: Create a User Account

// Create a new user account
const user = await fiatsend.users.create({
  phoneNumber: "+1234567890",
  country: "US"
});
 
console.log("User ID:", user.id);

Step 4: Process a Transaction

// Send USDT to fiat
const transaction = await fiatsend.transactions.create({
  userId: user.id,
  type: "offramp",
  amount: "100",
  currency: "USDT",
  targetCurrency: "GHS",
  targetPhone: "+1234567890"
});
 
console.log("Transaction ID:", transaction.id);

Core Concepts

Network Participants

Transaction Types

  • Onramp: Fiat → Crypto (Cash to USDT/USDC)
  • Offramp: Crypto → Fiat (USDT/USDC to Cash)
  • P2P Transfer: User-to-user transfers
  • Merchant Payment: Business payment processing

Supported Assets

  • Stablecoins: USDT, USDC
  • Fiat-Backed Tokens: GHSfiat, NGN, KES

Integration Examples

For Merchants

// Accept crypto payments and settle in fiat
const payment = await fiatsend.merchants.createPayment({
  amount: "50",
  currency: "USDT",
  customerPhone: "+1234567890",
  merchantId: "your-merchant-id"
});

For Wallets & Exchanges

// Provide fiat on-ramp service
const onramp = await fiatsend.onramp.create({
  userId: user.id,
  amount: "100",
  sourceCurrency: "USD",
  targetCurrency: "USDT",
  paymentMethod: "mobile_money"
});

For Agents

// Facilitate cash deposits
const deposit = await fiatsend.agents.createDeposit({
  agentId: "agent-id",
  userId: user.id,
  amount: "50",
  currency: "USD",
  location: "agent-location"
});

Authentication & Security

API Key Authentication

const fiatsend = new Fiatsend({
  apiKey: process.env.FIATSEND_API_KEY,
  secretKey: process.env.FIATSEND_SECRET_KEY
});

Webhook Verification

// Verify webhook signatures
const isValid = fiatsend.webhooks.verify(
  signature,
  payload,
  webhookSecret
);

Testing

Testnet Environment

const fiatsend = new Fiatsend({
  apiKey: "test-api-key",
  environment: "testnet"
});

Test Credentials

  • Test Phone: +1234567890
  • Test Amounts: $1-$100
  • Test Currencies: KES, NGN, GHS,

Error Handling

try {
  const transaction = await fiatsend.transactions.create({
    // transaction details
  });
} catch (error) {
  if (error.code === 'INSUFFICIENT_BALANCE') {
    console.log('User needs to add funds');
  } else if (error.code === 'KYC_REQUIRED') {
    console.log('User needs to complete KYC');
  }
}

Webhooks

Set up webhooks to receive real-time updates:

// Webhook endpoint
app.post('/webhooks/fiatsend', (req, res) => {
  const event = req.body;
  
  switch (event.type) {
    case 'transaction.completed':
      // Handle completed transaction
      break;
    case 'user.kyc.approved':
      // Handle KYC approval
      break;
  }
  
  res.status(200).send('OK');
});

Next Steps

  1. Explore the API Documentation: Get detailed endpoint information
  2. Join the Developer Community: Connect with other developers on Discord
  3. Test with Testnet: Try all features in the test environment
  4. Go Live: Deploy to mainnet when ready

Support & Resources


Ready to build the future of finance? Start integrating with Fiatsend today! 🚀