@rkfl/transact-server 2.1.0-alpha.1 → 2.1.0-alpha.3
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/dist/index.js +1 -1
- package/dist/payouts/constants.d.ts +9 -0
- package/dist/payouts/fiat.d.ts +17 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 createPayeeUser(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e}),s=`${this.domain}/payout/user/create?${t.toString()}`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders()});return a?.result??a}async getCountries(e){if(this.accessToken||await this.getAccessToken(),e.payeeId)try{await this.createPayeeUser(e.payeeId)}catch(e){console.debug("Failed to create payee user:",e)}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}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};
|
|
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 shouldShowExternalPayeeForm(){this.accessToken||await this.getAccessToken();const e=`${this.domain}/payout/user/create/external/check`,t=await this.requestWithRetry(e,{method:"GET",headers:this.getHeaders()});return t?.result??t}async createPayeeUserExternal(e){this.accessToken||await this.getAccessToken();const t=`${this.domain}/payout/user/create/external`,s=await this.requestWithRetry(t,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)});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){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}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
|
|
@@ -138,3 +138,12 @@ export interface ComplianceStatusQuery {
|
|
|
138
138
|
destinationRecordId?: string;
|
|
139
139
|
payeeId?: string;
|
|
140
140
|
}
|
|
141
|
+
export interface CreatePayeeUserExternalPayload {
|
|
142
|
+
fName: string;
|
|
143
|
+
lName: string;
|
|
144
|
+
email: string;
|
|
145
|
+
country: string;
|
|
146
|
+
}
|
|
147
|
+
export interface ShouldShowExternalPayeeFormResponse {
|
|
148
|
+
showForm: boolean;
|
|
149
|
+
}
|
package/dist/payouts/fiat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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, type ComplianceStatusQuery } from './constants';
|
|
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, type ComplianceStatusQuery, type CreatePayeeUserExternalPayload, type ShouldShowExternalPayeeFormResponse } from './constants';
|
|
2
2
|
import { PayoutBase, type PayoutClientConfig } from './core';
|
|
3
3
|
export declare class FiatPayoutClient extends PayoutBase {
|
|
4
4
|
constructor(config: PayoutClientConfig);
|
|
@@ -15,15 +15,25 @@ export declare class FiatPayoutClient extends PayoutBase {
|
|
|
15
15
|
*/
|
|
16
16
|
getStatus(query: FiatStatusQuery): Promise<any>;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
+
shouldShowExternalPayeeForm(): 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>;
|
|
22
34
|
/**
|
|
23
35
|
* Get list of supported payout countries.
|
|
24
|
-
*
|
|
25
|
-
* Maps to: POST /api/payout/user/create?payeeId={payeeId} (if payeeId provided)
|
|
26
|
-
* and GET /api/payout/fiat/country?[payeeId={payeeId}][¤cy={currency}]
|
|
36
|
+
* Maps to: GET /api/payout/fiat/country?[payeeId={payeeId}][¤cy={currency}]
|
|
27
37
|
*/
|
|
28
38
|
getCountries(query: FiatCountryQuery): Promise<any>;
|
|
29
39
|
/**
|