pawapay-sdk 0.1.4 → 0.1.5
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var l=Object.create;var u=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var i=(s,e)=>u(s,"name",{value:e,configurable:!0});var q=(s,e)=>{for(var t in e)u(s,t,{get:e[t],enumerable:!0})},c=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of h(e))!y.call(s,a)&&a!==t&&u(s,a,{get:()=>e[a],enumerable:!(r=d(e,a))||r.enumerable});return s};var m=(s,e,t)=>(t=s!=null?l(p(s)):{},c(e||!s||!s.__esModule?u(t,"default",{value:s,enumerable:!0}):t,s)),T=s=>c(u({},"__esModule",{value:!0}),s);var b={};q(b,{PawaPayClient:()=>o});module.exports=T(b);var n=m(require("axios"),1);var o=class{static{i(this,"PawaPayClient")}apiClient;apiKey;config;constructor(e,t){this.apiKey=e,this.config=t,this.apiClient=n.default.create({baseURL:t?.overrideUrl??t?.environment=="live"?"https://api.pawapay.io":"https://api.sandbox.pawapay.io",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}})}async request(e,t){try{let r=await this.apiClient.request(e);return{success:!0,data:r.data,status:r.status,headers:r.headers}}catch(r){return n.default.isAxiosError(r)?{success:!1,error:r.response?.data||r.message,status:r.response?.status||500}:{success:!1,error:{errorMessage:"Unknown error occurred"},status:500}}}async requestDeposit(e,{options:t}={}){return this.request({method:"POST",url:"/deposits",data:e},t)}async checkDepositStatus(e,{options:t}={}){return this.request({method:"GET",url:`/deposits/${e}`},t)}async resendDepositCallback(e,{options:t}={}){
|
|
1
|
+
var l=Object.create;var u=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var i=(s,e)=>u(s,"name",{value:e,configurable:!0});var q=(s,e)=>{for(var t in e)u(s,t,{get:e[t],enumerable:!0})},c=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of h(e))!y.call(s,a)&&a!==t&&u(s,a,{get:()=>e[a],enumerable:!(r=d(e,a))||r.enumerable});return s};var m=(s,e,t)=>(t=s!=null?l(p(s)):{},c(e||!s||!s.__esModule?u(t,"default",{value:s,enumerable:!0}):t,s)),T=s=>c(u({},"__esModule",{value:!0}),s);var b={};q(b,{PawaPayClient:()=>o});module.exports=T(b);var n=m(require("axios"),1);var o=class{static{i(this,"PawaPayClient")}apiClient;apiKey;config;constructor(e,t){this.apiKey=e,this.config=t,this.apiClient=n.default.create({baseURL:t?.overrideUrl??t?.environment=="live"?"https://api.pawapay.io":"https://api.sandbox.pawapay.io",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}})}async request(e,t){try{let r=await this.apiClient.request(e);return{success:!0,data:r.data,status:r.status,headers:r.headers}}catch(r){return n.default.isAxiosError(r)?{success:!1,error:r.response?.data||r.message,status:r.response?.status||500}:{success:!1,error:{errorMessage:"Unknown error occurred"},status:500}}}async requestDeposit(e,{options:t}={}){return this.request({method:"POST",url:"/deposits",data:e},t)}async checkDepositStatus(e,{options:t}={}){return this.request({method:"GET",url:`/deposits/${e}`},t)}async resendDepositCallback(e,{options:t}={}){let r={depositId:e};return this.request({method:"POST",url:"/deposits/resend-callback",data:r},t)}async requestPayout(e,{options:t}={}){return this.request({method:"POST",url:"/payouts",data:e},t)}async checkPayoutStatus(e,{options:t}={}){return this.request({method:"GET",url:`/payouts/${e}`},t)}async resendPayoutCallback(e,{options:t}={}){let r={payoutId:e};return this.request({method:"POST",url:"/payouts/resend-callback",data:r},t)}async cancelEnqueuedPayout(e,{options:t}={}){return this.request({method:"POST",url:`/payouts/fail-enqueued/${e}`},t)}async requestBulkPayout(e,{options:t}={}){return this.request({method:"POST",url:"/payouts/bulk",data:e},t)}async requestRefund(e,{options:t}={}){return this.request({method:"POST",url:"/refunds",data:e},t)}async checkRefundStatus(e,{options:t}={}){return this.request({method:"GET",url:`/refunds/${e}`},t)}async resendRefundCallback(e,{options:t}={}){return this.request({method:"POST",url:"/refund/resend-callback",data:{refundId:e}},t)}async requestPaymentPage(e,{options:t}={}){return this.request({method:"POST",url:"/v1/widget/sessions",data:e})}async checkWalletBalances({options:e}={}){return this.request({method:"GET",url:"/v1/wallet-balances"},e)}async checkWalletBalancesByCountry(e,{options:t}={}){return this.request({method:"GET",url:`/v1/wallet-balances/${e}`})}async getActiveConfiguration({options:e}={}){return this.request({method:"GET",url:"/active-conf"},e)}async getAvailableCorrespondent({options:e}={}){return this.request({method:"GET",url:"/availability"},e)}predictCorrespondent(e,{options:t}={}){let r={msisdn:e};return this.request({method:"GET",url:"/v1/predict-correspondent",data:r},t)}getPublicKey({options:e}={}){return this.request({method:"GET",url:"/public-key/https"},e)}};0&&(module.exports={PawaPayClient});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export * from \"./client.ts\"\nexport type {\n PawaPayError,\n DepositConfig,\n DepositResponse,\n RequestPayPageConfig,\n RequestPayPageResponse,\n RequestRefundConfig,\n RequestRefundResponse,\n WalletBalance,\n ActiveConfigurationResponse,\n AvailableCorrespondentResponse,\n PredictCorrespondentResponse,\n PublicKeysResponse,\n ResendDepositResponse,\n PayoutCallback,\n PawaPayResponse,\n RequestOptions,\n DepositStatus,\n ResendRefundCallbackResponse,\n RequestPayoutConfig,\n RequestPayoutRespose,\n CheckPayoutStatusResponse,\n CancelEnqueuedPayoutResponse,\n RequestBulkPayoutConfig,\n RequestBuildPayoutResponse,\n ResendPayoutCallbackResponse,\n RefundCallback,\n CheckRefundStatusResponse\n} from \"./types/index.t.ts\"","import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';\nimport {\n DepositConfig,\n PawaPayError,\n DepositResponse,\n PawaPayResponse,\n RequestOptions,\n DepositStatus,\n ResendDepositResponse,\n WalletBalance,\n PublicKeysResponse,\n ActiveConfigurationResponse,\n AvailableCorrespondentResponse,\n PredictCorrespondentResponse,\n RequestPayPageConfig,\n RequestPayPageResponse,\n RequestRefundConfig,\n RequestRefundResponse,\n ResendRefundCallbackResponse,\n RequestPayoutConfig,\n RequestPayoutRespose,\n CheckPayoutStatusResponse,\n CancelEnqueuedPayoutResponse,\n RequestBulkPayoutConfig,\n RequestBuildPayoutResponse,\n ResendPayoutCallbackResponse,\n CheckRefundStatusResponse\n} from './types/index.t.ts';\n\ntype Args = {\n options?: RequestOptions;\n};\n\ntype ClientConfig = {\n environment?: \"live\" | \"sandbox\",\n overrideUrl?: string\n}\n\nexport class PawaPayClient {\n private apiClient: AxiosInstance;\n protected apiKey: string;\n private config?: ClientConfig;\n\n constructor(apiKey: string, config?: ClientConfig,) {\n this.apiKey = apiKey;\n this.config = config\n this.apiClient = axios.create({\n baseURL: config?.overrideUrl ?? config?.environment == \"live\" ? 'https://api.pawapay.io' : 'https://api.sandbox.pawapay.io',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.apiKey}`\n }\n });\n }\n\n private async request<T, E>(config: AxiosRequestConfig, options?: RequestOptions)\n : Promise<PawaPayResponse<T, E>> {\n try {\n const response = await this.apiClient.request<T>(config);\n return {\n success: true,\n data: response.data,\n status: response.status,\n headers: response.headers\n }\n } catch (error) {\n if (axios.isAxiosError(error)) {\n return {\n success: false,\n error: error.response?.data || error.message,\n status: error.response?.status || 500\n }\n }\n return {\n success: false,\n error: {\n errorMessage: 'Unknown error occurred'\n } as E,\n status: 500\n };\n }\n }\n\n // --- Deposits\n\n async requestDeposit(data: DepositConfig, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<DepositResponse, PawaPayError>> {\n\n return this.request({\n method: 'POST',\n url: '/deposits',\n data,\n }, options)\n }\n\n\n async checkDepositStatus(depositId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<DepositStatus[], PawaPayError>> {\n return this.request({\n method: 'GET',\n url: `/deposits/${depositId}`\n }, options)\n }\n\n async resendDepositCallback(depositId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<ResendDepositResponse, PawaPayError>> {\n var data = { depositId }\n return this.request({\n method: 'POST',\n url: '/deposits/resend-callback',\n data,\n }, options)\n }\n\n // --- PAYOUTS\n\n async requestPayout(data: RequestPayoutConfig, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<RequestPayoutRespose, PawaPayError>> {\n return this.request({\n method: 'POST',\n url: '/payouts',\n data\n }, options)\n }\n\n async checkPayoutStatus(payoutId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<CheckPayoutStatusResponse[], PawaPayError>> {\n return this.request({\n method: 'GET',\n url: `/payouts/${payoutId}`\n }, options)\n }\n\n async resendPayoutCallback(payoutId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<ResendPayoutCallbackResponse, PawaPayError>> {\n const data = { payoutId }\n return this.request({\n method: 'POST',\n url: '/payouts/resend-callback',\n data\n }, options)\n }\n\n async cancelEnqueuedPayout(payoutId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<CancelEnqueuedPayoutResponse, PawaPayError>> {\n return this.request({\n method: 'POST',\n url: `/payouts/fail-enqueued/${payoutId}`,\n }, options)\n }\n\n async requestBulkPayout(data: RequestBulkPayoutConfig[], { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<RequestBuildPayoutResponse[], PawaPayError>> {\n return this.request({\n method: 'POST',\n url: '/payouts/bulk',\n data,\n }, options)\n }\n\n // --- REFUND\n async requestRefund(refundConfig: RequestRefundConfig, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<RequestRefundResponse, PawaPayError>> {\n return this.request({\n method: \"POST\",\n url: '/refunds',\n data: refundConfig\n }, options)\n }\n\n async checkRefundStatus(refundId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<CheckRefundStatusResponse[], PawaPayError>> {\n return this.request({\n method: 'GET',\n url: `/refunds/${refundId}`\n }, options)\n }\n\n async resendRefundCallback(refundId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<ResendRefundCallbackResponse, PawaPayError>> {\n return this.request({\n method: 'POST',\n url: '/refund/resend-callback',\n data: { refundId }\n }, options)\n }\n\n // --- PAYMENT PAGE\n\n async requestPaymentPage(payload: RequestPayPageConfig, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<RequestPayPageResponse, PawaPayError>> {\n return this.request({\n method: 'POST',\n url: '/v1/widget/sessions',\n data: payload\n })\n }\n\n // --- WALLETS\n\n async checkWalletBalances({ options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<WalletBalance, PawaPayError>> {\n return this.request({\n method: 'GET',\n url: '/v1/wallet-balances'\n }, options)\n }\n\n async checkWalletBalancesByCountry(country: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<WalletBalance, PawaPayError>> {\n return this.request({\n method: 'GET',\n url: `/v1/wallet-balances/${country}`\n })\n }\n\n // --- TOOLKIT\n\n async getActiveConfiguration({ options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<ActiveConfigurationResponse, PawaPayError>> {\n return this.request({\n method: `GET`,\n url: `/active-conf`\n }, options)\n }\n\n async getAvailableCorrespondent({ options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<AvailableCorrespondentResponse[], PawaPayError>> {\n return this.request({\n method: 'GET',\n url: '/availability'\n }, options)\n }\n\n predictCorrespondent(msisdn: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<PredictCorrespondentResponse, PawaPayError>> {\n const data = { msisdn }\n return this.request({\n method: 'GET',\n url: '/v1/predict-correspondent',\n data\n }, options)\n }\n\n getPublicKey({ options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<PublicKeysResponse[], PawaPayError>> {\n return this.request({\n method: 'GET',\n url: '/public-key/https'\n }, options)\n }\n}"],"mappings":"gmBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAyD,sBAsClD,IAAMC,EAAN,KAAMA,CAtCb,MAsCaA,CAAAA,EAAAA,sBACDC,UACEC,OACFC,OAERC,YAAYF,EAAgBC,EAAwB,CAChD,KAAKD,OAASA,EACd,KAAKC,OAASA,EACd,KAAKF,UAAYI,EAAAA,QAAMC,OAAO,CAC1BC,QAASJ,GAAQK,aAAeL,GAAQM,aAAe,OAAS,yBAA2B,iCAC3FC,QAAS,CACL,eAAgB,mBAChB,cAAiB,UAAU,KAAKR,MAAM,EAC1C,CACJ,CAAA,CACJ,CAEA,MAAcS,QAAcR,EAA4BS,EACnB,CACjC,GAAI,CACA,IAAMC,EAAW,MAAM,KAAKZ,UAAUU,QAAWR,CAAAA,EACjD,MAAO,CACHW,QAAS,GACTC,KAAMF,EAASE,KACfC,OAAQH,EAASG,OACjBN,QAASG,EAASH,OACtB,CACJ,OAASO,EAAO,CACZ,OAAIZ,EAAAA,QAAMa,aAAaD,CAAAA,EACZ,CACHH,QAAS,GACTG,MAAOA,EAAMJ,UAAUE,MAAQE,EAAME,QACrCH,OAAQC,EAAMJ,UAAUG,QAAU,GACtC,EAEG,CACHF,QAAS,GACTG,MAAO,CACHG,aAAc,wBAClB,EACAJ,OAAQ,GACZ,CACJ,CACJ,CAIA,MAAMK,eAAeN,EAAqB,CAAEH,QAAAA,CAAO,EAAmC,CAAC,EACzB,CAE1D,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,OACRC,IAAK,YACLR,KAAAA,CACJ,EAAGH,CAAAA,CACP,CAGA,MAAMY,m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CAEAiC,qBAAqBC,EAAgB,CAAElC,QAAAA,CAAO,EAAmC,CAAC,EACP,CACvE,IAAMG,EAAO,CAAE+B,OAAAA,CAAO,EACtB,OAAO,KAAKnC,QAAQ,CAChBW,OAAQ,MACRC,IAAK,4BACLR,KAAAA,CACJ,EAAGH,CAAAA,CACP,CAEAmC,aAAa,CAAEnC,QAAAA,CAAO,EAAmC,CAAC,EACS,CAC/D,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,MACRC,IAAK,mBACT,EAAGX,CAAAA,CACP,CACJ","names":["index_exports","__export","PawaPayClient","__toCommonJS","import_axios","PawaPayClient","apiClient","apiKey","config","constructor","axios","create","baseURL","overrideUrl","environment","headers","request","options","response","success","data","status","error","isAxiosError","message","errorMessage","requestDeposit","method","url","checkDepositStatus","depositId","resendDepositCallback","requestPayout","checkPayoutStatus","payoutId","resendPayoutCallback","cancelEnqueuedPayout","requestBulkPayout","requestRefund","refundConfig","checkRefundStatus","refundId","resendRefundCallback","requestPaymentPage","payload","checkWalletBalances","checkWalletBalancesByCountry","country","getActiveConfiguration","getAvailableCorrespondent","predictCorrespondent","msisdn","getPublicKey"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export * from \"./client.ts\"\nexport type {\n PawaPayError,\n DepositConfig,\n DepositResponse,\n RequestPayPageConfig,\n RequestPayPageResponse,\n RequestRefundConfig,\n RequestRefundResponse,\n WalletBalance,\n ActiveConfigurationResponse,\n AvailableCorrespondentResponse,\n PredictCorrespondentResponse,\n PublicKeysResponse,\n ResendDepositResponse,\n PayoutCallback,\n PawaPayResponse,\n RequestOptions,\n DepositStatus,\n ResendRefundCallbackResponse,\n RequestPayoutConfig,\n RequestPayoutRespose,\n CheckPayoutStatusResponse,\n CancelEnqueuedPayoutResponse,\n RequestBulkPayoutConfig,\n RequestBuildPayoutResponse,\n ResendPayoutCallbackResponse,\n RefundCallback,\n CheckRefundStatusResponse\n} from \"./types/index.t.ts\"","import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';\nimport {\n DepositConfig,\n PawaPayError,\n DepositResponse,\n PawaPayResponse,\n RequestOptions,\n DepositStatus,\n ResendDepositResponse,\n WalletBalance,\n PublicKeysResponse,\n ActiveConfigurationResponse,\n AvailableCorrespondentResponse,\n PredictCorrespondentResponse,\n RequestPayPageConfig,\n RequestPayPageResponse,\n RequestRefundConfig,\n RequestRefundResponse,\n ResendRefundCallbackResponse,\n RequestPayoutConfig,\n RequestPayoutRespose,\n CheckPayoutStatusResponse,\n CancelEnqueuedPayoutResponse,\n RequestBulkPayoutConfig,\n RequestBuildPayoutResponse,\n ResendPayoutCallbackResponse,\n CheckRefundStatusResponse\n} from './types/index.t.ts';\n\n\n\ntype ClientConfig = {\n environment?: \"live\" | \"sandbox\",\n overrideUrl?: string\n}\n\nexport class PawaPayClient {\n private apiClient: AxiosInstance;\n protected apiKey: string;\n private config?: ClientConfig;\n\n constructor(apiKey: string, config?: ClientConfig,) {\n this.apiKey = apiKey;\n this.config = config\n this.apiClient = axios.create({\n baseURL: config?.overrideUrl ?? config?.environment == \"live\" ? 'https://api.pawapay.io' : 'https://api.sandbox.pawapay.io',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.apiKey}`\n }\n });\n }\n\n private async request<T, E>(config: AxiosRequestConfig, options?: RequestOptions)\n : Promise<PawaPayResponse<T, E>> {\n try {\n const response = await this.apiClient.request<T>(config);\n return {\n success: true,\n data: response.data,\n status: response.status,\n headers: response.headers\n }\n } catch (error) {\n if (axios.isAxiosError(error)) {\n return {\n success: false,\n error: error.response?.data || error.message,\n status: error.response?.status || 500\n }\n }\n return {\n success: false,\n error: {\n errorMessage: 'Unknown error occurred'\n } as E,\n status: 500\n };\n }\n }\n\n // --- Deposits\n\n async requestDeposit(data: DepositConfig, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<DepositResponse, PawaPayError>> {\n\n return this.request({\n method: 'POST',\n url: '/deposits',\n data,\n }, options)\n }\n\n\n async checkDepositStatus(depositId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<DepositStatus[], PawaPayError>> {\n return this.request({\n method: 'GET',\n url: `/deposits/${depositId}`\n }, options)\n }\n\n async resendDepositCallback(depositId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<ResendDepositResponse, PawaPayError>> {\n const data = { depositId }\n return this.request({\n method: 'POST',\n url: '/deposits/resend-callback',\n data,\n }, options)\n }\n\n // --- PAYOUTS\n\n async requestPayout(data: RequestPayoutConfig, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<RequestPayoutRespose, PawaPayError>> {\n return this.request({\n method: 'POST',\n url: '/payouts',\n data\n }, options)\n }\n\n async checkPayoutStatus(payoutId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<CheckPayoutStatusResponse[], PawaPayError>> {\n return this.request({\n method: 'GET',\n url: `/payouts/${payoutId}`\n }, options)\n }\n\n async resendPayoutCallback(payoutId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<ResendPayoutCallbackResponse, PawaPayError>> {\n const data = { payoutId }\n return this.request({\n method: 'POST',\n url: '/payouts/resend-callback',\n data\n }, options)\n }\n\n async cancelEnqueuedPayout(payoutId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<CancelEnqueuedPayoutResponse, PawaPayError>> {\n return this.request({\n method: 'POST',\n url: `/payouts/fail-enqueued/${payoutId}`,\n }, options)\n }\n\n async requestBulkPayout(data: RequestBulkPayoutConfig[], { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<RequestBuildPayoutResponse[], PawaPayError>> {\n return this.request({\n method: 'POST',\n url: '/payouts/bulk',\n data,\n }, options)\n }\n\n // --- REFUND\n async requestRefund(refundConfig: RequestRefundConfig, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<RequestRefundResponse, PawaPayError>> {\n return this.request({\n method: \"POST\",\n url: '/refunds',\n data: refundConfig\n }, options)\n }\n\n async checkRefundStatus(refundId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<CheckRefundStatusResponse[], PawaPayError>> {\n return this.request({\n method: 'GET',\n url: `/refunds/${refundId}`\n }, options)\n }\n\n async resendRefundCallback(refundId: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<ResendRefundCallbackResponse, PawaPayError>> {\n return this.request({\n method: 'POST',\n url: '/refund/resend-callback',\n data: { refundId }\n }, options)\n }\n\n // --- PAYMENT PAGE\n\n async requestPaymentPage(payload: RequestPayPageConfig, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<RequestPayPageResponse, PawaPayError>> {\n return this.request({\n method: 'POST',\n url: '/v1/widget/sessions',\n data: payload\n })\n }\n\n // --- WALLETS\n\n async checkWalletBalances({ options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<WalletBalance, PawaPayError>> {\n return this.request({\n method: 'GET',\n url: '/v1/wallet-balances'\n }, options)\n }\n\n async checkWalletBalancesByCountry(country: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<WalletBalance, PawaPayError>> {\n return this.request({\n method: 'GET',\n url: `/v1/wallet-balances/${country}`\n })\n }\n\n // --- TOOLKIT\n\n async getActiveConfiguration({ options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<ActiveConfigurationResponse, PawaPayError>> {\n return this.request({\n method: `GET`,\n url: `/active-conf`\n }, options)\n }\n\n async getAvailableCorrespondent({ options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<AvailableCorrespondentResponse[], PawaPayError>> {\n return this.request({\n method: 'GET',\n url: '/availability'\n }, options)\n }\n\n predictCorrespondent(msisdn: string, { options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<PredictCorrespondentResponse, PawaPayError>> {\n const data = { msisdn }\n return this.request({\n method: 'GET',\n url: '/v1/predict-correspondent',\n data\n }, options)\n }\n\n getPublicKey({ options }: { options?: RequestOptions } = {})\n : Promise<PawaPayResponse<PublicKeysResponse[], PawaPayError>> {\n return this.request({\n method: 'GET',\n url: '/public-key/https'\n }, options)\n }\n}"],"mappings":"gmBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAyD,sBAoClD,IAAMC,EAAN,KAAMA,CApCb,MAoCaA,CAAAA,EAAAA,sBACDC,UACEC,OACFC,OAERC,YAAYF,EAAgBC,EAAwB,CAChD,KAAKD,OAASA,EACd,KAAKC,OAASA,EACd,KAAKF,UAAYI,EAAAA,QAAMC,OAAO,CAC1BC,QAASJ,GAAQK,aAAeL,GAAQM,aAAe,OAAS,yBAA2B,iCAC3FC,QAAS,CACL,eAAgB,mBAChB,cAAiB,UAAU,KAAKR,MAAM,EAC1C,CACJ,CAAA,CACJ,CAEA,MAAcS,QAAcR,EAA4BS,EACnB,CACjC,GAAI,CACA,IAAMC,EAAW,MAAM,KAAKZ,UAAUU,QAAWR,CAAAA,EACjD,MAAO,CACHW,QAAS,GACTC,KAAMF,EAASE,KACfC,OAAQH,EAASG,OACjBN,QAASG,EAASH,OACtB,CACJ,OAASO,EAAO,CACZ,OAAIZ,EAAAA,QAAMa,aAAaD,CAAAA,EACZ,CACHH,QAAS,GACTG,MAAOA,EAAMJ,UAAUE,MAAQE,EAAME,QACrCH,OAAQC,EAAMJ,UAAUG,QAAU,GACtC,EAEG,CACHF,QAAS,GACTG,MAAO,CACHG,aAAc,wBAClB,EACAJ,OAAQ,GACZ,CACJ,CACJ,CAIA,MAAMK,eAAeN,EAAqB,CAAEH,QAAAA,CAAO,EAAmC,CAAC,EACzB,CAE1D,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,OACRC,IAAK,YACLR,KAAAA,CACJ,EAAGH,CAAAA,CACP,CAGA,MAAMY,mBAAmBC,EAAmB,CAAEb,QAAAA,CAAO,EAAmC,CAAC,EAC3B,CAC1D,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,MACRC,IAAK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,OAAO,KAAKnC,QAAQ,CAChBW,OAAQ,MACRC,IAAK,4BACLR,KAAAA,CACJ,EAAGH,CAAAA,CACP,CAEAmC,aAAa,CAAEnC,QAAAA,CAAO,EAAmC,CAAC,EACS,CAC/D,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,MACRC,IAAK,mBACT,EAAGX,CAAAA,CACP,CACJ","names":["index_exports","__export","PawaPayClient","__toCommonJS","import_axios","PawaPayClient","apiClient","apiKey","config","constructor","axios","create","baseURL","overrideUrl","environment","headers","request","options","response","success","data","status","error","isAxiosError","message","errorMessage","requestDeposit","method","url","checkDepositStatus","depositId","resendDepositCallback","requestPayout","checkPayoutStatus","payoutId","resendPayoutCallback","cancelEnqueuedPayout","requestBulkPayout","requestRefund","refundConfig","checkRefundStatus","refundId","resendRefundCallback","requestPaymentPage","payload","checkWalletBalances","checkWalletBalancesByCountry","country","getActiveConfiguration","getAvailableCorrespondent","predictCorrespondent","msisdn","getPublicKey"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1110,12 +1110,12 @@ type RefundCallback = {
|
|
|
1110
1110
|
type WalletBalance = {
|
|
1111
1111
|
balances: {
|
|
1112
1112
|
/**
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1113
|
+
* @description The country in which the MMO operates.
|
|
1114
|
+
*
|
|
1115
|
+
* Format is ISO 3166-1 alpha-3, three character country code in upper case. Read more from {@link https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3#Officially_assigned_code_elements | Wikipedia}.
|
|
1116
|
+
*
|
|
1117
|
+
* @example Example: "MWI"
|
|
1118
|
+
*/
|
|
1119
1119
|
country: string;
|
|
1120
1120
|
/**
|
|
1121
1121
|
* @description The current balance of the wallet.
|
|
@@ -1169,7 +1169,7 @@ type CorrespondentOperationalType = {
|
|
|
1169
1169
|
};
|
|
1170
1170
|
type CorrespondentData = {
|
|
1171
1171
|
correspondent: string;
|
|
1172
|
-
|
|
1172
|
+
operationalType: Array<CorrespondentOperationalType>;
|
|
1173
1173
|
};
|
|
1174
1174
|
interface AvailableCorrespondentResponse extends Countries<CorrespondentData> {
|
|
1175
1175
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pawapay-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "A comprehensive TypeScript/JavaScript SDK for integrating with the pawaPay API, enabling seamless mobile money operations such as deposits, payouts, refunds, wallet balance checks, and more.",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"types": "./dist/index.d.cts",
|