paj_ramp 1.2.3 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,470 +1,514 @@
1
- # PAJ Ramp SDK
2
-
3
- A comprehensive SDK for PAJ Ramp onramp and offramp operations with real-time transaction updates using Socket.IO.
4
-
5
- ## Features
6
-
7
- - **Onramp Operations**: Create orders and observe real-time updates
8
- - **Offramp Operations**: Complete offramp workflow with bank account management
9
- - **Real-time Updates**: Socket.IO integration for live transaction status updates
10
- - **TypeScript Support**: Full TypeScript definitions included
11
- - **Functional API**: Clean functional approach for better composability
12
-
13
- ## Installation
14
-
15
- ```bash
16
- npm install paj_ramp
17
- ```
18
-
19
- ```bash
20
- yarn add paj_ramp
21
- ```
22
-
23
- ---
24
-
25
- ## Initialize SDK (select environment: "staging" | "production")
26
-
27
- ```typescript
28
- import { initializeSDK } from "paj_ramp";
29
-
30
- // Selects the environment you want to work with
31
- initializeSDK("staging"); // or production
32
- ```
33
-
34
- ---
35
-
36
- # Onramp SDK (Real-time Order Observation)
37
-
38
- ## Quick Start
39
-
40
- ### Real-time Order Observation
41
-
42
- The SDK provides Socket.IO functionality to observe onramp orders in real-time:
43
-
44
- ```typescript
45
- import { observeOrder } from "paj_ramp";
46
-
47
- // Using observeOrder function
48
- const observer = observeOrder({
49
- orderId: "your_order_id",
50
- onOrderUpdate: (data) => {
51
- console.log("Order update:", data);
52
- // Handle status changes: pending, processing, completed, failed, cancelled
53
- },
54
- onError: (error) => {
55
- console.error("Socket error:", error);
56
- },
57
- });
58
-
59
- await observer.connect();
60
- ```
61
-
62
- ### Order Update Data Structure
63
-
64
- ```typescript
65
- interface OnRampOrderUpdate {
66
- id: string;
67
- fiatAmount: string;
68
- currency: string;
69
- recipient: string; // wallet address
70
- mint: string; // token address
71
- chain: Chain; // enum: 'solana', 'ethereum', 'polygon'
72
- status: OnRampStatus; // enum: 'pending', 'processing', 'completed', 'failed', 'cancelled'
73
- }
74
- ```
75
-
76
- ### Socket Events
77
-
78
- The SDK listens for these Socket.IO events:
79
-
80
- - **ORDER_UPDATE**: Real-time order status updates
81
- - **ERROR**: Error messages from the server
82
-
83
- ## API Reference
84
-
85
- ### observeOrder(options)
86
-
87
- Creates an order observer.
88
-
89
- **Parameters:**
90
-
91
- - `options.orderId` (string, required): The order ID to observe
92
- - `options.onOrderUpdate` (function, optional): Callback for order updates
93
- - `options.onError` (function, optional): Callback for errors
94
- - `options.onConnect` (function, optional): Callback when connected
95
- - `options.onDisconnect` (function, optional): Callback when disconnected
96
- - `options.onConnectionStatusChange` (function, optional): Callback for connection status changes
97
-
98
- **Returns:**
99
-
100
- - `socket`: The Socket.IO instance
101
- - `isConnected()`: Function to check connection status
102
- - `connect()`: Function to connect to the socket
103
- - `disconnect()`: Function to disconnect from the socket
104
-
105
- **Example:**
106
-
107
- ```typescript
108
- import { observeOrder } from "paj_ramp";
109
-
110
- const observer = observeOrder({
111
- orderId: "your_order_id",
112
- onOrderUpdate: (data) => console.log(data),
113
- });
114
-
115
- // Connect manually
116
- await observer.connect();
117
-
118
- // Check connection status
119
- console.log("Connected:", observer.isConnected());
120
-
121
- // Disconnect manually: you could use setTimeout to keep the socket alive for a certain amount of time before you disconnect
122
- observer.disconnect();
123
- ```
124
-
125
- ## Error Handling
126
-
127
- The SDK provides comprehensive error handling:
128
-
129
- ```typescript
130
- const observer = observeOrder({
131
- orderId: "your_order_id",
132
- onError: (error) => {
133
- // Handle connection errors, order not found, etc.
134
- console.error("Socket error:", error);
135
- },
136
- });
137
- ```
138
-
139
- Common error messages:
140
-
141
- - `"Order not found: {orderId}"`
142
- - `"Connection failed"`
143
- - `"Socket timeout"`
144
-
145
- ### createOrder(orderData)
146
-
147
- Creates a new onramp order.
148
-
149
- **Parameters:**
150
-
151
- - `orderData` (object, required): Order creation data
152
- - `orderData.fiatAmount` (number, required): Order amount
153
- - `orderData.currency` (string, required): Currency code (e.g., 'USD', 'NGN')
154
- - `orderData.recipient` (string, required): Wallet address to receive tokens
155
- - `orderData.mint` (string, required): Token mint address
156
- - `orderData.chain` (Chain, required): Blockchain network ('solana', 'ethereum', 'polygon')
157
- - `orderData.token` (string, required): Verification token
158
-
159
- **Returns:**
160
-
161
- - `id` (string): Unique order identifier
162
- - `accountNumber` (string): Bank account number for payment
163
- - `accountName` (string): Bank account holder name
164
- - `fiatAmount` (number): Order amount in fiat currency
165
- - `bank` (string): Bank name
166
-
167
- **Example:**
168
-
169
- ```typescript
170
- import { createOrder } from "paj_ramp";
171
-
172
- const order = await createOrder({
173
- fiatAmount: 10000,
174
- currency: "NGN",
175
- recipient: "wallet_address_here",
176
- mint: "token_mint_address_here",
177
- chain: "SOLANA",
178
- token: "token_from_verification",
179
- });
180
- // Response: { id: string, accountNumber: string, accountName: string, fiatAmount: number, bank: string }
181
- ```
182
-
183
- ### Usage Example
184
-
185
- ```typescript
186
- import { observeOrder } from "paj_ramp";
187
-
188
- async function example(orderId) {
189
- console.log("Observe Order");
190
-
191
- const observer = observeOrder({
192
- orderId,
193
- onOrderUpdate: (data) => {
194
- console.log("Order update received:", data);
195
- console.log("Status:", data.status);
196
- console.log("Amount:", data.amount);
197
- console.log("Currency:", data.currency);
198
- },
199
- onError: (error) => {
200
- console.error("Socket error:", error);
201
- },
202
- onConnect: () => {
203
- console.log("Connected to order socket");
204
- },
205
- onDisconnect: () => {
206
- console.log("Disconnected from order socket");
207
- },
208
- onConnectionStatusChange: (connected) => {
209
- console.log(
210
- "Connection status changed:",
211
- connected ? "Connected" : "Disconnected"
212
- );
213
- },
214
- });
215
-
216
- try {
217
- await observer.connect();
218
- console.log("Successfully connected to order observer");
219
-
220
- // Keep the connection alive for 1 minute
221
- setTimeout(() => {
222
- console.log("Disconnecting after 1 minute...");
223
- observer.disconnect();
224
- }, 1 * 60 * 1000);
225
- } catch (error) {
226
- console.error("Failed to connect:", error);
227
- }
228
- }
229
-
230
- const order = await createOrder({
231
- fiatAmount: 10000,
232
- currency: "NGN",
233
- recipient: "your_wallet_address",
234
- mint: "your_token_mint_address",
235
- chain: "SOLANA",
236
- token: token_from_verification,
237
- });
238
-
239
- await example(order.id);
240
- // Response: { id: string, fiatAmount: string, currency: string, , recipient: string, mint: string, chain: Chain, amount: number, status: OnRampStatus }
241
- ```
242
-
243
- ---
244
-
245
- # Offramp SDK
246
-
247
- ## Overview
248
-
249
- The Offramp SDK provides a set of functions to help users convert Solana-based digital assets to fiat and transfer the resulting funds to traditional bank accounts. It includes session management, rate queries, bank account management, and wallet operations.
250
-
251
- ## Usage Examples
252
-
253
- ### Get TX Pool Address
254
-
255
- ```typescript
256
- import { getTXPoolAddress } from "paj_ramp";
257
-
258
- const txpooladdress = await getTXPoolAddress();
259
- // Response: { address: string }
260
- ```
261
-
262
- ### Get Rate
263
-
264
- ```typescript
265
- import { getRate } from "paj_ramp";
266
-
267
- const rate = await getRate();
268
- /*
269
- Response:
270
- {
271
- "onRampRate": {
272
- "baseCurrency": "USD",
273
- "targetCurrency": "NGN",
274
- "isActive": true,
275
- "rate": 1510,
276
- "type": "onRamp"
277
- },
278
- "offRampRate": {
279
- "baseCurrency": "USD",
280
- "targetCurrency": "NGN",
281
- "isActive": true,
282
- "rate": 1525,
283
- "type": "offRamp"
284
- }
285
- }*/
286
- ```
287
-
288
- ### Get Rate by Amount
289
-
290
- ```typescript
291
- import { getRate } from "paj_ramp";
292
-
293
- const rate = await getRate(50000);
294
- /*
295
- Response:
296
- {
297
- rate: {
298
- baseCurrency: string,
299
- targetCurrency: string,
300
- rate: number
301
- },
302
- amounts: {
303
- userTax": number,
304
- merchantTax": number,
305
- amountUSD": number,
306
- userAmountFiat": number
307
- }
308
- }*/
309
- ```
310
-
311
- ### Get Rate by Rate Type
312
-
313
- ```typescript
314
- import { getRate, RateType } from "paj_ramp";
315
-
316
- const rate = await getRate(RateType.offRamp); // or RateType.onRamp
317
-
318
- /*
319
- Response:
320
- "offRampRate": {
321
- "baseCurrency": "USD",
322
- "targetCurrency": "NGN",
323
- "isActive": true,
324
- "rate": 1525,
325
- "type": "offRamp"
326
- }*/
327
- ```
328
-
329
- ### Initiate Session
330
-
331
- ```typescript
332
- import { initiate } from "paj_ramp";
333
-
334
- const initialized = await initiate("your_email@gmail.com", "business_api_key");
335
- // Response: { email: string }
336
- ```
337
-
338
- ### Verify Session
339
-
340
- ```typescript
341
- import { verify } from "paj_ramp";
342
-
343
- const verified = await verify(
344
- "your_email@gmail.com",
345
- "otp",
346
- {
347
- uuid: string,
348
- device: string,
349
- //optionL ↓↓↓↓↓
350
- os: string, //IOS
351
- browser: string, //chrome
352
- ip: string,
353
- },
354
- "business_api_key"
355
- );
356
- // Response: { email: string, isActive: string, expiresAt: string, token: string }
357
- ```
358
-
359
- ### Get Banks
360
-
361
- ```typescript
362
- import { getBanks } from "paj_ramp";
363
-
364
- const banks = await getBanks();
365
- // Response: [ { id: string, name: string, country: string } ]
366
- ```
367
-
368
- ### Resolve Bank Account
369
-
370
- ```typescript
371
- import { resolveBankAccount } from "paj_ramp";
372
-
373
- const resolvedBankAccount = await resolveBankAccount(
374
- "bank id",
375
- "account number"
376
- );
377
- // Response: { accountName: string, accountNumber: string, bank: { id: string, name: string, code: string, country: string } }
378
- ```
379
-
380
- ### Add Bank Account
381
-
382
- ```typescript
383
- import { addBankAccount } from "paj_ramp";
384
-
385
- const addedBankAccount = await addBankAccount(
386
- "token",
387
- "bank id",
388
- "account number"
389
- );
390
- // Response: { id: string, accountName: string, accountNumber: string, bank: string }
391
- ```
392
-
393
- ### Get Bank Accounts
394
-
395
- ```typescript
396
- import { getBankAccounts } from "paj_ramp";
397
-
398
- const accounts = await getBankAccounts("token");
399
- // Response: [ { id: string, accountName: string, accountNumber: string, bank: string } ]
400
- ```
401
-
402
- ### Get Wallet Info
403
-
404
- ```typescript
405
- import { getWallet } from "paj_ramp";
406
-
407
- const wallet = await getWallet("wallet public key");
408
- // Response: { id: string, publicKey: string, bankAccount: { id: string, accountName: string, accountNumber: string, bank: string } }
409
- ```
410
-
411
- ### Add Wallet
412
-
413
- ```typescript
414
- import { addWallet } from "paj_ramp";
415
-
416
- // To create wallet.json file with an array of 64 numbers
417
- // npm install @solana/web3.js then run this code
418
- import { Keypair } from "@solana/web3.js";
419
- import fs from "fs";
420
-
421
- const keypair = Keypair.generate();
422
- const secretKey = Array.from(keypair.secretKey);
423
-
424
- fs.writeFileSync("wallet.json", JSON.stringify(secretKey));
425
- console.log("✅ wallets.json generated successfully");
426
-
427
- // To get secret key
428
- import * as fs from "fs";
429
- import { fileURLToPath } from "url";
430
- import { dirname, resolve } from "path";
431
-
432
- const __filename = fileURLToPath(import.meta.url);
433
- const __dirname = dirname(__filename);
434
-
435
- // wallet.json that you created with an array of 64 numbers
436
- const walletPath = resolve(__dirname, "./wallet.json");
437
- const secretKeyRaw = fs.readFileSync(walletPath, "utf8");
438
- const secretKeyArray = JSON.parse(secretKeyRaw);
439
-
440
- if (!Array.isArray(secretKeyArray) || secretKeyArray.length !== 64) {
441
- throw new Error("Invalid secret key: must be an array of 64 numbers.");
442
- }
443
-
444
- const secretKey = Uint8Array.from(secretKeyArray);
445
-
446
- const addedWallet = await addWallet("token", "bank account id", secretKey);
447
- // Response: { id: string, publicKey: string, bankAccount: { id: string, accountName: string, accountNumber: string, bank: string } }
448
- ```
449
-
450
- ### Switch Bank Account on Wallet
451
-
452
- ```typescript
453
- import { switchWalletBankAccount } from "paj_ramp";
454
-
455
- const switchedWallet = await switchWalletBankAccount(
456
- "token",
457
- "bank account id to switch to",
458
- "wallet id",
459
- "secret key"
460
- );
461
- // Response: { id: string, publicKey: string, bankAccount: { id: string, accountName: string, accountNumber: string, bank: string } }
462
- ```
463
-
464
- ## License
465
-
466
- MIT
467
-
468
- ## 🧑‍💻 Author
469
-
470
- Gospel Chidiebube Chukwu
1
+ # PAJ Ramp SDK
2
+
3
+ A comprehensive SDK for PAJ Ramp onramp and offramp operations with real-time transaction updates using Socket.IO.
4
+
5
+ ## Features
6
+
7
+ - **Onramp Operations**: Create orders and observe real-time updates
8
+ - **Offramp Operations**: Complete offramp workflow with bank account management
9
+ - **Real-time Updates**: Socket.IO integration for live transaction status updates
10
+ - **TypeScript Support**: Full TypeScript definitions included
11
+ - **Functional API**: Clean functional approach for better composability
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install paj_ramp
17
+ ```
18
+
19
+ ```bash
20
+ yarn add paj_ramp
21
+ ```
22
+
23
+ ---
24
+
25
+ ## Initialize SDK (select environment: "staging" | "production")
26
+
27
+ ```typescript
28
+ import { initializeSDK } from 'paj_ramp';
29
+
30
+ // Selects the environment you want to work with
31
+ initializeSDK('staging'); // or production
32
+ ```
33
+
34
+ ---
35
+
36
+ # Onramp SDK (Real-time Order Observation)
37
+
38
+ ## Quick Start
39
+
40
+ ### Real-time Order Observation
41
+
42
+ The SDK provides Socket.IO functionality to observe onramp orders in real-time:
43
+
44
+ ```typescript
45
+ import { observeOrder } from 'paj_ramp';
46
+
47
+ // Using observeOrder function
48
+ const observer = observeOrder({
49
+ orderId: 'your_order_id',
50
+ onOrderUpdate: data => {
51
+ console.log('Order update:', data);
52
+ // Handle status changes: pending, processing, completed, failed, cancelled
53
+ },
54
+ onError: error => {
55
+ console.error('Socket error:', error);
56
+ },
57
+ });
58
+
59
+ await observer.connect();
60
+ ```
61
+
62
+ ### Order Update Data Structure
63
+
64
+ ```typescript
65
+ interface OnRampOrderUpdate {
66
+ id: string;
67
+ fiatAmount: string;
68
+ currency: string;
69
+ recipient: string; // wallet address
70
+ mint: string; // token address
71
+ chain: Chain; // enum: 'solana', 'ethereum', 'polygon'
72
+ status: OnRampStatus; // enum: 'pending', 'processing', 'completed', 'failed', 'cancelled'
73
+ }
74
+ ```
75
+
76
+ ### Socket Events
77
+
78
+ The SDK listens for these Socket.IO events:
79
+
80
+ - **ORDER_UPDATE**: Real-time order status updates
81
+ - **ERROR**: Error messages from the server
82
+
83
+ ## API Reference
84
+
85
+ ### observeOrder(options)
86
+
87
+ Creates an order observer.
88
+
89
+ **Parameters:**
90
+
91
+ - `options.orderId` (string, required): The order ID to observe
92
+ - `options.onOrderUpdate` (function, optional): Callback for order updates
93
+ - `options.onError` (function, optional): Callback for errors
94
+ - `options.onConnect` (function, optional): Callback when connected
95
+ - `options.onDisconnect` (function, optional): Callback when disconnected
96
+ - `options.onConnectionStatusChange` (function, optional): Callback for connection status changes
97
+
98
+ **Returns:**
99
+
100
+ - `socket`: The Socket.IO instance
101
+ - `isConnected()`: Function to check connection status
102
+ - `connect()`: Function to connect to the socket
103
+ - `disconnect()`: Function to disconnect from the socket
104
+
105
+ **Example:**
106
+
107
+ ```typescript
108
+ import { observeOrder } from 'paj_ramp';
109
+
110
+ const observer = observeOrder({
111
+ orderId: 'your_order_id',
112
+ onOrderUpdate: data => console.log(data),
113
+ });
114
+
115
+ // Connect manually
116
+ await observer.connect();
117
+
118
+ // Check connection status
119
+ console.log('Connected:', observer.isConnected());
120
+
121
+ // Disconnect manually: you could use setTimeout to keep the socket alive for a certain amount of time before you disconnect
122
+ observer.disconnect();
123
+ ```
124
+
125
+ ## Error Handling
126
+
127
+ The SDK provides comprehensive error handling:
128
+
129
+ ```typescript
130
+ const observer = observeOrder({
131
+ orderId: 'your_order_id',
132
+ onError: error => {
133
+ // Handle connection errors, order not found, etc.
134
+ console.error('Socket error:', error);
135
+ },
136
+ });
137
+ ```
138
+
139
+ Common error messages:
140
+
141
+ - `"Order not found: {orderId}"`
142
+ - `"Connection failed"`
143
+ - `"Socket timeout"`
144
+
145
+ ### createOrder(orderData)
146
+
147
+ Creates a new onramp order.
148
+
149
+ **Parameters:**
150
+
151
+ - `orderData` (object, required): Order creation data
152
+ - `orderData.fiatAmount` (number, required): Order amount
153
+ - `orderData.currency` (string, required): Currency code (e.g., 'USD', 'NGN')
154
+ - `orderData.recipient` (string, required): Wallet address to receive tokens
155
+ - `orderData.mint` (string, required): Token mint address
156
+ - `orderData.chain` (Chain, required): Blockchain network ('solana', 'ethereum', 'polygon')
157
+ - `orderData.token` (string, required): Verification token
158
+
159
+ **Returns:**
160
+
161
+ - `id` (string): Unique order identifier
162
+ - `accountNumber` (string): Bank account number for payment
163
+ - `accountName` (string): Bank account holder name
164
+ - `fiatAmount` (number): Order amount in fiat currency
165
+ - `bank` (string): Bank name
166
+
167
+ **Example:**
168
+
169
+ ```typescript
170
+ import { createOrder } from 'paj_ramp';
171
+
172
+ const order = await createOrder({
173
+ fiatAmount: 10000,
174
+ currency: 'NGN',
175
+ recipient: 'wallet_address_here',
176
+ mint: 'token_mint_address_here',
177
+ chain: 'SOLANA',
178
+ webhookURL: 'webhook_url',
179
+ token: 'token_from_verification',
180
+ });
181
+ // Response: { id: string, accountNumber: string, accountName: string, fiatAmount: number, bank: string }
182
+ ```
183
+
184
+ ### Usage Example
185
+
186
+ ```typescript
187
+ import { observeOrder, createOrder } from 'paj_ramp';
188
+
189
+ async function example(orderId) {
190
+ console.log('Observe Order');
191
+
192
+ const observer = observeOrder({
193
+ orderId,
194
+ onOrderUpdate: data => {
195
+ console.log('Order update received:', data);
196
+ console.log('Status:', data.status);
197
+ console.log('Amount:', data.amount);
198
+ console.log('Currency:', data.currency);
199
+ },
200
+ onError: error => {
201
+ console.error('Socket error:', error);
202
+ },
203
+ onConnect: () => {
204
+ console.log('Connected to order socket');
205
+ },
206
+ onDisconnect: () => {
207
+ console.log('Disconnected from order socket');
208
+ },
209
+ onConnectionStatusChange: connected => {
210
+ console.log(
211
+ 'Connection status changed:',
212
+ connected ? 'Connected' : 'Disconnected'
213
+ );
214
+ },
215
+ });
216
+
217
+ try {
218
+ await observer.connect();
219
+ console.log('Successfully connected to order observer');
220
+
221
+ // Keep the connection alive for 1 minute
222
+ setTimeout(() => {
223
+ console.log('Disconnecting after 1 minute...');
224
+ observer.disconnect();
225
+ }, 1 * 60 * 1000);
226
+ } catch (error) {
227
+ console.error('Failed to connect:', error);
228
+ }
229
+ }
230
+
231
+ const order = await createOrder({
232
+ fiatAmount: 10000,
233
+ currency: 'NGN',
234
+ recipient: 'your_wallet_address',
235
+ mint: 'your_token_mint_address',
236
+ chain: 'SOLANA',
237
+ webhookURL: 'webhook_url',
238
+ token: token_from_verification,
239
+ });
240
+
241
+ await example(order.id);
242
+ // Response: { id: string, fiatAmount: string, currency: string, , recipient: string, mint: string, chain: Chain, amount: number, status: OnRampStatus }
243
+ ```
244
+
245
+ ---
246
+
247
+ # Offramp SDK
248
+
249
+ ## Overview
250
+
251
+ The Offramp SDK provides a set of functions to help users convert Solana-based digital assets to fiat and transfer the resulting funds to traditional bank accounts. It includes session management, rate queries, bank account management, and wallet operations.
252
+
253
+ ## Usage Examples
254
+
255
+ <!-- ### Get TX Pool Address
256
+
257
+ ```typescript
258
+ import { getTXPoolAddress } from "paj_ramp";
259
+
260
+ const txpooladdress = await getTXPoolAddress();
261
+ // Response: { address: string }
262
+ ``` -->
263
+
264
+ ### Get Rate
265
+
266
+ ```typescript
267
+ import { getRate } from 'paj_ramp';
268
+
269
+ const rate = await getRate();
270
+ /*
271
+ Response:
272
+ {
273
+ "onRampRate": {
274
+ "baseCurrency": "USD",
275
+ "targetCurrency": "NGN",
276
+ "isActive": true,
277
+ "rate": 1510,
278
+ "type": "onRamp"
279
+ },
280
+ "offRampRate": {
281
+ "baseCurrency": "USD",
282
+ "targetCurrency": "NGN",
283
+ "isActive": true,
284
+ "rate": 1525,
285
+ "type": "offRamp"
286
+ }
287
+ }*/
288
+ ```
289
+
290
+ ### Get Rate by Amount
291
+
292
+ ```typescript
293
+ import { getRate } from 'paj_ramp';
294
+
295
+ const rate = await getRate(50000);
296
+ /*
297
+ Response:
298
+ {
299
+ rate: {
300
+ baseCurrency: string,
301
+ targetCurrency: string,
302
+ rate: number
303
+ },
304
+ amounts: {
305
+ userTax": number,
306
+ merchantTax": number,
307
+ amountUSD": number,
308
+ userAmountFiat": number
309
+ }
310
+ }*/
311
+ ```
312
+
313
+ ### Get Token Value from Amount and Mint Token
314
+
315
+ ```typescript
316
+ import { getRate } from 'paj_ramp';
317
+
318
+ const tokenValue = await getRate(
319
+ 50000,
320
+ 'token_mint_address'
321
+ );
322
+ /*
323
+ Response:
324
+ {
325
+ amount: number, // requested token amount
326
+ usdcValue: number, // USD value of the token amount
327
+ mint: string // token mint address
328
+ }
329
+ */
330
+ ```
331
+
332
+ ### Get Rate by Rate Type
333
+
334
+ ```typescript
335
+ import { getRate, RateType } from 'paj_ramp';
336
+
337
+ const rate = await getRate(RateType.offRamp); // or RateType.onRamp
338
+
339
+ /*
340
+ Response:
341
+ "offRampRate": {
342
+ "baseCurrency": "USD",
343
+ "targetCurrency": "NGN",
344
+ "isActive": true,
345
+ "rate": 1525,
346
+ "type": "offRamp"
347
+ }*/
348
+ ```
349
+
350
+ ### Initiate Session
351
+
352
+ ```typescript
353
+ import { initiate } from 'paj_ramp';
354
+
355
+ const initiated = await initiate('your_email@gmail.com', 'business_api_key');
356
+ // Response: { email: string }
357
+ ```
358
+
359
+ ### Verify Session
360
+
361
+ ```typescript
362
+ import { verify } from 'paj_ramp';
363
+
364
+ const verified = await verify(
365
+ 'your_email@gmail.com',
366
+ 'otp',
367
+ {
368
+ uuid: string,
369
+ device: string,
370
+ //optionL ↓↓↓↓↓
371
+ os: string, //IOS
372
+ browser: string, //chrome
373
+ ip: string,
374
+ },
375
+ 'business_api_key'
376
+ );
377
+ // Response: { email: string, isActive: string, expiresAt: string, token: string }
378
+ ```
379
+
380
+ ### Get Banks
381
+
382
+ ```typescript
383
+ import { getBanks } from 'paj_ramp';
384
+
385
+ const banks = await getBanks('token');
386
+ // Response: [ { id: string, name: string, country: string } ]
387
+ ```
388
+
389
+ ### Resolve Bank Account
390
+
391
+ ```typescript
392
+ import { resolveBankAccount } from 'paj_ramp';
393
+
394
+ const resolvedBankAccount = await resolveBankAccount(
395
+ 'token',
396
+ 'bank_id',
397
+ 'account_number'
398
+ );
399
+ // Response: { accountName: string, accountNumber: string, bank: { id: string, name: string, code: string, country: string } }
400
+ ```
401
+
402
+ ### Add Bank Account
403
+
404
+ ```typescript
405
+ import { addBankAccount } from 'paj_ramp';
406
+
407
+ const addedBankAccount = await addBankAccount(
408
+ 'token',
409
+ 'bank_id',
410
+ 'account_number'
411
+ );
412
+ // Response: { id: string, accountName: string, accountNumber: string, bank: string }
413
+ ```
414
+
415
+ ### Get Bank Accounts
416
+
417
+ ```typescript
418
+ import { getBankAccounts } from 'paj_ramp';
419
+
420
+ const accounts = await getBankAccounts('token');
421
+ // Response: [ { id: string, accountName: string, accountNumber: string, bank: string } ]
422
+ ```
423
+
424
+ # Offramp 2 (Direct Offramp)
425
+
426
+ ## Usage Examples
427
+
428
+ ### Create Order
429
+
430
+ ```typescript
431
+ import { offRampCreateOrder } from 'paj_ramp';
432
+
433
+ const createOrder = await offRampCreateOrder(
434
+ 'token',
435
+ 'bank_id',
436
+ 'account_number',
437
+ 'NGN', // Currency
438
+ 10000, // amount
439
+ 'token_mint_address'
440
+ 'webhook_url'
441
+ );
442
+ // Response: { id: string, address: string, signature?: string, mint: string, currency: Currency, amount: number, usdcAmount: number, fiatAmount: number, sender: string, receipiant: string, rate: number, status: TransactionStatus, transactionType: TransactionType }
443
+ ```
444
+
445
+ <!--
446
+ ### Get Wallet Info
447
+
448
+ ```typescript
449
+ import { getWallet } from 'paj_ramp';
450
+
451
+ const wallet = await getWallet('wallet public key');
452
+ // Response: { id: string, publicKey: string, bankAccount: { id: string, accountName: string, accountNumber: string, bank: string } }
453
+ ``` -->
454
+ <!--
455
+ ### Add Wallet
456
+
457
+ ```typescript
458
+ import { addWallet } from 'paj_ramp';
459
+
460
+ // To create wallet.json file with an array of 64 numbers
461
+ // npm install @solana/web3.js then run this code
462
+ import { Keypair } from '@solana/web3.js';
463
+ import fs from 'fs';
464
+
465
+ const keypair = Keypair.generate();
466
+ const secretKey = Array.from(keypair.secretKey);
467
+
468
+ fs.writeFileSync('wallet.json', JSON.stringify(secretKey));
469
+ console.log('✅ wallets.json generated successfully');
470
+
471
+ // To get secret key
472
+ import * as fs from 'fs';
473
+ import { fileURLToPath } from 'url';
474
+ import { dirname, resolve } from 'path';
475
+
476
+ const __filename = fileURLToPath(import.meta.url);
477
+ const __dirname = dirname(__filename);
478
+
479
+ // wallet.json that you created with an array of 64 numbers
480
+ const walletPath = resolve(__dirname, './wallet.json');
481
+ const secretKeyRaw = fs.readFileSync(walletPath, 'utf8');
482
+ const secretKeyArray = JSON.parse(secretKeyRaw);
483
+
484
+ if (!Array.isArray(secretKeyArray) || secretKeyArray.length !== 64) {
485
+ throw new Error('Invalid secret key: must be an array of 64 numbers.');
486
+ }
487
+
488
+ const secretKey = Uint8Array.from(secretKeyArray);
489
+
490
+ const addedWallet = await addWallet('token', 'bank account id', secretKey);
491
+ // Response: { id: string, publicKey: string, bankAccount: { id: string, accountName: string, accountNumber: string, bank: string } }
492
+ ``` -->
493
+ <!--
494
+ ### Switch Bank Account on Wallet
495
+
496
+ ```typescript
497
+ import { switchWalletBankAccount } from 'paj_ramp';
498
+
499
+ const switchedWallet = await switchWalletBankAccount(
500
+ 'token',
501
+ 'bank account id to switch to',
502
+ 'wallet id',
503
+ 'secret key'
504
+ );
505
+ // Response: { id: string, publicKey: string, bankAccount: { id: string, accountName: string, accountNumber: string, bank: string } }
506
+ ``` -->
507
+
508
+ ## License
509
+
510
+ MIT
511
+
512
+ ## 🧑‍💻 Author
513
+
514
+ Gospel Chidiebube Chukwu