Skip to main content

Alipay WAP / H5 Payments

Use Cases

  • Payment initiated via mobile browsers (not inside apps)
  • Suitable for mobile websites, WebApps, or cases where merchants guide users to open links in mobile browsers
  • Supported wallets:
    • Alipay Cross-Border (801107)
    • AlipayHK (801512)
    • Alipay Service Window H5 (800107)
note

Social apps like WeChat or Facebook Messenger often block redirection to external wallet apps. It's recommended to guide users to open payment links in Chrome, Safari, or other mobile browsers.


HTTP Request

  • Endpoint: /trade/v1/payment
  • Method: POST
  • PayType Reference Table:
PayTypeWallet NameDescription
801107Alipay Cross-BorderWeb or WAP international payment
801512AlipayHKAlipay Hong Kong WAP payments
800107Alipay H5 (JSAPI)Requires user authorization code

Request Parameters

For the full list of shared request parameters, see Public Request Parameters. Below are fields specific to Alipay WAP / H5 payments:

ParameterRequiredDescription
txamtYesTransaction amount in cents (e.g. 100 = $1). Recommended to be > 200
txcurrcdYesCurrency code (e.g., HKD)
pay_typeYesSee PayType table above
out_trade_noYesUnique transaction ID from merchant system
txdtmYesTransaction timestamp in YYYY-MM-DD hh:mm:ss format
return_urlYesURL to redirect users after successful payment
notify_urlYesEndpoint to receive asynchronous payment result
goods_nameYesProduct name (required by some wallets)
mchidYesQFPay merchant ID (required if assigned)
openidConditionalOnly required for 800107 (Alipay H5 / Service Window)
limit_payNoRequired only for Mainland China restrictions

Sample Request

#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 USD,EUR,etc. Cent. Suggest value > 200 to avoid risk control
txcurrcd = 'HKD'
pay_type = '801107' # Alipay Wap Payment = 801107
auth_code='283854702356157409' #CPM only
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, 'goods_name': goods_name, 'mchid': mchid}
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())

Response Parameters

Refer to Public Response Parameters for shared fields.

Sample Response

{
"sysdtm": "2020-04-13 11:32:03",
"paydtm": "2020-04-13 11:32:03",
"txcurrcd": "HKD",
"respmsg": "",
"pay_type": "801107",
"cardcd": "",
"udid": "qiantai2",
"txdtm": "2020-04-13 11:32:03",
"txamt": "300",
"resperr": "success",
"out_trade_no": "BUFB3PT9ZDUWEUAE4ATD21JKNHVEIIPV",
"syssn": "20200413000200020087171988",
"respcd": "0000",
"pay_url": "https://globalmapi.alipay.com/gateway.do?total_fee=3.0&secondary_merchant_name=###merchant_name###&out_trade_no=20200413000200020087171988&secondary_merchant_industry=7011&service=create_forex_trade_wap&_input_charset=UTF-8&sign=f16ef36efbb55058d1c1d36fef89bcf8&currency=THB&timeout_rule=30m&notify_url=https%3A%2F%2Fo2-hk.qfapi.com%2Fonline-test%2Ftrade%2Falipay%2Fv1%2Fonline_notify&secondary_merchant_id=2565075&sign_type=MD5&partner=2088631377368888&product_code=NEW_WAP_OVERSEAS_SELLER&return_url=&subject=###merchant_name###",
"chnlsn": ""
}

Sequence Diagram

Alipay H5 process-flow

Asynchronous Notification

After payment is completed, QFPay will notify your backend via the notify_url.

warning

Never rely solely on frontend redirection. Always validate with backend notification and signature verification.


Security Considerations


Additional References