coralpay-node-sdk
Version:
Coral Pay NodeJS SDK
99 lines (98 loc) • 2.77 kB
TypeScript
/// <reference types="node" />
import { IncomingHttpHeaders } from "http";
import { PGPEncryption } from "./encryption";
import { BankUtil } from "./bank-util";
declare type Logger = (...args: any) => any;
export interface CoralConfig {
privateKey: string;
coralPublicKey?: string;
merchantId: string;
terminalId: string;
userName: string;
password: string;
passphrase?: string;
env: "test" | "prod";
baseUrl?: string;
trace?: boolean | Logger;
isInsecureTwoByteHashPrivateKey?: boolean;
}
interface ApiResponse<T = Record<string, any>> {
statusCode: number;
statusMessage: string;
headers: IncomingHttpHeaders;
body: T | null;
}
export interface CoralPayResponse<T = Record<string, any>> {
ResponseHeader: {
ResponseCode: string;
ResponseMessage: string;
};
ResponseDetails: T;
}
export interface InvokeReferenceRequest {
Channel: string;
Amount: number;
TraceID?: string;
TransactionType?: string;
SubMerchantName?: string;
TerminalId?: string;
}
export interface InvokeReferenceResponse {
Reference: string;
Amount: string;
TransactionID: string;
TraceID?: string;
}
export interface StatusQueryRequest {
Amount: number;
TransactionID: string;
TerminalId?: string;
}
export interface StatusQueryResponse {
responseCode: string;
responsemessage: string;
reference: string;
amount: number;
terminalId: string;
merchantId: string;
retrievalReference: string;
institutionCode: string;
shortName: string;
customer_mobile: string;
SubMerchantName: string;
TransactionID: string;
UserID: string;
TraceID: string;
}
export interface RefundPaymentRequest {
Reference: string;
Amount: number;
TransactionID: string;
TerminalId?: string;
}
export interface RefundPaymentResponse {
MerchantId: string;
TerminalId: string;
Amount: number;
Reference: string;
TransactionID: string;
}
export declare enum METHOD {
POST = "POST",
GET = "GET"
}
export declare class CoralPay {
#private;
private config;
encryption: PGPEncryption;
bankUtil: BankUtil;
private trace;
private logger;
constructor(config: CoralConfig);
sendEncryptedRequest<T = Record<string, any>>(method: METHOD, uri: string, payload?: Record<string, any>, params?: Record<string, any>): Promise<ApiResponse<T>>;
invokeReference(payload: InvokeReferenceRequest): Promise<ApiResponse<CoralPayResponse<InvokeReferenceResponse>>>;
queryTransaction(payload: StatusQueryRequest): Promise<ApiResponse<StatusQueryResponse>>;
refundPayment(payload: RefundPaymentRequest): Promise<ApiResponse<RefundPaymentResponse>>;
private log;
}
export {};