paj_ramp
v1.5.1
Published
paj offramp/onramp service
Downloads
411
Readme
PAJ Ramp SDK
A comprehensive SDK for PAJ Ramp onramp and offramp operations with real-time transaction updates using webhooks.
Installation
npm install paj_rampyarn add paj_rampGetting Started
Initialize SDK (select environment: "staging" | "production")
import { initializeSDK, Environment } from 'paj_ramp';
// Selects the environment you want to work with
initializeSDK(Environment.Production); // or Environment.StagingInitiate Session
import { initiate } from 'paj_ramp';
// You can get otp by either adding your phone number or email address
// Phone number must start with a country code
const initiated = await initiate(
'[email protected]' // +2349053231563
'business_api_key'
);
// Response: { email?: string, phone?: string}Verify Session
import { verify } from 'paj_ramp';
// You can get otp by either adding your phone number or email address
// Phone number must start with a country code
const verified = await verify(
'[email protected]', // or +2349053231563
'otp',
{
uuid: string,
device: string,
//optionL ↓↓↓↓↓
os: string, //IOS
browser: string, //chrome
ip: string,
},
'business_api_key'
);
/* Response: {
email?: string,
phone?: string,
isActive: string,
expiresAt: string,
token: string
} */📚 Examples
Check out our examples directory for complete, runnable examples:
- Basic Onramp - Simple onramp transaction flow showing how users can buy crypto with fiat
- Basic Offramp - Simple offramp transaction flow showing how users can sell crypto for fiat
- Webhook Integration - Express server with webhook handling for real-time order updates
Each example includes its own README with detailed setup instructions. Perfect for understanding how to integrate PAJ Ramp into your application!
cd examples/basic-onramp
npm install
cp .env.example .env
# Edit .env with your credentials
npm startUtility Endpoints
Handle Rate:
Get All Rate
import { getAllRate } from 'paj_ramp';
const rate = await getAllRate();
/*
Response:
{
"onRampRate": {
"baseCurrency": "USD",
"targetCurrency": "NGN",
"isActive": true,
"rate": 1510,
"type": "onRamp"
},
"offRampRate": {
"baseCurrency": "USD",
"targetCurrency": "NGN",
"isActive": true,
"rate": 1525,
"type": "offRamp"
}
}*/Get Rate by Amount
import { getRateByAmount } from 'paj_ramp';
const rate = await getRateByAmount(50000);
/*
Response:
{
rate: {
baseCurrency: string,
targetCurrency: string,
rate: number
},
amounts: {
userTax": number,
merchantTax": number,
amountUSD": number,
userAmountFiat": number
}
}*/Get Rate by Rate Type
import { getRateByType, RateType } from 'paj_ramp';
const rate = await getRateByType(RateType.offRamp); // or RateType.onRamp
/*
Response:
"offRampRate": {
"baseCurrency": "USD",
"targetCurrency": "NGN",
"isActive": true,
"rate": 1525,
"type": "offRamp"
}*/Get Token Value from Amount and Mint Token
import { getTokenValue } from 'paj_ramp';
const tokenValue = await getTokenValue(50000, 'token_mint_address');
/*
Response:
{
amount: number, // requested token amount
usdcValue: number, // USDC value of the token amount
mint: string // token mint address
}
*/Handle Banks:
Get Banks
import { getBanks } from 'paj_ramp';
const banks = await getBanks('token');
// Response: [ { id: string, name: string, country: string } ]Resolve Bank Account
import { resolveBankAccount } from 'paj_ramp';
const resolvedBankAccount = await resolveBankAccount(
'token',
'bank_id',
'account_number'
);
// Response: { accountName: string, accountNumber: string, bank: { id: string, name: string, code: string, country: string } }Add Bank Account
import { addBankAccount } from 'paj_ramp';
const addedBankAccount = await addBankAccount(
'token',
'bank_id',
'account_number'
);
// Response: { id: string, accountName: string, accountNumber: string, bank: string }Get Bank Accounts
import { getBankAccounts } from 'paj_ramp';
const accounts = await getBankAccounts('token');
// Response: [ { id: string, accountName: string, accountNumber: string, bank: string } ]Transaction History:
Get All Transactions
import { getAllTransactions } from 'paj_ramp';
const transactions = await getAllTransactions('token_from_verification');
/* Response: [{
id: string;
address: string;
mint: string;
currency: Currency;
amount: number;
usdcAmount: number;
fiatAmount: number;
sender: string;
receipient: string;
rate: number;
status: TransactionStatus;
transactionType: TransactionType;
createdAt: string | Date;
}]*/Get Transaction
import { getTransaction } from 'paj_ramp';
const transactions = await getTransaction(
'token_from_verification',
'transaction_id'
);
/* Response: {
id: string;
address: string;
mint: string;
currency: Currency;
amount: number;
usdcAmount: number;
fiatAmount: number;
sender: string;
receipint: string;
rate: number;
status: TransactionStatus;
transactionType: TransactionType;
createdAt: string | Date;
}*/Offramp Webhook (Direct Offramp)
Usage Example
import { createOfframpOrder, Currency } from 'paj_ramp';
const createOrder = await createOfframpOrder(
{
bank: 'bank_id',
accountNumber: 'account_number',
currency: 'NGN' as Currency, // Currency
amount: 10000, // amount
mint: 'token_mint_address',
webhookURL: 'webhook_url', // https://your-domain.com/webhook
},
'token'
);
/* Response: {
id: string,
address: string,
mint: string,
currency: Currency,
amount: number,
fiatAmount: number,
sender: string,
rate: number,
status: TransactionStatus,
transactionType: TransactionType
createdAt: string
}*/Onramp Webhook: Creates a new onramp order and sends status to the webhook url.
Usage Example
import { createOrder, Currency } from 'paj_ramp';
const order = await createOrder(
{
fiatAmount: 10000,
currency: 'NGN' as Currency,
recipient: 'wallet_address_here',
mint: 'token_mint_address_here',
chain: 'SOLANA', //ethereum, polygon, etc
webhookURL: 'your_webhook_url', // https://your-domain.com/webhook
},
'token_from_verification'
);
// Response: { id: string, accountNumber: string, accountName: string, fiatAmount: number, bank: string }Webhook Response Data Structure
For both onramp and offramp
{
id: string;
address: string;
signature?: string;
mint: string;
currency: Currency; // eg. NGN, USD
amount: number;
usdcAmount: number;
fiatAmount: number;
sender: string;
receipient: string;
rate: number;
status: TransactionStatus; // eg. INIT, PAID, COMPLETED
transactionType: TransactionType; // ON_RAMP or OFF_RAMP
}Other types
import {
// Chain, // SOLANA, etc
TransactionStatus, // INIT, etc
TransactionType, // ON_RAMP, etc
Currency, // NGN
Environment,
RateType,
} from 'paj_ramp';License
MIT
🧑💻 Author
Gospel Chidiebube Chukwu
