promptparse
Version:
All-in-one JS library for PromptPay & EMVCo QR Codes
136 lines (128 loc) • 4.53 kB
text/typescript
interface BOTBarcodeConfig {
/** Biller ID (Tax ID + Suffix) */
billerId: string;
/** Reference No. 1 / Customer No. */
ref1: string;
/** Reference No. 2 */
ref2?: string | null;
/** Transaction amount */
amount?: number | null;
}
/**
* Generate BOT Barcode
*
* @returns Barcode Payload
*/
declare function botBarcode({ billerId, ref1, ref2, amount }: BOTBarcodeConfig): string;
declare enum ProxyType {
/** Mobile number */
'MSISDN' = "01",
/** National ID or Tax ID */
'NATID' = "02",
/** E-Wallet ID */
'EWALLETID' = "03",
/** Bank Account (Reserved) */
'BANKACC' = "04"
}
interface AnyIDConfig {
/** Proxy type */
type: keyof typeof ProxyType;
/** Recipient number */
target: string;
/** Transaction amount */
amount?: number;
}
/**
* Generate PromptPay AnyID (Tag 29) QR Code
*
* @returns QR Code Payload
*/
declare function anyId({ type, target, amount }: AnyIDConfig): string;
interface BillPaymentConfig {
/** Biller ID (National ID or Tax ID + Suffix) */
billerId: string;
/** Transaction amount */
amount?: number;
/** Reference 1 */
ref1: string;
/** Reference 2 */
ref2?: string;
/** (Undocumented) Reference 3 */
ref3?: string;
}
/**
* Generate PromptPay Bill Payment (Tag 30) QR Code
*
* @returns QR Code Payload
*/
declare function billPayment({ billerId, amount, ref1, ref2, ref3, }: BillPaymentConfig): string;
interface SlipVerifyConfig {
/** Bank code */
sendingBank: string;
/** Transaction reference */
transRef: string;
}
/**
* Generate Slip Verify QR Code
*
* This also called "Mini-QR" that embedded in slip used for verify transactions
*
* @returns QR Code Payload
*/
declare function slipVerify({ sendingBank, transRef }: SlipVerifyConfig): string;
interface TrueMoneyConfig {
/** Mobile number */
mobileNo: string;
/** Transaction amount */
amount?: number;
/** Personal message (Tag 81) */
message?: string;
}
/**
* Generate QR Code for TrueMoney Wallet
*
* This QR Code can also be scanned with other apps,
* just like a regular e-Wallet PromptPay QR
* but `Personal Message (Tag 81)` will be ignored.
*
* @returns QR Code Payload
*/
declare function trueMoney({ mobileNo, amount, message }: TrueMoneyConfig): string;
interface TrueMoneySlipVerifyConfig {
/** Event Type (Example: P2P) */
eventType: string;
/** Transaction ID */
transactionId: string;
/** Date (DDMMYYYY) */
date: string;
}
/**
* Generate TrueMoney Slip Verify QR Code
*
* Same as a regular Slip Verify QR but with some differences
* - Tag 00 and 01 are set to '01'
* - Tag 51 does not exist
* - Additional tags that are TrueMoney-specific
* - CRC checksum are case-sensitive
*
* @returns QR Code Payload
*/
declare function trueMoneySlipVerify({ eventType, transactionId, date, }: TrueMoneySlipVerifyConfig): string;
type index_AnyIDConfig = AnyIDConfig;
type index_BOTBarcodeConfig = BOTBarcodeConfig;
type index_BillPaymentConfig = BillPaymentConfig;
type index_ProxyType = ProxyType;
declare const index_ProxyType: typeof ProxyType;
type index_SlipVerifyConfig = SlipVerifyConfig;
type index_TrueMoneyConfig = TrueMoneyConfig;
type index_TrueMoneySlipVerifyConfig = TrueMoneySlipVerifyConfig;
declare const index_anyId: typeof anyId;
declare const index_billPayment: typeof billPayment;
declare const index_botBarcode: typeof botBarcode;
declare const index_slipVerify: typeof slipVerify;
declare const index_trueMoney: typeof trueMoney;
declare const index_trueMoneySlipVerify: typeof trueMoneySlipVerify;
declare namespace index {
export { type index_AnyIDConfig as AnyIDConfig, type index_BOTBarcodeConfig as BOTBarcodeConfig, type index_BillPaymentConfig as BillPaymentConfig, index_ProxyType as ProxyType, type index_SlipVerifyConfig as SlipVerifyConfig, type index_TrueMoneyConfig as TrueMoneyConfig, type index_TrueMoneySlipVerifyConfig as TrueMoneySlipVerifyConfig, index_anyId as anyId, index_billPayment as billPayment, index_botBarcode as botBarcode, index_slipVerify as slipVerify, index_trueMoney as trueMoney, index_trueMoneySlipVerify as trueMoneySlipVerify };
}
export { type AnyIDConfig as A, type BOTBarcodeConfig as B, ProxyType as P, type SlipVerifyConfig as S, type TrueMoneyConfig as T, anyId as a, botBarcode as b, type BillPaymentConfig as c, billPayment as d, type TrueMoneySlipVerifyConfig as e, trueMoneySlipVerify as f, index as i, slipVerify as s, trueMoney as t };