Skip to main content

Alipay In-App Payments

This guide explains how to integrate Alipay In-App payments using the Alipay SDK (AlipayHK or AlipayCN). This payment method is used within a native app environment and provides a seamless user experience.

Alipay APP Payment process-flow

SDK Download

To begin integration, download the official SDK packages below:


HTTP Request

Endpoint : /trade/v1/payment
Method : POST

PayTypeDescription
801110Alipay In-App (Overseas Merchants)
801510Alipay In-App (HK Merchants)

Required Parameters

ParameterRequiredTypeDescription
txamtYesIntTransaction amount in cents. Example: 100 = $1
txcurrcdYesString(3)Currency code (e.g. HKD)
pay_typeYesString(6)Use 801110 for Alipay CN, 801510 for AlipayHK
out_trade_noYesString(128)Unique merchant transaction ID
txdtmYesString(20)Format: YYYY-MM-DD hh:mm:ss
goods_nameYesStringProduct name
return_urlYesStringRedirect URL after payment
seller_idYesStringAlipay seller account
mchidYesString(16)QFPay assigned Merchant ID

Optional Parameters

ParameterTypeDescription
goods_infoStringProduct description (avoid special characters)
goods_detailStringDetailed product info
trade_nameStringTrade name shown to customer
pay_tagString(16)Default: ALIPAYHK; Use ALIPAYCN for Alipay Mainland

Sample Request (Form Payload)

txamt=1
&txcurrcd=HKD
&pay_type=801510
&out_trade_no=052711570017898
&txdtm=2021-05-27 11:57:00
&goods_name=goods_name
&goods_info=goods_info
&mchid=nDB64h9qJ1An
&trade_name=trade_name
&goods_detail=goods_detail
&return_url=https://www.qfpay.global/
&pay_tag=ALIPAYHK
&seller_id=testoverseas9191@alipay.com

Response Fields (pay_params)

These fields are returned by QFPay and should be passed into the Alipay SDK.

FieldDescription
partnerAlipay partner ID
seller_idSeller account ID
subjectProduct name
bodyProduct description
total_feeTotal transaction amount
notify_urlCallback URL for payment result
serviceUsually mobile.securitypay.pay
payment_typePayment type
_input_charsetEncoding format (e.g. UTF-8)
it_b_payTransaction timeout
return_urlReturn URL
payment_instPayment institution (e.g. ALIPAYHK)
currencyCurrency code (e.g. HKD)
product_codeAlipay product code
signRSA signature
sign_typeSignature type (e.g. RSA)
secondary_merchant_idSub-merchant ID
secondary_merchant_nameSub-merchant name
secondary_merchant_industryIndustry code of sub-merchant

See Public Payment Parameters for shared fields.

Sample QFPay Response

{
"pay_type": "801510",
"sysdtm": "2021-05-27 11:57:02",
"paydtm": "2021-05-27 11:57:02",
"udid": "qiantai2",
"txcurrcd": "HKD",
"txdtm": "2021-05-27 11:57:00",
"txamt": "1",
"resperr": "交易成功",
"respmsg": "",
"out_trade_no": "052711570017898",
"syssn": "20210527154100020004180921",
"pay_params": {
"body": "goods_info",
"forex_biz": "FP",
"seller_id": "2088231067382451",
"secondary_merchant_id": "1000007081",
"service": "mobile.securitypay.pay",
"payment_inst": "ALIPAYHK",
"it_b_pay": "30m",
"secondary_merchant_name": "IFlare Hong Kong Limited (external) - online",
"_input_charset": "UTF-8",
"sign": "iU1yXUnsCK7rJAu0DoN61arVexbIfo3GLR5jr3QzjkZ29INSPhcA4e%2F2%2BdPrsf5huzQAkxVKP0CTfvaGPMYqNkxmhoaJWUH0ZhgYDgKugMvtweBvRqOX2W0h3A%2F%2FIdJuxeyOAuh7bHiuazSB3ZH%2BEQwRGP%2Bkk8Jpha930gHwPtw%3D",
"currency": "HKD",
"out_trade_no": "20210527154100020004180921",
"payment_type": "1",
"total_fee": 0.01,
"sign_type": "RSA",
"notify_url": "https://test-o2-hk.qfapi.com/trade/alipay_hk/v1/notify",
"partner": "2088231067382451",
"secondary_merchant_industry": "5941",
"product_code": "NEW_WAP_OVERSEAS_SELLER",
"return_url": "https://www.qfpay.global/",
"subject": "goods_name"
},
"respcd": "0000",
"chnlsn": "",
"cardcd": ""
}

Using Alipay SDK

After receiving the pay_params in the response, construct the orderInfo string required by the SDK in the following format:

  1. Join all fields in the format: key="value"
  2. Sort keys in ascending order (alphabetical)
  3. Concatenate with &
  4. Place sign and sign_type at the end

Sample

_input_charset="UTF-8"&body="goods_info"&currency="HKD"&forex_biz="FP"&it_b_pay="30m"&notify_url="https://test-o2-hk.qfapi.com/trade/alipay_hk/v1/notify"&out_trade_no="20210527154100020004180921"&partner="2088231067382451"&payment_inst="ALIPAYHK"&payment_type="1"&product_code="NEW_WAP_OVERSEAS_SELLER"&return_url="https://www.qfpay.global/"&secondary_merchant_id="1000007081"&secondary_merchant_industry="5941"&secondary_merchant_name="IFlare Hong Kong Limited (external) - online"&seller_id="2088231067382451"&service="mobile.securitypay.pay"&subject="goods_name"&total_fee="0.01"&sign="iU1yXUnsCK7rJAu0DoN61arVexbIfo3GLR5jr3QzjkZ29INSPhcA4e%2F2%2BdPrsf5huzQAkxVKP0CTfvaGPMYqNkxmhoaJWUH0ZhgYDgKugMvtweBvRqOX2W0h3A%2F%2FIdJuxeyOAuh7bHiuazSB3ZH%2BEQwRGP%2Bkk8Jpha930gHwPtw%3D"&sign_type="RSA"

note

Make sure you:

  • Follow the correct SDK version and region (HK vs CN)
  • Use the exact key names and values returned in pay_params
  • Keep your sign logic consistent with Alipay SDK format