1. Overview
1.1 Prerequisites
Before starting the integration, ensure you have:- Provide your UQPAY account ID to enable the POS API feature
1.2 Integration Flow
2. Terminal Registration
Each POS terminal must be registered with UQPAY before processing transactions. This is a one time setup; you only need to register each terminal once.2.1 API Endpoint
2.2 Request Parameters
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
firm_code | string | Yes | Terminal manufacturer code | "03" |
firm_sn | string | Yes | Terminal serial number from manufacturer | "TG676SX1764902333" |
terminal_model | string | Yes | Terminal model name | "P1000" |
| Code | Manufacturer |
|---|---|
01 | Shengben |
02 | Newland |
03 | Xinguodu |
04 | iMin |
05 | PAX |
2.3 Request Example
2.4 Response
| Field | Type | Description |
|---|---|---|
terminal_id | string | UQPAY assigned terminal identifier (TID) |
firm_sn | string | Terminal serial number |
create_time | string | Registration timestamp |
Note: Store the terminal_id securely. You will need it for all subsequent API calls.
3. PIN Key Management
To securely process PIN based transactions, you must obtain and manage PIN encryption keys.3.1 Generate AES Private Key
Before requesting a PIN key, generate an AES private key on your terminal or server:| Requirement | Specification |
|---|---|
| Algorithm | AES |
| Key Length | Up to 256 bits (64 hex characters) |
| Format | Hexadecimal string |
Important: Store this private key securely. You will use it to decrypt the encrypt_pin_key returned from the Get PIN Key API.
3.2 Request PIN Key
API Endpoint:| Field | Type | Required | Description | Example |
|---|---|---|---|---|
terminal_id | string | Yes | Terminal ID received from registration | "10000254" |
prv_key | string | Yes | Your AES private key (hex format, max 64 characters) | "5214abf357f2cc47645c4d942c02fd0180acc6d8de8fae3708849b6a459cba00" |
| Field | Type | Description |
|---|---|---|
terminal_id | string | Terminal identifier |
encrypt_pin_key | string | Encrypted PIN key (Base64 encoded) |
pin_key_expire | integer | PIN key expiration timestamp (milliseconds) |
3.3 Decrypt PIN Key
Use your AES private key to decrypt theencrypt_pin_key and obtain the actual PINKEY.
Decryption Parameters:
| Parameter | Value |
|---|---|
| Algorithm | AES-256-GCM |
| Input | encrypt_pin_key |
| Key | Your prv_key |
| Output | PINKEY |
- encrypt_pin_key:
LASDho1ILHoYRf/5YEyIgieoc+SXJkUsHZElXOMNGv7WnC3fZzFPYDH8mJaDbnwvom3QEtdv3NjvaEUtVeetWdQsv2RtQw4XEYh/Cg== - actual PINKEY:
26e1734e4d52b905e74574b7bf0897daeec7e217c61b3ac0
See Appendix for decryption code samples.
3.4 Key Expiration
Monitor thepin_key_expire timestamp and refresh the PIN key before expiration. Request a new PIN key using the same process when needed.
4. PIN Block Encryption
When processing PIN based transactions, you must encrypt the cardholder PIN into a PIN block.4.1 Overview
The PIN block is created by combining:- Card PAN (Primary Account Number)
- Cardholder PIN
- PINKEY
4.2 Example
Input:| Parameter | Value |
|---|---|
| Card Number | 5554748800260229 |
| PIN | 302312 |
| PINKEY | 26e1734e4d52b905e74574b7bf0897daeec7e217c61b3ac0 |
| Parameter | Value |
|---|---|
| PINBLOCK | 4F5D12303995DD06 |
See Appendix for PIN block encryption code samples.
5. Create Payment Intent
After setting up your terminal and obtaining the PINKEY, you can process card present transactions.5.1 API Endpoint
5.2 Request Example
Use thecard_present payment method type for POS transactions. Key fields to note:
terminal_id: Set to the TID received from terminal registrationencrypted_pin: Set to the PINBLOCK generated from PIN encryptionsystem_trace_audit_number: Must be unique for each new transaction (STAN)
5.3 Response Example
6. Error Handling
6.1 POS API Error Codes
| Error Code | Error Message |
|---|---|
account_pos_api_no_permission | Account pos api no permission |
terminal_not_belong_to_account | Terminal not belong to account |
terminal_register_failed | Terminal register failed |
terminal_info_not_found | Terminal info not found |
pinkey_retrieve_failed | Pinkey retrieve failed |
7. Testing
7.1 Test Card
Use the following test card data in the sandbox environment:| Field | Value |
|---|---|
| Card Number | 5554748800161559 |
| Expiry Month | 07 |
| Expiry Year | 2027 |
| PIN (raw) | “ |
| Card Brand | Mastercard |
Note: Remember to use a unique system_trace_audit_number for each test transaction.
8. Appendix
8.1 Code Samples
AES-256-GCM Decryption (Python)
PIN Block Encryption (Python)
8.2 Glossary
| Term | Definition |
|---|---|
| TID | Terminal Identifier, unique ID assigned by UQPAY |
| PINKEY | PIN encryption key used to encrypt cardholder PINs |
| PIN Block | Encrypted representation of cardholder PIN |
| STAN | System Trace Audit Number, unique transaction trace number |
| EMV | Europay, Mastercard, Visa; chip card standard |
| PAN | Primary Account Number (card number) |
| CVM | Cardholder Verification Method |

