1.0.7 • Published 8 months ago

promptpay-js v1.0.7

Weekly downloads
214
License
MIT
Repository
github
Last release
8 months ago

PromptPay

NPM Version NPM Downloads

PromptPay Generator and Parser for Node.js

Install

$ npm install promptpay-js

Method

Generate

NameTypeLengthRequiredDescription
methodEnumRequired- QR_STATIC- QR_DYNAMIC- BLE_STATIC- BLE_DYNAMIC- NFC_STATIC- NFC_DYNAMIC
applicationEnumRequired- PROMPTPAY_CREDIT_TRANSFER- PROMPTPAY_CREDIT_TRANSFER_WITH_OTA- PROMPTPAY_BILL_PAYMENT- PROMPTPAY_BILL_PAYMENT_CROSS_BORDER
mobileNumberString13ConditionedFor application- PROMPTPAY_CREDIT_TRANSFER- PROMPTPAY_CREDIT_TRANSFER_WITH_OTA
nationalIDString13ConditionedFor QR_DYMANIC method only.For application- PROMPTPAY_CREDIT_TRANSFER- PROMPTPAY_CREDIT_TRANSFER_WITH_OTA
taxIDString13ConditionedFor application- PROMPTPAY_CREDIT_TRANSFER- PROMPTPAY_CREDIT_TRANSFER_WITH_OTA
eWalletIDString15ConditionedFor application- PROMPTPAY_CREDIT_TRANSFER- PROMPTPAY_CREDIT_TRANSFER_WITH_OTA
bankAccountString1 - 43ConditionedBank code (3 digits) + account no.For application- PROMPTPAY_CREDIT_TRANSFER- PROMPTPAY_CREDIT_TRANSFER_WITH_OTA
otaString10ConditionedFor PROMPTPAY_CREDIT_TRANSFER_WITH_OTA application only.
billerIDString15ConditionedNational ID/Tax ID + SuffixFor application- PROMPTPAY_BILL_PAYMENT- PROMPTPAY_BILL_PAYMENT_CROSS_BORDER
reference1String1 - 20ConditionedFor application- PROMPTPAY_BILL_PAYMENT- PROMPTPAY_BILL_PAYMENT_CROSS_BORDER
reference2String1 - 20OptionalFor application- PROMPTPAY_BILL_PAYMENT- PROMPTPAY_BILL_PAYMENT_CROSS_BORDER
mccString4OptionalAs defined by ISO 8583:1993 for Card Acceptor Business Code (MCC).
currencyCodeString3Required764 for Thai Baht (ISO 4217).
amountString1 - 13OptionalThis amount is expressed as to how the value appears,amount "100.00" is defined as "100.00", or amount "99.85" is defined as "99.85", or amount "99.333" is defined as "99.333"amount "99.3456" is defined as "99.3456"
tipString1 - 13OptionalThe convenience fee of a fixed amount should be specified here.This amount is expressed as to how the value appears,amount "100.00" is defined as "100.00", oramount "99.85" is defined as "99.85", oramount "99.333" is defined as "99.333"amount "99.3456" is defined as "99.3456"Note: 0 is not a valid value.
countryCodeString2RequiredTH for Thailand (ISO 3166-1 alpha-2).
merchantNameString1 - 25Optional
merchantCityString1 - 15Optional
postalCodeString1 - 10OptionalZipcode or Pin code or Postal code of the merchant.
additionalObjectOptionalAdditional information may be required in certain cases.This information may be either presented by the merchant or acquireror the Consumer may be prompted for entry on the app.
additional.billNumberString1 - 26OptionalInvoice number or bill number.
additional.mobileNumberString1 - 26OptionalTo be used for top-up or bill payment.
additional.storeIDString1 - 26OptionalA distinctive number associated to the store.
additional.loyaltyNumberString1 - 26OptionalAs defined by store or airline.
additional.referenceIDString1 - 26OptionalAs defined by merchant or acquirer.
additional.customerIDString1 - 26OptionalTypically a subscriber ID for subscription services or student.
additional.terminalIDString1 - 26OptionalA distinctive number associated with the terminal in the store.For application- PROMPTPAY_BILL_PAYMENT- PROMPTPAY_BILL_PAYMENT_CROSS_BORDER
additional.purposeOfTransactionString1 - 26OptionalFor application- PROMPTPAY_BILL_PAYMENT- PROMPTPAY_BILL_PAYMENT_CROSS_BORDERCurrency Code (3 digits) +Local Amount (13 digits) +Country Code (2 digits)
additional.additionalCustomerDataString1 - 3Optional
merchantInformationString1 - 99Optional
sellerTaxBranchIDString4OptionalVAT TQRC
vatRateString1 - 5Optional
vatAmountString1 - 13Conditioned

Parse

NameTypeRequiredDescription
payloadStringRequired
tagTypeEnumOptional- PROMPTPAY_CREDIT_TRANSFER- PROMPTPAY_BILL_PAYMENT- ADDITIONAL_DATA_FIELD

Usage

Generate

const promptpay = require('promptpay-js')

const payload = promptpay.generate({
  method: 'QR_STATIC',
  application: 'PROMPTPAY_CREDIT_TRANSFER',
  mobileNumber: '0066XXXXXXXXX',
  currencyCode: '764',
  countryCode: 'TH'
})

console.log(payload)
00020101021129370016A00000067701011101130066XXXXXXXXX53037645802TH6304D37F

Parse

const promptpay = require('promptpay-js')

const payload = '00020101021129370016A00000067701011101130066XXXXXXXXX53037645802TH6304D37F'
const data = promptpay.parse(payload)

console.log(data)
{
  "00": { "key": "PAYLOAD_FORMAT_INDICATOR", "value": "01" },
  "01": { "key": "POINT_OF_INITIATION_METHOD", "value": "11" },
  "29": {
    "key": "PROMPTPAY_CREDIT_TRANSFER",
    "value": {
      "00": { "key": "AID", "value": "A000000677010111" },
      "01": { "key": "MOBILE_NUMBER", "value": "0066XXXXXXXXX" }
    }
  },
  "53": { "key": "CURRENCY_CODE", "value": "764" },
  "58": { "key": "COUNTRY_CODE", "value": "TH" },
  "63": { "key": "CRC", "value": "D37F" }
}

License

MIT

1.0.7

8 months ago

1.0.6

2 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago