In this guide, we’ll explore the standardized format for encoding transport tickets as QR codes, designed to align with the EMV QR Code Specification for Payment Systems (EMV QRCPS), ensuring seamless integration and interoperability.
General Requirements and Features
The QR Code Standard meets the EMV QRCPS Consumer Presented Mode and includes several key features:
- Base64 Encoded Payload: Ensures compatibility across various platforms.
- BER-TLV Encoded Data: Facilitates efficient data transfer.
- Mandatory EMV Data Elements: This includes, Payload format indicator, at least one application template, and use of the EMV application-specific transparent template for ticket-specific data
- Payload Limit: Maximum payload size of 512 bytes, adhering to EMVCo requirements.
- EMVCo Processing Rules: Validation terminal QR Code readers must recognize codes that meet EMV specifications, ensuring security and reliability.
QR Ticket Format
QR Ticket Encoding
The QR Code is encoded according to ASN.1 and BER encoding rules, ensuring that data fields can be flexible in their order, presence, and quantity.
QR Code Fields
Mandatory Fields
Ticket Identifier
- Tag: 1
- Format: Unsigned Integer (32 bit)
- Sample Value: 1250184
- Sample TLV Value: 131388
- Notes:
- Must be a unique identifier
Ticket Creator Id
- Tag: 2
- Format: Unsigned Integer (16 bit)
- Sample Value: 275
- Sample TLV Value: 0113
Ticket Creation Time
- Tag: 3
- Format: Timestamp
- Sample Value: 2019–09–11T19:38:30+08:00
- Sample TLV Value: 5D78DCB6
Ticket Validity Period
- Tag: 4
- Format: Unsigned Integer (32 bit)
- Sample Value: PT15M
- Sample TLV Value: 0384
- Notes:
- Validate if expired using the following conditions
- If Ticket Effective Time is present, Ticket Effective Time + Ticket Validity Period
- Else, Ticket Creation Time + Ticket Validity Period
Optional Fields
Ticket Validity Domain
- Tag: 5
- Format: Unsigned Integer (16 bit)
- Sample Value: 5
- Sample TLV Value: 05
- Notes:
- Using a value of 0 means all domains
Transport Operator Id
- Tag: 6
- Format: Unsigned Integer (32 bit)
- Sample Value: 23
- Sample TLV Value: 17
- Notes:
- You can have multiple entry of this field
Ticket Effective Time
- Tag: 7
- Format: Timestamp
- Sample Value: 2019–09–11T19:38:30+08:00
- Sample TLV Value: 5D78DCB6
- Notes:
- Using a value of 0 means immediate
Refresh Time
- Tag: 8
- Format: Timestamp
- Sample Value: 2019–09–11T19:39:00+08:00
- Sample TLV Value: 5D78DCD4
- Notes:
- The QR is considered static using the following conditions
- Using a value of 0
- Excluding this field
Ticket Type
- Tag: 9
- Format: Unsigned Integer (16 bit)
- Sample Value: 1
- Sample TLV Value: 01
- Notes:
- Using a value of 1 means standard
Account Identifier
- Tag: 10
- Format: Unsigned Integer (16 bit)
- Sample Value: 1234567890123456
- Sample TLV Value: 31323334353637383930313233343536
Boarding Station
- Tag: 11
- Format: Unsigned Integer (32 bit)
- Sample Value: 23
- Sample TLV Value: 17
Destination Station
- Tag: 12
- Format: Unsigned Integer (32 bit)
- Sample Value: 17
- Sample TLV Value: 11
Vehicle Id
- Tag: 13
- Format: Unsigned Integer (32 bit)
- Sample Value: 345
- Sample TLV Value: 0159
Route Id
- Tag: 14
- Format: Unsigned Integer (32 bit)
- Sample Value: 4
- Sample TLV Value: 04
Seat Number
- Tag: 15
- Format: ASCII
- Max Length: 5 Characters
- Sample Value: 3D
- Sample TLV Value: 3344
Seat Class
- Tag: 16
- Format: ASCII
- Max Length: 5 Characters
- Sample Value: ECO
- Sample TLV Value: 45434F
Maximum Authorized Amount
- Tag: 17
- Format: Unsigned Integer (32 bit)
- Sample Value: 30.00
- Sample TLV Value: 0BB8
- Notes:
- This amount is in centavos
- Using 0 as value means unlimited
Signature Key Identifier
- Tag: 18
- Format: ASCII
- Sample Value: STAG-AFPI-V2
- Sample TLV Value: 535441472D414650492D5632
- Notes:
- Used to distinguish multiple public key assigned to a single issuer
Terminal Identifier
- Tag: 19
- Format: ASCII
- Sample Value: 1234567890
- Sample TLV Value: 31323334353637383930
Funding Source Type
- Tag: 20
- Format: Unsigned Integer (32 bit)
- Sample Value: 1
- Sample TLV Value: 01
Funding Source Provider
- Tag: 21
- Format: ASCII
- Sample Value: 1
- Sample TLV Value: 31
Signature
- Tag: 30
- Format: Binary
Conclusion
The QR Code Standard for Transport Ticketing enhances efficiency and user experience in public transport systems. By adhering to strict guidelines, this standard ensures secure, reliable, and flexible ticketing solutions for various transport providers.
If you’d like to learn more or get involved in the QCAT ecosystem, feel free to check out my guides on QCAT specification below or check out AF Payments Inc.’s GitHub for the latest updates and contribution guidelines.
DISCLAIMER
The information provided in this article is for informational purposes only and does not constitute professional advice. While efforts have been made to ensure accuracy, AF Payments Inc. reserves the right to update or modify the QCAT standard and related materials at any time. Use of the QCAT standard is subject to the terms of its license agreement, and any implementation must adhere to AFPI’s guidelines and licensing requirements. For the latest details and official documentation, please refer to AF Payments Inc.’s authorized channels.