Thursday, June 25, 2020

Generate FPS QR Code with customized amount


  1. Scan an existing QR code at https://zxing.org/w/decode.jspx to get the text content
  2. Remove the last 4 characters, which is the checksum (CRC), from the text content
  3. Spot the substring that contains the amount from the text content
  4. Replace the amount substring with new amount using the *same number* of characters, for example, replacing 
    • 1755.00
      • with
    • 0050.00
      • will update the amount from $1,755 to $50
  5. Calculate the new checksum
    1. http://www.sunshine2k.de/coding/javascript/crc/crc_js.html
      1. width: CRC-16
      2. parametrization: Custom
      3. Polynomial: 0x1021
      4. Initial Value: 0xFFFF
      5. Input Data: String
      6. Paste the updated text content from above
      7. Click Calculate CRC
  6. Generate new QR code
    1. https://www.qrcode-monkey.com/#text
    2. Paste the updated text content appended with the new 4-character CRC
    3. Click Create QR Code


Ref: FPS QR code specification at https://www.hkma.gov.hk/media/eng/doc/key-functions/financial-infrastructure/infrastructure/retail-payment-initiatives/Common_QR_Code_Specification.pdf