Create an orderStr
In order to use payment in the wallet app, you will need to place the orderStr
in JSAPI my.tradePay
, this document aims to provide instruction on creating an orderStr
.
For direct payment with HK acquirer, you should follow below steps.
Merchant using Antom / international acquirer should NOT use this document. |
1. Prepare payload body for payment
HK merchant using HK acquirer should see create_forex_trade_wap.
{
"_input_charset": "UTF-8",
"body": "Product description body",
"currency": "HKD",
"notify_url": "https://docs.alipay.hk/alipayhkdocs/hk/mapi/",
"out_trade_no": "1751878347",
"partner": 2088021966645500,
"payment_inst": "ALIPAYHK",
"product_code": "NEW_WAP_OVERSEAS_SELLER",
"refer_url": "https://docs.alipay.hk/alipayhkdocs/hk/mapi/",
"return_url": "https://docs.alipay.hk/alipayhkdocs/hk/mapi/",
"service": "create_forex_trade_wap",
"subject": "Product Title",
"total_fee": 0.1,
"trade_information": {
"business_type": "5",
"other_business_type": "Demo"
}
}
2. Re-structure in key=value
format
Re-structure the JSON to key=value&key=value
format.
_input_charset=UTF-8&body=Product description body¤cy=HKD¬ify_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&out_trade_no=1751878347&partner=2088021966645500&payment_inst=ALIPAYHK&product_code=NEW_WAP_OVERSEAS_SELLER&refer_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&return_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&service=create_forex_trade_wap&subject=Product Title&total_fee=0.1&trade_information={"business_type":"5","other_business_type":"Demo"}
3. Generate signature for the orderStr
Generate a signature with MD5
, RSA
or RSA2
.
When signing with MD5
, add your MD5 key after pre-sign string (text + key) before hashing.
4. Append the signature & sign type
Append the signature & sign type after the orderStr, i.e. &sign=caed2dfc66d2bdf12697975d9269c7fb&sign_type=MD5
_input_charset=UTF-8&body=Product description body¤cy=HKD¬ify_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&out_trade_no=1751878347&partner=2088021966645500&payment_inst=ALIPAYHK&product_code=NEW_WAP_OVERSEAS_SELLER&refer_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&return_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&service=create_forex_trade_wap&subject=Product Title&total_fee=0.1&trade_information={"business_type":"5","other_business_type":"Demo"}&sign=caed2dfc66d2bdf12697975d9269c7fb&sign_type=MD5
Validate the orderStr
You may check the validity of orderStr by placing it after the url prefix https://api-sea-global.alipayplus.com/gateway.do?
, i.e. https://api-sea-global.alipayplus.com/gateway.do?_input_charset=UTF-8&body=Product description body¤cy=HKD¬ify_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&out_trade_no=1751878347&partner=2088021966645500&payment_inst=ALIPAYHK&product_code=NEW_WAP_OVERSEAS_SELLER&refer_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&return_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&service=create_forex_trade_wap&subject=Product Title&total_fee=0.1&trade_information={"business_type":"5","other_business_type":"Demo"}&sign=caed2dfc66d2bdf12697975d9269c7fb&sign_type=MD5
Open the url with browser, it should be able to display a checkout redirect page.
5. Request with my.tradePay
Escape the quotes "
with \"
and place in my.tradePay
.
my.tradePay({
orderStr: '_input_charset=UTF-8&body=Product description body¤cy=HKD¬ify_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&out_trade_no=1751878347&partner=2088021966645500&payment_inst=ALIPAYHK&product_code=NEW_WAP_OVERSEAS_SELLER&refer_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&return_url=https://docs.alipay.hk/alipayhkdocs/hk/mapi/&service=create_forex_trade_wap&subject=Product Title&total_fee=0.1&trade_information={\"business_type\":\"5\",\"other_business_type\":\"Demo\"}&sign=caed2dfc66d2bdf12697975d9269c7fb&sign_type=MD5',
success: function(res) {
my.alert({
content: JSON.stringify(res),
});
},
fail: function(res) {
my.alert({
content: JSON.stringify(res),
});
},
});