paj_ramp 1.4.0 → 1.4.2

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
@@ -17,10 +17,10 @@ yarn add paj_ramp
17
17
  ### Initialize SDK (select environment: "staging" | "production")
18
18
 
19
19
  ```typescript
20
- import { initializeSDK } from "paj_ramp";
20
+ import { initializeSDK, Environment } from 'paj_ramp';
21
21
 
22
22
  // Selects the environment you want to work with
23
- initializeSDK("staging"); // or production
23
+ initializeSDK(Environment.Production); // or Environment.Staging
24
24
  ```
25
25
 
26
26
  ### Initiate Session
@@ -40,13 +40,13 @@ const initiated = await initiate(
40
40
  ### Verify Session
41
41
 
42
42
  ```typescript
43
- import { verify } from "paj_ramp";
43
+ import { verify } from 'paj_ramp';
44
44
 
45
45
  // You can get otp by either adding your phone number or email address
46
46
  // Phone number must start with a country code
47
47
  const verified = await verify(
48
- "your_email@gmail.com", // or +2349053231563
49
- "otp",
48
+ 'your_email@gmail.com', // or +2349053231563
49
+ 'otp',
50
50
  {
51
51
  uuid: string,
52
52
  device: string,
@@ -55,7 +55,7 @@ const verified = await verify(
55
55
  browser: string, //chrome
56
56
  ip: string,
57
57
  },
58
- "business_api_key"
58
+ 'business_api_key'
59
59
  );
60
60
  /* Response: {
61
61
  email?: string,
@@ -91,7 +91,7 @@ npm start
91
91
  **_Get All Rate_**
92
92
 
93
93
  ```typescript
94
- import { getAllRate } from "paj_ramp";
94
+ import { getAllRate } from 'paj_ramp';
95
95
 
96
96
  const rate = await getAllRate();
97
97
  /*
@@ -117,7 +117,7 @@ Response:
117
117
  **_Get Rate by Amount_**
118
118
 
119
119
  ```typescript
120
- import { getRateByAmount } from "paj_ramp";
120
+ import { getRateByAmount } from 'paj_ramp';
121
121
 
122
122
  const rate = await getRateByAmount(50000);
123
123
  /*
@@ -140,7 +140,7 @@ Response:
140
140
  **_Get Rate by Rate Type_**
141
141
 
142
142
  ```typescript
143
- import { getRateByType, RateType } from "paj_ramp";
143
+ import { getRateByType, RateType } from 'paj_ramp';
144
144
 
145
145
  const rate = await getRateByType(RateType.offRamp); // or RateType.onRamp
146
146
 
@@ -158,9 +158,9 @@ Response:
158
158
  **_Get Token Value from Amount and Mint Token_**
159
159
 
160
160
  ```typescript
161
- import { getTokenValue } from "paj_ramp";
161
+ import { getTokenValue } from 'paj_ramp';
162
162
 
163
- const tokenValue = await getTokenValue(50000, "token_mint_address");
163
+ const tokenValue = await getTokenValue(50000, 'token_mint_address');
164
164
  /*
165
165
  Response:
166
166
  {
@@ -176,21 +176,21 @@ Response:
176
176
  **_Get Banks_**
177
177
 
178
178
  ```typescript
179
- import { getBanks } from "paj_ramp";
179
+ import { getBanks } from 'paj_ramp';
180
180
 
181
- const banks = await getBanks("token");
181
+ const banks = await getBanks('token');
182
182
  // Response: [ { id: string, name: string, country: string } ]
183
183
  ```
184
184
 
185
185
  **_Resolve Bank Account_**
186
186
 
187
187
  ```typescript
188
- import { resolveBankAccount } from "paj_ramp";
188
+ import { resolveBankAccount } from 'paj_ramp';
189
189
 
190
190
  const resolvedBankAccount = await resolveBankAccount(
191
- "token",
192
- "bank_id",
193
- "account_number"
191
+ 'token',
192
+ 'bank_id',
193
+ 'account_number'
194
194
  );
195
195
  // Response: { accountName: string, accountNumber: string, bank: { id: string, name: string, code: string, country: string } }
196
196
  ```
@@ -198,12 +198,12 @@ const resolvedBankAccount = await resolveBankAccount(
198
198
  **_Add Bank Account_**
199
199
 
200
200
  ```typescript
201
- import { addBankAccount } from "paj_ramp";
201
+ import { addBankAccount } from 'paj_ramp';
202
202
 
203
203
  const addedBankAccount = await addBankAccount(
204
- "token",
205
- "bank_id",
206
- "account_number"
204
+ 'token',
205
+ 'bank_id',
206
+ 'account_number'
207
207
  );
208
208
  // Response: { id: string, accountName: string, accountNumber: string, bank: string }
209
209
  ```
@@ -211,9 +211,9 @@ const addedBankAccount = await addBankAccount(
211
211
  **_Get Bank Accounts_**
212
212
 
213
213
  ```typescript
214
- import { getBankAccounts } from "paj_ramp";
214
+ import { getBankAccounts } from 'paj_ramp';
215
215
 
216
- const accounts = await getBankAccounts("token");
216
+ const accounts = await getBankAccounts('token');
217
217
  // Response: [ { id: string, accountName: string, accountNumber: string, bank: string } ]
218
218
  ```
219
219
 
@@ -222,9 +222,9 @@ const accounts = await getBankAccounts("token");
222
222
  **_Get All Transactions_**
223
223
 
224
224
  ```typescript
225
- import { getAllTransactions } from "paj_ramp";
225
+ import { getAllTransactions } from 'paj_ramp';
226
226
 
227
- const transactions = await getAllTransactions("token_from_verification");
227
+ const transactions = await getAllTransactions('token_from_verification');
228
228
  /* Response: [{
229
229
  id: string;
230
230
  address: string;
@@ -245,11 +245,11 @@ createdAt: string | Date;
245
245
  **_Get Transaction_**
246
246
 
247
247
  ```typescript
248
- import { getTransaction } from "paj_ramp";
248
+ import { getTransaction } from 'paj_ramp';
249
249
 
250
250
  const transactions = await getTransaction(
251
- "token_from_verification",
252
- "transaction_id"
251
+ 'token_from_verification',
252
+ 'transaction_id'
253
253
  );
254
254
  /* Response: {
255
255
  id: string;
@@ -273,31 +273,31 @@ createdAt: string | Date;
273
273
  ### Usage Example
274
274
 
275
275
  ```typescript
276
- import { offRampCreateOrder } from 'paj_ramp';
276
+ import { createOfframpOrder, Currency } from 'paj_ramp';
277
277
 
278
- const createOrder = await offRampCreateOrder(
279
- 'token',
280
- 'bank_id',
281
- 'account_number',
282
- 'NGN', // Currency
283
- 10000, // amount
284
- 'token_mint_address'
285
- 'webhook_url'
278
+ const createOrder = await createOfframpOrder(
279
+ {
280
+ bank: 'bank_id',
281
+ accountNumber: 'account_number',
282
+ currency: 'NGN' as Currency, // Currency
283
+ amount: 10000, // amount
284
+ mint: 'token_mint_address',
285
+ webhookURL: 'webhook_url', // https://your-domain.com/webhook
286
+ },
287
+ 'token'
286
288
  );
287
289
  /* Response: {
288
290
  id: string,
289
291
  address: string,
290
- signature?: string,
291
292
  mint: string,
292
293
  currency: Currency,
293
294
  amount: number,
294
- usdcAmount: number,
295
295
  fiatAmount: number,
296
296
  sender: string,
297
- receipint: string,
298
297
  rate: number,
299
298
  status: TransactionStatus,
300
299
  transactionType: TransactionType
300
+ createdAt: string
301
301
  }*/
302
302
  ```
303
303
 
@@ -306,17 +306,19 @@ transactionType: TransactionType
306
306
  ### Usage Example
307
307
 
308
308
  ```typescript
309
- import { createOrder } from "paj_ramp";
310
-
311
- const order = await createOrder({
312
- fiatAmount: 10000,
313
- currency: "NGN",
314
- recipient: "wallet_address_here",
315
- mint: "token_mint_address_here",
316
- chain: "SOLANA", //ethereum, polygon, etc
317
- webhookURL: "your_webhook_url",
318
- token: "token_from_verification",
319
- });
309
+ import { createOrder, Currency } from 'paj_ramp';
310
+
311
+ const order = await createOrder(
312
+ {
313
+ fiatAmount: 10000,
314
+ currency: 'NGN' as Currency,
315
+ recipient: 'wallet_address_here',
316
+ mint: 'token_mint_address_here',
317
+ chain: 'SOLANA', //ethereum, polygon, etc
318
+ webhookURL: 'your_webhook_url', // https://your-domain.com/webhook
319
+ },
320
+ 'token_from_verification'
321
+ );
320
322
  // Response: { id: string, accountNumber: string, accountName: string, fiatAmount: number, bank: string }
321
323
  ```
322
324
 
@@ -350,180 +352,11 @@ import {
350
352
  TransactionStatus, // INIT, etc
351
353
  TransactionType, // ON_RAMP, etc
352
354
  Currency, // NGN
353
- } from "paj_ramp";
354
- ```
355
-
356
- <!--
357
- ## Quick Start
358
-
359
- ### Real-time Order Observation
360
-
361
- The SDK provides Socket.IO functionality to observe onramp orders in real-time:
362
-
363
- ```typescript
364
- import { observeOrder } from 'paj_ramp';
365
-
366
- // Using observeOrder function
367
- const observer = observeOrder({
368
- orderId: 'your_order_id',
369
- onOrderUpdate: data => {
370
- console.log('Order update:', data);
371
- // Handle status changes: pending, processing, completed, failed, cancelled
372
- },
373
- onError: error => {
374
- console.error('Socket error:', error);
375
- },
376
- });
377
-
378
- await observer.connect();
379
- ```
380
-
381
- ### Order Update Data Structure
382
-
383
- ```typescript
384
- interface OnRampOrderUpdate {
385
- id: string;
386
- fiatAmount: string;
387
- currency: string;
388
- recipient: string; // wallet address
389
- mint: string; // token address
390
- chain: Chain; // enum: 'solana', 'ethereum', 'polygon'
391
- status: OnRampStatus; // enum: 'pending', 'processing', 'completed', 'failed', 'cancelled'
392
- }
393
- ```
394
-
395
- ### Socket Events
396
-
397
- The SDK listens for these Socket.IO events:
398
-
399
- - **ORDER_UPDATE**: Real-time order status updates
400
- - **ERROR**: Error messages from the server
401
-
402
- ## API Reference
403
-
404
- ### observeOrder(options)
405
-
406
- Creates an order observer.
407
-
408
- **Parameters:**
409
-
410
- - `options.orderId` (string, required): The order ID to observe
411
- - `options.onOrderUpdate` (function, optional): Callback for order updates
412
- - `options.onError` (function, optional): Callback for errors
413
- - `options.onConnect` (function, optional): Callback when connected
414
- - `options.onDisconnect` (function, optional): Callback when disconnected
415
- - `options.onConnectionStatusChange` (function, optional): Callback for connection status changes
416
-
417
- **Returns:**
418
-
419
- - `socket`: The Socket.IO instance
420
- - `isConnected()`: Function to check connection status
421
- - `connect()`: Function to connect to the socket
422
- - `disconnect()`: Function to disconnect from the socket
423
-
424
- **Example:**
425
-
426
- ```typescript
427
- import { observeOrder } from 'paj_ramp';
428
-
429
- const observer = observeOrder({
430
- orderId: 'your_order_id',
431
- onOrderUpdate: data => console.log(data),
432
- });
433
-
434
- // Connect manually
435
- await observer.connect();
436
-
437
- // Check connection status
438
- console.log('Connected:', observer.isConnected());
439
-
440
- // Disconnect manually: you could use setTimeout to keep the socket alive for a certain amount of time before you disconnect
441
- observer.disconnect();
355
+ Environment,
356
+ RateType,
357
+ } from 'paj_ramp';
442
358
  ```
443
359
 
444
- ## Error Handling
445
-
446
- The SDK provides comprehensive error handling:
447
-
448
- ```typescript
449
- const observer = observeOrder({
450
- orderId: 'your_order_id',
451
- onError: error => {
452
- // Handle connection errors, order not found, etc.
453
- console.error('Socket error:', error);
454
- },
455
- });
456
- ```
457
-
458
- Common error messages:
459
-
460
- - `"Order not found: {orderId}"`
461
- - `"Connection failed"`
462
- - `"Socket timeout"`
463
-
464
- ### Usage Example
465
-
466
- ```typescript
467
- import { observeOrder, createOrder } from 'paj_ramp';
468
-
469
- async function example(orderId) {
470
- console.log('Observe Order');
471
-
472
- const observer = observeOrder({
473
- orderId,
474
- onOrderUpdate: data => {
475
- console.log('Order update received:', data);
476
- console.log('Status:', data.status);
477
- console.log('Amount:', data.amount);
478
- console.log('Currency:', data.currency);
479
- },
480
- onError: error => {
481
- console.error('Socket error:', error);
482
- },
483
- onConnect: () => {
484
- console.log('Connected to order socket');
485
- },
486
- onDisconnect: () => {
487
- console.log('Disconnected from order socket');
488
- },
489
- onConnectionStatusChange: connected => {
490
- console.log(
491
- 'Connection status changed:',
492
- connected ? 'Connected' : 'Disconnected'
493
- );
494
- },
495
- });
496
-
497
- try {
498
- await observer.connect();
499
- console.log('Successfully connected to order observer');
500
-
501
- // Keep the connection alive for 1 minute
502
- setTimeout(() => {
503
- console.log('Disconnecting after 1 minute...');
504
- observer.disconnect();
505
- }, 1 * 60 * 1000);
506
- } catch (error) {
507
- console.error('Failed to connect:', error);
508
- }
509
- }
510
-
511
- const order = await createOrder({
512
- fiatAmount: 10000,
513
- currency: 'NGN',
514
- recipient: 'your_wallet_address',
515
- mint: 'your_token_mint_address',
516
- chain: 'SOLANA',
517
- webhookURL: 'webhook_url',
518
- token: token_from_verification,
519
- });
520
-
521
- await example(order.id);
522
- // Response: { id: string, fiatAmount: string, currency: string, , recipient: string, mint: string, chain: Chain, amount: number, status: OnRampStatus }
523
- ``` -->
524
-
525
- ---
526
-
527
360
  ## License
528
361
 
529
362
  MIT
@@ -1,19 +1,20 @@
1
- import { Currency, TransactionStatus, TransactionType } from '../../utils/enums.js';
2
- type offRampCreateOrderResponse = {
1
+ import { Currency } from "../../utils/enums.js";
2
+ interface CreateOfframpOrder {
3
+ bank: string;
4
+ accountNumber: string;
5
+ currency: Currency;
6
+ amount: number;
7
+ mint: string;
8
+ webhookURL: string;
9
+ }
10
+ export interface OfframpOrder {
3
11
  id: string;
4
12
  address: string;
5
- signature?: string;
6
13
  mint: string;
7
14
  currency: Currency;
8
15
  amount: number;
9
- usdcAmount: number;
10
16
  fiatAmount: number;
11
- sender: string;
12
- receipiant: string;
13
17
  rate: number;
14
- status: TransactionStatus;
15
- transactionType: TransactionType;
16
- createdAt: string;
17
- };
18
- export declare const offRampCreateOrder: (token: string, bank: string, accountNumber: string, currency: string, amount: number, mint: string, webhookURL: string) => Promise<offRampCreateOrderResponse>;
18
+ }
19
+ export declare const createOfframpOrder: (order: CreateOfframpOrder, sessionToken: string) => Promise<OfframpOrder>;
19
20
  export {};
@@ -1,19 +1,14 @@
1
- import { post } from '../../utils/api.js';
2
- export const offRampCreateOrder = async (token, bank, accountNumber, currency, amount, mint, webhookURL) => {
1
+ import { post } from "../../utils/api.js";
2
+ export const createOfframpOrder = async (order, sessionToken) => {
3
3
  try {
4
- return await post('/pub/offramp', {
5
- bank,
6
- accountNumber,
7
- currency,
8
- amount,
9
- mint,
10
- webhookURL,
4
+ return await post("/pub/offramp", {
5
+ ...order,
11
6
  }, {
12
- Authorization: `Bearer ${token}`,
7
+ Authorization: `Bearer ${sessionToken}`,
13
8
  });
14
9
  }
15
10
  catch (err) {
16
- console.error('Error Creating Order', err);
11
+ console.error("Error Creating Order", err);
17
12
  throw err;
18
13
  }
19
14
  };
@@ -1,18 +1,23 @@
1
- type CreateOrderType = {
1
+ import { Currency } from "../../utils/enums.js";
2
+ type CreateOnrampOrder = {
2
3
  fiatAmount: number;
3
4
  currency: string;
4
5
  recipient: string;
5
6
  mint: string;
6
7
  chain: string;
7
8
  webhookURL: string;
8
- token?: string;
9
9
  };
10
- type CreateOrderResponseType = {
10
+ export interface OnrampOrder {
11
11
  id: string;
12
12
  accountNumber: string;
13
13
  accountName: string;
14
14
  amount: number;
15
+ fiatAmount: number;
15
16
  bank: string;
16
- };
17
- export declare const createOrder: (options: CreateOrderType) => Promise<CreateOrderResponseType>;
17
+ rate: number;
18
+ recipient: string;
19
+ currency: Currency;
20
+ mint: string;
21
+ }
22
+ export declare const createOnrampOrder: (order: CreateOnrampOrder, sessionToken: string) => Promise<OnrampOrder>;
18
23
  export {};
@@ -1,20 +1,14 @@
1
- import { post } from '../../utils/api.js';
2
- export const createOrder = async (options) => {
3
- const { fiatAmount, currency, recipient, mint, chain, webhookURL, token } = options;
1
+ import { post } from "../../utils/api.js";
2
+ export const createOnrampOrder = async (order, sessionToken) => {
4
3
  try {
5
- return await post('/pub/onramp', {
6
- fiatAmount,
7
- currency,
8
- recipient,
9
- mint,
10
- chain,
11
- webhookURL,
4
+ return await post("/pub/onramp", {
5
+ ...order,
12
6
  }, {
13
- Authorization: `Bearer ${token}`,
7
+ Authorization: `Bearer ${sessionToken}`,
14
8
  });
15
9
  }
16
10
  catch (err) {
17
- console.error('Error creating order:', err);
11
+ console.error("Error creating order:", err);
18
12
  throw err;
19
13
  }
20
14
  };
@@ -1,5 +1,6 @@
1
1
  type InitiateResponse = {
2
- recipient: string;
2
+ email?: string;
3
+ phone?: string;
3
4
  };
4
5
  export declare const initiate: (recipient: string, apiKey: string) => Promise<InitiateResponse>;
5
6
  export {};
@@ -1,4 +1,4 @@
1
- import { post } from '../../../utils/api.js';
1
+ import { post } from "../../../utils/api.js";
2
2
  export const initiate = async (recipient, apiKey) => {
3
3
  let body;
4
4
  try {
@@ -6,13 +6,13 @@ export const initiate = async (recipient, apiKey) => {
6
6
  body = { email: recipient };
7
7
  else
8
8
  body = { phone: recipient };
9
- return await post('/pub/initiate', body, {
10
- 'x-api-key': apiKey,
11
- 'Content-Type': 'application/json',
9
+ return await post("/pub/initiate", body, {
10
+ "x-api-key": apiKey,
11
+ "Content-Type": "application/json",
12
12
  });
13
13
  }
14
14
  catch (err) {
15
- console.error('Error initiating:', err);
15
+ console.error("Error initiating:", err);
16
16
  throw err;
17
17
  }
18
18
  };
@@ -1,10 +1,10 @@
1
- type VerifyType = {
1
+ export type VerifyType = {
2
2
  recipient: string;
3
3
  isActive: string;
4
4
  expiresAt: string;
5
5
  token: string;
6
6
  };
7
- type deviceSignatureType = {
7
+ export type deviceSignatureType = {
8
8
  uuid: string;
9
9
  device: string;
10
10
  os?: string;
@@ -12,4 +12,3 @@ type deviceSignatureType = {
12
12
  ip?: string;
13
13
  };
14
14
  export declare const verify: (recipient: string, otp: string, device: deviceSignatureType, apiKey: string) => Promise<VerifyType>;
15
- export {};
@@ -1,4 +1,4 @@
1
- import { post } from '../../../utils/api.js';
1
+ import { post } from "../../../utils/api.js";
2
2
  export const verify = async (recipient, otp, device, apiKey) => {
3
3
  let body;
4
4
  try {
@@ -6,10 +6,10 @@ export const verify = async (recipient, otp, device, apiKey) => {
6
6
  body = { email: recipient, otp, device };
7
7
  else
8
8
  body = { phone: recipient, otp, device };
9
- return await post('/pub/verify', body, { 'x-api-key': apiKey });
9
+ return await post("/pub/verify", body, { "x-api-key": apiKey });
10
10
  }
11
11
  catch (err) {
12
- console.error('Error verifying:', err);
12
+ console.error("Error verifying:", err);
13
13
  throw err;
14
14
  }
15
15
  };
@@ -1,12 +1,10 @@
1
- import { TransactionResponse } from './getTransaction.js';
2
- type TransactionsResponse = TransactionResponse[];
1
+ import { PajTransaction } from "./getTransaction.js";
3
2
  /**
4
3
  * The function getAllTransactions fetches all transactions from a specified endpoint and handles any
5
4
  * errors that occur.
6
5
  * @returns The `getAllTransactions` function is returning the result of the `get` function called with
7
- * the '/pub/transactions' endpoint. The result is expected to be of type `TransactionsResponse`. If
6
+ * the '/pub/transactions' endpoint. The result is expected to be of type `PajTransaction[]`. If
8
7
  * successful, the function will return the transactions data. If an error occurs during the API call,
9
8
  * it will be caught, logged to the console, and rethrown.
10
9
  */
11
- export declare const getAllTransactions: (token: string) => Promise<TransactionsResponse>;
12
- export {};
10
+ export declare const getAllTransactions: (token: string) => Promise<PajTransaction[]>;
@@ -1,20 +1,20 @@
1
- import { get } from '../../../utils/api.js';
1
+ import { get } from "../../../utils/api.js";
2
2
  /**
3
3
  * The function getAllTransactions fetches all transactions from a specified endpoint and handles any
4
4
  * errors that occur.
5
5
  * @returns The `getAllTransactions` function is returning the result of the `get` function called with
6
- * the '/pub/transactions' endpoint. The result is expected to be of type `TransactionsResponse`. If
6
+ * the '/pub/transactions' endpoint. The result is expected to be of type `PajTransaction[]`. If
7
7
  * successful, the function will return the transactions data. If an error occurs during the API call,
8
8
  * it will be caught, logged to the console, and rethrown.
9
9
  */
10
10
  export const getAllTransactions = async (token) => {
11
11
  try {
12
- return await get('/pub/transactions', {}, {
12
+ return await get("/pub/transactions", {}, {
13
13
  Authorization: `Bearer ${token}`,
14
14
  });
15
15
  }
16
16
  catch (err) {
17
- console.error('Error fetching Transactions:', err);
17
+ console.error("Error fetching Transactions:", err);
18
18
  throw err;
19
19
  }
20
20
  };
@@ -1,19 +1,13 @@
1
- import { Currency, TransactionStatus, TransactionType } from '../../../utils/enums.js';
2
- export type TransactionResponse = {
3
- id: string;
4
- address: string;
5
- mint: string;
6
- currency: Currency;
7
- amount: number;
8
- usdcAmount: number;
9
- fiatAmount: number;
10
- sender: string;
11
- receipiant: string;
12
- rate: number;
1
+ import { TransactionStatus, TransactionType } from "../../../utils/enums.js";
2
+ import { OnrampOrder } from "../../on_ramp/createOrder.js";
3
+ import { OfframpOrder } from "../../off_ramp/directCreateOrder.js";
4
+ export interface PajTransaction extends OnrampOrder, OfframpOrder {
5
+ signature: string;
13
6
  status: TransactionStatus;
14
7
  transactionType: TransactionType;
15
8
  createdAt: string | Date;
16
- };
9
+ usdcAmount: number;
10
+ }
17
11
  /**
18
12
  * The function `getTransaction` asynchronously fetches a transaction with a specified ID and handles
19
13
  * any errors that may occur.
@@ -23,4 +17,4 @@ export type TransactionResponse = {
23
17
  * endpoint `/pub/transactions/`. This function is fetching transaction data based on the provided
24
18
  * `id`.
25
19
  */
26
- export declare const getTransaction: (token: string, id: string) => Promise<TransactionResponse>;
20
+ export declare const getTransaction: (token: string, id: string) => Promise<PajTransaction>;
@@ -1,4 +1,4 @@
1
- import { get } from '../../../utils/api.js';
1
+ import { get } from "../../../utils/api.js";
2
2
  /**
3
3
  * The function `getTransaction` asynchronously fetches a transaction with a specified ID and handles
4
4
  * any errors that may occur.
@@ -15,7 +15,7 @@ export const getTransaction = async (token, id) => {
15
15
  });
16
16
  }
17
17
  catch (err) {
18
- console.error('Error fetching Transaction:', err);
18
+ console.error("Error fetching Transaction:", err);
19
19
  throw err;
20
20
  }
21
21
  };
package/dist/sdk.d.ts CHANGED
@@ -1,16 +1,17 @@
1
- export declare const initializeSDK: (env: "staging" | "production") => void;
2
- export { initiate } from './lib/utility/session/initiate.js';
3
- export { verify } from './lib/utility/session/verify.js';
4
- export { getAllRate } from './lib/utility/rate/getAllRate.js';
5
- export { getRateByAmount } from './lib/utility/rate/getRateByAmount.js';
6
- export { getRateByType } from './lib/utility/rate/getRateByType.js';
7
- export { getTokenValue } from './lib/utility/rate/getTokenValue.js';
8
- export { getBanks } from './lib/utility/bank/getBanks.js';
9
- export { resolveBankAccount } from './lib/utility/bank/resolveBankAccount.js';
10
- export { addBankAccount } from './lib/utility/bank/addBankAccount.js';
11
- export { getBankAccounts } from './lib/utility/bank/getBankAccounts.js';
12
- export { getAllTransactions } from './lib/utility/transaction/getAllTransactions.js';
13
- export { getTransaction } from './lib/utility/transaction/getTransaction.js';
14
- export { offRampCreateOrder } from './lib/off_ramp/directCreateOrder.js';
15
- export { createOrder } from './lib/on_ramp/createOrder.js';
16
- export { RateType, Currency, TransactionType, TransactionStatus, } from './utils/enums.js';
1
+ import { Environment } from "./utils/enums.js";
2
+ export declare const initializeSDK: (env: Environment) => void;
3
+ export { initiate } from "./lib/utility/session/initiate.js";
4
+ export { verify } from "./lib/utility/session/verify.js";
5
+ export { getAllRate } from "./lib/utility/rate/getAllRate.js";
6
+ export { getRateByAmount } from "./lib/utility/rate/getRateByAmount.js";
7
+ export { getRateByType } from "./lib/utility/rate/getRateByType.js";
8
+ export { getTokenValue } from "./lib/utility/rate/getTokenValue.js";
9
+ export { getBanks } from "./lib/utility/bank/getBanks.js";
10
+ export { resolveBankAccount } from "./lib/utility/bank/resolveBankAccount.js";
11
+ export { addBankAccount } from "./lib/utility/bank/addBankAccount.js";
12
+ export { getBankAccounts } from "./lib/utility/bank/getBankAccounts.js";
13
+ export { getAllTransactions } from "./lib/utility/transaction/getAllTransactions.js";
14
+ export { getTransaction, PajTransaction, } from "./lib/utility/transaction/getTransaction.js";
15
+ export { createOfframpOrder } from "./lib/off_ramp/directCreateOrder.js";
16
+ export { createOnrampOrder } from "./lib/on_ramp/createOrder.js";
17
+ export { RateType, Currency, TransactionType, TransactionStatus, Environment, } from "./utils/enums.js";
package/dist/sdk.js CHANGED
@@ -1,38 +1,42 @@
1
1
  // A JavaScript SDK for interacting with our offramp and onramp service.
2
2
  // Switch Environment: "staging" | "production"
3
- import { setBaseUrl } from './utils/axios.js';
3
+ import { setBaseUrl } from "./utils/axios.js";
4
+ import { Environment } from "./utils/enums.js";
4
5
  export const initializeSDK = (env) => {
5
- if (env === 'staging') {
6
- setBaseUrl('https://api-staging.paj.cash');
6
+ if (env === Environment.Staging) {
7
+ setBaseUrl("https://api-staging.paj.cash");
7
8
  }
8
- else {
9
- setBaseUrl('https://api.paj.cash');
9
+ else if (env === Environment.Production) {
10
+ setBaseUrl("https://api.paj.cash");
11
+ }
12
+ else if (env === Environment.Local) {
13
+ setBaseUrl("http://localhost:3000");
10
14
  }
11
15
  };
12
16
  // UTILITY ENDPOINTS
13
17
  // Session Management
14
- export { initiate } from './lib/utility/session/initiate.js';
15
- export { verify } from './lib/utility/session/verify.js';
18
+ export { initiate } from "./lib/utility/session/initiate.js";
19
+ export { verify } from "./lib/utility/session/verify.js";
16
20
  // Rate Operations
17
- export { getAllRate } from './lib/utility/rate/getAllRate.js';
18
- export { getRateByAmount } from './lib/utility/rate/getRateByAmount.js';
19
- export { getRateByType } from './lib/utility/rate/getRateByType.js';
20
- export { getTokenValue } from './lib/utility/rate/getTokenValue.js';
21
+ export { getAllRate } from "./lib/utility/rate/getAllRate.js";
22
+ export { getRateByAmount } from "./lib/utility/rate/getRateByAmount.js";
23
+ export { getRateByType } from "./lib/utility/rate/getRateByType.js";
24
+ export { getTokenValue } from "./lib/utility/rate/getTokenValue.js";
21
25
  // Banking Operations
22
- export { getBanks } from './lib/utility/bank/getBanks.js';
23
- export { resolveBankAccount } from './lib/utility/bank/resolveBankAccount.js';
24
- export { addBankAccount } from './lib/utility/bank/addBankAccount.js';
25
- export { getBankAccounts } from './lib/utility/bank/getBankAccounts.js';
26
+ export { getBanks } from "./lib/utility/bank/getBanks.js";
27
+ export { resolveBankAccount } from "./lib/utility/bank/resolveBankAccount.js";
28
+ export { addBankAccount } from "./lib/utility/bank/addBankAccount.js";
29
+ export { getBankAccounts } from "./lib/utility/bank/getBankAccounts.js";
26
30
  // Transaction History
27
- export { getAllTransactions } from './lib/utility/transaction/getAllTransactions.js';
28
- export { getTransaction } from './lib/utility/transaction/getTransaction.js';
31
+ export { getAllTransactions } from "./lib/utility/transaction/getAllTransactions.js";
32
+ export { getTransaction, } from "./lib/utility/transaction/getTransaction.js";
29
33
  // OFF RAMP
30
34
  // DIRECT OFF RAMP
31
- export { offRampCreateOrder } from './lib/off_ramp/directCreateOrder.js';
35
+ export { createOfframpOrder } from "./lib/off_ramp/directCreateOrder.js";
32
36
  // ON RAMP
33
37
  // Create Order
34
- export { createOrder } from './lib/on_ramp/createOrder.js';
38
+ export { createOnrampOrder } from "./lib/on_ramp/createOrder.js";
35
39
  // Types
36
- export { RateType, Currency, TransactionType, TransactionStatus,
40
+ export { RateType, Currency, TransactionType, TransactionStatus, Environment,
37
41
  // Chain
38
- } from './utils/enums.js';
42
+ } from "./utils/enums.js";
package/dist/utils/api.js CHANGED
@@ -64,6 +64,8 @@ export function get(url, params, headers) {
64
64
  * Throws the error response data or error message if the request fails.
65
65
  */
66
66
  export function post(url, data, headers) {
67
+ // console.log("POST request to:", url);
68
+ // console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
67
69
  return request("post", url, { data, headers });
68
70
  }
69
71
  /**
@@ -19,3 +19,8 @@ export declare enum RateType {
19
19
  onRamp = "onRamp",
20
20
  offRamp = "offRamp"
21
21
  }
22
+ export declare enum Environment {
23
+ Staging = "staging",
24
+ Production = "production",
25
+ Local = "local"
26
+ }
@@ -28,3 +28,9 @@ export var RateType;
28
28
  RateType["onRamp"] = "onRamp";
29
29
  RateType["offRamp"] = "offRamp";
30
30
  })(RateType || (RateType = {}));
31
+ export var Environment;
32
+ (function (Environment) {
33
+ Environment["Staging"] = "staging";
34
+ Environment["Production"] = "production";
35
+ Environment["Local"] = "local";
36
+ })(Environment || (Environment = {}));
@@ -1,12 +1,9 @@
1
1
  import { post } from "../../utils/api.js";
2
2
  import {
3
3
  Currency,
4
- TransactionStatus,
5
- TransactionType,
6
4
  } from "../../utils/enums.js";
7
5
 
8
6
  interface CreateOfframpOrder {
9
- token: string;
10
7
  bank: string;
11
8
  accountNumber: string;
12
9
  currency: Currency;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paj_ramp",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "paj offramp/onramp service",
5
5
  "main": "dist/sdk.js",
6
6
  "types": "dist/sdk.d.ts",