跳到主要内容

PayMe Online Payment


For code instructions select Python, Java, Node.js or PHP with the tabs below.

#coding=utf8
import urllib.request, urllib.parse, urllib.error, urllib.request, urllib.error, urllib.parse, hashlib
import requests
import datetime
import string

# 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)

print(current_time)

# 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
txamt = '10' # In cents
txcurrcd = 'HKD'
pay_type = '805814' # PayMe Web Payment = 805814
out_trade_no = '01234567890123'
txdtm = current_time
goods_name = 'test1'
mchid = 'ZaMVg*****'
key = client_key

data ={'txamt': txamt, 'txcurrcd': txcurrcd, 'pay_type': pay_type, 'out_trade_no': out_trade_no, 'txdtm': txdtm, 'mchid': mchid}

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

print(r.json())

The above command returns JSON structured like this:

{
"sysdtm": "2020-04-13 10:30:34",
"paydtm": "2020-04-13 10:30:34",
"txcurrcd": "HKD",
"respmsg": "",
"pay_type": "805814",
"cardcd": "",
"udid": "qiantai2",
"txdtm": "2020-04-13 10:30:34",
"txamt": "300",
"resperr": "success",
"out_trade_no": "4K35N374II7UJJ8RGIAE45O2CVHGHFF0",
"syssn": "20200413000300020087033882",
"respcd": "0000",
"pay_url": "https://qr.payme.hsbc.com.hk/2/C5bvYGEyrgXbxxxxxxxxxx",
"chnlsn": ""
}

Web/WAP Payment

Customers make purchases on a merchant website with PayMe. The user scans the displayed QR code to pay, confirms the total amount and makes the payment. Finally the customer can be redirected to a selected page on the merchant's website using the return_url parameter. PayMe deducts the payment amount from the consumer's PayMe wallet in real-time in HKD and QFPay settles the payment amount to merchants in HKD.

HTTP Request

POST ../trade/v1/payment
PayType: 805814 PayMe Online WEB (in browser Chrome etc.) Payment (HK Merchants)
PayType: 805812 PayMe Online WAP (in mobile browser Chrome etc.) Payment (HK Merchants)

Request Parameters

Parameter nameAttributeMandatoryTypeDescription
Payment amounttxamtYesInt(11)Amount of the transaction. Unit in cents (i.e. 100 = $1)
CurrencytxcurrcdYesString(3)Transaction currency. View the Currencies table for a complete list of available currencies
Payment typepay_typeYesString(6)PayMe Web Payment = 805814
API Order Numberout_trade_noYesString(128)External transaction number / Merchant platform transaction number: This parameter must be unique for each payment and refund request under the same merchant account in the system.
Request transaction timetxdtmYesString(20)Transaction time format:
YYYY-MM-DD hh:mm:ss
Order expiration timeexpired_timeNo
(MPM only)
String(3)QRC expiration time in unit minutes. The default expiration time is 30 minutes. The parameter can manually be adjusted to a minimum of 5 minutes, and up to a maximum of 120 minutes.
Product name identificationgoods_nameNoString(64)Goods Name / Marking: Cannot exceed 20 alphanumeric or contain special characters. Cannot be empty for app payment. Parameter needs to be UTF-8 encoded if it is written in Chinese characters.
QFPay merchant numbermchidNoString(16)May or may not be given to merchant. If MCHID is given, it is mandatory to provide the MCHID .On the contrary, if MCHID is not provided, merchants shall not pass the MCHID field in the API request.
Device IDudidNoString(40)Unique transaction device ID. Is displayed on the merchant portal.
Redirect URLreturn_urlNoString(512)URL that the user will be redirected to when the payment finishes.

Response Parameters

Parameter nameAttributeTypeDescription
Payment typepay_typeString(6)PayMe Web/Wap Payment
System transaction timesysdtmString(20)Format:YYYY-MM-DD hh:mm:ss
This parameter value is used as the cut-off time for settlements.
Request transaction timetxdtmString(20)Format:YYYY-MM-DD hh:mm:ss
Response messageresperrString(128)
Payment amounttxamtInt(11)
Other message informationrespmsgString(128)
External transaction numberout_trade_noString(128)External transaction number
QFPay transaction numbersyssnString(40)
Return coderespcdString(4)0000 = Request successful.
1143/1145 = merchants are required to continue to query the transaction result.
All other return codes indicate transaction failure. Please refer to the page Transaction Status Codes for a complete list of response codes.
Payment URLpay_urlString(512)generate QR code in Desktop web; redirect URL in WAP