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 +514 -470
- package/dist/lib/direct_off_ramp/directCreateOrder.d.ts +19 -0
- package/dist/lib/direct_off_ramp/directCreateOrder.js +23 -0
- package/dist/lib/off_ramp/addBankAccount.js +1 -1
- package/dist/lib/off_ramp/getBankAccounts.js +1 -1
- package/dist/lib/off_ramp/getBanks.d.ts +1 -1
- package/dist/lib/off_ramp/getBanks.js +6 -4
- package/dist/lib/off_ramp/getRate.d.ts +67 -45
- package/dist/lib/off_ramp/getRate.js +69 -57
- package/dist/lib/off_ramp/resolveBankAccount.d.ts +1 -1
- package/dist/lib/off_ramp/resolveBankAccount.js +6 -4
- package/dist/lib/on_ramp/createOrder.d.ts +1 -0
- package/dist/lib/on_ramp/createOrder.js +2 -1
- package/dist/sdk.d.ts +7 -9
- package/dist/sdk.js +18 -14
- package/jest.config.js +8 -8
- package/lib/direct_off_ramp/directCreateOrder.ts +60 -0
- package/lib/off_ramp/addBankAccount.ts +1 -1
- package/lib/off_ramp/getBankAccounts.ts +1 -1
- package/lib/off_ramp/getBanks.ts +10 -4
- package/lib/off_ramp/getRate.ts +95 -68
- package/lib/off_ramp/resolveBankAccount.ts +8 -3
- package/lib/on_ramp/createOrder.ts +3 -1
- package/package.json +42 -42
- package/sdk.ts +22 -15
- package/versions +0 -0
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
|
|
29
|
-
|
|
30
|
-
// Selects the environment you want to work with
|
|
31
|
-
initializeSDK(
|
|
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
|
|
46
|
-
|
|
47
|
-
// Using observeOrder function
|
|
48
|
-
const observer = observeOrder({
|
|
49
|
-
orderId:
|
|
50
|
-
onOrderUpdate:
|
|
51
|
-
console.log(
|
|
52
|
-
// Handle status changes: pending, processing, completed, failed, cancelled
|
|
53
|
-
},
|
|
54
|
-
onError:
|
|
55
|
-
console.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
|
|
109
|
-
|
|
110
|
-
const observer = observeOrder({
|
|
111
|
-
orderId:
|
|
112
|
-
onOrderUpdate:
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
// Connect manually
|
|
116
|
-
await observer.connect();
|
|
117
|
-
|
|
118
|
-
// Check connection status
|
|
119
|
-
console.log(
|
|
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:
|
|
132
|
-
onError:
|
|
133
|
-
// Handle connection errors, order not found, etc.
|
|
134
|
-
console.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
|
|
171
|
-
|
|
172
|
-
const order = await createOrder({
|
|
173
|
-
fiatAmount: 10000,
|
|
174
|
-
currency:
|
|
175
|
-
recipient:
|
|
176
|
-
mint:
|
|
177
|
-
chain:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
console.log(
|
|
196
|
-
console.log(
|
|
197
|
-
console.log(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
"
|
|
275
|
-
"
|
|
276
|
-
"
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
"
|
|
282
|
-
"
|
|
283
|
-
"
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
"
|
|
345
|
-
"
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
);
|
|
356
|
-
// Response: { email: string
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
###
|
|
360
|
-
|
|
361
|
-
```typescript
|
|
362
|
-
import {
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
);
|
|
377
|
-
// Response: {
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
###
|
|
381
|
-
|
|
382
|
-
```typescript
|
|
383
|
-
import {
|
|
384
|
-
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
// Response:
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
###
|
|
403
|
-
|
|
404
|
-
```typescript
|
|
405
|
-
import {
|
|
406
|
-
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
import {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
//
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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
|