@rkfl/transact-server 1.0.7 → 1.0.9
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 +178 -5
- package/dist/index.d.ts +2 -14
- package/dist/index.js +1 -1
- package/dist/payins/index.d.ts +14 -0
- package/dist/payouts/admin.d.ts +40 -0
- package/dist/payouts/constants.d.ts +169 -0
- package/dist/payouts/core.d.ts +20 -0
- package/dist/payouts/crypto.d.ts +35 -0
- package/dist/payouts/fiat.d.ts +119 -0
- package/dist/payouts/index.d.ts +20 -0
- package/dist/payouts/webhook.d.ts +36 -0
- package/package.json +12 -3
- /package/dist/{constants.d.ts → payins/constants.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -77,24 +77,197 @@ checkTransaction('12345ABC');
|
|
|
77
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
78
|
This function returns true if the signature is valid, otherwise false.
|
|
79
79
|
|
|
80
|
-
```
|
|
81
|
-
|
|
80
|
+
```ts
|
|
82
81
|
function handleWebhook(req, res) {
|
|
83
82
|
const isValid = client.verifyWebhookSignature(req.body);
|
|
84
|
-
|
|
83
|
+
|
|
85
84
|
if (!isValid) {
|
|
86
85
|
console.warn('Webhook signature verification failed');
|
|
87
86
|
return res.status(403).send('Invalid signature');
|
|
88
87
|
}
|
|
89
|
-
|
|
88
|
+
|
|
90
89
|
const payload = JSON.parse(req.body.data.data);
|
|
91
90
|
console.log('Verified Webhook Payload:', payload);
|
|
92
|
-
|
|
91
|
+
|
|
93
92
|
// Process your payload
|
|
94
93
|
res.status(200).send('Webhook received');
|
|
95
94
|
}
|
|
96
95
|
```
|
|
97
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
|
+
|
|
98
271
|
## 📦 NPM Commands Documentation
|
|
99
272
|
### 1. npm:login
|
|
100
273
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
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});e.destinationRecordId&&t.set("destinationRecordId",e.destinationRecordId);const 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 shouldShowExternalPayeeForm(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e}),s=`${this.domain}/payout/user/create/external/check?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async createPayeeUserExternal(e){this.accessToken||await this.getAccessToken();const t=`${this.domain}/payout/user/create/external?payeeId=${e.payeeId}`,s=await this.requestWithRetry(t,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({fName:e.fName,lName:e.lName,email:e.email,country:e.country})});return s?.result??s}async getPublicCountries(e){const t=`${this.domain}/payout/countries?payeeId=${e}`,s=await this.requestWithRetry(t,{method:"GET",headers:this.getHeaders()});return s?.result??s}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,s){this.accessToken||await this.getAccessToken();const a=new URLSearchParams({payeeId:e,currency:t.currency,country:t.country});s?.oldDestinationRecordId&&a.set("oldDestinationRecordId",s.oldDestinationRecordId);const r=`${this.domain}/payout/fiat/bank-configuration?${a.toString()}`,n=await this.requestWithRetry(r,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return n?.result??n}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 getFiatOptions(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({country:e.country,amount:String(e.amount),type:e.type});e.payeeId&&t.set("payeeId",e.payeeId);const s=`${this.domain}/payout/fiat/options?${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}async getComplianceStatus(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({country:e.country,service:e.service});e.destinationRecordId&&t.set("destinationRecordId",e.destinationRecordId),e.payeeId&&t.set("payeeId",e.payeeId);const s=`${this.domain}/payout/compliance-status?${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,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,169 @@
|
|
|
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
|
+
currency: 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
|
+
requireAllocation?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface AdminTransferAllocationPayload {
|
|
53
|
+
payeeId: string;
|
|
54
|
+
amount: string;
|
|
55
|
+
currency: string;
|
|
56
|
+
descriptor: string;
|
|
57
|
+
label: string;
|
|
58
|
+
}
|
|
59
|
+
export interface AdminAllocateTransferPayload {
|
|
60
|
+
retryStatus: boolean;
|
|
61
|
+
payeeId: string;
|
|
62
|
+
}
|
|
63
|
+
export interface BankConfigurationQuery {
|
|
64
|
+
payeeId: string;
|
|
65
|
+
currency: string;
|
|
66
|
+
country: string;
|
|
67
|
+
destinationRecordId?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface FiatCountryQuery {
|
|
70
|
+
payeeId?: string;
|
|
71
|
+
currency?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface FiatCurrencyQuery {
|
|
74
|
+
payeeId: string;
|
|
75
|
+
country?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface FiatStatusQuery {
|
|
78
|
+
payeeId: string;
|
|
79
|
+
country: string;
|
|
80
|
+
currency: string;
|
|
81
|
+
}
|
|
82
|
+
export interface SaveBankDetailsPayload {
|
|
83
|
+
bankDetail: {
|
|
84
|
+
bankAccountId: string;
|
|
85
|
+
bankId: string;
|
|
86
|
+
[key: string]: any;
|
|
87
|
+
};
|
|
88
|
+
personalDetail: {
|
|
89
|
+
firstName: string;
|
|
90
|
+
lastName: string;
|
|
91
|
+
address: string;
|
|
92
|
+
[key: string]: any;
|
|
93
|
+
};
|
|
94
|
+
currency: string;
|
|
95
|
+
country: string;
|
|
96
|
+
destinationRecordId?: string;
|
|
97
|
+
paymentMethod?: string;
|
|
98
|
+
attributes?: Record<string, any>;
|
|
99
|
+
}
|
|
100
|
+
export interface DeleteBankDetailsParams {
|
|
101
|
+
bankId: string;
|
|
102
|
+
payeeId: string;
|
|
103
|
+
}
|
|
104
|
+
export interface ListBankDetailsQuery {
|
|
105
|
+
payeeId: string;
|
|
106
|
+
}
|
|
107
|
+
export interface FiatTransferFeeQuery {
|
|
108
|
+
payeeId: string;
|
|
109
|
+
country: string;
|
|
110
|
+
currency: string;
|
|
111
|
+
}
|
|
112
|
+
export interface FiatTransferFeePayload {
|
|
113
|
+
currency: string;
|
|
114
|
+
accountToken: string;
|
|
115
|
+
amount: string;
|
|
116
|
+
destinationRecordId?: string;
|
|
117
|
+
}
|
|
118
|
+
export interface FiatTransferQuery {
|
|
119
|
+
payeeId: string;
|
|
120
|
+
country: string;
|
|
121
|
+
currency: string;
|
|
122
|
+
}
|
|
123
|
+
export interface FiatTransferPayload {
|
|
124
|
+
accountToken: string;
|
|
125
|
+
amount: string;
|
|
126
|
+
currency: string;
|
|
127
|
+
recordId: string;
|
|
128
|
+
requireAllocation?: boolean;
|
|
129
|
+
destinationRecordId?: string;
|
|
130
|
+
}
|
|
131
|
+
export interface FiatPaymentMethodsQuery {
|
|
132
|
+
amount: string;
|
|
133
|
+
country?: string;
|
|
134
|
+
currency?: string;
|
|
135
|
+
payeeId?: string;
|
|
136
|
+
}
|
|
137
|
+
/** Query for GET /payout/fiat/options (currency list / payers for a payout type). */
|
|
138
|
+
export interface FiatOptionsQuery {
|
|
139
|
+
payeeId: string;
|
|
140
|
+
country: string;
|
|
141
|
+
amount: number;
|
|
142
|
+
type: string;
|
|
143
|
+
}
|
|
144
|
+
export interface FileUploadUrlQuery {
|
|
145
|
+
contentType: string;
|
|
146
|
+
payeeId?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface ComplianceStatusQuery {
|
|
149
|
+
country: string;
|
|
150
|
+
service: string;
|
|
151
|
+
destinationRecordId?: string;
|
|
152
|
+
payeeId?: string;
|
|
153
|
+
}
|
|
154
|
+
export interface CreatePayeeUserExternalPayload {
|
|
155
|
+
payeeId: string;
|
|
156
|
+
fName: string;
|
|
157
|
+
lName: string;
|
|
158
|
+
email: string;
|
|
159
|
+
country: string;
|
|
160
|
+
}
|
|
161
|
+
export interface ShouldShowExternalPayeeFormResponse {
|
|
162
|
+
showForm: boolean;
|
|
163
|
+
}
|
|
164
|
+
export interface Country {
|
|
165
|
+
id: number;
|
|
166
|
+
name: string;
|
|
167
|
+
iso2: string;
|
|
168
|
+
iso3: string;
|
|
169
|
+
}
|
|
@@ -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,119 @@
|
|
|
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 FiatOptionsQuery, type FileUploadUrlQuery, type ComplianceStatusQuery, type CreatePayeeUserExternalPayload, type ShouldShowExternalPayeeFormResponse, type Country } 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}¤cy={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}¤cy={currency}
|
|
15
|
+
*/
|
|
16
|
+
getStatus(query: FiatStatusQuery): Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* Check if external payee form should be shown.
|
|
19
|
+
* Returns true if payee is external, individual, and doesn't have MassPay mapping yet.
|
|
20
|
+
* Maps to: GET /api/payout/user/create/external/check
|
|
21
|
+
*/
|
|
22
|
+
shouldShowExternalPayeeForm(payeeId: string): Promise<ShouldShowExternalPayeeFormResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* Create an external payee user.
|
|
25
|
+
* Maps to: POST /api/payout/user/create/external
|
|
26
|
+
*
|
|
27
|
+
* Required fields:
|
|
28
|
+
* - fName: string (first name)
|
|
29
|
+
* - lName: string (last name)
|
|
30
|
+
* - email: string (valid email address)
|
|
31
|
+
* - country: string (ISO3 code, 3 uppercase letters)
|
|
32
|
+
*/
|
|
33
|
+
createPayeeUserExternal(payload: CreatePayeeUserExternalPayload): Promise<any>;
|
|
34
|
+
/**
|
|
35
|
+
* Get public list of all countries with id, name, iso2, and iso3 codes.
|
|
36
|
+
* This is a public endpoint that does not require authentication.
|
|
37
|
+
* Maps to: GET /api/payout/countries
|
|
38
|
+
*/
|
|
39
|
+
getPublicCountries(payeeId: string): Promise<Country[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Get list of supported payout countries.
|
|
42
|
+
* Maps to: GET /api/payout/fiat/country?[payeeId={payeeId}][¤cy={currency}]
|
|
43
|
+
*/
|
|
44
|
+
getCountries(query: FiatCountryQuery): Promise<any>;
|
|
45
|
+
/**
|
|
46
|
+
* Get list of supported payout currencies for a payee and country.
|
|
47
|
+
* Maps to: GET /api/payout/fiat/currency?payeeId={payeeId}[&country={country}]
|
|
48
|
+
*/
|
|
49
|
+
getCurrencies(query: FiatCurrencyQuery): Promise<any>;
|
|
50
|
+
/**
|
|
51
|
+
* Save/update bank details for a payee.
|
|
52
|
+
* Maps to: POST /api/payout/fiat/bank-configuration?payeeId={payeeId}¤cy={currency}&country={country}[&oldDestinationRecordId={oldDestinationRecordId}]
|
|
53
|
+
*/
|
|
54
|
+
saveBankDetails(payeeId: string, payload: SaveBankDetailsPayload, options?: {
|
|
55
|
+
oldDestinationRecordId?: string;
|
|
56
|
+
}): Promise<any>;
|
|
57
|
+
/**
|
|
58
|
+
* Delete a specific bank detail for a payee.
|
|
59
|
+
* Maps to: DELETE /api/payout/fiat/bank/{bankId}?payeeId={payeeId}
|
|
60
|
+
*/
|
|
61
|
+
deleteBankDetails(params: DeleteBankDetailsParams): Promise<any>;
|
|
62
|
+
/**
|
|
63
|
+
* List all bank details for a payee.
|
|
64
|
+
* Maps to: GET /api/payout/fiat/bank-detail?payeeId={payeeId}
|
|
65
|
+
*/
|
|
66
|
+
listBankDetails(query: ListBankDetailsQuery): Promise<any>;
|
|
67
|
+
/**
|
|
68
|
+
* Get transfer fee quote.
|
|
69
|
+
* Maps to: POST /api/payout/fiat/fees?payeeId={payeeId}&country={country}¤cy={currency}
|
|
70
|
+
*/
|
|
71
|
+
getTransferFee(query: FiatTransferFeeQuery, payload: FiatTransferFeePayload): Promise<any>;
|
|
72
|
+
/**
|
|
73
|
+
* Initiate transfer to a bank account.
|
|
74
|
+
*
|
|
75
|
+
* Maps to: POST /api/payout/fiat/transfer?payeeId={payeeId}&country={country}¤cy={currency}
|
|
76
|
+
*
|
|
77
|
+
* If payload.requireAllocation === true, the backend will first create a CREDIT
|
|
78
|
+
* allocation entry and then perform the transfer atomically.
|
|
79
|
+
*/
|
|
80
|
+
transfer(query: FiatTransferQuery, payload: FiatTransferPayload): Promise<any>;
|
|
81
|
+
/**
|
|
82
|
+
* Get transfer status for a payout.
|
|
83
|
+
* Maps to: GET /api/payout/order/{orderId}?payeeId={payeeId}
|
|
84
|
+
*/
|
|
85
|
+
getTransferStatus(orderId: string, payeeId: string): Promise<any>;
|
|
86
|
+
/**
|
|
87
|
+
* Get fiat payment methods (options) for a given amount/country/currency.
|
|
88
|
+
* Maps to: GET /api/payout/fiat/payment-methods
|
|
89
|
+
*
|
|
90
|
+
* Backend route query:
|
|
91
|
+
* - amount: string (required)
|
|
92
|
+
* - country: string (optional, ISO2)
|
|
93
|
+
* - currency: string (optional, ISO3)
|
|
94
|
+
*/
|
|
95
|
+
getPaymentMethods(query: FiatPaymentMethodsQuery): Promise<any>;
|
|
96
|
+
/**
|
|
97
|
+
* Get fiat payout options (currency list / payers) for a payee.
|
|
98
|
+
* Maps to: GET /api/payout/fiat/options?country={country}&amount={amount}&type={type}
|
|
99
|
+
* Same as payout-app getCurrencyListFiat(amount, country, type).
|
|
100
|
+
* Returns either { payers: [...] } (list of options with destinationRecordId) or { currencySymbols, destinationRecordId }.
|
|
101
|
+
*/
|
|
102
|
+
getFiatOptions(query: FiatOptionsQuery): Promise<any>;
|
|
103
|
+
/**
|
|
104
|
+
* Get presigned S3 upload URL for file uploads.
|
|
105
|
+
* Maps to: GET /api/payout/files/upload-url
|
|
106
|
+
*
|
|
107
|
+
* Backend route query:
|
|
108
|
+
* - contentType: string (required) - The content type of the file to upload
|
|
109
|
+
* - payeeId: string (optional) - The payee ID (if not provided, uses authenticated payee)
|
|
110
|
+
*
|
|
111
|
+
* Returns: { uploadUrl: string, fileKey: string }
|
|
112
|
+
*/
|
|
113
|
+
getFileUploadUrl(query: FileUploadUrlQuery): Promise<any>;
|
|
114
|
+
/**
|
|
115
|
+
* Get the compliance status of payee.
|
|
116
|
+
* Maps to: GET /api/payout/compliance-status?country={country}&service={service}&destinationRecordId={destinationRecordId}
|
|
117
|
+
*/
|
|
118
|
+
getComplianceStatus(query: ComplianceStatusQuery): Promise<any>;
|
|
119
|
+
}
|
|
@@ -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
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
"name": "@rkfl/transact-server",
|
|
3
3
|
"main": "./dist/index.js",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.9",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rollup -c",
|
|
8
8
|
"npm:login": "npm login",
|
|
9
9
|
"npm:publish": "npm run build && npm publish --access public",
|
|
10
|
+
"npm:publish:alpha": "npm run build && npm publish --access public --tag alpha",
|
|
10
11
|
"npm:patch": "npm version patch",
|
|
11
12
|
"npm:minor": "npm version minor",
|
|
12
13
|
"npm:major": "npm version major",
|
|
13
|
-
"
|
|
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"
|
|
14
19
|
},
|
|
15
20
|
"types": "./dist/index.d.ts",
|
|
16
21
|
"exports": {
|
|
@@ -31,13 +36,17 @@
|
|
|
31
36
|
"rocketfuel",
|
|
32
37
|
"server",
|
|
33
38
|
"crypto",
|
|
34
|
-
"payments"
|
|
39
|
+
"payments",
|
|
40
|
+
"payouts"
|
|
35
41
|
],
|
|
36
42
|
"devDependencies": {
|
|
37
43
|
"@types/crypto-js": "^4.2.2",
|
|
44
|
+
"@types/jest": "^29.5.14",
|
|
45
|
+
"jest": "^29.7.0",
|
|
38
46
|
"rollup": "^2.79.2",
|
|
39
47
|
"rollup-plugin-terser": "^7.0.2",
|
|
40
48
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
49
|
+
"ts-jest": "^29.4.6",
|
|
41
50
|
"typescript": "^5.8.3"
|
|
42
51
|
},
|
|
43
52
|
"dependencies": {
|
|
File without changes
|