pawapay-sdk 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -90,7 +90,7 @@ const payoutConfig = {
90
90
  amount: '50.00',
91
91
  currency: 'MWK',
92
92
  correspondent: 'AIRTEL_MWI',
93
- receipient: '265991234567',
93
+ recipient: '265991234567',
94
94
  customerTimestamp: new Date().toISOString(),
95
95
  statementDescription: 'Payout for service',
96
96
  country: 'MWI',
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}={}){var 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)}redictCorrespondent(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});
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}={}){var 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
@@ -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 redictCorrespondent(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}"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ACP,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","redictCorrespondent","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\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,IAAA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W,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
@@ -195,7 +195,7 @@ type RequestPayoutConfig = {
195
195
  * Format: Only digits, no whitespaces or separators, no leading zero, must include country code.
196
196
  * @example "265999123456"
197
197
  */
198
- receipient: string;
198
+ recipient: string;
199
199
  /**
200
200
  * @description The timestamp of when the payout was created in the pawaPay platform.
201
201
  * Format defined by 'date-time' in RFC3339 section 5.6.
@@ -1246,7 +1246,7 @@ declare class PawaPayClient {
1246
1246
  getAvailableCorrespondent({ options }?: {
1247
1247
  options?: RequestOptions;
1248
1248
  }): Promise<PawaPayResponse<AvailableCorrespondentResponse[], PawaPayError>>;
1249
- redictCorrespondent(msisdn: string, { options }?: {
1249
+ predictCorrespondent(msisdn: string, { options }?: {
1250
1250
  options?: RequestOptions;
1251
1251
  }): Promise<PawaPayResponse<PredictCorrespondentResponse, PawaPayError>>;
1252
1252
  getPublicKey({ options }?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pawapay-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
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",
@@ -54,4 +54,4 @@
54
54
  "engines": {
55
55
  "node": ">=16"
56
56
  }
57
- }
57
+ }