paj_ramp 1.2.5 → 1.2.7

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,14 +1,6 @@
1
1
  # PAJ Ramp SDK
2
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
3
+ A comprehensive SDK for PAJ Ramp onramp and offramp operations with real-time transaction updates using webhooks.
12
4
 
13
5
  ## Installation
14
6
 
@@ -20,9 +12,9 @@ npm install paj_ramp
20
12
  yarn add paj_ramp
21
13
  ```
22
14
 
23
- ---
15
+ ## Getting Started
24
16
 
25
- ## Initialize SDK (select environment: "staging" | "production")
17
+ ### Initialize SDK (select environment: "staging" | "production")
26
18
 
27
19
  ```typescript
28
20
  import { initializeSDK } from 'paj_ramp';
@@ -31,10 +23,208 @@ import { initializeSDK } from 'paj_ramp';
31
23
  initializeSDK('staging'); // or production
32
24
  ```
33
25
 
34
- ---
26
+ ### Initiate Session
27
+
28
+ ```typescript
29
+ import { initiate } from 'paj_ramp';
35
30
 
36
- # Onramp SDK (Real-time Order Observation)
31
+ const initiated = await initiate('your_email@gmail.com', 'business_api_key');
32
+ // Response: { email: string }
33
+ ```
37
34
 
35
+ ### Verify Session
36
+
37
+ ```typescript
38
+ import { verify } from 'paj_ramp';
39
+
40
+ const verified = await verify(
41
+ 'your_email@gmail.com',
42
+ 'otp',
43
+ {
44
+ uuid: string,
45
+ device: string,
46
+ //optionL ↓↓↓↓↓
47
+ os: string, //IOS
48
+ browser: string, //chrome
49
+ ip: string,
50
+ },
51
+ 'business_api_key'
52
+ );
53
+ // Response: { email: string, isActive: string, expiresAt: string, token: string }
54
+ ```
55
+
56
+ ## Utility Endpoints
57
+
58
+ ### Handle Rate:
59
+
60
+ **_Get All Rate_**
61
+
62
+ ```typescript
63
+ import { getRate } from 'paj_ramp';
64
+
65
+ const rate = await getRate();
66
+ /*
67
+ Response:
68
+ {
69
+ "onRampRate": {
70
+ "baseCurrency": "USD",
71
+ "targetCurrency": "NGN",
72
+ "isActive": true,
73
+ "rate": 1510,
74
+ "type": "onRamp"
75
+ },
76
+ "offRampRate": {
77
+ "baseCurrency": "USD",
78
+ "targetCurrency": "NGN",
79
+ "isActive": true,
80
+ "rate": 1525,
81
+ "type": "offRamp"
82
+ }
83
+ }*/
84
+ ```
85
+
86
+ **_Get Rate by Amount_**
87
+
88
+ ```typescript
89
+ import { getRate } from 'paj_ramp';
90
+
91
+ const rate = await getRate(50000);
92
+ /*
93
+ Response:
94
+ {
95
+ rate: {
96
+ baseCurrency: string,
97
+ targetCurrency: string,
98
+ rate: number
99
+ },
100
+ amounts: {
101
+ userTax": number,
102
+ merchantTax": number,
103
+ amountUSD": number,
104
+ userAmountFiat": number
105
+ }
106
+ }*/
107
+ ```
108
+
109
+ **_Get Rate by Rate Type_**
110
+
111
+ ```typescript
112
+ import { getRate, RateType } from 'paj_ramp';
113
+
114
+ const rate = await getRate(RateType.offRamp); // or RateType.onRamp
115
+
116
+ /*
117
+ Response:
118
+ "offRampRate": {
119
+ "baseCurrency": "USD",
120
+ "targetCurrency": "NGN",
121
+ "isActive": true,
122
+ "rate": 1525,
123
+ "type": "offRamp"
124
+ }*/
125
+ ```
126
+
127
+ **_Get Token Value from Amount and Mint Token_**
128
+
129
+ ```typescript
130
+ import { getRate } from 'paj_ramp';
131
+
132
+ const tokenValue = await getRate(50000, 'token_mint_address');
133
+ /*
134
+ Response:
135
+ {
136
+ amount: number, // requested token amount
137
+ usdcValue: number, // USDC value of the token amount
138
+ mint: string // token mint address
139
+ }
140
+ */
141
+ ```
142
+
143
+ ### Handle Banks:
144
+
145
+ **_Get Banks_**
146
+
147
+ ```typescript
148
+ import { getBanks } from 'paj_ramp';
149
+
150
+ const banks = await getBanks('token');
151
+ // Response: [ { id: string, name: string, country: string } ]
152
+ ```
153
+
154
+ **_Resolve Bank Account_**
155
+
156
+ ```typescript
157
+ import { resolveBankAccount } from 'paj_ramp';
158
+
159
+ const resolvedBankAccount = await resolveBankAccount(
160
+ 'token',
161
+ 'bank_id',
162
+ 'account_number'
163
+ );
164
+ // Response: { accountName: string, accountNumber: string, bank: { id: string, name: string, code: string, country: string } }
165
+ ```
166
+
167
+ **_Add Bank Account_**
168
+
169
+ ```typescript
170
+ import { addBankAccount } from 'paj_ramp';
171
+
172
+ const addedBankAccount = await addBankAccount(
173
+ 'token',
174
+ 'bank_id',
175
+ 'account_number'
176
+ );
177
+ // Response: { id: string, accountName: string, accountNumber: string, bank: string }
178
+ ```
179
+
180
+ **_Get Bank Accounts_**
181
+
182
+ ```typescript
183
+ import { getBankAccounts } from 'paj_ramp';
184
+
185
+ const accounts = await getBankAccounts('token');
186
+ // Response: [ { id: string, accountName: string, accountNumber: string, bank: string } ]
187
+ ```
188
+
189
+ ## Offramp Webhook (Direct Offramp)
190
+
191
+ ### Usage Example
192
+
193
+ ```typescript
194
+ import { offRampCreateOrder } from 'paj_ramp';
195
+
196
+ const createOrder = await offRampCreateOrder(
197
+ 'token',
198
+ 'bank_id',
199
+ 'account_number',
200
+ 'NGN', // Currency
201
+ 10000, // amount
202
+ 'token_mint_address'
203
+ 'webhook_url'
204
+ );
205
+ // 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 }
206
+ ```
207
+
208
+ ## Onramp Webhook: Creates a new onramp order and sends status to the webhook url.
209
+
210
+ ### Usage Example
211
+
212
+ ```typescript
213
+ import { createOrder } from 'paj_ramp';
214
+
215
+ const order = await createOrder({
216
+ fiatAmount: 10000,
217
+ currency: 'NGN',
218
+ recipient: 'wallet_address_here',
219
+ mint: 'token_mint_address_here',
220
+ chain: 'SOLANA', //ethereum, polygon, etc
221
+ webhookURL: 'your_webhook_url',
222
+ token: 'token_from_verification',
223
+ });
224
+ // Response: { id: string, accountNumber: string, accountName: string, fiatAmount: number, bank: string }
225
+ ```
226
+
227
+ <!--
38
228
  ## Quick Start
39
229
 
40
230
  ### Real-time Order Observation
@@ -142,45 +332,6 @@ Common error messages:
142
332
  - `"Connection failed"`
143
333
  - `"Socket timeout"`
144
334
 
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
335
  ### Usage Example
185
336
 
186
337
  ```typescript
@@ -240,270 +391,9 @@ const order = await createOrder({
240
391
 
241
392
  await example(order.id);
242
393
  // 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
394
  ``` -->
493
- <!--
494
- ### Switch Bank Account on Wallet
495
395
 
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
- ``` -->
396
+ ---
507
397
 
508
398
  ## License
509
399
 
@@ -1,17 +1,17 @@
1
1
  type AllRateResponseType = {
2
2
  onRampRate: {
3
- baseCurrency: 'USD';
4
- targetCurrency: 'NGN';
5
- isActive: true;
6
- rate: 1510;
7
- type: 'onRamp';
3
+ baseCurrency: string;
4
+ targetCurrency: string;
5
+ isActive: boolean;
6
+ rate: number;
7
+ type: string;
8
8
  };
9
9
  offRampRate: {
10
- baseCurrency: 'USD';
11
- targetCurrency: 'NGN';
12
- isActive: true;
13
- rate: 1525;
14
- type: 'offRamp';
10
+ baseCurrency: string;
11
+ targetCurrency: string;
12
+ isActive: boolean;
13
+ rate: number;
14
+ type: string;
15
15
  };
16
16
  };
17
17
  type RateByAmountType = {
@@ -28,11 +28,11 @@ type RateByAmountType = {
28
28
  };
29
29
  };
30
30
  type RateByRateTypeType = {
31
- baseCurrency: 'USD';
32
- targetCurrency: 'NGN';
31
+ baseCurrency: string;
32
+ targetCurrency: string;
33
33
  isActive: true;
34
- rate: 1525;
35
- type: 'offRamp';
34
+ rate: number;
35
+ type: string;
36
36
  };
37
37
  type TokenValueType = {
38
38
  amount: number;
@@ -2,18 +2,18 @@ import { get } from '../../utils/api.js';
2
2
 
3
3
  type AllRateResponseType = {
4
4
  onRampRate: {
5
- baseCurrency: 'USD';
6
- targetCurrency: 'NGN';
7
- isActive: true;
8
- rate: 1510;
9
- type: 'onRamp';
5
+ baseCurrency: string;
6
+ targetCurrency: string;
7
+ isActive: boolean;
8
+ rate: number;
9
+ type: string;
10
10
  };
11
11
  offRampRate: {
12
- baseCurrency: 'USD';
13
- targetCurrency: 'NGN';
14
- isActive: true;
15
- rate: 1525;
16
- type: 'offRamp';
12
+ baseCurrency: string;
13
+ targetCurrency: string;
14
+ isActive: boolean;
15
+ rate: number;
16
+ type: string;
17
17
  };
18
18
  };
19
19
 
@@ -32,11 +32,11 @@ type RateByAmountType = {
32
32
  };
33
33
 
34
34
  type RateByRateTypeType = {
35
- baseCurrency: 'USD';
36
- targetCurrency: 'NGN';
35
+ baseCurrency: string;
36
+ targetCurrency: string;
37
37
  isActive: true;
38
- rate: 1525;
39
- type: 'offRamp';
38
+ rate: number;
39
+ type: string;
40
40
  };
41
41
 
42
42
  type TokenValueType = {
@@ -120,7 +120,6 @@ export const getRateByAmount = async (url: string, amount: number) => {
120
120
  }
121
121
  };
122
122
 
123
-
124
123
  /**
125
124
  * The function `getRateByRateType` fetches a rate based on a specified rate type from a given URL.
126
125
  * @param {string} url - The `url` parameter is a string representing the base URL used to fetch data.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paj_ramp",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "paj offramp/onramp service",
5
5
  "main": "dist/sdk.js",
6
6
  "types": "dist/sdk.d.ts",
@@ -15,7 +15,10 @@
15
15
  "url": "git+https://github.com/paj-cash/paj_ramp.git"
16
16
  },
17
17
  "keywords": [
18
- "PAJ"
18
+ "PAJ",
19
+ "paj",
20
+ "paj_ramp",
21
+ "Paj"
19
22
  ],
20
23
  "author": "Ebube",
21
24
  "license": "ISC",