create_forex_trade
Call this interface to initiate a website payment request.
Request
Service address
Environment | HTTPS request URL |
Production environment |
Request parameters
Parameter | Description |
Basic parameter | |
service String | Interface name
|
partner String(16) Required | The partner ID that is assigned by Alipay to identify an Alipay account. The partner ID is composed of 16 digits and begins with 2088.
|
_input_charset String | The charset with which the request data is encoded. GBK and UTF-8 are supported.
|
sign_type String | Sign type. RSA, RSA2 are supported. RSA2 is preferred. Use uppercase.
|
sign String | Sign value
|
notify_url URL(200) | The URL for receiving asynchronous notifications after the payment is done.
|
Business parameter | |
subject String(256) | Brief description of the transaction. Special characters are not supported. Note: The value of this field will be displayed to customers.
|
body String(400) | Detailed description about the goods. Special characters are not supported.
|
out_trade_no String(64) | The unique transaction ID that is assigned by the partner. If the ID is duplicated with the out_trade_no of a previous transaction, the payment fails and an error message is returned to indicate the payment is duplicated.
|
currency String(10) | The settlement currency that the merchant specifies in the contract. Only HKD is supported.
|
total_fee Number(9,2) | The transaction amount, which is a floating number in the range 0.01 - 1000000.00.
|
order_gmt_create Date | This parameter can only be used with order_valid_time to control the valid time from redirection to login. The format is yyyy-MM-dd HH:mm:ss. Use Beijing time to synchronize with Alipay system.
|
order_valid_time String(5) | Order valid time in seconds, with a maximum value of 2592000. This field can only be used with the order_gmt_create field to control the valid time. The payment transaction is to be closed after the order valid time from the order creation time specified by the order_gmt_create field.
|
refer_url URL(200) | The URL of the merchant website homepage. If the merchant doesn't have a website, the merchant app download address can be used for this field. Note: This field is required for merchants that are directly integrated with Alipay, and is optional for acquirers.
|
product_code String | Product code of the Alipay product that you use, with a value of NEW_WAP_OVERSEAS_SELLER for this interface.
|
qr_pay_mode String | QR code payment mode. Forward QR code mode and redirecting mode are supported. Forward mode is the mode of placing the QR code to the merchant's order confirmation page. Fixed value: 4
|
qrcode_width Integer | The merchant customized QR code width. When qr_pay_mode=4, this parameter takes effect.
|
payment_inst String | Indicates the type of wallet this QR code can be scanned. If this field is set to ALIPAYHK, the QR code can only be scanned by Alipay HK Wallet. If this field is set to ALIPAYCN, the QR code can only be scanned by Alipay Wallet. If this field is set to null, the QR code can only be scanned by Alipay Wallet.
|
secondary_merchant_id String(32) | The unique ID assigned by the partner to identify a secondary merchant. The ID can contain letters, numbers, and underscores. Note: This field is required for acquirers and system integrators with secondary merchants, and is not required for merchants that are directly integrated with Alipay.
|
secondary_merchant_name String(32) | Registration legal name of the secondary merchant, shown in the Alipay Wallet and the reconciliation file to identify a secondary merchant. Note: This field is required for acquirers and system integrators with secondary merchants, and is not required for merchants that are directly integrated with Alipay.
|
secondary_merchant_industry String(4) | Industry classification identifier of the secondary merchant, which is assigned by Alipay. For more information about the MCC code, see MCC list. Note: This field is required for acquirers and system integrators with secondary merchants, and is not required for merchants that are directly integrated with Alipay.
|
Note:
Do not use the halfwidth quotation mark (") in parameter values.
Response
Synchronous response
The synchronous response of this request is an independent QR code HTML page. The merchant needs to use an iframe to open the HTML page. The following graphic shows an example of a synchronous respopnse.

Return QR Code from international domain:
(Example : https://render.alipay.hk/p/yuyan/180020010000007201/www/index.html/#/common/qrCode?qrCode=....)
Merchants must whitelist *.alipay.hk to domain whitelist.
Asynchronous response
Parameter | Description |
Basic parameter | |
notify_type String | Notification type, with a value of trade_status_sync
|
notify_id String | Notification ID, used by the partner system to verify the notification
|
notify_time Timestamp | The time in GMT+8 when the notification is sent. The time format is yyyy-MM-dd HH:mm:ss.
|
sign_type String | Sign type. RSA, RSA2 are supported. Use uppercase.
|
sign String | Sign value
|
Business parameter | |
trade_status String | Alipay transaction status.
|
trade_no String | Alipay transaction ID, with a length in the range 16 - 64 bits.
|
out_trade_no String | The unique transaction ID that is assigned by the merchant. This parameter is transmitted by the corresponding request and needs to be returned with the original value.
|
currency String | The settlement currency
|
total_fee Number(9,2) | The transaction amount, which is a floating number in the range 0.01 - 1000000.00.
|
Nofitication trigger condition
Trigger condition name | Description | Note |
TRADE_FINISHED | Trade successfully | true (trigger nofitication) |
WAIT_BUYER_PAY | Trade creation | false (does not trigger nofitication) |
TRADE_CLOSED | Trade closed | false (does not trigger nofitication) |
For more information about the asynchronous response, see Asynchronous notification.
Error codes
Business errors
Returned Result | Description |
FOREX_MERCHANT_NOT_SUPPORT_THIS_CURRENCY | This currency is not supported. |
ILLEGAL_SECURITY_PROFILE | This kind of encryption is not supported. |
REPEAT_OUT_TRADE_NO | The out_trade_no parameter is duplicated. |
ILLEGAL_CURRENCY | The currency parameter is incorrect. |
ILLEGAL_TIMEOUT_RULE | The timeout_rule parameter is incorrect. |
SYSTEM_EXCEPTION | Alipay system error |
ILLEGAL_ARGUMENT | Incorrect parameter |
Access errors
Returned Result | Description |
ILLEGAL_SIGN | Illegal signature |
ILLEGAL_SERVICE | The service parameter is incorrect. |
ILLEGAL_PARTNER | Incorrect partner ID |
ILLEGAL_SIGN_TYPE | Signature is of wrong type. |
ILLEGAL_PARTNER_EXTERFACE | Service is not activated for this account. |
ILLEGAL_DYN_MD5_KEY | Dynamic key information is incorrect. |
ILLEGAL_ENCRYPT | Encryption is incorrect. |
ILLEGAL_USER | User ID is incorrect. |
ILLEGAL_EXTERFACE | Interface configuration is incorrect. |
ILLEGAL_AGENT | Agency ID is incorrect. |
HAS_NO_PRIVILEGE | No right to visit |
INVALID_CHARACTER_SET | The character set is invalid. |
System errors
Returned result | Description |
SYSTEM_ERROR | Alipay system error |
SESSION_TIMEOUT | Session timeout |
ILLEGAL_TARGET_SERVICE | Wrong target service |
ILLEGAL_ACCESS_SWITCH_SYSTEM | Merchant is not allowed to visit system of this type. |
EXTERFACE_IS_CLOSED | The interface has been closed. |
Samples
Request
Request sample for merchants directly integrated with Alipay
https://api-sea-global.alipayplus.com/gateway.do?service=create_forex_trade&partner=2160xxxxxxxxx5500&_input_charset=UTF-8&sign_type=RSA2¬ify_url=http%3A%2F%2Fwww.mikascoffee.com%2Fnotify¤cy=HKD&product_code=NEW_WAP_OVERSEAS_SELLER&subject=Mika's%20coffee%20shop&out_trade_no=out_trade_no_20190910_134443&total_fee=0.01&refer_url=http%3A%2F%2Fwww.mikascoffee.com&qr_pay_mode=4&qrcode_width=200&payment_inst=ALIPAYHK&trade_information=%7B%22business_type%22%3A%224%22%2C%22goods_info%22%3A%22Mika's%20capsule%20coffee%5E1%22%2C%22total_quantity%22%3A%221%22%7D&sign=e68a25685c013bca7c44093c40854f22
Request sample for acquirers and system integrators with secondary merchants
https://api-sea-global.alipayplus.com/gateway.do?service=create_forex_trade&partner=2160xxxxxxxxx5500&_input_charset=UTF-8&sign_type=RSA2¬ify_url=http%3A%2F%2Fwww.mikascoffee.com%2Fnotify¤cy=HKD&product_code=NEW_WAP_OVERSEAS_SELLER&subject=Mika's%20coffee%20shop&out_trade_no=out_trade_no_20190910_134443&total_fee=0.01&qr_pay_mode=4&qrcode_width=200&payment_inst=ALIPAYHK&secondary_merchant_id=1314520&secondary_merchant_name=Mika's%20coffee%20shop&secondary_merchant_industry=5499&sign=5d179bd676cc17a6147a89eaa710f296
Response
Synchronous response
Asynchronous response
http://www.mikascoffee.com/notify
notify_id=201xxxxxxxxxxxxxxxxxxxxxxxxxxx4116
notify_type=trade_status_sync
sign=$$$
trade_no=201xxxxxxxxxxxxxxxxxxxxx5753
total_fee=0.01
out_trade_no=out_trade_no_20190910_134242
notify_time=2019-09-10 13:59:32
currency=HKD
trade_status=TRADE_FINISHED
sign_type=RSA2