UNPKG

@alsharie/kuraimiepay

Version:

TypeScript Node.js SDK for integrating with Kuraimi Bank E-Pay API for suppliers.

57 lines (56 loc) 1.72 kB
import { AxiosError } from 'axios'; interface KuraimiEPayClientOptions { username: string; password: string; environment?: 'UAT' | 'PROD'; baseUrl?: string; /** * DANGER: Set to `true` to disable SSL/TLS certificate verification. * ONLY use this for trusted UAT/development environments where the server * might have a self-signed certificate. NEVER use in production. * Defaults to `false`. */ dangerouslyDisableSSLCertVerification?: boolean; } interface BaseApiPayload { SCustID: string; REFNO: string; } export interface SendPaymentPayload extends BaseApiPayload { AMOUNT: number; CRCY?: string; MRCHNTNAME: string; PINPASS: string; } export interface ReversePaymentPayload extends BaseApiPayload { } interface ResultSet { PH_REF_NO?: string; } export interface ApiResponse<T = ResultSet | null> { Code: number; Message: string; MessageDesc: string; Date: string; ResultSet: T; } export interface ApiErrorResponseData extends Omit<ApiResponse<null>, 'Code'> { Code?: number; } export interface ApiError extends Error { statusCode?: number; data?: ApiErrorResponseData; originalError?: AxiosError | Error; } declare class KuraimiEPayClient { private axiosInstance; private username; private password; private environment; constructor({ username, password, environment, baseUrl, dangerouslyDisableSSLCertVerification, }: KuraimiEPayClientOptions); private _encodePin; private _handleApiError; sendPayment(paymentData: SendPaymentPayload): Promise<ApiResponse>; reversePayment(reversalData: ReversePaymentPayload): Promise<ApiResponse>; } export default KuraimiEPayClient;