@rkfl/transact-server 1.0.7 → 2.0.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 CHANGED
@@ -1,174 +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
- ```
81
-
82
- function handleWebhook(req, res) {
83
- const isValid = client.verifyWebhookSignature(req.body);
84
-
85
- if (!isValid) {
86
- console.warn('Webhook signature verification failed');
87
- return res.status(403).send('Invalid signature');
88
- }
89
-
90
- const payload = JSON.parse(req.body.data.data);
91
- console.log('Verified Webhook Payload:', payload);
92
-
93
- // Process your payload
94
- res.status(200).send('Webhook received');
95
- }
96
- ```
97
-
98
- ## 📦 NPM Commands Documentation
99
- ### 1. npm:login
100
-
101
- Logs you into your npm account from the terminal.
102
- You’ll be prompted for your npm username, password, and email.
103
- ```
104
- npm run npm:login
105
- ```
106
- Use this before your first publish or if you’re logged out.
107
-
108
- ### 2. npm:publish
109
- Publishes the current package to npm with public access.
110
- The package name and version must be unique on npm.
111
- ```
112
- npm run npm:publish
113
- ```
114
-
115
- ### 3. npm:patch
116
- Increments the patch version (last digit) in package.json by +1.
117
- Used for bug fixes or small improvements.
118
- ```
119
- npm run npm:patch
120
- ```
121
- Example Version Change:
122
- ```
123
- 1.0.9 → 1.0.10
124
- 1.0.10 → 1.0.11
125
- ```
126
- ### 4. npm:minor
127
- Increments the minor version (middle digit) by +1 and resets patch to 0.
128
- Used for adding new features without breaking compatibility.
129
- ```
130
- npm run npm:minor
131
- ```
132
- Example Version Change:
133
- ```
134
- 1.0.5 → 1.1.0
135
- 1.2.7 → 1.3.0
136
- ```
137
- ### 5. npm:major
138
- Increments the major version (first digit) by +1 and resets minor and patch to 0.
139
- Used for breaking changes or major redesigns.
140
- ```
141
- npm run npm:major
142
- ```
143
- Example Version Change:
144
- ```
145
- 1.4.8 → 2.0.0
146
- 2.1.3 → 3.0.0
147
- ```
148
- ## 🚀 Recommended Workflow
149
- ### Login once:
150
- ```
151
- npm run npm:login
152
- ```
153
- Make changes to your code.
154
-
155
- ### Bump version:
156
- ```
157
- npm run npm:patch
158
- ```
159
- Minor:
160
-
161
- ```
162
- npm run npm:minor
163
- ```
164
- Major:
165
- ```
166
- npm run npm:major
167
- ```
168
-
169
- ### Publish:
170
- ```
171
- npm run npm:publish
172
- ```
173
- ## 📄 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
174
347
  MIT License © RocketFuel Blockchain, Inc.
@@ -1,73 +1,73 @@
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
- }
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
+ }
package/dist/index.d.ts CHANGED
@@ -1,14 +1,2 @@
1
- import type { CartData, Environment } from './constants';
2
- export declare class Rocketfuel {
3
- #private;
4
- constructor({ clientId, clientSecret, merchantId, environment, }: {
5
- clientId: string;
6
- clientSecret: string;
7
- merchantId: string;
8
- environment: Environment;
9
- });
10
- createOrder(payload: CartData): Promise<any>;
11
- transactionLookup(txId: string, type?: 'ORDERID' | 'TXID'): Promise<any>;
12
- verifyAgeVerification(auditId: string): Promise<any>;
13
- verifyWebhookSignature(body: any): boolean;
14
- }
1
+ export * from './payins';
2
+ export * from './payouts';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import t from"crypto-js";import*as e from"crypto";const s={production:"https://app.rocketfuel.inc/api",qa:"https://qa-app.rfdemo.co/api",preprod:"https://preprod-app.rocketdemo.net/api",sandbox:"https://app-sandbox.rocketfuel.inc/api"};class r{#t;#e;#s;#r;#n=null;#a=null;constructor({clientId:t,clientSecret:e,merchantId:r,environment:n}){this.#t=t,this.#e=e,this.#s=r,this.#r=s[n||"production"]}#i(){const e=JSON.stringify({merchantId:this.#s,totop:""});return t.AES.encrypt(e,this.#e).toString()}#o(){const t={"Content-Type":"application/json"};return this.#n&&(t.Authorization=`Bearer ${this.#n}`),t}async#c(){const t={clientId:this.#t,encryptedPayload:this.#i()},e=await fetch(`${this.#r}/auth/generate-auth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error(`Auth failed: ${e.status}`);const s=await e.json(),r=s?.result;if(!r?.access)throw new Error("Token missing in response");this.#n=r.access,this.#a=r.refresh}async#h(t,e,s=!0){const r=await fetch(t,e);if(403===r.status&&s){console.warn(`Received 403, refreshing token and retrying: ${t}`),await this.#c();const s={...e,headers:this.#o()};return this.#h(t,s,!1)}if(!r.ok){const t=new Error(r.statusText);throw t.status=r.status,t}return r.json()}async createOrder(t){this.#n||await this.#c();const e=await this.#h(`${this.#r}/hosted-page`,{method:"POST",headers:this.#o(),body:JSON.stringify(t)});return{uuid:e?.result?.uuid}}async transactionLookup(t,e="ORDERID"){this.#n||await this.#c();const s=await this.#h(`${this.#r}/purchase/transactionLookup`,{method:"POST",headers:this.#o(),body:JSON.stringify({txId:t,type:e})});return s?.result}async verifyAgeVerification(t){this.#n||await this.#c();const e=await this.#h(`${this.#r}/merchant/audit/${t}`,{method:"GET",headers:this.#o()});return e?.result}verifyWebhookSignature(t){try{const{data:{data:s},signature:r}=t,n=e.createVerify("RSA-SHA256");return n.update(s),n.verify("-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2e4stIYooUrKHVQmwztC\n/l0YktX6uz4bE1iDtA2qu4OaXx+IKkwBWa0hO2mzv6dAoawyzxa2jmN01vrpMkMj\nrB+Dxmoq7tRvRTx1hXzZWaKuv37BAYosOIKjom8S8axM1j6zPkX1zpMLE8ys3dUX\nFN5Dl/kBfeCTwGRV4PZjP4a+QwgFRzZVVfnpcRI/O6zhfkdlRah8MrAPWYSoGBpG\nCPiAjUeHO/4JA5zZ6IdfZuy/DKxbcOlt9H+z14iJwB7eVUByoeCE+Bkw+QE4msKs\naIn4xl9GBoyfDZKajTzL50W/oeoE1UcuvVfaULZ9DWnHOy6idCFH1WbYDxYYIWLi\nAQIDAQAB\n-----END PUBLIC KEY-----",r,"base64")}catch(t){return console.error("Signature verification failed:",t),!1}}}export{r as Rocketfuel};
1
+ import e from"crypto-js";import*as t from"crypto";const s={production:"https://app.rocketfuel.inc/api",qa:"https://qa-app.rfdemo.co/api",preprod:"https://preprod-app.rocketdemo.net/api",sandbox:"https://app-sandbox.rocketfuel.inc/api"};class a{#e;#t;#s;#a;#r=null;#n=null;constructor({clientId:e,clientSecret:t,merchantId:a,environment:r}){this.#e=e,this.#t=t,this.#s=a,this.#a=s[r||"production"]}#i(){const t=JSON.stringify({merchantId:this.#s,totop:""});return e.AES.encrypt(t,this.#t).toString()}#o(){const e={"Content-Type":"application/json"};return this.#r&&(e.Authorization=`Bearer ${this.#r}`),e}async#c(){const e={clientId:this.#e,encryptedPayload:this.#i()},t=await fetch(`${this.#a}/auth/generate-auth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`Auth failed: ${t.status}`);const s=await t.json(),a=s?.result;if(!a?.access)throw new Error("Token missing in response");this.#r=a.access,this.#n=a.refresh}async#h(e,t,s=!0){const a=await fetch(e,t);if((401===a.status||403===a.status)&&s){await this.#c();const s={...t,headers:this.#o()};return this.#h(e,s,!1)}if(!a.ok){const e=new Error(a.statusText);throw e.status=a.status,e}return a.json()}async createOrder(e){this.#r||await this.#c();const t=await this.#h(`${this.#a}/hosted-page`,{method:"POST",headers:this.#o(),body:JSON.stringify(e)});return{uuid:t?.result?.uuid}}async transactionLookup(e,t="ORDERID"){this.#r||await this.#c();const s=await this.#h(`${this.#a}/purchase/transactionLookup`,{method:"POST",headers:this.#o(),body:JSON.stringify({txId:e,type:t})});return s?.result}async verifyAgeVerification(e){this.#r||await this.#c();const t=await this.#h(`${this.#a}/merchant/audit/${e}`,{method:"GET",headers:this.#o()});return t?.result}verifyWebhookSignature(e){try{const{data:{data:s},signature:a}=e,r=t.createVerify("RSA-SHA256");return r.update(s),r.verify("-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2e4stIYooUrKHVQmwztC\n/l0YktX6uz4bE1iDtA2qu4OaXx+IKkwBWa0hO2mzv6dAoawyzxa2jmN01vrpMkMj\nrB+Dxmoq7tRvRTx1hXzZWaKuv37BAYosOIKjom8S8axM1j6zPkX1zpMLE8ys3dUX\nFN5Dl/kBfeCTwGRV4PZjP4a+QwgFRzZVVfnpcRI/O6zhfkdlRah8MrAPWYSoGBpG\nCPiAjUeHO/4JA5zZ6IdfZuy/DKxbcOlt9H+z14iJwB7eVUByoeCE+Bkw+QE4msKs\naIn4xl9GBoyfDZKajTzL50W/oeoE1UcuvVfaULZ9DWnHOy6idCFH1WbYDxYYIWLi\nAQIDAQAB\n-----END PUBLIC KEY-----",a,"base64")}catch(e){return console.error("Signature verification failed:",e),!1}}}const r={production:"https://app.rocketfuel.inc/api",qa:"https://qa-app.rfdemo.co/api",preprod:"https://preprod-app.rocketdemo.net/api",sandbox:"https://app-sandbox.rocketfuel.inc/api"};class n{clientId;clientSecret;merchantId;domain;accessToken=null;refreshToken=null;constructor({clientId:e,clientSecret:t,merchantId:s,environment:a}){this.clientId=e,this.clientSecret=t,this.merchantId=s,this.domain=r[a||"production"]}getAuthPayload(){const t=JSON.stringify({merchantId:this.merchantId,totop:""});return e.AES.encrypt(t,this.clientSecret).toString()}getHeaders(){const e={"Content-Type":"application/json"};return this.accessToken&&(e.Authorization=`Bearer ${this.accessToken}`),e}async getAccessToken(){const e={clientId:this.clientId,encryptedPayload:this.getAuthPayload()},t=await fetch(`${this.domain}/auth/generate-auth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`Auth failed: ${t.status}`);const s=await t.json(),a=s?.result;if(!a?.access)throw new Error("Token missing in response");this.accessToken=a.access,this.refreshToken=a.refresh}async requestWithRetry(e,t,s=!0){const a=await fetch(e,t);if((401===a.status||403===a.status)&&s){await this.getAccessToken();const s={...t,headers:this.getHeaders()};return this.requestWithRetry(e,s,!1)}if(!a.ok){const e=new Error(a.statusText);throw e.status=a.status,e}return a.json()}}class i extends n{constructor(e){super(e)}async getBankConfiguration(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId,currency:e.currency,country:e.country}),s=`${this.domain}/payout/fiat/bank-configuration?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()}),r=new URLSearchParams({payeeId:e.payeeId}),n=`${this.domain}/payout/fiat/personal-field-values?${r.toString()}`,i=await this.requestWithRetry(n,{method:"GET",headers:this.getHeaders()}),o=a?.result??a,c=i?.result?.fields;if(c&&o){const e=Object.keys(c),t={};return Object.keys(o).forEach(s=>{t[s]=o[s].map(t=>(e.indexOf(t.name)>-1&&(t.acceptedValues=c[t.name]),t))}),console.debug("fetched personal field values and appended it"),t}return console.debug("no personal field values found"),o}async getStatus(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId,country:e.country,currency:e.currency}),s=`${this.domain}/payout/services?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getCountries(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams;e.payeeId&&t.set("payeeId",e.payeeId),e.currency&&t.set("currency",e.currency);const s=`${this.domain}/payout/fiat/country${t.toString()?`?${t.toString()}`:""}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getCurrencies(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId});e.country&&t.set("country",e.country);const s=`${this.domain}/payout/fiat/currency?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async saveBankDetails(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:e,currency:t.currency,country:t.country}),a=`${this.domain}/payout/fiat/bank-configuration?${s.toString()}`,r=await this.requestWithRetry(a,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return r?.result??r}async deleteBankDetails(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId}),s=`${this.domain}/payout/fiat/bank/${encodeURIComponent(e.bankId)}?${t.toString()}`,a=await this.requestWithRetry(s,{method:"DELETE",headers:this.getHeaders()});return a?.result??a}async listBankDetails(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId}),s=`${this.domain}/payout/fiat/bank-detail?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getTransferFee(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:e.payeeId,country:e.country,currency:e.currency}),a=`${this.domain}/payout/fiat/fees?${s.toString()}`,r=await this.requestWithRetry(a,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return r?.result??r}async transfer(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:e.payeeId,country:e.country,currency:e.currency}),a=`${this.domain}/payout/fiat/transfer?${s.toString()}`,r=await this.requestWithRetry(a,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return r?.result??r}async getTransferStatus(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:t}),a=`${this.domain}/payout/order/${encodeURIComponent(e)}?${s.toString()}`,r=await this.requestWithRetry(a,{method:"GET",headers:this.getHeaders()});return r?.result??r}async getPaymentMethods(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({amount:e.amount});e.payeeId&&t.set("payeeId",e.payeeId),e.country&&t.set("country",e.country),e.currency&&t.set("currency",e.currency);const s=`${this.domain}/payout/fiat/payment-methods?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getFileUploadUrl(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({contentType:e.contentType});e.payeeId&&t.set("payeeId",e.payeeId);const s=`${this.domain}/payout/files/upload-url?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}}class o extends n{constructor(e){super(e)}async getCurrencies(e){this.accessToken||await this.getAccessToken();const t=`${this.domain}/payout/currencies?payeeId=${encodeURIComponent(e)}`,s=await this.requestWithRetry(t,{method:"GET",headers:this.getHeaders()});return s?.result}async checkAddress(e){this.accessToken||await this.getAccessToken();return await this.requestWithRetry(`${this.domain}/payout/know-your-address`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)})}async getTransferFee(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout/fee?payeeId=${encodeURIComponent(e)}`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result}async checkTransfer(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout/withdraw-check?payeeId=${encodeURIComponent(e)}`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result}async transfer(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout/withdraw?payeeId=${encodeURIComponent(e)}`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result}async getTransferStatus(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:t}),a=`${this.domain}/payout/order/${encodeURIComponent(e)}?${s.toString()}`,r=await this.requestWithRetry(a,{method:"GET",headers:this.getHeaders()});return r?.result??r}}class c extends n{constructor(e){super(e)}async invitePayee(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/payout/external/payee`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)});return t?.result}async submitPayeeKyc(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/compliance/kyc`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)});return t?.result}async getPayeeBalance(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/payout-admin/payee/${encodeURIComponent(e)}/balance`,{method:"GET",headers:this.getHeaders()});return t?.result}async getBalance(){this.accessToken||await this.getAccessToken();return await this.requestWithRetry(`${this.domain}/payout-admin/balance`,{method:"GET",headers:this.getHeaders()})}async getRunningBalance(){this.accessToken||await this.getAccessToken();return await this.requestWithRetry(`${this.domain}/payout-admin/running-balance`,{method:"GET",headers:this.getHeaders()})}async createTransferAllocation(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/payout-admin/transfer`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)});return t?.result??t}async allocateTransfer(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout-admin/transfer/${encodeURIComponent(e)}/allocate`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result??a}}class h{static verify(e){try{const{data:s,signature:a}=e||{};if(!s||!a)return!1;const r=t.createVerify("RSA-SHA256");return r.update(s),r.verify("-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2e4stIYooUrKHVQmwztC\n/l0YktX6uz4bE1iDtA2qu4OaXx+IKkwBWa0hO2mzv6dAoawyzxa2jmN01vrpMkMj\nrB+Dxmoq7tRvRTx1hXzZWaKuv37BAYosOIKjom8S8axM1j6zPkX1zpMLE8ys3dUX\nFN5Dl/kBfeCTwGRV4PZjP4a+QwgFRzZVVfnpcRI/O6zhfkdlRah8MrAPWYSoGBpG\nCPiAjUeHO/4JA5zZ6IdfZuy/DKxbcOlt9H+z14iJwB7eVUByoeCE+Bkw+QE4msKs\naIn4xl9GBoyfDZKajTzL50W/oeoE1UcuvVfaULZ9DWnHOy6idCFH1WbYDxYYIWLi\nAQIDAQAB\n-----END PUBLIC KEY-----",a,"base64")}catch(e){return console.error("Payout signature verification failed:",e),!1}}}const d="PAYOUT",u={PayeeAdded:"PayeeAdded",PayeeKycStarted:"PayeeKycStarted",PayeeKycStatusChange:"PayeeKycStatusChange",PayeeFundAllocated:"PayeeFundAllocated",PayoutStarted:"PayoutStarted",PayoutStatusChange:"PayoutStatusChange"};class y{fiat;crypto;admin;constructor(e){this.fiat=new i(e),this.crypto=new o(e),this.admin=new c(e)}}export{u as PAYOUT_WEBHOOK_EVENTS,d as PAYOUT_WEBHOOK_EVENT_TYPE,h as PayoutWebhookVerifier,a as Rocketfuel,y as RocketfuelPayouts};
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,73 @@
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
+ }
@@ -0,0 +1,14 @@
1
+ import type { CartData, Environment } from './constants';
2
+ export declare class Rocketfuel {
3
+ #private;
4
+ constructor({ clientId, clientSecret, merchantId, environment, }: {
5
+ clientId: string;
6
+ clientSecret: string;
7
+ merchantId: string;
8
+ environment: Environment;
9
+ });
10
+ createOrder(payload: CartData): Promise<any>;
11
+ transactionLookup(txId: string, type?: 'ORDERID' | 'TXID'): Promise<any>;
12
+ verifyAgeVerification(auditId: string): Promise<any>;
13
+ verifyWebhookSignature(body: any): boolean;
14
+ }
@@ -0,0 +1,40 @@
1
+ import { type AdminTransferAllocationPayload, type AdminAllocateTransferPayload, type InvitePayeePayload, type PayeeKycPayload } from './constants';
2
+ import { PayoutBase, type PayoutClientConfig } from './core';
3
+ export declare class PayoutAdminClient extends PayoutBase {
4
+ constructor(config: PayoutClientConfig);
5
+ /**
6
+ * Invite a new payee.
7
+ * Maps to: POST /api/payout/external/payee
8
+ */
9
+ invitePayee(payload: InvitePayeePayload): Promise<any>;
10
+ /**
11
+ * Submit KYC for a payee.
12
+ * Maps to: POST /api/compliance/kyc
13
+ */
14
+ submitPayeeKyc(payload: PayeeKycPayload): Promise<any>;
15
+ /**
16
+ * Get the balance of a specific payee.
17
+ * Maps to: GET /api/payout-admin/payee/{payeeId}/balance
18
+ */
19
+ getPayeeBalance(payeeId: string): Promise<any>;
20
+ /**
21
+ * Get payout admin balance.
22
+ * Maps to: GET /api/payout-admin/balance
23
+ */
24
+ getBalance(): Promise<any>;
25
+ /**
26
+ * Get payout admin running balance.
27
+ * Maps to: GET /api/payout-admin/running-balance
28
+ */
29
+ getRunningBalance(): Promise<any>;
30
+ /**
31
+ * Create an allocation transfer for a payee.
32
+ * Maps to: POST /api/payout-admin/transfer
33
+ */
34
+ createTransferAllocation(payload: AdminTransferAllocationPayload): Promise<any>;
35
+ /**
36
+ * Allocate (confirm / retry) a transfer allocation.
37
+ * Maps to: POST /api/payout-admin/transfer/{allocationId}/allocate
38
+ */
39
+ allocateTransfer(allocationId: string, payload: AdminAllocateTransferPayload): Promise<any>;
40
+ }
@@ -0,0 +1,133 @@
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 InvitePayeeExtra {
12
+ email: string;
13
+ refId: string;
14
+ [key: string]: any;
15
+ }
16
+ export interface InvitePayeePayload {
17
+ firstName: string;
18
+ lastName: string;
19
+ countryCode?: string;
20
+ extra: InvitePayeeExtra;
21
+ [key: string]: any;
22
+ }
23
+ export interface PayeeKycPayload {
24
+ referenceId: string;
25
+ type: 'payee' | string;
26
+ kycData: any;
27
+ }
28
+ export interface KnowYourAddressPayload {
29
+ walletAddress: string;
30
+ network: string;
31
+ }
32
+ export interface CryptoTransferFeePayload {
33
+ amount: number;
34
+ cryptoCurrency: string;
35
+ cryptoNetwork: string;
36
+ }
37
+ export interface CryptoTransferCheckPayload {
38
+ amount: string;
39
+ currency: string;
40
+ cryptoCurrency: string;
41
+ cryptoNetwork: string;
42
+ walletAddress: string;
43
+ }
44
+ export interface CryptoTransferPayload {
45
+ amount: string;
46
+ currency: string;
47
+ cryptoCurrency: string;
48
+ cryptoNetwork: string;
49
+ walletAddress: string;
50
+ }
51
+ export interface AdminTransferAllocationPayload {
52
+ payeeId: string;
53
+ amount: string;
54
+ currency: string;
55
+ descriptor: string;
56
+ label: string;
57
+ }
58
+ export interface AdminAllocateTransferPayload {
59
+ retryStatus: boolean;
60
+ payeeId: string;
61
+ }
62
+ export interface BankConfigurationQuery {
63
+ payeeId: string;
64
+ currency: string;
65
+ country: string;
66
+ }
67
+ export interface FiatCountryQuery {
68
+ payeeId?: string;
69
+ currency?: string;
70
+ }
71
+ export interface FiatCurrencyQuery {
72
+ payeeId: string;
73
+ country?: string;
74
+ }
75
+ export interface FiatStatusQuery {
76
+ payeeId: string;
77
+ country: string;
78
+ currency: string;
79
+ }
80
+ export interface SaveBankDetailsPayload {
81
+ bankDetail: {
82
+ bankAccountId: string;
83
+ bankId: string;
84
+ [key: string]: any;
85
+ };
86
+ personalDetail: {
87
+ firstName: string;
88
+ lastName: string;
89
+ address: string;
90
+ [key: string]: any;
91
+ };
92
+ currency: string;
93
+ country: string;
94
+ }
95
+ export interface DeleteBankDetailsParams {
96
+ bankId: string;
97
+ payeeId: string;
98
+ }
99
+ export interface ListBankDetailsQuery {
100
+ payeeId: string;
101
+ }
102
+ export interface FiatTransferFeeQuery {
103
+ payeeId: string;
104
+ country: string;
105
+ currency: string;
106
+ }
107
+ export interface FiatTransferFeePayload {
108
+ currency: string;
109
+ accountToken: string;
110
+ amount: string;
111
+ }
112
+ export interface FiatTransferQuery {
113
+ payeeId: string;
114
+ country: string;
115
+ currency: string;
116
+ }
117
+ export interface FiatTransferPayload {
118
+ accountToken: string;
119
+ amount: string;
120
+ currency: string;
121
+ recordId: string;
122
+ requireAllocation?: boolean;
123
+ }
124
+ export interface FiatPaymentMethodsQuery {
125
+ amount: string;
126
+ country?: string;
127
+ currency?: string;
128
+ payeeId?: string;
129
+ }
130
+ export interface FileUploadUrlQuery {
131
+ contentType: string;
132
+ payeeId?: string;
133
+ }
@@ -0,0 +1,20 @@
1
+ import { type Environment } from './constants';
2
+ export interface PayoutClientConfig {
3
+ clientId: string;
4
+ clientSecret: string;
5
+ merchantId: string;
6
+ environment: Environment;
7
+ }
8
+ export declare abstract class PayoutBase {
9
+ protected clientId: string;
10
+ protected clientSecret: string;
11
+ protected merchantId: string;
12
+ protected domain: string;
13
+ protected accessToken: string | null;
14
+ protected refreshToken: string | null;
15
+ protected constructor({ clientId, clientSecret, merchantId, environment, }: PayoutClientConfig);
16
+ protected getAuthPayload(): string;
17
+ protected getHeaders(): Record<string, string>;
18
+ protected getAccessToken(): Promise<void>;
19
+ protected requestWithRetry(url: string, options: RequestInit, retry?: boolean): Promise<any>;
20
+ }
@@ -0,0 +1,35 @@
1
+ import { type KnowYourAddressPayload, type CryptoTransferFeePayload, type CryptoTransferCheckPayload, type CryptoTransferPayload } from './constants';
2
+ import { PayoutBase, type PayoutClientConfig } from './core';
3
+ export declare class CryptoPayoutClient extends PayoutBase {
4
+ constructor(config: PayoutClientConfig);
5
+ /**
6
+ * Get available payout currencies for a payee.
7
+ * Maps to: GET /api/payout/currencies?payeeId={payeeId}
8
+ */
9
+ getCurrencies(payeeId: string): Promise<any>;
10
+ /**
11
+ * Check risk / compliance for a wallet address.
12
+ * Maps to: POST /api/payout/know-your-address
13
+ */
14
+ checkAddress(payload: KnowYourAddressPayload): Promise<any>;
15
+ /**
16
+ * Get transfer fee quote for a payee.
17
+ * Maps to: POST /api/payout/crypto/fee?payeeId={payeeId}
18
+ */
19
+ getTransferFee(payeeId: string, payload: CryptoTransferFeePayload): Promise<any>;
20
+ /**
21
+ * Check and prepare a crypto transfer for a payee.
22
+ * Maps to: POST /api/payout/withdraw-check?payeeId={payeeId}
23
+ */
24
+ checkTransfer(payeeId: string, payload: CryptoTransferCheckPayload): Promise<any>;
25
+ /**
26
+ * Execute a crypto transfer for a payee.
27
+ * Maps to: POST /api/payout/withdraw?payeeId={payeeId}
28
+ */
29
+ transfer(payeeId: string, payload: CryptoTransferPayload): Promise<any>;
30
+ /**
31
+ * Get transfer status for a payout (crypto / generic).
32
+ * Maps to: GET /api/payout/order/{orderId}?payeeId={payeeId}
33
+ */
34
+ getTransferStatus(orderId: string, payeeId: string): Promise<any>;
35
+ }
@@ -0,0 +1,82 @@
1
+ import { type BankConfigurationQuery, type FiatCountryQuery, type FiatCurrencyQuery, type FiatStatusQuery, type SaveBankDetailsPayload, type DeleteBankDetailsParams, type ListBankDetailsQuery, type FiatTransferFeeQuery, type FiatTransferFeePayload, type FiatTransferQuery, type FiatTransferPayload, type FiatPaymentMethodsQuery, type FileUploadUrlQuery } from './constants';
2
+ import { PayoutBase, type PayoutClientConfig } from './core';
3
+ export declare class FiatPayoutClient extends PayoutBase {
4
+ constructor(config: PayoutClientConfig);
5
+ /**
6
+ * Get bank configuration (fields/schema) for a payee's fiat payout.
7
+ * Also fetches personal field values and merges them into the form data.
8
+ * Maps to: GET /api/payout/fiat/bank-configuration?payeeId={payeeId}&currency={currency}&country={country}
9
+ * and GET /api/payout/fiat/personal-field-values
10
+ */
11
+ getBankConfiguration(query: BankConfigurationQuery): Promise<any>;
12
+ /**
13
+ * Get payout service status (fees and availability).
14
+ * Maps to: GET /api/payout/services?payeeId={payeeId}&country={country}&currency={currency}
15
+ */
16
+ getStatus(query: FiatStatusQuery): Promise<any>;
17
+ /**
18
+ * Get list of supported payout countries.
19
+ * Maps to: GET /api/payout/fiat/country?[payeeId={payeeId}][&currency={currency}]
20
+ */
21
+ getCountries(query: FiatCountryQuery): Promise<any>;
22
+ /**
23
+ * Get list of supported payout currencies for a payee and country.
24
+ * Maps to: GET /api/payout/fiat/currency?payeeId={payeeId}[&country={country}]
25
+ */
26
+ getCurrencies(query: FiatCurrencyQuery): Promise<any>;
27
+ /**
28
+ * Save/update bank details for a payee.
29
+ * Maps to: POST /api/payout/fiat/bank-configuration?payeeId={payeeId}&currency={currency}&country={country}
30
+ */
31
+ saveBankDetails(payeeId: string, payload: SaveBankDetailsPayload): Promise<any>;
32
+ /**
33
+ * Delete a specific bank detail for a payee.
34
+ * Maps to: DELETE /api/payout/fiat/bank/{bankId}?payeeId={payeeId}
35
+ */
36
+ deleteBankDetails(params: DeleteBankDetailsParams): Promise<any>;
37
+ /**
38
+ * List all bank details for a payee.
39
+ * Maps to: GET /api/payout/fiat/bank-detail?payeeId={payeeId}
40
+ */
41
+ listBankDetails(query: ListBankDetailsQuery): Promise<any>;
42
+ /**
43
+ * Get transfer fee quote.
44
+ * Maps to: POST /api/payout/fiat/fees?payeeId={payeeId}&country={country}&currency={currency}
45
+ */
46
+ getTransferFee(query: FiatTransferFeeQuery, payload: FiatTransferFeePayload): Promise<any>;
47
+ /**
48
+ * Initiate transfer to a bank account.
49
+ *
50
+ * Maps to: POST /api/payout/fiat/transfer?payeeId={payeeId}&country={country}&currency={currency}
51
+ *
52
+ * If payload.requireAllocation === true, the backend will first create a CREDIT
53
+ * allocation entry and then perform the transfer atomically.
54
+ */
55
+ transfer(query: FiatTransferQuery, payload: FiatTransferPayload): Promise<any>;
56
+ /**
57
+ * Get transfer status for a payout.
58
+ * Maps to: GET /api/payout/order/{orderId}?payeeId={payeeId}
59
+ */
60
+ getTransferStatus(orderId: string, payeeId: string): Promise<any>;
61
+ /**
62
+ * Get fiat payment methods (options) for a given amount/country/currency.
63
+ * Maps to: GET /api/payout/fiat/payment-methods
64
+ *
65
+ * Backend route query:
66
+ * - amount: string (required)
67
+ * - country: string (optional, ISO2)
68
+ * - currency: string (optional, ISO3)
69
+ */
70
+ getPaymentMethods(query: FiatPaymentMethodsQuery): Promise<any>;
71
+ /**
72
+ * Get presigned S3 upload URL for file uploads.
73
+ * Maps to: GET /api/payout/files/upload-url
74
+ *
75
+ * Backend route query:
76
+ * - contentType: string (required) - The content type of the file to upload
77
+ * - payeeId: string (optional) - The payee ID (if not provided, uses authenticated payee)
78
+ *
79
+ * Returns: { uploadUrl: string, fileKey: string }
80
+ */
81
+ getFileUploadUrl(query: FileUploadUrlQuery): Promise<any>;
82
+ }
@@ -0,0 +1,20 @@
1
+ import type { PayoutClientConfig } from './core';
2
+ import { FiatPayoutClient } from './fiat';
3
+ import { CryptoPayoutClient } from './crypto';
4
+ import { PayoutAdminClient } from './admin';
5
+ export { PayoutWebhookVerifier, PAYOUT_WEBHOOK_EVENT_TYPE, PAYOUT_WEBHOOK_EVENTS, } from './webhook';
6
+ /**
7
+ * High‑level Rocketfuel payouts client that groups all payout operations.
8
+ *
9
+ * Usage:
10
+ * const client = new RocketfuelPayouts(config);
11
+ * await client.fiat.transfer(...);
12
+ * await client.crypto.transfer(...);
13
+ * await client.admin.getBalance();
14
+ */
15
+ export declare class RocketfuelPayouts {
16
+ readonly fiat: FiatPayoutClient;
17
+ readonly crypto: CryptoPayoutClient;
18
+ readonly admin: PayoutAdminClient;
19
+ constructor(config: PayoutClientConfig);
20
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Helper for verifying payout webhook signatures.
3
+ */
4
+ export declare class PayoutWebhookVerifier {
5
+ /**
6
+ * Verify the signature of a payout webhook.
7
+ *
8
+ * The payout webhook sender signs the canonical JSON payload and sends:
9
+ * {
10
+ * ...otherFields,
11
+ * data: "<canonical-json-string>",
12
+ * signature: "<base64-signature>"
13
+ * }
14
+ *
15
+ * This method recomputes the signature using Rocketfuel's public key.
16
+ */
17
+ static verify(body: any): boolean;
18
+ }
19
+ /**
20
+ * Webhook event type for payout webhooks.
21
+ * Matches the `WEBHOOK_EVENT_TYPES.PAYOUT` value in backend models.
22
+ */
23
+ export declare const PAYOUT_WEBHOOK_EVENT_TYPE: "PAYOUT";
24
+ /**
25
+ * Payout webhook event names exposed for SDK consumers.
26
+ * Mirrors the payout-related entries from backend `WEBHOOK_EVENTS`.
27
+ */
28
+ export declare const PAYOUT_WEBHOOK_EVENTS: {
29
+ readonly PayeeAdded: "PayeeAdded";
30
+ readonly PayeeKycStarted: "PayeeKycStarted";
31
+ readonly PayeeKycStatusChange: "PayeeKycStatusChange";
32
+ readonly PayeeFundAllocated: "PayeeFundAllocated";
33
+ readonly PayoutStarted: "PayoutStarted";
34
+ readonly PayoutStatusChange: "PayoutStatusChange";
35
+ };
36
+ export type PayoutWebhookEvent = (typeof PAYOUT_WEBHOOK_EVENTS)[keyof typeof PAYOUT_WEBHOOK_EVENTS];
package/package.json CHANGED
@@ -1,48 +1,57 @@
1
- {
2
- "name": "@rkfl/transact-server",
3
- "main": "./dist/index.js",
4
- "type": "module",
5
- "version": "1.0.7",
6
- "scripts": {
7
- "build": "rollup -c",
8
- "npm:login": "npm login",
9
- "npm:publish": "npm run build && npm publish --access public",
10
- "npm:patch": "npm version patch",
11
- "npm:minor": "npm version minor",
12
- "npm:major": "npm version major",
13
- "test": "echo \"Error: no test specified\" && exit 1"
14
- },
15
- "types": "./dist/index.d.ts",
16
- "exports": {
17
- ".": {
18
- "import": "./dist/index.js",
19
- "require": "./dist/index.js",
20
- "default": "./dist/index.js",
21
- "types": "./dist/index.d.ts"
22
- }
23
- },
24
- "files": [
25
- "dist"
26
- ],
27
- "author": "Rocketfuel",
28
- "license": "ISC",
29
- "description": "Package for the node js server side. to create orders and do more",
30
- "keywords": [
31
- "rocketfuel",
32
- "server",
33
- "crypto",
34
- "payments"
35
- ],
36
- "devDependencies": {
37
- "@types/crypto-js": "^4.2.2",
38
- "rollup": "^2.79.2",
39
- "rollup-plugin-terser": "^7.0.2",
40
- "rollup-plugin-typescript2": "^0.36.0",
41
- "typescript": "^5.8.3"
42
- },
43
- "dependencies": {
44
- "axios": "^1.11.0",
45
- "crypto": "^1.0.1",
46
- "crypto-js": "^4.2.0"
47
- }
48
- }
1
+ {
2
+ "name": "@rkfl/transact-server",
3
+ "main": "./dist/index.js",
4
+ "type": "module",
5
+ "version": "2.0.0-alpha.0",
6
+ "scripts": {
7
+ "build": "rollup -c",
8
+ "npm:login": "npm login",
9
+ "npm:publish": "npm run build && npm publish --access public",
10
+ "npm:publish:alpha": "npm run build && npm publish --access public --tag alpha",
11
+ "npm:patch": "npm version patch",
12
+ "npm:minor": "npm version minor",
13
+ "npm:major": "npm version major",
14
+ "npm:alpha": "npm version prerelease --preid=alpha",
15
+ "npm:alpha:patch": "npm version prepatch --preid=alpha",
16
+ "npm:alpha:minor": "npm version preminor --preid=alpha",
17
+ "npm:alpha:major": "npm version premajor --preid=alpha",
18
+ "test": "jest"
19
+ },
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.js",
25
+ "default": "./dist/index.js",
26
+ "types": "./dist/index.d.ts"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "author": "Rocketfuel",
33
+ "license": "ISC",
34
+ "description": "Package for the node js server side. to create orders and do more",
35
+ "keywords": [
36
+ "rocketfuel",
37
+ "server",
38
+ "crypto",
39
+ "payments",
40
+ "payouts"
41
+ ],
42
+ "devDependencies": {
43
+ "@types/crypto-js": "^4.2.2",
44
+ "@types/jest": "^29.5.14",
45
+ "jest": "^29.7.0",
46
+ "rollup": "^2.79.2",
47
+ "rollup-plugin-terser": "^7.0.2",
48
+ "rollup-plugin-typescript2": "^0.36.0",
49
+ "ts-jest": "^29.4.6",
50
+ "typescript": "^5.8.3"
51
+ },
52
+ "dependencies": {
53
+ "axios": "^1.11.0",
54
+ "crypto": "^1.0.1",
55
+ "crypto-js": "^4.2.0"
56
+ }
57
+ }