-
Notifications
You must be signed in to change notification settings - Fork 87
/
api.d.ts
69 lines (67 loc) · 2.4 KB
/
api.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* The `promptpay-qr` npm package provides a function to generate a PromptPay QR code that can be scanned by mobile banking apps.
* @remarks
* A {@link https://www.blognone.com/node/95133 | PromptPay QR code} payload format is based on the {@link https://www.emvco.com/emv-technologies/qrcodes/ | EMV QR Code specification}.
* Specifically, the Merchant-Presented Mode is supported by this library.
*
* This package is a CommonJS module. Import the {@link (generatePayload:function)} function from CommonJS code like this:
* ```
* const generatePayload = require('promptpay-qr')
* ```
*
* If you use ES modules, you can use the default import syntax:
* ```
* import generatePayload from 'promptpay-qr'
* ```
*
* If you use TypeScript, make sure to set `"esModuleInterop": true` in the `tsconfig.json` file.
* @packageDocumentation
*/
/**
* Generates a PromptPay QR payload.
* @remarks
* This package is a CommonJS module. Import this function from CommonJS code like this:
* ```
* const generatePayload = require('promptpay-qr')
* ```
*
* If you use ES modules, you can use the default import syntax:
* ```
* import generatePayload from 'promptpay-qr'
* ```
*
* If you use TypeScript, make sure to set `"esModuleInterop": true` in the `tsconfig.json` file.
* @param target - The target PromptPay ID. This can be a phone number (10 digits), a citizen ID (13 digits), a tax ID (13 digits), or an e-Wallet account ID (15 digits).
* @param options - Options for generating a PromptPay QR payload
* @returns A PromptPay QR payload. Use this payload to generate a QR code that can be scanned by mobile banking apps in Thailand.
* @example Generate a PromptPay QR payload for a phone number
* ```
* generatePayload('0812345678', {})
* ```
* @example Generate a PromptPay QR payload for a phone number with a fixed amount
* ```
* generatePayload('0812345678', { amount: 4.22 })
* ```
* @public
*/
export function generatePayload(
target: string,
options: generatePayload.Options
): string;
/**
* This namespace exports the types that can be used with the {@link (generatePayload:function)} function.
* @public
*/
export namespace generatePayload {
/**
* Options to pass to {@link (generatePayload:function)}.
*/
export interface Options {
/**
* The amount of money.
* @remarks
* If specified, some banking apps will prefill the amount field.
*/
amount?: number;
}
}