pawapay-sdk 0.1.5 → 0.1.6
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.map +1 -1
- package/dist/index.d.cts +176 -1
- package/package.json +2 -2
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\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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RC,IAAK,sBACLR,KAAMwB,CACV,CAAA,CACJ,CAIA,MAAMC,oBAAoB,CAAE5B,QAAAA,CAAO,EAAmC,CAAC,EACX,CACxD,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,MACRC,IAAK,qBACT,EAAGX,CAAAA,CACP,CAEA,MAAM6B,6BAA6BC,EAAiB,CAAE9B,QAAAA,CAAO,EAAmC,CAAC,EACrC,CACxD,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,MACRC,IAAK,uBAAuBmB,CAAAA,EAChC,CAAA,CACJ,CAIA,MAAMC,uBAAuB,CAAE/B,QAAAA,CAAO,EAAmC,CAAC,EACA,CACtE,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,MACRC,IAAK,cACT,EAAGX,CAAAA,CACP,CAEA,MAAMgC,0BAA0B,CAAEhC,QAAAA,CAAO,EAAmC,CAAC,EACE,CAC3E,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,MACRC,IAAK,eACT,EAAGX,CAAAA,CACP,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 DepositCallback,\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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EACX,CACxD,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,MACRC,IAAK,qBACT,EAAGX,CAAAA,CACP,CAEA,MAAM6B,6BAA6BC,EAAiB,CAAE9B,QAAAA,CAAO,EAAmC,CAAC,EACrC,CACxD,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,MACRC,IAAK,uBAAuBmB,CAAAA,EAChC,CAAA,CACJ,CAIA,MAAMC,uBAAuB,CAAE/B,QAAAA,CAAO,EAAmC,CAAC,EACA,CACtE,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,MACRC,IAAK,cACT,EAAGX,CAAAA,CACP,CAEA,MAAMgC,0BAA0B,CAAEhC,QAAAA,CAAO,EAAmC,CAAC,EACE,CAC3E,OAAO,KAAKD,QAAQ,CAChBW,OAAQ,MACRC,IAAK,eACT,EAAGX,CAAAA,CACP,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"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -162,6 +162,181 @@ type DepositConfig = {
|
|
|
162
162
|
isPII?: boolean;
|
|
163
163
|
}>;
|
|
164
164
|
};
|
|
165
|
+
type DepositCallback = {
|
|
166
|
+
/**
|
|
167
|
+
* @description A UUIDv4 based ID specified by you, that uniquely identifies the deposit.
|
|
168
|
+
* Required string length: 36
|
|
169
|
+
* @example depositId: "<INSERT_UUID_FOR_DEPOSIT>"
|
|
170
|
+
*/
|
|
171
|
+
depositId: string;
|
|
172
|
+
/**
|
|
173
|
+
* @description The final status of the payment.
|
|
174
|
+
* COMPLETED - The payment has been successfully processed.
|
|
175
|
+
* FAILED - The payment request has been proceessed, but failed.
|
|
176
|
+
* Available options: `COMPLETED`, `FAILED`
|
|
177
|
+
*/
|
|
178
|
+
status: string;
|
|
179
|
+
/**
|
|
180
|
+
* @description The amount to be collected or disbursed.
|
|
181
|
+
*
|
|
182
|
+
* Amount must follow below requirements or the request will be rejected:
|
|
183
|
+
*
|
|
184
|
+
* Between zero and two decimal places can be supplied, depending on what the specific MMO supports. Learn about all MMO supported decimal places.
|
|
185
|
+
* The minimum and maximum amount depends on the limits of the specific MMO. You can find them from the Active Configuration endpoint.
|
|
186
|
+
* Leading zeroes are not permitted except where the value is less than 1. For any value less than one, one and only one leading zero must be supplied.
|
|
187
|
+
* Trailing zeroes are permitted.
|
|
188
|
+
*
|
|
189
|
+
* Valid examples:
|
|
190
|
+
*
|
|
191
|
+
* 5, 5.0, 5.00, 5.5, 5.55, 5555555, 0.5
|
|
192
|
+
*
|
|
193
|
+
* Not valid examples:
|
|
194
|
+
*
|
|
195
|
+
* @ 5., 5.555, 5555555555555555555, .5, -5.5, 00.5, 00.00, 00001.32
|
|
196
|
+
*
|
|
197
|
+
* Required string length: 1 - 23
|
|
198
|
+
*
|
|
199
|
+
* @example Example: "15"
|
|
200
|
+
|
|
201
|
+
*/
|
|
202
|
+
requestedAmount: string;
|
|
203
|
+
/**
|
|
204
|
+
* @description The currency in which the amount is specified.
|
|
205
|
+
*
|
|
206
|
+
* Format must be the ISO 4217 three character currency code in upper case. Read more from {@link https://en.wikipedia.org/wiki/ISO_4217#Active_codes |Wikipedia}.
|
|
207
|
+
*
|
|
208
|
+
* You can find all the supported currencies that the specific correspondent supports {@link https://docs.pawapay.io/using_the_api#correspondents | from here}.
|
|
209
|
+
*
|
|
210
|
+
* The {@link https://docs.pawapay.io/v1/api-reference/toolkit/active-configuration | active configuration} endpoint provides the list of correspondents configured for your account together with the currencies.
|
|
211
|
+
*
|
|
212
|
+
* @example Example: "MWK"
|
|
213
|
+
*/
|
|
214
|
+
currency: string;
|
|
215
|
+
/**
|
|
216
|
+
* @description The country in which the MMO operates.
|
|
217
|
+
*
|
|
218
|
+
* 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}.
|
|
219
|
+
*
|
|
220
|
+
* @example Example: "MWI"
|
|
221
|
+
*/
|
|
222
|
+
country: string;
|
|
223
|
+
/**
|
|
224
|
+
* @description The correspondent code refers to the specific MMO that the specified phone number (MSISDN) has an active mobile money wallet with.
|
|
225
|
+
*
|
|
226
|
+
* You can find all the supported correspondents {@link https://docs.pawapay.io/using_the_api#correspondents | listed here}.
|
|
227
|
+
*
|
|
228
|
+
* The {@link https://docs.pawapay.io/v1/api-reference/toolkit/active-configuration | active configuration} endpoint provides the list of correspondents configured for your account.
|
|
229
|
+
*
|
|
230
|
+
* You can use the {@link https://docs.pawapay.io/v1/api-reference/toolkit/predict-correspondent | predict correspondent} enpoint to predict the correct correspondent to use based on the phone number (MSISDN).
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* Example: "AIRTEL_MWI"
|
|
234
|
+
*/
|
|
235
|
+
correspondent: string;
|
|
236
|
+
/**
|
|
237
|
+
* @description The phone number (MSISDN) of the recipient or payer must be specified as the `value` of the `address`.
|
|
238
|
+
*/
|
|
239
|
+
payer: {
|
|
240
|
+
/** @description The type of financial address. At the moment, only MSISDN is supported as the financial address.
|
|
241
|
+
* @example
|
|
242
|
+
* {
|
|
243
|
+
* type: "MSISDN"
|
|
244
|
+
* }
|
|
245
|
+
*/
|
|
246
|
+
type: "MSISDN" & string;
|
|
247
|
+
/**
|
|
248
|
+
* @description The phone number (MSISDN) of the payer or recipient.
|
|
249
|
+
*
|
|
250
|
+
* The format is described in {@link https://en.wikipedia.org/wiki/MSISDN | Wikipedia}.
|
|
251
|
+
*
|
|
252
|
+
* MSISDN validation has following rules:
|
|
253
|
+
*
|
|
254
|
+
* - Only digits without whitespaces or any other separators or prefixes like '+'
|
|
255
|
+
* - Should not start with zero.
|
|
256
|
+
* - Country code is mandatory.
|
|
257
|
+
* - Should not exceed or be less than the valid length of specified country.
|
|
258
|
+
* - Valid examples for Malawi: 265999123456
|
|
259
|
+
*
|
|
260
|
+
* Not valid examples for Malawi:
|
|
261
|
+
* +265999123456, +2650999123456, 265 999 123 456, 265-9991-23456, 0265999123456,
|
|
262
|
+
*
|
|
263
|
+
* @example {value: "265 999 123 678"}
|
|
264
|
+
*
|
|
265
|
+
*/
|
|
266
|
+
address: {
|
|
267
|
+
value: string;
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* @description The timestamp of when the deposit was created in the pawaPay platform.
|
|
272
|
+
*
|
|
273
|
+
* Format defined by 'date-time' in RFC3339 section 5.6 from {@link https://tools.ietf.org/html/rfc3339#section-5.6 | IETF}
|
|
274
|
+
*
|
|
275
|
+
* @example Example:"2020-02-21T17:32:28Z"
|
|
276
|
+
*/
|
|
277
|
+
customerTimestamp: string;
|
|
278
|
+
/**
|
|
279
|
+
* @description Short description for the transaction.
|
|
280
|
+
*
|
|
281
|
+
* Depending on the specific MMO performing the transaction this message may be visible to the customer in the SMS receipt or within their transaction history.
|
|
282
|
+
*
|
|
283
|
+
* Must be between 4 and 22 alphanumeric characters.
|
|
284
|
+
*
|
|
285
|
+
* Required string length: 4 - 22
|
|
286
|
+
*
|
|
287
|
+
* @example Example: "Note of 4 to 22 chars"
|
|
288
|
+
*/
|
|
289
|
+
statementDescription: string;
|
|
290
|
+
/**
|
|
291
|
+
* ISO Date String
|
|
292
|
+
* @example "2020-10-19T11:17:01Z"
|
|
293
|
+
*/
|
|
294
|
+
created: string;
|
|
295
|
+
/**
|
|
296
|
+
* @description The amount to be collected or disbursed.
|
|
297
|
+
*
|
|
298
|
+
* Amount must follow below requirements or the request will be rejected:
|
|
299
|
+
*
|
|
300
|
+
* Between zero and two decimal places can be supplied, depending on what the specific MMO supports. Learn about all MMO supported decimal places.
|
|
301
|
+
* The minimum and maximum amount depends on the limits of the specific MMO. You can find them from the Active Configuration endpoint.
|
|
302
|
+
* Leading zeroes are not permitted except where the value is less than 1. For any value less than one, one and only one leading zero must be supplied.
|
|
303
|
+
* Trailing zeroes are permitted.
|
|
304
|
+
*
|
|
305
|
+
* Valid examples:
|
|
306
|
+
*
|
|
307
|
+
* 5, 5.0, 5.00, 5.5, 5.55, 5555555, 0.5
|
|
308
|
+
*
|
|
309
|
+
* Not valid examples:
|
|
310
|
+
*
|
|
311
|
+
* @ 5., 5.555, 5555555555555555555, .5, -5.5, 00.5, 00.00, 00001.32
|
|
312
|
+
*
|
|
313
|
+
* Required string length: 1 - 23
|
|
314
|
+
*
|
|
315
|
+
* @example Example: "15"
|
|
316
|
+
|
|
317
|
+
*/
|
|
318
|
+
depositedAmount: string;
|
|
319
|
+
/**
|
|
320
|
+
* @description When the MNO responded to this deposit request.
|
|
321
|
+
* Format defined by 'date-time' in RFC3339 section 5.6 (https://tools.ietf.org/html/rfc3339#section-5.6)
|
|
322
|
+
*
|
|
323
|
+
* Example: "2020-02-21T17:32:30Z"
|
|
324
|
+
*/
|
|
325
|
+
respondedByPayer: string;
|
|
326
|
+
/**
|
|
327
|
+
* @description The unqiue ID for this financial transaction assigned by the MNO.
|
|
328
|
+
*/
|
|
329
|
+
correspondentIds: {};
|
|
330
|
+
suspiciousActivityReport: {
|
|
331
|
+
activityTypw: string;
|
|
332
|
+
comment: string;
|
|
333
|
+
}[];
|
|
334
|
+
failureReason: {
|
|
335
|
+
failureCode: string;
|
|
336
|
+
failureMessage: string;
|
|
337
|
+
};
|
|
338
|
+
metadata: {};
|
|
339
|
+
};
|
|
165
340
|
type RequestPayoutConfig = {
|
|
166
341
|
/**
|
|
167
342
|
* @description A UUIDv4 based ID specified by you, that uniquely identifies the payout.
|
|
@@ -1254,4 +1429,4 @@ declare class PawaPayClient {
|
|
|
1254
1429
|
}): Promise<PawaPayResponse<PublicKeysResponse[], PawaPayError>>;
|
|
1255
1430
|
}
|
|
1256
1431
|
|
|
1257
|
-
export { type ActiveConfigurationResponse, type AvailableCorrespondentResponse, type CancelEnqueuedPayoutResponse, type CheckPayoutStatusResponse, type CheckRefundStatusResponse, type DepositConfig, type DepositResponse, type DepositStatus, PawaPayClient, type PawaPayError, type PawaPayResponse, type PayoutCallback, type PredictCorrespondentResponse, type PublicKeysResponse, type RefundCallback, type RequestBuildPayoutResponse, type RequestBulkPayoutConfig, type RequestOptions, type RequestPayPageConfig, type RequestPayPageResponse, type RequestPayoutConfig, type RequestPayoutRespose, type RequestRefundConfig, type RequestRefundResponse, type ResendDepositResponse, type ResendPayoutCallbackResponse, type ResendRefundCallbackResponse, type WalletBalance };
|
|
1432
|
+
export { type ActiveConfigurationResponse, type AvailableCorrespondentResponse, type CancelEnqueuedPayoutResponse, type CheckPayoutStatusResponse, type CheckRefundStatusResponse, type DepositCallback, type DepositConfig, type DepositResponse, type DepositStatus, PawaPayClient, type PawaPayError, type PawaPayResponse, type PayoutCallback, type PredictCorrespondentResponse, type PublicKeysResponse, type RefundCallback, type RequestBuildPayoutResponse, type RequestBulkPayoutConfig, type RequestOptions, type RequestPayPageConfig, type RequestPayPageResponse, type RequestPayoutConfig, type RequestPayoutRespose, type RequestRefundConfig, type RequestRefundResponse, type ResendDepositResponse, type ResendPayoutCallbackResponse, type ResendRefundCallbackResponse, type WalletBalance };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pawapay-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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
|
+
}
|