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

See Public Payment Parameters for shared fields.


Optional Parameters

Parameter NameParameter KeyRequiredTypeDescription
Product Descriptiongoods_infoNoStringRequired by Alipay. Special characters are not allowed.
Payment Tagpay_tagNoString(16)Default: ALIPAYHK
For Alipay Mainland use: ALIPAYCN
Order Expiry Timeexpired_timeNo
(Main-scan only)
String(3)Expiration time in minutes. Default is 30 minutes. Min: 5, Max: 120.
Applicable to WeChat Pay and Alipay

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.

Parameter KeySub Parameter KeyDescription
pay_paramspartnerPartner ID
seller_idUnique Alipay user ID of the receiving account
subjectProduct title / trade title / order title
bodyDetailed description of the transaction. For multiple items, concatenate descriptions into this field
total_feeTotal order amount
notify_urlNotification callback URL
serviceService name
cardcdCard number
payment_typePayment type
_input_charsetCharacter encoding format
it_b_payCustom timeout parameter
return_urlRedirect URL after payment
payment_instPayment institution
currencyCurrency code
product_codeProduct code
signRSA signature (Required)
sign_typeSignature type
secondary_merchant_idSecondary merchant ID
secondary_merchant_nameSecondary merchant name
secondary_merchant_industrySecondary merchant industry
chnlsnChannel transaction number
Common Response Parameters

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