Skip to main content

Transaction Enquiry

API Endpoint for Transaction Enquiry

After making a payment, refund or cancellation request, merchants can use the enquiry interface to obtain the transaction status.

This API allows querying by:

  • syssn (QFPay transaction number)
  • out_trade_no (merchant-side order number)
  • Or with start_time / end_time for time-based filtering

If querying a refund transaction, the response will also return origssn, which refers to the original transaction's syssn.

HTTP Request

  • Endpoint : /trade/v1/query
  • Method : POST

Request Headers:

Content-Type: application/x-www-form-urlencoded
X-QF-APPCODE: <your-app-code>
X-QF-SIGN: <signature>

Request Parameters

Full details are documented in Common API Request Format, but key parameters for transaction enquiry include:

ParameterTypeRequiredDescription
mchidString(16)ConditionalRequired if assigned to the merchant. See warning above.
syssnString(128)NoQFPay transaction number(s), comma-separated.
out_trade_noString(128)NoMerchant platform transaction number(s), comma-separated.
pay_typeString(6)NoPayment type(s), comma-separated.
respcdString(4)NoFilter by specific return code (e.g. 0000).
start_timeString(20)NoFormat: YYYY-MM-DD hh:mm:ss. Required for cross-month queries.
end_timeString(20)NoFormat: YYYY-MM-DD hh:mm:ss. Required for cross-month queries.
pageIntegerNoDefaults to 1.
page_sizeIntegerNoDefaults to 10. Max is 100.

Request Body:

mchid=<merchant-id>&syssn=<qfpay-tx-id>&start_time=2022-12-01 00:00:00&end_time=2022-12-01 23:59:59
import urllib.request, urllib.parse, urllib.error, urllib.request, urllib.error, urllib.parse, hashlib
import requests
from hashids import Hashids
import datetime
import string
import random

# Enter Client Credentials
environment = 'https://test-openapi-hk.qfapi.com'
app_code = 'D5589D2A1F2E42A9A60C37**********'
client_key = '0E32A59A8B454940A2FF39**********'

# Create parameter values for data payload
current_time = datetime.datetime.now().replace(microsecond=0)
random_string = ''.join(random.choices(string.ascii_uppercase + string.digits, k=32))


# Create signature
def make_req_sign(data, key):
keys = list(data.keys())
keys.sort()
p = []
for k in keys:
v = data[k]
p.append('%s=%s'%(k,v))
unsign_str = ('&'.join(p) + key).encode("utf-8")
s = hashlib.md5(unsign_str).hexdigest()
return s.upper()


# Body payload
mchid = 'ZaMVg*****' #(Agent ID, Merchant ID)
syssn = '20191227000200020061752831' #Search by transaction number only
out_trade_no = '2019122722001411461404119764' #Search by out_trade_no only
start_time = '2019-12-27 00:00:00'
end_time = '2019-12-27 23:59:59'
key = client_key


#data ={'mchid': mchid, 'syssn': syssn, 'out_trade_no': out_trade_no, 'start_time': start_time, 'end_time': end_time}
data ={'mchid': mchid, 'syssn': syssn}

r = requests.post(environment+"/trade/v1/query",data=data,headers={'X-QF-APPCODE':app_code,'X-QF-SIGN':make_req_sign(data, key)})

print(make_req_sign(data, key))
print(r.json())

Response Parameters

These fields are explained in Common API Response Format. The most relevant response fields for transaction enquiry include:

FieldTypeDescription
syssnStringQFPay transaction ID
out_trade_noStringMerchant order ID
txamtIntegerTransaction amount (in cents)
txcurrcdStringCurrency code (e.g. HKD)
respcdStringTransaction result code. See Status Codes.
errmsgStringResult message
order_typeStringpayment or refund
pay_typeStringPayment channel used
cancelStringCancellation/refund flag (0–5). See Refund Guide for full explanation.
cash_feeStringActual paid amount (after discount)
cash_fee_typeStringActual payment currency (e.g. CNY)
cash_refund_feeStringActual refund amount (if applicable)
cash_refund_fee_typeStringRefund currency
exchange_rateStringApplied exchange rate (if cross-currency)
sysdtmStringQFPay system transaction time
txdtmStringMerchant transaction time
chnlsnStringWallet-side transaction number
origssnStringOriginal transaction ID (for refunds only)

{
"respcd": "0000",
"resperr": "Request successful",
"data": [
{
"syssn": "20230423000200020088888888",
"out_trade_no": "YOUR_ORDER_001",
"txamt": "100",
"txcurrcd": "HKD",
"respcd": "0000",
"errmsg": "success",
"pay_type": "801107",
"order_type": "payment",
"txdtm": "2023-04-23 12:00:00",
"sysdtm": "2023-04-23 12:00:03",
"cancel": "0",
"cash_fee": "100",
"cash_fee_type": "HKD"
}
]
}

Account Statement

Clearing statements are periodically generated per payment channel. Requests for historical reports are only supported in production environment.

API Endpoint for Statement Download

  • Endpoint : /download/v1/trade_bill
  • Method : GET

Request Parameter

ParameterTypeRequiredDescription
trade_dateString(10)YesFormat: YYYY-MM-DD. E.g. 2023-04-01