Documentation Index
Fetch the complete documentation index at: https://docs.fyatu.com/llms.txt
Use this file to discover all available pages before exploring further.
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: 'customer@example.com',
name: 'Alice Example',
},
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
| Module | Description |
|---|
fyatu.collections | Accept payments via checkout |
fyatu.refunds | Manage refunds |
fyatu.payouts | Send money to recipients |
fyatu.cardholders | Manage cardholders |
fyatu.cards | Issue and manage virtual cards |
fyatu.account | Access 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