@pqthanh/pay-code-gen
Version:
A package to generate pay codes for fast money transfer (excluding QR code generation).
82 lines (78 loc) • 2.89 kB
TypeScript
type BuildContentMap = Map<number, string | number | BuildContentMap>;
declare class PayCodeContent {
payload: BuildContentMap;
protected validate(): void;
protected value(): string;
protected set(keys: number, value: string | number): this;
protected set(keys: number[], value: string | number): this;
protected remove(...ids: number[]): void;
protected build(value: BuildContentMap | string | number): string;
}
/**
* Invoice/receipt number issued by Merchant or automatically entered by the Customer Application
*/
declare const BILL_NUMBER = 1;
/**
* The mobile phone number can be provided by the merchant or entered by the customer.
*/
declare const MOBILE_NUMBER = 2;
/**
* A special value associated with a store.
* This value can be provided by the merchant or entered by the customer.
*/
declare const STORE_LABEL = 3;
/**
* Usually the loyalty card number.
* This number may be provided by the merchant or the customer may have to enter their Loyalty Card Number.
*/
declare const LOYALTY_NUMBER = 4;
declare const REFERENCE_LABEL = 5;
/**
* Can be customer code, customer phone number, invoice number
*/
declare const CUSTOMER_LABEL = 6;
/**
* A unique code associated with the store's terminal.
*/
declare const TERMINAL_LABEL = 7;
/**
* Value to determine the purpose of the transaction, eg: phone top-up, purchase of goods...
*/
declare const PURPOSE_OF_TRANSACTION = 8;
/**
* One or more of the following characters may appear, indicating the corresponding data that needs to be provided during transaction initiation:
* • "A" = Customer address
* • "M" = Customer phone number
* • "E" = Customer email address
*/
declare const ADDITIONAL_CONSUMER_DATA_REQUEST = 9;
declare class PayCodeGen extends PayCodeContent {
guid: string;
constructor();
toString(): string;
/** Code using multiple time, as type static */
static(): this;
/** Code using once time, as type dynamic */
dynamic(): this;
acquirer(id: string): this;
cosumer(data: string): this;
cosumerType(type?: "C" | "A"): this;
category(catId: number | string): this;
/**
* @param currency follow rule ISO 4217
*/
currency(currency?: CurrencySupport): this;
amount(value: number | string): this;
tip(): void;
fixedFee(value: number): void;
percentFee(value: number): void;
country(countryCode?: string): this;
bankName(name: string): this;
city(name: string): this;
portal(code: string): this;
additional(id: number, content: string): this;
content(content: string): this;
protected validate(): void;
}
type CurrencySupport = number;
export { ADDITIONAL_CONSUMER_DATA_REQUEST, BILL_NUMBER, CUSTOMER_LABEL, type CurrencySupport, LOYALTY_NUMBER, MOBILE_NUMBER, PURPOSE_OF_TRANSACTION, REFERENCE_LABEL, STORE_LABEL, TERMINAL_LABEL, PayCodeGen as default };