ipay-payment-gateway
Version: 
Nodejs library to accept ipay (ipay.com.bd) payments on your backend application
108 lines (103 loc) • 3.02 kB
TypeScript
interface IpayCreatePayment {
    amount: number;
    referenceId?: string;
    description?: string;
    successUrl?: string;
    failureUrl?: string;
    cancelUrl?: string;
}
interface IpayCreatePaymentResponse {
    message: string;
    referenceId: string;
    orderId: string;
    paymentUrl: string;
}
interface IpayCheckStatusResponse {
    statusCode?: number;
    status: string;
    orderId: string;
    referenceId: string;
    orderAmount: number;
    transactionId?: string;
    transactionTime?: string;
}
interface IpayConstructor {
    apiKey: string;
    baseURL: string;
    successUrl: string;
    failureUrl: string;
    cancelUrl: string;
}
declare class IpayGateway {
    private readonly apiKey;
    private readonly baseURL;
    private successUrl;
    private failureUrl;
    private cancelUrl;
    /**
     *
     * @param config config object required by the `ipay-payment-gateway` package
     * @example
     * ```
     * const ipayConfig = {
     *   baseURL: 'https://demo.ipay.com.bd/api/pg',
     *   apiKey: 'abcdxxxxxxxxxxxxxx',
     *   successUrl: 'https://example.com/success',
     *   failureUrl: 'https://example.com/failure',
     *   cancelUrl: 'https://example.com/cancel',
     * }
     * const ipay = new IpayGateway(ipayConfig)
     * ```
     *
     */
    constructor(config: IpayConstructor);
    /**
     * Start the initial payment request
     *
     * @param paymentDetails Information required to start a payment flow
     *
     * @returns Promise of Ipay Create payment Response
     * @example
     * ```
     * const result = await ipay.createPayment({
     *   amount: 100,
     *   referenceId: 'RefXXXX',
     *   description: 'Payment for something',
     *   successUrl: 'https://example.com/success',
     *   failureUrl: 'https://example.com/failure',
     *   cancelUrl: 'https://example.com/cancel',
     * });
     * ```
     */
    createPayment: (paymentDetails: IpayCreatePayment) => Promise<IpayCreatePaymentResponse>;
    /**
     * Check payment status by order id
     *
     * @param orderId Information required to start a payment flow
     *
     * @returns Promise of Ipay Check payment Status Response
     * @example
     * ```
     * const result = await ipay.checkStatusByOrderId('OrderXXXX');
     * ```
     */
    checkStatusByOrderId: (orderId: string) => Promise<IpayCheckStatusResponse>;
    /**
     * Check payment status by Reference id
     *
     * @param refId Information required to start a payment flow
     *
     * @returns Promise of Ipay Check payment Status Response
     * @example
     * ```
     * const result = await ipay.checkStatusByRefId('RefXXXX');
     * ```
     */
    checkStatusByRefId: (refId: string) => Promise<IpayCheckStatusResponse>;
    /**
     * @description Validates the config object
     * @param config
     */
    private validateConfig;
}
export { IpayGateway, IpayGateway as default };