FinFusion SDK Reference
Complete reference for the official FinFusion SDK
SDK Version
Current stable version:
1.0.0
. View changelog on
GitHub.
Installation
npm install @finfusion/sdk
Initialization
Initialize the SDK with your API key and configuration options:
init.ts
import { FinFusion } from '@finfusion/sdk';
const finfusion = new FinFusion({
apiKey: 'your_api_key',
environment: 'sandbox', // or 'production'
baseUrl: 'https://api.finfusion.cloud'
});
Core Modules
Payments
Process payments, refunds, and manage payment methods:
payments.ts
// Create a payment
const payment = await finfusion.payments.create({
amount: 1000,
currency: 'USD',
description: 'Test payment',
source: 'card_123'
});
// Retrieve a payment
const payment = await finfusion.payments.retrieve('pay_123');
// List payments
const payments = await finfusion.payments.list({
limit: 10,
starting_after: 'pay_123'
});
Banking
Manage accounts, transfers, and banking operations:
banking.ts
// Create an account
const account = await finfusion.banking.accounts.create({
type: 'checking',
currency: 'USD',
customer_id: 'cust_123'
});
// Get account balance
const balance = await finfusion.banking.accounts.getBalance('acc_123');
// List transactions
const transactions = await finfusion.banking.transactions.list({
account_id: 'acc_123',
limit: 20
});
Cards
Issue and manage virtual and physical cards:
cards.ts
// Issue a new card
const card = await finfusion.cards.issue({
customer_id: 'cust_123',
type: 'virtual',
currency: 'USD'
});
// Activate a card
await finfusion.cards.activate('card_123');
// Get card details
const cardDetails = await finfusion.cards.retrieve('card_123');
Error Handling
The SDK provides structured error handling with specific error types:
error-handling.ts
try {
const payment = await finfusion.payments.create({
amount: 1000,
currency: 'USD'
});
} catch (error) {
if (error instanceof FinFusion.errors.InvalidRequestError) {
console.error('Invalid request:', error.message);
} else if (error instanceof FinFusion.errors.AuthenticationError) {
console.error('Authentication failed:', error.message);
} else {
console.error('Unexpected error:', error);
}
}
Common Error Types
- InvalidRequestError
- AuthenticationError
- APIError
- NetworkError
Error Properties
- message: Error description
- code: Error code
- type: Error type
- data: Additional data
TypeScript Support
The SDK is written in TypeScript and provides full type definitions out of the box.
Full IntelliSense support
Type-safe API responses
Comprehensive type exports
Need help? Contact us at support@finfusion.cloud