Skip to main content
This SDK is coming soon. Subscribe to our changelog to be notified when it’s released.
The official Node.js SDK for FYATU API v3, built with TypeScript for full type safety.

Installation

npm install @fyatu/sdk
# or
yarn add @fyatu/sdk
# or
pnpm add @fyatu/sdk

Quick Start

import { Fyatu } from '@fyatu/sdk';

const fyatu = new Fyatu({
  appId: 'your_app_id',
  secretKey: 'your_secret_key',
});

// Create a collection
const collection = await fyatu.collections.create({
  amount: 10.00,
  currency: 'USD',
  reference: 'order_123',
  description: 'Payment for Order #123',
  customer: {
    email: '[email protected]',
    name: 'John Doe',
  },
  redirectUrl: 'https://yoursite.com/payment/success',
  webhookUrl: 'https://yoursite.com/webhooks/fyatu',
});

console.log(collection.checkoutUrl);

Features

  • Full TypeScript Support - Complete type definitions for all endpoints
  • Automatic Token Management - Handles JWT refresh automatically
  • Promise-based API - Works with async/await
  • Automatic Retries - Configurable retry logic with exponential backoff
  • Webhook Verification - Built-in helpers for validating webhook signatures

Configuration Options

const fyatu = new Fyatu({
  appId: 'your_app_id',
  secretKey: 'your_secret_key',

  // Optional configuration
  baseUrl: 'https://api.fyatu.com/api/v3', // Custom API endpoint
  timeout: 30000, // Request timeout in ms
  retries: 3, // Number of retry attempts
});

Available Modules

ModuleDescription
fyatu.collectionsAccept payments via checkout
fyatu.refundsManage refunds
fyatu.payoutsSend money to recipients
fyatu.cardholdersManage cardholders
fyatu.cardsIssue and manage virtual cards
fyatu.esimPurchase and manage eSIMs
fyatu.accountAccess account information

Error Handling

import { Fyatu, FyatuError, ValidationError } from '@fyatu/sdk';

try {
  const payout = await fyatu.payouts.create({
    amount: 100,
    currency: 'USD',
    recipientId: 'invalid_id',
  });
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Validation failed:', error.details);
  } else if (error instanceof FyatuError) {
    console.error('API error:', error.code, error.message);
  }
}

Webhook Verification

import { verifyWebhookSignature } from '@fyatu/sdk';

// Express.js example
app.post('/webhooks/fyatu', (req, res) => {
  const signature = req.headers['x-fyatu-signature'];
  const isValid = verifyWebhookSignature(
    req.body,
    signature,
    'your_webhook_secret'
  );

  if (!isValid) {
    return res.status(401).send('Invalid signature');
  }

  // Process webhook event
  const event = req.body;
  console.log('Received event:', event.type);

  res.status(200).send('OK');
});

Resources