paj_ramp 1.5.0 → 1.5.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/.github/CODEOWNERS +1 -0
- package/LICENSE +21 -0
- package/README.md +230 -144
- package/__tests__/session.test.ts +2 -35
- package/dist/lib/off_ramp/createOrder.d.ts +3 -2
- package/dist/lib/on_ramp/createOrder.d.ts +7 -5
- package/dist/lib/utility/bank/addBankAccount.d.ts +3 -4
- package/dist/lib/utility/bank/addBankAccount.js +3 -3
- package/dist/lib/utility/bank/getBankAccounts.d.ts +3 -4
- package/dist/lib/utility/bank/getBanks.d.ts +5 -4
- package/dist/lib/utility/bank/getBanks.js +2 -2
- package/dist/lib/utility/bank/resolveBankAccount.d.ts +3 -4
- package/dist/lib/utility/bank/resolveBankAccount.js +2 -2
- package/dist/lib/utility/rate/getAllRate.d.ts +3 -3
- package/dist/lib/utility/rate/getAllRate.js +4 -4
- package/dist/lib/utility/rate/getRateByAmount.d.ts +3 -4
- package/dist/lib/utility/rate/getRateByType.d.ts +4 -5
- package/dist/lib/utility/rate/getRateByType.js +1 -1
- package/dist/lib/utility/rate/getTokenValue.d.ts +3 -3
- package/dist/lib/utility/session/initiate.d.ts +2 -3
- package/dist/lib/utility/session/verify.d.ts +5 -5
- package/dist/lib/utility/token/getTokenInfo.d.ts +10 -0
- package/dist/lib/utility/token/getTokenInfo.js +10 -0
- package/dist/lib/utility/transaction/getTransaction.d.ts +1 -1
- package/dist/lib/utility/value/getOfframpValue.d.ts +1 -2
- package/dist/lib/utility/value/getOnrampValue.d.ts +1 -8
- package/dist/sdk.d.ts +17 -11
- package/dist/sdk.js +21 -15
- package/dist/utils/onramp-socket.d.ts +2 -3
- package/dist/utils/onramp-socket.js +2 -3
- package/examples/README.md +27 -12
- package/examples/{basic-offramp → offramp}/README.md +44 -23
- package/examples/{basic-offramp → offramp}/index.ts +8 -7
- package/examples/{basic-onramp → onramp}/README.md +42 -19
- package/examples/{basic-onramp → onramp}/index.ts +2 -2
- package/examples/utility/.env.example +12 -0
- package/examples/utility/README.md +175 -0
- package/examples/utility/index.ts +137 -0
- package/examples/utility/package-lock.json +605 -0
- package/examples/utility/package.json +26 -0
- package/examples/utility/tsconfig.json +15 -0
- package/jest.config.js +7 -4
- package/lib/off_ramp/{directCreateOrder.ts → createOrder.ts} +9 -7
- package/lib/on_ramp/createOrder.ts +9 -6
- package/lib/utility/bank/addBankAccount.ts +6 -6
- package/lib/utility/bank/getBankAccounts.ts +3 -3
- package/lib/utility/bank/getBanks.ts +8 -6
- package/lib/utility/bank/resolveBankAccount.ts +5 -5
- package/lib/utility/rate/getAllRate.ts +6 -6
- package/lib/utility/rate/getRateByAmount.ts +3 -3
- package/lib/utility/rate/getRateByType.ts +4 -4
- package/lib/utility/rate/getTokenValue.ts +3 -3
- package/lib/utility/session/initiate.ts +2 -2
- package/lib/utility/session/verify.ts +6 -6
- package/lib/utility/token/getTokenInfo.ts +20 -0
- package/lib/utility/transaction/getTransaction.ts +1 -1
- package/lib/utility/value/getOfframpValue.ts +24 -0
- package/lib/utility/value/getOnrampValue.ts +17 -0
- package/package.json +1 -1
- package/sdk.ts +82 -13
- package/tsconfig.json +1 -1
- package/utils/axios.ts +1 -1
- package/utils/onramp-socket.ts +2 -3
- /package/examples/{basic-offramp → offramp}/.env.example +0 -0
- /package/examples/{basic-offramp → offramp}/package-lock.json +0 -0
- /package/examples/{basic-offramp → offramp}/package.json +0 -0
- /package/examples/{basic-onramp → onramp}/.env.example +0 -0
- /package/examples/{basic-onramp → onramp}/package-lock.json +0 -0
- /package/examples/{basic-onramp → onramp}/package.json +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @Twist96 @GOSPEL-CHUKWU
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jit Technologies LTD and contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -14,12 +14,12 @@ yarn add paj_ramp
|
|
|
14
14
|
|
|
15
15
|
## Getting Started
|
|
16
16
|
|
|
17
|
-
### Initialize SDK
|
|
17
|
+
### Initialize SDK
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
20
|
import { initializeSDK, Environment } from 'paj_ramp';
|
|
21
21
|
|
|
22
|
-
//
|
|
22
|
+
// Select the environment you want to work with
|
|
23
23
|
initializeSDK(Environment.Production); // or Environment.Staging
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -28,13 +28,12 @@ initializeSDK(Environment.Production); // or Environment.Staging
|
|
|
28
28
|
```typescript
|
|
29
29
|
import { initiate } from 'paj_ramp';
|
|
30
30
|
|
|
31
|
-
// You can
|
|
32
|
-
// Phone number must start with a country code
|
|
31
|
+
// You can use either an email address or a phone number (with country code)
|
|
33
32
|
const initiated = await initiate(
|
|
34
|
-
'your_email@gmail.com' // +2349053231563
|
|
33
|
+
'your_email@gmail.com', // or '+2349053231563'
|
|
35
34
|
'business_api_key'
|
|
36
|
-
|
|
37
|
-
// Response: { email?: string, phone?: string}
|
|
35
|
+
);
|
|
36
|
+
// Response: { email?: string, phone?: string }
|
|
38
37
|
```
|
|
39
38
|
|
|
40
39
|
### Verify Session
|
|
@@ -42,27 +41,24 @@ const initiated = await initiate(
|
|
|
42
41
|
```typescript
|
|
43
42
|
import { verify } from 'paj_ramp';
|
|
44
43
|
|
|
45
|
-
// You can get otp by either adding your phone number or email address
|
|
46
|
-
// Phone number must start with a country code
|
|
47
44
|
const verified = await verify(
|
|
48
|
-
'your_email@gmail.com', // or +2349053231563
|
|
45
|
+
'your_email@gmail.com', // or '+2349053231563'
|
|
49
46
|
'otp',
|
|
50
47
|
{
|
|
51
|
-
uuid:
|
|
52
|
-
device:
|
|
53
|
-
//
|
|
54
|
-
os:
|
|
55
|
-
browser:
|
|
56
|
-
ip:
|
|
48
|
+
uuid: 'device-uuid',
|
|
49
|
+
device: 'Desktop',
|
|
50
|
+
// optional fields:
|
|
51
|
+
os: 'MacOS',
|
|
52
|
+
browser: 'Chrome',
|
|
53
|
+
ip: '127.0.0.1',
|
|
57
54
|
},
|
|
58
55
|
'business_api_key'
|
|
59
56
|
);
|
|
60
57
|
/* Response: {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
token: string
|
|
58
|
+
recipient: string,
|
|
59
|
+
isActive: string,
|
|
60
|
+
expiresAt: string,
|
|
61
|
+
token: string
|
|
66
62
|
} */
|
|
67
63
|
```
|
|
68
64
|
|
|
@@ -70,14 +66,13 @@ token: string
|
|
|
70
66
|
|
|
71
67
|
Check out our [examples directory](./examples) for complete, runnable examples:
|
|
72
68
|
|
|
73
|
-
- **[
|
|
74
|
-
- **[
|
|
75
|
-
- **[
|
|
76
|
-
|
|
77
|
-
Each example includes its own README with detailed setup instructions. Perfect for understanding how to integrate PAJ Ramp into your application!
|
|
69
|
+
- **[Onramp](./examples/onramp)** - Complete onramp flow: buy crypto with fiat
|
|
70
|
+
- **[Offramp](./examples/offramp)** - Complete offramp flow: sell crypto for fiat
|
|
71
|
+
- **[Utility](./examples/utility)** - Utility functions: rates, banks, value conversions
|
|
72
|
+
- **[Webhook Integration](./examples/webhook-integration)** - Express server with real-time webhook handling
|
|
78
73
|
|
|
79
74
|
```bash
|
|
80
|
-
cd examples/
|
|
75
|
+
cd examples/onramp
|
|
81
76
|
npm install
|
|
82
77
|
cp .env.example .env
|
|
83
78
|
# Edit .env with your credentials
|
|
@@ -86,9 +81,9 @@ npm start
|
|
|
86
81
|
|
|
87
82
|
## Utility Endpoints
|
|
88
83
|
|
|
89
|
-
### Handle Rate
|
|
84
|
+
### Handle Rate
|
|
90
85
|
|
|
91
|
-
**_Get All
|
|
86
|
+
**_Get All Rates_**
|
|
92
87
|
|
|
93
88
|
```typescript
|
|
94
89
|
import { getAllRate } from 'paj_ramp';
|
|
@@ -97,21 +92,22 @@ const rate = await getAllRate();
|
|
|
97
92
|
/*
|
|
98
93
|
Response:
|
|
99
94
|
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
95
|
+
"onRampRate": {
|
|
96
|
+
"baseCurrency": "USD",
|
|
97
|
+
"targetCurrency": "NGN",
|
|
98
|
+
"isActive": true,
|
|
99
|
+
"rate": 1510,
|
|
100
|
+
"type": "onRamp"
|
|
101
|
+
},
|
|
102
|
+
"offRampRate": {
|
|
103
|
+
"baseCurrency": "USD",
|
|
104
|
+
"targetCurrency": "NGN",
|
|
105
|
+
"isActive": true,
|
|
106
|
+
"rate": 1525,
|
|
107
|
+
"type": "offRamp"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
*/
|
|
115
111
|
```
|
|
116
112
|
|
|
117
113
|
**_Get Rate by Amount_**
|
|
@@ -123,63 +119,95 @@ const rate = await getRateByAmount(50000);
|
|
|
123
119
|
/*
|
|
124
120
|
Response:
|
|
125
121
|
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
rate: {
|
|
123
|
+
baseCurrency: string,
|
|
124
|
+
targetCurrency: string,
|
|
125
|
+
rate: number
|
|
130
126
|
},
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
amounts: {
|
|
128
|
+
userTax: number,
|
|
129
|
+
merchantTax: number,
|
|
130
|
+
amountUSD: number,
|
|
131
|
+
userAmountFiat: number
|
|
136
132
|
}
|
|
137
|
-
}
|
|
133
|
+
}
|
|
134
|
+
*/
|
|
138
135
|
```
|
|
139
136
|
|
|
140
|
-
**_Get Rate by
|
|
137
|
+
**_Get Rate by Type_**
|
|
141
138
|
|
|
142
139
|
```typescript
|
|
143
140
|
import { getRateByType, RateType } from 'paj_ramp';
|
|
144
141
|
|
|
145
142
|
const rate = await getRateByType(RateType.offRamp); // or RateType.onRamp
|
|
146
|
-
|
|
147
143
|
/*
|
|
148
144
|
Response:
|
|
149
|
-
|
|
145
|
+
{
|
|
150
146
|
"baseCurrency": "USD",
|
|
151
147
|
"targetCurrency": "NGN",
|
|
152
148
|
"isActive": true,
|
|
153
149
|
"rate": 1525,
|
|
154
150
|
"type": "offRamp"
|
|
155
|
-
}
|
|
151
|
+
}
|
|
152
|
+
*/
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**_Get Token Value (fiat → token amount)_**
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
import { getTokenValue, Currency } from 'paj_ramp';
|
|
159
|
+
|
|
160
|
+
const tokenValue = await getTokenValue(
|
|
161
|
+
{
|
|
162
|
+
amount: 50000, // fiat amount
|
|
163
|
+
mint: 'token_mint_address',
|
|
164
|
+
currency: Currency.NGN,
|
|
165
|
+
},
|
|
166
|
+
sessionToken
|
|
167
|
+
);
|
|
168
|
+
/*
|
|
169
|
+
Response:
|
|
170
|
+
{
|
|
171
|
+
amount: number, // token amount
|
|
172
|
+
mint: string,
|
|
173
|
+
currency: string
|
|
174
|
+
}
|
|
175
|
+
*/
|
|
156
176
|
```
|
|
157
177
|
|
|
158
|
-
**_Get
|
|
178
|
+
**_Get Fiat Value (token amount → fiat)_**
|
|
159
179
|
|
|
160
180
|
```typescript
|
|
161
|
-
import {
|
|
181
|
+
import { getFiatValue, Currency } from 'paj_ramp';
|
|
162
182
|
|
|
163
|
-
const
|
|
183
|
+
const fiatValue = await getFiatValue(
|
|
184
|
+
{
|
|
185
|
+
amount: 100, // token amount
|
|
186
|
+
mint: 'token_mint_address',
|
|
187
|
+
currency: Currency.NGN,
|
|
188
|
+
},
|
|
189
|
+
sessionToken
|
|
190
|
+
);
|
|
164
191
|
/*
|
|
165
192
|
Response:
|
|
166
193
|
{
|
|
167
|
-
amount: number,
|
|
168
|
-
|
|
169
|
-
|
|
194
|
+
amount: number,
|
|
195
|
+
mint: string,
|
|
196
|
+
currency: string,
|
|
197
|
+
fiatAmount: number // equivalent fiat amount
|
|
170
198
|
}
|
|
171
199
|
*/
|
|
172
200
|
```
|
|
173
201
|
|
|
174
|
-
### Handle Banks
|
|
202
|
+
### Handle Banks
|
|
175
203
|
|
|
176
204
|
**_Get Banks_**
|
|
177
205
|
|
|
178
206
|
```typescript
|
|
179
207
|
import { getBanks } from 'paj_ramp';
|
|
180
208
|
|
|
181
|
-
const banks = await getBanks(
|
|
182
|
-
// Response: [ { id: string, name: string, country: string } ]
|
|
209
|
+
const banks = await getBanks(sessionToken);
|
|
210
|
+
// Response: [ { id: string, code: string, name: string, logo: string, country: string } ]
|
|
183
211
|
```
|
|
184
212
|
|
|
185
213
|
**_Resolve Bank Account_**
|
|
@@ -187,8 +215,8 @@ const banks = await getBanks('token');
|
|
|
187
215
|
```typescript
|
|
188
216
|
import { resolveBankAccount } from 'paj_ramp';
|
|
189
217
|
|
|
190
|
-
const
|
|
191
|
-
|
|
218
|
+
const resolved = await resolveBankAccount(
|
|
219
|
+
sessionToken,
|
|
192
220
|
'bank_id',
|
|
193
221
|
'account_number'
|
|
194
222
|
);
|
|
@@ -200,8 +228,8 @@ const resolvedBankAccount = await resolveBankAccount(
|
|
|
200
228
|
```typescript
|
|
201
229
|
import { addBankAccount } from 'paj_ramp';
|
|
202
230
|
|
|
203
|
-
const
|
|
204
|
-
|
|
231
|
+
const added = await addBankAccount(
|
|
232
|
+
sessionToken,
|
|
205
233
|
'bank_id',
|
|
206
234
|
'account_number'
|
|
207
235
|
);
|
|
@@ -213,33 +241,54 @@ const addedBankAccount = await addBankAccount(
|
|
|
213
241
|
```typescript
|
|
214
242
|
import { getBankAccounts } from 'paj_ramp';
|
|
215
243
|
|
|
216
|
-
const accounts = await getBankAccounts(
|
|
244
|
+
const accounts = await getBankAccounts(sessionToken);
|
|
217
245
|
// Response: [ { id: string, accountName: string, accountNumber: string, bank: string } ]
|
|
218
246
|
```
|
|
219
247
|
|
|
220
|
-
###
|
|
248
|
+
### Token Info
|
|
249
|
+
|
|
250
|
+
**_Get Token Info_**
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
import { getTokenInfo, Chain } from 'paj_ramp';
|
|
254
|
+
|
|
255
|
+
const tokenInfo = await getTokenInfo('token_mint_address', Chain.SOLANA);
|
|
256
|
+
/*
|
|
257
|
+
Response:
|
|
258
|
+
{
|
|
259
|
+
name: string,
|
|
260
|
+
symbol: string,
|
|
261
|
+
logo: string,
|
|
262
|
+
mint: string,
|
|
263
|
+
decimals: number,
|
|
264
|
+
chain: Chain
|
|
265
|
+
}
|
|
266
|
+
*/
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Transaction History
|
|
221
270
|
|
|
222
271
|
**_Get All Transactions_**
|
|
223
272
|
|
|
224
273
|
```typescript
|
|
225
274
|
import { getAllTransactions } from 'paj_ramp';
|
|
226
275
|
|
|
227
|
-
const transactions = await getAllTransactions(
|
|
276
|
+
const transactions = await getAllTransactions(sessionToken);
|
|
228
277
|
/* Response: [{
|
|
229
|
-
id: string;
|
|
230
|
-
address: string;
|
|
231
|
-
mint: string;
|
|
232
|
-
currency: Currency;
|
|
233
|
-
amount: number;
|
|
234
|
-
usdcAmount: number;
|
|
235
|
-
fiatAmount: number;
|
|
236
|
-
sender: string;
|
|
237
|
-
|
|
238
|
-
rate: number;
|
|
239
|
-
status: TransactionStatus;
|
|
240
|
-
transactionType: TransactionType;
|
|
241
|
-
createdAt: string | Date;
|
|
242
|
-
}]*/
|
|
278
|
+
id: string;
|
|
279
|
+
address: string;
|
|
280
|
+
mint: string;
|
|
281
|
+
currency: Currency;
|
|
282
|
+
amount: number;
|
|
283
|
+
usdcAmount: number;
|
|
284
|
+
fiatAmount: number;
|
|
285
|
+
sender: string;
|
|
286
|
+
recipient: string;
|
|
287
|
+
rate: number;
|
|
288
|
+
status: TransactionStatus;
|
|
289
|
+
transactionType: TransactionType;
|
|
290
|
+
createdAt: string | Date;
|
|
291
|
+
}] */
|
|
243
292
|
```
|
|
244
293
|
|
|
245
294
|
**_Get Transaction_**
|
|
@@ -247,79 +296,81 @@ createdAt: string | Date;
|
|
|
247
296
|
```typescript
|
|
248
297
|
import { getTransaction } from 'paj_ramp';
|
|
249
298
|
|
|
250
|
-
const
|
|
251
|
-
'token_from_verification',
|
|
252
|
-
'transaction_id'
|
|
253
|
-
);
|
|
299
|
+
const transaction = await getTransaction(sessionToken, 'transaction_id');
|
|
254
300
|
/* Response: {
|
|
255
|
-
id: string;
|
|
256
|
-
address: string;
|
|
257
|
-
mint: string;
|
|
258
|
-
currency: Currency;
|
|
259
|
-
amount: number;
|
|
260
|
-
usdcAmount: number;
|
|
261
|
-
fiatAmount: number;
|
|
262
|
-
sender: string;
|
|
263
|
-
|
|
264
|
-
rate: number;
|
|
265
|
-
status: TransactionStatus;
|
|
266
|
-
transactionType: TransactionType;
|
|
267
|
-
createdAt: string | Date;
|
|
268
|
-
}*/
|
|
301
|
+
id: string;
|
|
302
|
+
address: string;
|
|
303
|
+
mint: string;
|
|
304
|
+
currency: Currency;
|
|
305
|
+
amount: number;
|
|
306
|
+
usdcAmount: number;
|
|
307
|
+
fiatAmount: number;
|
|
308
|
+
sender: string;
|
|
309
|
+
recipient: string;
|
|
310
|
+
rate: number;
|
|
311
|
+
status: TransactionStatus;
|
|
312
|
+
transactionType: TransactionType;
|
|
313
|
+
createdAt: string | Date;
|
|
314
|
+
} */
|
|
269
315
|
```
|
|
270
316
|
|
|
271
|
-
## Offramp
|
|
317
|
+
## Offramp (Direct Offramp)
|
|
272
318
|
|
|
273
319
|
### Usage Example
|
|
274
320
|
|
|
275
321
|
```typescript
|
|
276
|
-
import { createOfframpOrder, Currency } from 'paj_ramp';
|
|
322
|
+
import { createOfframpOrder, Currency, Chain } from 'paj_ramp';
|
|
277
323
|
|
|
278
|
-
const
|
|
324
|
+
const order = await createOfframpOrder(
|
|
279
325
|
{
|
|
280
326
|
bank: 'bank_id',
|
|
281
327
|
accountNumber: 'account_number',
|
|
282
|
-
currency:
|
|
283
|
-
amount: 10000,
|
|
328
|
+
currency: Currency.NGN,
|
|
329
|
+
amount: 10000, // token amount (optional if fiatAmount provided)
|
|
330
|
+
fiatAmount: 10000, // fiat amount (optional if amount provided)
|
|
284
331
|
mint: 'token_mint_address',
|
|
285
|
-
|
|
332
|
+
chain: Chain.SOLANA, // Chain.SOLANA or Chain.MONAD
|
|
333
|
+
webhookURL: 'https://your-domain.com/webhook',
|
|
286
334
|
},
|
|
287
|
-
|
|
335
|
+
sessionToken
|
|
288
336
|
);
|
|
289
337
|
/* Response: {
|
|
290
|
-
id: string,
|
|
291
|
-
address: string,
|
|
292
|
-
mint: string,
|
|
293
|
-
currency: Currency,
|
|
294
|
-
amount: number,
|
|
295
|
-
fiatAmount: number,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
transactionType: TransactionType
|
|
300
|
-
createdAt: string
|
|
301
|
-
}*/
|
|
338
|
+
id: string,
|
|
339
|
+
address: string,
|
|
340
|
+
mint: string,
|
|
341
|
+
currency: Currency,
|
|
342
|
+
amount: number,
|
|
343
|
+
fiatAmount: number,
|
|
344
|
+
rate: number,
|
|
345
|
+
fee: number
|
|
346
|
+
} */
|
|
302
347
|
```
|
|
303
348
|
|
|
304
|
-
## Onramp
|
|
349
|
+
## Onramp: Creates a new onramp order and sends status to the webhook URL.
|
|
305
350
|
|
|
306
351
|
### Usage Example
|
|
307
352
|
|
|
308
353
|
```typescript
|
|
309
|
-
import {
|
|
354
|
+
import { createOnrampOrder, Currency, Chain } from 'paj_ramp';
|
|
310
355
|
|
|
311
|
-
const order = await
|
|
356
|
+
const order = await createOnrampOrder(
|
|
312
357
|
{
|
|
313
358
|
fiatAmount: 10000,
|
|
314
|
-
currency:
|
|
359
|
+
currency: Currency.NGN,
|
|
315
360
|
recipient: 'wallet_address_here',
|
|
316
361
|
mint: 'token_mint_address_here',
|
|
317
|
-
chain:
|
|
318
|
-
webhookURL: '
|
|
362
|
+
chain: Chain.SOLANA, // Chain.SOLANA or Chain.MONAD
|
|
363
|
+
webhookURL: 'https://your-domain.com/webhook',
|
|
319
364
|
},
|
|
320
|
-
|
|
365
|
+
sessionToken
|
|
321
366
|
);
|
|
322
|
-
|
|
367
|
+
/* Response: {
|
|
368
|
+
id: string,
|
|
369
|
+
accountNumber: string,
|
|
370
|
+
accountName: string,
|
|
371
|
+
fiatAmount: number,
|
|
372
|
+
bank: string
|
|
373
|
+
} */
|
|
323
374
|
```
|
|
324
375
|
|
|
325
376
|
## Webhook Response Data Structure
|
|
@@ -332,28 +383,63 @@ const order = await createOrder(
|
|
|
332
383
|
address: string;
|
|
333
384
|
signature?: string;
|
|
334
385
|
mint: string;
|
|
335
|
-
currency: Currency;
|
|
386
|
+
currency: Currency;
|
|
336
387
|
amount: number;
|
|
337
388
|
usdcAmount: number;
|
|
338
389
|
fiatAmount: number;
|
|
339
390
|
sender: string;
|
|
340
|
-
|
|
391
|
+
recipient: string;
|
|
341
392
|
rate: number;
|
|
342
|
-
status: TransactionStatus;
|
|
343
|
-
transactionType: TransactionType;
|
|
393
|
+
status: TransactionStatus; // INIT, PAID, COMPLETED, etc.
|
|
394
|
+
transactionType: TransactionType; // ON_RAMP or OFF_RAMP
|
|
344
395
|
}
|
|
345
396
|
```
|
|
346
397
|
|
|
347
|
-
##
|
|
398
|
+
## Exported Types
|
|
399
|
+
|
|
400
|
+
### Enums
|
|
348
401
|
|
|
349
402
|
```typescript
|
|
350
403
|
import {
|
|
351
|
-
|
|
352
|
-
TransactionStatus, // INIT, etc
|
|
353
|
-
TransactionType,
|
|
354
|
-
Currency,
|
|
355
|
-
Environment,
|
|
356
|
-
RateType,
|
|
404
|
+
Chain, // SOLANA, MONAD
|
|
405
|
+
TransactionStatus, // INIT, PAID, COMPLETED, etc.
|
|
406
|
+
TransactionType, // ON_RAMP, OFF_RAMP
|
|
407
|
+
Currency, // NGN, USD, etc.
|
|
408
|
+
Environment, // Staging, Production, Local
|
|
409
|
+
RateType, // onRamp, offRamp
|
|
410
|
+
OnRampStatus,
|
|
411
|
+
} from 'paj_ramp';
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Interfaces
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
import type {
|
|
418
|
+
// Session
|
|
419
|
+
InitiateResponse,
|
|
420
|
+
Verify,
|
|
421
|
+
DeviceSignature,
|
|
422
|
+
// Banks
|
|
423
|
+
Bank,
|
|
424
|
+
ResolveBankAccount,
|
|
425
|
+
AddBankAccount,
|
|
426
|
+
GetBankAccounts,
|
|
427
|
+
// Rates
|
|
428
|
+
RateByAmount,
|
|
429
|
+
RateBy,
|
|
430
|
+
// Token
|
|
431
|
+
TokenInfo,
|
|
432
|
+
// Orders
|
|
433
|
+
CreateOnrampOrder,
|
|
434
|
+
OnrampOrder,
|
|
435
|
+
CreateOfframpOrder,
|
|
436
|
+
OfframpOrder,
|
|
437
|
+
// Observe Order
|
|
438
|
+
ObserveOrderOptions,
|
|
439
|
+
ObserveOrderReturn,
|
|
440
|
+
OnRampOrderUpdate,
|
|
441
|
+
OnRampSocketOptions,
|
|
442
|
+
OnRampSocketInstance,
|
|
357
443
|
} from 'paj_ramp';
|
|
358
444
|
```
|
|
359
445
|
|
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
import { initiate } from "../lib/utility/session/initiate";
|
|
2
|
-
import { deviceSignatureType, verify } from "../lib/utility/session/verify";
|
|
3
|
-
import * as api from "../utils/api";
|
|
4
|
-
|
|
5
1
|
describe("Session", () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
afterEach(() => {
|
|
10
|
-
jest.restoreAllMocks();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should return session when API call succeeds", async () => {
|
|
14
|
-
jest.spyOn(api, "get").mockResolvedValue({ email: mockEmail });
|
|
15
|
-
|
|
16
|
-
const result = await initiate(mockEmail, ApiKey);
|
|
17
|
-
expect(result).toEqual({ email: mockEmail });
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should throw an error when API call fails", async () => {
|
|
21
|
-
const error = new Error("API Failure");
|
|
22
|
-
jest.spyOn(api, "get").mockRejectedValue(error);
|
|
23
|
-
|
|
24
|
-
await expect(initiate(mockEmail, ApiKey)).rejects.toThrow("API Failure");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("Should verify session when API call succeeds", async () => {
|
|
28
|
-
jest.spyOn(api, "get").mockResolvedValue({ email: mockEmail });
|
|
29
|
-
|
|
30
|
-
const device: deviceSignatureType = {
|
|
31
|
-
uuid: "uuid",
|
|
32
|
-
device: "device",
|
|
33
|
-
os: "os",
|
|
34
|
-
};
|
|
35
|
-
const result = await verify(mockEmail, "OTP", device, ApiKey);
|
|
36
|
-
expect(result).toEqual({ email: mockEmail });
|
|
2
|
+
it("should pass", () => {
|
|
3
|
+
expect(true).toBe(true);
|
|
37
4
|
});
|
|
38
5
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { Chain } from "../../sdk.js";
|
|
1
2
|
import { Currency } from "../../utils/enums.js";
|
|
2
|
-
interface CreateOfframpOrder {
|
|
3
|
+
export interface CreateOfframpOrder {
|
|
3
4
|
bank: string;
|
|
4
5
|
accountNumber: string;
|
|
5
6
|
currency: Currency;
|
|
6
7
|
amount?: number;
|
|
7
8
|
fiatAmount?: number;
|
|
8
9
|
mint: string;
|
|
10
|
+
chain: Chain;
|
|
9
11
|
webhookURL: string;
|
|
10
12
|
}
|
|
11
13
|
export interface OfframpOrder {
|
|
@@ -19,4 +21,3 @@ export interface OfframpOrder {
|
|
|
19
21
|
fee: number;
|
|
20
22
|
}
|
|
21
23
|
export declare const createOfframpOrder: (order: CreateOfframpOrder, sessionToken: string) => Promise<OfframpOrder>;
|
|
22
|
-
export {};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Currency } from "../../utils/enums.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { Chain } from "../../utils/onramp-socket.js";
|
|
3
|
+
export interface CreateOnrampOrder {
|
|
4
|
+
amount?: number;
|
|
5
|
+
fiatAmount?: number;
|
|
4
6
|
currency: string;
|
|
5
7
|
recipient: string;
|
|
6
8
|
mint: string;
|
|
7
|
-
chain:
|
|
9
|
+
chain: Chain;
|
|
8
10
|
webhookURL: string;
|
|
9
|
-
}
|
|
11
|
+
}
|
|
10
12
|
export interface OnrampOrder {
|
|
11
13
|
id: string;
|
|
12
14
|
accountNumber: string;
|
|
@@ -18,6 +20,6 @@ export interface OnrampOrder {
|
|
|
18
20
|
recipient: string;
|
|
19
21
|
currency: Currency;
|
|
20
22
|
mint: string;
|
|
23
|
+
fee: number;
|
|
21
24
|
}
|
|
22
25
|
export declare const createOnrampOrder: (order: CreateOnrampOrder, sessionToken: string) => Promise<OnrampOrder>;
|
|
23
|
-
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
export interface AddBankAccount {
|
|
2
2
|
id: string;
|
|
3
3
|
accountName: string;
|
|
4
4
|
accountNumber: string;
|
|
5
5
|
bank: string;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
/**
|
|
8
8
|
* Adds a new bank account by sending the provided token, bank ID, and account number to the public API.
|
|
9
9
|
* Returns the added bank account details or throws an error if the request fails.
|
|
@@ -19,5 +19,4 @@ type AddBankAccountType = {
|
|
|
19
19
|
* Raises:
|
|
20
20
|
* Throws an error if the request fails.
|
|
21
21
|
*/
|
|
22
|
-
export declare const addBankAccount: (token: string, bankId: string, accountNumber: string) => Promise<
|
|
23
|
-
export {};
|
|
22
|
+
export declare const addBankAccount: (token: string, bankId: string, accountNumber: string) => Promise<AddBankAccount>;
|