UNPKG

pawapay-sdk

Version:

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.

2 lines 3.43 kB
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}); //# sourceMappingURL=index.cjs.map