@rkfl/transact-server 2.1.1-alpha.0 β 2.2.0-alpha.0
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 +346 -346
- package/package.json +1 -1
- package/dist/constants.d.ts +0 -73
package/README.md
CHANGED
|
@@ -1,347 +1,347 @@
|
|
|
1
|
-
# Rocketfuel SDK (Node.js)
|
|
2
|
-
|
|
3
|
-
A secure and minimal Node.js SDK to interact with Rocketfuel payment APIs. (This SDK is for Node.js server-side usage.)
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm i @rkfl/transact-server
|
|
9
|
-
```
|
|
10
|
-
## Documentation
|
|
11
|
-
Click here for more detailed [Documentation](https://docs.rocketfuel.inc/plug-ins-and-sdks/javascript-js/rocketfuel-sdk-nodejs)
|
|
12
|
-
## Usage
|
|
13
|
-
|
|
14
|
-
### Create order
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
import { Rocketfuel } from '@rocketfuel/plugin';
|
|
18
|
-
|
|
19
|
-
const client = new Rocketfuel({
|
|
20
|
-
clientId: 'YOUR_ID',
|
|
21
|
-
clientSecret: 'YOUR_SECRET',
|
|
22
|
-
merchantId: 'YOUR_MERCHANT_ID',
|
|
23
|
-
domain: 'production' // or 'sandbox'
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const orderData = {
|
|
27
|
-
amount: "10",
|
|
28
|
-
currency: "USD",
|
|
29
|
-
cart: [
|
|
30
|
-
{
|
|
31
|
-
id: "iphone_14_pro_max",
|
|
32
|
-
name: "iPhone 14 Pro Max",
|
|
33
|
-
price: "10",
|
|
34
|
-
quantity: 1
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
|
-
customerInfo: {
|
|
38
|
-
name: "John Doe",
|
|
39
|
-
email: "john.doe@example.com"
|
|
40
|
-
},
|
|
41
|
-
customParameter: {
|
|
42
|
-
returnMethod: "GET",
|
|
43
|
-
params: [
|
|
44
|
-
{
|
|
45
|
-
name: "submerchant",
|
|
46
|
-
value: "mobilesale"
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
},
|
|
50
|
-
merchant_id: '14ec584d-53af-476d-aacd-2b7f025cf21b'
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const result = await client.createOrder(orderData);
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Transaction Lookup
|
|
58
|
-
To check or confirm the transaction status using order id or Rocketfuel provided transaction id
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
async function checkTransaction(txId) {
|
|
63
|
-
try {
|
|
64
|
-
const result = await client.transactionLookup(txId, 'ORDERID');
|
|
65
|
-
console.log('Transaction Details:', result);
|
|
66
|
-
// Process the transaction details as needed
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error('Error fetching transaction details:', error.message);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
β
|
|
72
|
-
// Example call:
|
|
73
|
-
checkTransaction('12345ABC');
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### Webook Verification
|
|
77
|
-
Use this function to verify that a webhook is valid and trusted before processing its contents. It prevents spoofed requests, data tampering, and unauthorized events.
|
|
78
|
-
This function returns true if the signature is valid, otherwise false.
|
|
79
|
-
|
|
80
|
-
```ts
|
|
81
|
-
function handleWebhook(req, res) {
|
|
82
|
-
const isValid = client.verifyWebhookSignature(req.body);
|
|
83
|
-
|
|
84
|
-
if (!isValid) {
|
|
85
|
-
console.warn('Webhook signature verification failed');
|
|
86
|
-
return res.status(403).send('Invalid signature');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const payload = JSON.parse(req.body.data.data);
|
|
90
|
-
console.log('Verified Webhook Payload:', payload);
|
|
91
|
-
|
|
92
|
-
// Process your payload
|
|
93
|
-
res.status(200).send('Webhook received');
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## Payouts SDK (Fiat, Crypto & Admin)
|
|
98
|
-
|
|
99
|
-
The payouts SDK lets you invite payees, manage KYC, allocate/administer balances, and send fiat or crypto payouts using a single high-level client.
|
|
100
|
-
|
|
101
|
-
### Payout client setup
|
|
102
|
-
|
|
103
|
-
```ts
|
|
104
|
-
import { RocketfuelPayouts } from '@rkfl/transact-server';
|
|
105
|
-
|
|
106
|
-
const payouts = new RocketfuelPayouts({
|
|
107
|
-
clientId: 'YOUR_ID',
|
|
108
|
-
clientSecret: 'YOUR_SECRET',
|
|
109
|
-
merchantId: 'YOUR_MERCHANT_ID',
|
|
110
|
-
environment: 'sandbox', // 'production' | 'qa' | 'preprod' | 'sandbox'
|
|
111
|
-
});
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
The `RocketfuelPayouts` client exposes three scoped clients:
|
|
115
|
-
|
|
116
|
-
- **Fiat payouts**: `payouts.fiat`
|
|
117
|
-
- **Crypto payouts**: `payouts.crypto`
|
|
118
|
-
- **Admin operations**: `payouts.admin`
|
|
119
|
-
|
|
120
|
-
### Fiat payouts (bank payouts)
|
|
121
|
-
|
|
122
|
-
```ts
|
|
123
|
-
// Get bank configuration for a payee
|
|
124
|
-
const bankConfig = await payouts.fiat.getBankConfiguration({
|
|
125
|
-
payeeId: 'payee-id',
|
|
126
|
-
country: 'US',
|
|
127
|
-
currency: 'USD',
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// Save/update bank details
|
|
131
|
-
await payouts.fiat.saveBankDetails('payee-id', {
|
|
132
|
-
currency: 'USD',
|
|
133
|
-
country: 'US',
|
|
134
|
-
// ...bank fields as required by bankConfig
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// Get transfer fee quote
|
|
138
|
-
const feeQuote = await payouts.fiat.getTransferFee(
|
|
139
|
-
{ payeeId: 'payee-id', country: 'US', currency: 'USD' },
|
|
140
|
-
{
|
|
141
|
-
amount: '100.00',
|
|
142
|
-
currency: 'USD',
|
|
143
|
-
country: 'US',
|
|
144
|
-
},
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
// Send a fiat transfer
|
|
148
|
-
const transferResult = await payouts.fiat.transfer(
|
|
149
|
-
{ payeeId: 'payee-id', country: 'US', currency: 'USD' },
|
|
150
|
-
{
|
|
151
|
-
amount: '100.00',
|
|
152
|
-
currency: 'USD',
|
|
153
|
-
country: 'US',
|
|
154
|
-
// ...bank detail reference / additional payload
|
|
155
|
-
},
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
// Check transfer status (fiat or generic payout)
|
|
159
|
-
const status = await payouts.fiat.getTransferStatus('order-id', 'payee-id');
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### Crypto payouts
|
|
163
|
-
|
|
164
|
-
```ts
|
|
165
|
-
// Get payout currencies available for a payee
|
|
166
|
-
const currencies = await payouts.crypto.getCurrencies('payee-id');
|
|
167
|
-
|
|
168
|
-
// Optionally check address risk/compliance
|
|
169
|
-
await payouts.crypto.checkAddress({
|
|
170
|
-
address: '0x...',
|
|
171
|
-
chain: 'ETH',
|
|
172
|
-
// ...other KYT fields
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Get crypto transfer fee quote
|
|
176
|
-
const cryptoFee = await payouts.crypto.getTransferFee('payee-id', {
|
|
177
|
-
amount: '10',
|
|
178
|
-
currency: 'ETH',
|
|
179
|
-
chain: 'ETH',
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
// Prepare/validate transfer
|
|
183
|
-
const check = await payouts.crypto.checkTransfer('payee-id', {
|
|
184
|
-
amount: '10',
|
|
185
|
-
currency: 'ETH',
|
|
186
|
-
chain: 'ETH',
|
|
187
|
-
toAddress: '0x...',
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
// Execute crypto transfer
|
|
191
|
-
const tx = await payouts.crypto.transfer('payee-id', {
|
|
192
|
-
amount: '10',
|
|
193
|
-
currency: 'ETH',
|
|
194
|
-
chain: 'ETH',
|
|
195
|
-
toAddress: '0x...',
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// Check transfer status (crypto or generic payout)
|
|
199
|
-
const cryptoStatus = await payouts.crypto.getTransferStatus('order-id', 'payee-id');
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Payout admin operations
|
|
203
|
-
|
|
204
|
-
```ts
|
|
205
|
-
// Invite a new payee
|
|
206
|
-
const newPayee = await payouts.admin.invitePayee({
|
|
207
|
-
email: 'user@example.com',
|
|
208
|
-
// ...other payee fields
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
// Submit KYC for a payee
|
|
212
|
-
await payouts.admin.submitPayeeKyc({
|
|
213
|
-
payeeId: newPayee.id,
|
|
214
|
-
// ...KYC payload
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
// Get a payee's internal balance
|
|
218
|
-
const payeeBalance = await payouts.admin.getPayeeBalance('payee-id');
|
|
219
|
-
|
|
220
|
-
// Get overall payout admin balance and running balance
|
|
221
|
-
const adminBalance = await payouts.admin.getBalance();
|
|
222
|
-
const runningBalance = await payouts.admin.getRunningBalance();
|
|
223
|
-
|
|
224
|
-
// Create an allocation transfer
|
|
225
|
-
const allocation = await payouts.admin.createTransferAllocation({
|
|
226
|
-
payeeId: 'payee-id',
|
|
227
|
-
amount: '100.00',
|
|
228
|
-
currency: 'USD',
|
|
229
|
-
// ...other allocation fields
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
// Confirm / allocate a transfer
|
|
233
|
-
await payouts.admin.allocateTransfer(allocation.id, {
|
|
234
|
-
action: 'CONFIRM', // or other allocation actions supported by backend
|
|
235
|
-
});
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Payout webhook verification & events
|
|
239
|
-
|
|
240
|
-
Use the payout webhook helper to validate webhook signatures and use typed event names:
|
|
241
|
-
|
|
242
|
-
```ts
|
|
243
|
-
import {
|
|
244
|
-
PayoutWebhookVerifier,
|
|
245
|
-
PAYOUT_WEBHOOK_EVENT_TYPE,
|
|
246
|
-
PAYOUT_WEBHOOK_EVENTS,
|
|
247
|
-
} from '@rkfl/transact-server';
|
|
248
|
-
|
|
249
|
-
function handlePayoutWebhook(req, res) {
|
|
250
|
-
const isValid = PayoutWebhookVerifier.verify(req.body);
|
|
251
|
-
|
|
252
|
-
if (!isValid) {
|
|
253
|
-
console.warn('Payout webhook signature verification failed');
|
|
254
|
-
return res.status(403).send('Invalid signature');
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Top-level event metadata
|
|
258
|
-
const { event, notificationType, timestamp } = req.body;
|
|
259
|
-
|
|
260
|
-
// Canonical payload string signed by Rocketfuel
|
|
261
|
-
const payload = JSON.parse(req.body.data);
|
|
262
|
-
|
|
263
|
-
if (event === PAYOUT_WEBHOOK_EVENTS.PayoutStatusChange) {
|
|
264
|
-
// handle payout status change
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
return res.status(200).send('OK');
|
|
268
|
-
}
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
## π¦ NPM Commands Documentation
|
|
272
|
-
### 1. npm:login
|
|
273
|
-
|
|
274
|
-
Logs you into your npm account from the terminal.
|
|
275
|
-
Youβll be prompted for your npm username, password, and email.
|
|
276
|
-
```
|
|
277
|
-
npm run npm:login
|
|
278
|
-
```
|
|
279
|
-
Use this before your first publish or if youβre logged out.
|
|
280
|
-
|
|
281
|
-
### 2. npm:publish
|
|
282
|
-
Publishes the current package to npm with public access.
|
|
283
|
-
The package name and version must be unique on npm.
|
|
284
|
-
```
|
|
285
|
-
npm run npm:publish
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
### 3. npm:patch
|
|
289
|
-
Increments the patch version (last digit) in package.json by +1.
|
|
290
|
-
Used for bug fixes or small improvements.
|
|
291
|
-
```
|
|
292
|
-
npm run npm:patch
|
|
293
|
-
```
|
|
294
|
-
Example Version Change:
|
|
295
|
-
```
|
|
296
|
-
1.0.9 β 1.0.10
|
|
297
|
-
1.0.10 β 1.0.11
|
|
298
|
-
```
|
|
299
|
-
### 4. npm:minor
|
|
300
|
-
Increments the minor version (middle digit) by +1 and resets patch to 0.
|
|
301
|
-
Used for adding new features without breaking compatibility.
|
|
302
|
-
```
|
|
303
|
-
npm run npm:minor
|
|
304
|
-
```
|
|
305
|
-
Example Version Change:
|
|
306
|
-
```
|
|
307
|
-
1.0.5 β 1.1.0
|
|
308
|
-
1.2.7 β 1.3.0
|
|
309
|
-
```
|
|
310
|
-
### 5. npm:major
|
|
311
|
-
Increments the major version (first digit) by +1 and resets minor and patch to 0.
|
|
312
|
-
Used for breaking changes or major redesigns.
|
|
313
|
-
```
|
|
314
|
-
npm run npm:major
|
|
315
|
-
```
|
|
316
|
-
Example Version Change:
|
|
317
|
-
```
|
|
318
|
-
1.4.8 β 2.0.0
|
|
319
|
-
2.1.3 β 3.0.0
|
|
320
|
-
```
|
|
321
|
-
## π Recommended Workflow
|
|
322
|
-
### Login once:
|
|
323
|
-
```
|
|
324
|
-
npm run npm:login
|
|
325
|
-
```
|
|
326
|
-
Make changes to your code.
|
|
327
|
-
|
|
328
|
-
### Bump version:
|
|
329
|
-
```
|
|
330
|
-
npm run npm:patch
|
|
331
|
-
```
|
|
332
|
-
Minor:
|
|
333
|
-
|
|
334
|
-
```
|
|
335
|
-
npm run npm:minor
|
|
336
|
-
```
|
|
337
|
-
Major:
|
|
338
|
-
```
|
|
339
|
-
npm run npm:major
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
### Publish:
|
|
343
|
-
```
|
|
344
|
-
npm run npm:publish
|
|
345
|
-
```
|
|
346
|
-
## π License
|
|
1
|
+
# Rocketfuel SDK (Node.js)
|
|
2
|
+
|
|
3
|
+
A secure and minimal Node.js SDK to interact with Rocketfuel payment APIs. (This SDK is for Node.js server-side usage.)
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @rkfl/transact-server
|
|
9
|
+
```
|
|
10
|
+
## Documentation
|
|
11
|
+
Click here for more detailed [Documentation](https://docs.rocketfuel.inc/plug-ins-and-sdks/javascript-js/rocketfuel-sdk-nodejs)
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Create order
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { Rocketfuel } from '@rocketfuel/plugin';
|
|
18
|
+
|
|
19
|
+
const client = new Rocketfuel({
|
|
20
|
+
clientId: 'YOUR_ID',
|
|
21
|
+
clientSecret: 'YOUR_SECRET',
|
|
22
|
+
merchantId: 'YOUR_MERCHANT_ID',
|
|
23
|
+
domain: 'production' // or 'sandbox'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const orderData = {
|
|
27
|
+
amount: "10",
|
|
28
|
+
currency: "USD",
|
|
29
|
+
cart: [
|
|
30
|
+
{
|
|
31
|
+
id: "iphone_14_pro_max",
|
|
32
|
+
name: "iPhone 14 Pro Max",
|
|
33
|
+
price: "10",
|
|
34
|
+
quantity: 1
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
customerInfo: {
|
|
38
|
+
name: "John Doe",
|
|
39
|
+
email: "john.doe@example.com"
|
|
40
|
+
},
|
|
41
|
+
customParameter: {
|
|
42
|
+
returnMethod: "GET",
|
|
43
|
+
params: [
|
|
44
|
+
{
|
|
45
|
+
name: "submerchant",
|
|
46
|
+
value: "mobilesale"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
merchant_id: '14ec584d-53af-476d-aacd-2b7f025cf21b'
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const result = await client.createOrder(orderData);
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Transaction Lookup
|
|
58
|
+
To check or confirm the transaction status using order id or Rocketfuel provided transaction id
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
async function checkTransaction(txId) {
|
|
63
|
+
try {
|
|
64
|
+
const result = await client.transactionLookup(txId, 'ORDERID');
|
|
65
|
+
console.log('Transaction Details:', result);
|
|
66
|
+
// Process the transaction details as needed
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error('Error fetching transaction details:', error.message);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
β
|
|
72
|
+
// Example call:
|
|
73
|
+
checkTransaction('12345ABC');
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Webook Verification
|
|
77
|
+
Use this function to verify that a webhook is valid and trusted before processing its contents. It prevents spoofed requests, data tampering, and unauthorized events.
|
|
78
|
+
This function returns true if the signature is valid, otherwise false.
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
function handleWebhook(req, res) {
|
|
82
|
+
const isValid = client.verifyWebhookSignature(req.body);
|
|
83
|
+
|
|
84
|
+
if (!isValid) {
|
|
85
|
+
console.warn('Webhook signature verification failed');
|
|
86
|
+
return res.status(403).send('Invalid signature');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const payload = JSON.parse(req.body.data.data);
|
|
90
|
+
console.log('Verified Webhook Payload:', payload);
|
|
91
|
+
|
|
92
|
+
// Process your payload
|
|
93
|
+
res.status(200).send('Webhook received');
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Payouts SDK (Fiat, Crypto & Admin)
|
|
98
|
+
|
|
99
|
+
The payouts SDK lets you invite payees, manage KYC, allocate/administer balances, and send fiat or crypto payouts using a single high-level client.
|
|
100
|
+
|
|
101
|
+
### Payout client setup
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { RocketfuelPayouts } from '@rkfl/transact-server';
|
|
105
|
+
|
|
106
|
+
const payouts = new RocketfuelPayouts({
|
|
107
|
+
clientId: 'YOUR_ID',
|
|
108
|
+
clientSecret: 'YOUR_SECRET',
|
|
109
|
+
merchantId: 'YOUR_MERCHANT_ID',
|
|
110
|
+
environment: 'sandbox', // 'production' | 'qa' | 'preprod' | 'sandbox'
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The `RocketfuelPayouts` client exposes three scoped clients:
|
|
115
|
+
|
|
116
|
+
- **Fiat payouts**: `payouts.fiat`
|
|
117
|
+
- **Crypto payouts**: `payouts.crypto`
|
|
118
|
+
- **Admin operations**: `payouts.admin`
|
|
119
|
+
|
|
120
|
+
### Fiat payouts (bank payouts)
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
// Get bank configuration for a payee
|
|
124
|
+
const bankConfig = await payouts.fiat.getBankConfiguration({
|
|
125
|
+
payeeId: 'payee-id',
|
|
126
|
+
country: 'US',
|
|
127
|
+
currency: 'USD',
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Save/update bank details
|
|
131
|
+
await payouts.fiat.saveBankDetails('payee-id', {
|
|
132
|
+
currency: 'USD',
|
|
133
|
+
country: 'US',
|
|
134
|
+
// ...bank fields as required by bankConfig
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Get transfer fee quote
|
|
138
|
+
const feeQuote = await payouts.fiat.getTransferFee(
|
|
139
|
+
{ payeeId: 'payee-id', country: 'US', currency: 'USD' },
|
|
140
|
+
{
|
|
141
|
+
amount: '100.00',
|
|
142
|
+
currency: 'USD',
|
|
143
|
+
country: 'US',
|
|
144
|
+
},
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
// Send a fiat transfer
|
|
148
|
+
const transferResult = await payouts.fiat.transfer(
|
|
149
|
+
{ payeeId: 'payee-id', country: 'US', currency: 'USD' },
|
|
150
|
+
{
|
|
151
|
+
amount: '100.00',
|
|
152
|
+
currency: 'USD',
|
|
153
|
+
country: 'US',
|
|
154
|
+
// ...bank detail reference / additional payload
|
|
155
|
+
},
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
// Check transfer status (fiat or generic payout)
|
|
159
|
+
const status = await payouts.fiat.getTransferStatus('order-id', 'payee-id');
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Crypto payouts
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
// Get payout currencies available for a payee
|
|
166
|
+
const currencies = await payouts.crypto.getCurrencies('payee-id');
|
|
167
|
+
|
|
168
|
+
// Optionally check address risk/compliance
|
|
169
|
+
await payouts.crypto.checkAddress({
|
|
170
|
+
address: '0x...',
|
|
171
|
+
chain: 'ETH',
|
|
172
|
+
// ...other KYT fields
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Get crypto transfer fee quote
|
|
176
|
+
const cryptoFee = await payouts.crypto.getTransferFee('payee-id', {
|
|
177
|
+
amount: '10',
|
|
178
|
+
currency: 'ETH',
|
|
179
|
+
chain: 'ETH',
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Prepare/validate transfer
|
|
183
|
+
const check = await payouts.crypto.checkTransfer('payee-id', {
|
|
184
|
+
amount: '10',
|
|
185
|
+
currency: 'ETH',
|
|
186
|
+
chain: 'ETH',
|
|
187
|
+
toAddress: '0x...',
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Execute crypto transfer
|
|
191
|
+
const tx = await payouts.crypto.transfer('payee-id', {
|
|
192
|
+
amount: '10',
|
|
193
|
+
currency: 'ETH',
|
|
194
|
+
chain: 'ETH',
|
|
195
|
+
toAddress: '0x...',
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// Check transfer status (crypto or generic payout)
|
|
199
|
+
const cryptoStatus = await payouts.crypto.getTransferStatus('order-id', 'payee-id');
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Payout admin operations
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
// Invite a new payee
|
|
206
|
+
const newPayee = await payouts.admin.invitePayee({
|
|
207
|
+
email: 'user@example.com',
|
|
208
|
+
// ...other payee fields
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Submit KYC for a payee
|
|
212
|
+
await payouts.admin.submitPayeeKyc({
|
|
213
|
+
payeeId: newPayee.id,
|
|
214
|
+
// ...KYC payload
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// Get a payee's internal balance
|
|
218
|
+
const payeeBalance = await payouts.admin.getPayeeBalance('payee-id');
|
|
219
|
+
|
|
220
|
+
// Get overall payout admin balance and running balance
|
|
221
|
+
const adminBalance = await payouts.admin.getBalance();
|
|
222
|
+
const runningBalance = await payouts.admin.getRunningBalance();
|
|
223
|
+
|
|
224
|
+
// Create an allocation transfer
|
|
225
|
+
const allocation = await payouts.admin.createTransferAllocation({
|
|
226
|
+
payeeId: 'payee-id',
|
|
227
|
+
amount: '100.00',
|
|
228
|
+
currency: 'USD',
|
|
229
|
+
// ...other allocation fields
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// Confirm / allocate a transfer
|
|
233
|
+
await payouts.admin.allocateTransfer(allocation.id, {
|
|
234
|
+
action: 'CONFIRM', // or other allocation actions supported by backend
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Payout webhook verification & events
|
|
239
|
+
|
|
240
|
+
Use the payout webhook helper to validate webhook signatures and use typed event names:
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
import {
|
|
244
|
+
PayoutWebhookVerifier,
|
|
245
|
+
PAYOUT_WEBHOOK_EVENT_TYPE,
|
|
246
|
+
PAYOUT_WEBHOOK_EVENTS,
|
|
247
|
+
} from '@rkfl/transact-server';
|
|
248
|
+
|
|
249
|
+
function handlePayoutWebhook(req, res) {
|
|
250
|
+
const isValid = PayoutWebhookVerifier.verify(req.body);
|
|
251
|
+
|
|
252
|
+
if (!isValid) {
|
|
253
|
+
console.warn('Payout webhook signature verification failed');
|
|
254
|
+
return res.status(403).send('Invalid signature');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Top-level event metadata
|
|
258
|
+
const { event, notificationType, timestamp } = req.body;
|
|
259
|
+
|
|
260
|
+
// Canonical payload string signed by Rocketfuel
|
|
261
|
+
const payload = JSON.parse(req.body.data);
|
|
262
|
+
|
|
263
|
+
if (event === PAYOUT_WEBHOOK_EVENTS.PayoutStatusChange) {
|
|
264
|
+
// handle payout status change
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return res.status(200).send('OK');
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## π¦ NPM Commands Documentation
|
|
272
|
+
### 1. npm:login
|
|
273
|
+
|
|
274
|
+
Logs you into your npm account from the terminal.
|
|
275
|
+
Youβll be prompted for your npm username, password, and email.
|
|
276
|
+
```
|
|
277
|
+
npm run npm:login
|
|
278
|
+
```
|
|
279
|
+
Use this before your first publish or if youβre logged out.
|
|
280
|
+
|
|
281
|
+
### 2. npm:publish
|
|
282
|
+
Publishes the current package to npm with public access.
|
|
283
|
+
The package name and version must be unique on npm.
|
|
284
|
+
```
|
|
285
|
+
npm run npm:publish
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### 3. npm:patch
|
|
289
|
+
Increments the patch version (last digit) in package.json by +1.
|
|
290
|
+
Used for bug fixes or small improvements.
|
|
291
|
+
```
|
|
292
|
+
npm run npm:patch
|
|
293
|
+
```
|
|
294
|
+
Example Version Change:
|
|
295
|
+
```
|
|
296
|
+
1.0.9 β 1.0.10
|
|
297
|
+
1.0.10 β 1.0.11
|
|
298
|
+
```
|
|
299
|
+
### 4. npm:minor
|
|
300
|
+
Increments the minor version (middle digit) by +1 and resets patch to 0.
|
|
301
|
+
Used for adding new features without breaking compatibility.
|
|
302
|
+
```
|
|
303
|
+
npm run npm:minor
|
|
304
|
+
```
|
|
305
|
+
Example Version Change:
|
|
306
|
+
```
|
|
307
|
+
1.0.5 β 1.1.0
|
|
308
|
+
1.2.7 β 1.3.0
|
|
309
|
+
```
|
|
310
|
+
### 5. npm:major
|
|
311
|
+
Increments the major version (first digit) by +1 and resets minor and patch to 0.
|
|
312
|
+
Used for breaking changes or major redesigns.
|
|
313
|
+
```
|
|
314
|
+
npm run npm:major
|
|
315
|
+
```
|
|
316
|
+
Example Version Change:
|
|
317
|
+
```
|
|
318
|
+
1.4.8 β 2.0.0
|
|
319
|
+
2.1.3 β 3.0.0
|
|
320
|
+
```
|
|
321
|
+
## π Recommended Workflow
|
|
322
|
+
### Login once:
|
|
323
|
+
```
|
|
324
|
+
npm run npm:login
|
|
325
|
+
```
|
|
326
|
+
Make changes to your code.
|
|
327
|
+
|
|
328
|
+
### Bump version:
|
|
329
|
+
```
|
|
330
|
+
npm run npm:patch
|
|
331
|
+
```
|
|
332
|
+
Minor:
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
npm run npm:minor
|
|
336
|
+
```
|
|
337
|
+
Major:
|
|
338
|
+
```
|
|
339
|
+
npm run npm:major
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Publish:
|
|
343
|
+
```
|
|
344
|
+
npm run npm:publish
|
|
345
|
+
```
|
|
346
|
+
## π License
|
|
347
347
|
MIT License Β© RocketFuel Blockchain, Inc.
|
package/package.json
CHANGED
package/dist/constants.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export declare const apiDomains: {
|
|
2
|
-
readonly production: "https://app.rocketfuel.inc/api";
|
|
3
|
-
readonly qa: "https://qa-app.rfdemo.co/api";
|
|
4
|
-
readonly preprod: "https://preprod-app.rocketdemo.net/api";
|
|
5
|
-
readonly sandbox: "https://app-sandbox.rocketfuel.inc/api";
|
|
6
|
-
};
|
|
7
|
-
export type Environment = keyof typeof apiDomains;
|
|
8
|
-
export interface HttpError extends Error {
|
|
9
|
-
status: number;
|
|
10
|
-
}
|
|
11
|
-
export interface CartItem {
|
|
12
|
-
id: string | null;
|
|
13
|
-
price: number;
|
|
14
|
-
name: string;
|
|
15
|
-
quantity: number;
|
|
16
|
-
key?: number;
|
|
17
|
-
totalPrice?: number;
|
|
18
|
-
isSubscription?: boolean | null;
|
|
19
|
-
frequency?: "weekly" | "monthly" | "quarterly" | "half-yearly" | "yearly" | "" | null;
|
|
20
|
-
subscriptionPeriod?: string | null;
|
|
21
|
-
merchantSubscriptionId?: string | null;
|
|
22
|
-
autoRenewal?: boolean | null;
|
|
23
|
-
isSubscriptionRenewal?: boolean | null;
|
|
24
|
-
subscriptionId?: string | null;
|
|
25
|
-
refundable?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface CustomerInfo {
|
|
28
|
-
name: string;
|
|
29
|
-
email?: string;
|
|
30
|
-
phone?: string;
|
|
31
|
-
address?: string;
|
|
32
|
-
allowLoginWithoutEmail?: boolean;
|
|
33
|
-
userIdentifier?: string;
|
|
34
|
-
}
|
|
35
|
-
export interface ShippingAddress {
|
|
36
|
-
firstname?: string;
|
|
37
|
-
lastname?: string;
|
|
38
|
-
phoneNo?: string;
|
|
39
|
-
address1: string;
|
|
40
|
-
address2?: string;
|
|
41
|
-
state: string;
|
|
42
|
-
city: string;
|
|
43
|
-
zipcode?: string;
|
|
44
|
-
country: string;
|
|
45
|
-
landmark?: string | null;
|
|
46
|
-
email?: string | null;
|
|
47
|
-
}
|
|
48
|
-
export interface CustomParameter {
|
|
49
|
-
returnMethod: any;
|
|
50
|
-
params: any;
|
|
51
|
-
}
|
|
52
|
-
export interface FeeConfiguration {
|
|
53
|
-
type: "FIAT" | "PERCENT";
|
|
54
|
-
value: number;
|
|
55
|
-
}
|
|
56
|
-
export interface SiteInfo {
|
|
57
|
-
siteUrl?: string | null;
|
|
58
|
-
siteName?: string | null;
|
|
59
|
-
siteLogo?: string | null;
|
|
60
|
-
}
|
|
61
|
-
export interface CartData {
|
|
62
|
-
merchant_id: string;
|
|
63
|
-
amount: string;
|
|
64
|
-
cart: CartItem[];
|
|
65
|
-
currency: string;
|
|
66
|
-
order?: string;
|
|
67
|
-
redirectUrl?: string;
|
|
68
|
-
customerInfo?: CustomerInfo;
|
|
69
|
-
shippingAddress?: ShippingAddress | null;
|
|
70
|
-
customParameter?: CustomParameter | null;
|
|
71
|
-
feeConfiguration?: FeeConfiguration | null;
|
|
72
|
-
siteInfo?: SiteInfo | null;
|
|
73
|
-
}
|