Promptpay
in package
Promptpay QR Code Payment Payload Generator based on EMV® QR Code Specification
Tags
Table of Contents
- $applicationID : string
- Merchant identifier
- $countryCode : string
- Country Code TH = Thailand
- $currencyCode : int
- Transaction Currency Code 764 = Thai Baht
- $phoneCountryCode : int
- Phone country code 66 = Thailand
- $amount : int
- Transaction Amount
- $merchant_id : string
- Recipient ID (Phone number, National ID, Tax ID, E-Wallet ID)
- create() : static
- Create Promptpay object
- payload() : string
- Generate payload for Prompt Pay QR code payment based on EMV® QR Code Specification
- __construct() : mixed
- Class constructor
- format() : string
- Format the data field with an ID, length, and optional padding.
- hashBytes() : int
- Calculate the hash (CRC-16) for an array of bytes.
- hashString() : string
- Generate the checksum (CRC) using the CRC-16 algorithm.
Properties
$applicationID
Merchant identifier
public
string
$applicationID
= 'A000000677010111'
$countryCode
Country Code TH = Thailand
public
string
$countryCode
= 'TH'
$currencyCode
Transaction Currency Code 764 = Thai Baht
public
int
$currencyCode
= 764
$phoneCountryCode
Phone country code 66 = Thailand
public
int
$phoneCountryCode
= 66
$amount
Transaction Amount
private
int
$amount
$merchant_id
Recipient ID (Phone number, National ID, Tax ID, E-Wallet ID)
private
string
$merchant_id
Methods
create()
Create Promptpay object
public
static create(string $merchant_id[, int|null $amount = null ]) : static
Parameters
- $merchant_id : string
-
Recipient ID (Phone number, Prompt Pay, or E-Wallet ID)
- $amount : int|null = null
-
Transaction amount
Tags
Return values
static —payload()
Generate payload for Prompt Pay QR code payment based on EMV® QR Code Specification
public
payload() : string
Return values
string —Generated payload string
__construct()
Class constructor
protected
__construct(string $merchant_id, int $amount) : mixed
Parameters
- $merchant_id : string
-
Recipient ID (Phone number, Prompt Pay, or E-Wallet ID)
- $amount : int
-
Transaction amount
Return values
mixed —format()
Format the data field with an ID, length, and optional padding.
private
format(string $id, mixed $data, int $length) : string
Parameters
- $id : string
-
The ID field.
- $data : mixed
-
The data field.
- $length : int
-
The length of the data field.
Return values
string —The formatted field.
hashBytes()
Calculate the hash (CRC-16) for an array of bytes.
private
hashBytes(array<string|int, mixed> $data) : int
Parameters
- $data : array<string|int, mixed>
-
The input data.
Return values
int —The calculated hash value.
hashString()
Generate the checksum (CRC) using the CRC-16 algorithm.
private
hashString(string $data) : string
Parameters
- $data : string
-
The input data.
Return values
string —The generated checksum.