alipay.acquire.create
Call this interface to create a payment transaction.
Request
Service address
Environment | HTTPS request URL |
Production environment | Priority: https://globalmapi.alipay.com/gateway.do |
Test environment |
Note:
If you use POST
method, please specify _input_charset
in the request URL.
For example: https://mapi.alipaydev.com/gateway.do?_input_charset=UTF-8
Request parameters
Parameter | Description |
Basic parameter | |
service String | Interface name
|
partner String(16) | 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(10) | The charset with which the request data are encoded. UTF-8, GBK, and GB2312 are supported.
|
sign_type String | Sign type. RSA, RSA2 and MD5 are supported. Use uppercase.
|
sign String | Sign value
|
notify_url URL(200) | The URL for receiving asynchronous notifications after the payment is completed.
|
timestamp String | The time when the merchant server sends the request. The time is in GMT+8, with a format of yyyy-MM-dd HH:mm:ss. By default, the request expires in 30 minutes.
|
terminal_timestamp String | The time when the terminal sends the request. The value is accurate to the millisecond.
|
Business parameter | |
out_trade_no String(64) | The unique serial number to identify a transaction in partner system. The number can contain letters, digits, and underscores.
|
subject String(256) | Brief description of the transaction. Special characters are not supported. Note: The value of this field will be displayed to customers.
|
product_code String(32) | Product code of the Alipay product that you use, which is specified in the contract you signed with Alipay.
|
total_fee Number(11,2) | Total amount of a transaction in trans_currency. The CNY amount the user actually pays is converted from the value of this parameter.
|
seller_id String(30) | Unique Alipay user ID of the seller, contains 16 digits and begins with 2088. If both seller_email and seller_id are null, use the partner ID as the default value.
|
seller_email String | Alipay ID of the seller, can be email or phone number. If the seller_id is not null, the seller_id is the seller’s Alipay ID and ignore the seller_email.
|
buyer_id String(30) | The unique Alipay user ID of the buyer corresponding to the signed Alipay account. The ID contains 16 digits and begins with 2088. The buyer_id and the buyer_email cannot be null at the same time.
|
buyer_email String | The buyer Alipay account. If both buyer_email and buyer_id are null, use the buyer ID as the default value.
|
body String(400) | Detailed description about the goods. Special characters are not supported.
|
show_url String(400) | The hyperlink for showing goods on the webpage of the checkout counter.
|
currency String(10) | The currency used for labelling the price of the transaction and also the settlement currency that the merchant specifies in the contract. Use upper case. For more information about supported currencies, see Supported Currencies.
|
price Number | Goods prices, which is accurate to 2 digits after the decimal point. The unit is RMB.
|
quantity Number | The quantity of goods
|
goods_detail String | Details about the goods, which is in the format of JSON. The maximum number of goods for this field is 50. For more information, see goods_detail.
|
extend_params String(512) | This parameter contains extended parameters of the request, and transmits business information of the merchant. Format: JSON. See extend_params for details.
|
it_b_pay String(200) | Specifies the expiration time of unpaid transactions. The trade is closed automatically once the time is up. The value of this field is in the range of 1m - 15d or can be an absolute time such as 2014-06-13 16:00:00. Notes:
|
passback_parameters String(256) | The response parameters returned to the merchant in a JSON format after the payment succeeds. Merchants can define the parameters.
|
trans_currency String | Pricing currency for the transaction. Use uppercase. For more information about supported currencies, see Supported Currencies.
|
goods_detail
Parameter | Description |
goodsId String | Goods ID
|
goodsName String | Goods name
|
goodsCategory String | Goods category
|
showUrl String | Hyperlink for the show of goods on the webpage of checkout counter.
|
quantity Number | The quantity of goods
|
body String(400) | Detailed description about the goods. Special characters are not supported.
|
price Number | Goods prices, which is accurate to 2 digits after the decimal point. The unit is RMB. |
extend_params
Parameter | Description |
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.
|
secondary_merchant_name String | Registration legal name of the secondary merchant. Can be null only in cross-border agency acquiring mode when the name is verified.
|
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.
|
store_name String | The store name. Can be null only when the store information is verified.
|
store_id String(32) | The unique ID that is assigned by the partner to identify a store of a merchant, which can contain letters, numbers, and underscores.
|
terminal_id String | Terminal ID
|
sys_service_provider_id String(32) | System service provider ID, which is used to identify the payment system provider.
|
Note:
The decimal place accuracy of amounts, such as the values of total_fee
and price
, depends on the value of currency
. If the value of currency
isJPY
, then the amount must be an integer. For example, 100 JPY. For other currencies, the amount is of two decimal place accuracy. For example, 100.00 USD. Amounts in other formats will cause error, for example, 100.999 USD.
Response
Synchronous response
Parameter | Description |
Basic parameter | |
is_success String | Indicates whether the request succeeds or not, with a value of T for success and F for failure. Note: a successful request does not mean the business is accepted and processed successfully.
|
sign String | Sign value
|
sign_type String | Sign type. RSA, RSA2 and MD5 are supported. Use uppercase.
|
error String(48) | Error code that is returned when the request is unsuccessful, to describe the request failure reason. This parameter is not returned if the request succeeds. For more information, see the Error codes section in this document.
|
Business parameter | |
result_code String(32) | Processing result of the transaction request, with a value of SUCCESS to indicate the transaction is successful, FAIL to indicate the transaction is failed, or UNKNOWN to indicate an unknown result.
|
trade_no String(64) | The unique transaction ID in Alipay system, with a length in the range 16 - 64.
|
out_trade_no String(64) | The unique serial number to identify a transaction in partner system. The number can contain letters, digits, and underscores.
|
m_discount_forex_amount Number(9,2) | If coupons/vouchers are used in the transaction, the discount amount redeemed in the settlement currency will be returned. Otherwise, no return.
|
detail_error_code String(48) | Reason of the returned response code. If the response code of result_code is SUCCESS, this parameter is not returned. For more information about the value of detail_error_code, see the Error codes section.
|
detail_error_des String(46) | Explanation of the detailed error code. If result_code is SUCCESS, this parameter is not returned.
|
Asynchronous response
Parameter | Description |
Basic parameter | |
notify_time Timestamp | The time when the notification is sent. The time format is yyyy-MM-dd HH:mm:ss.
|
notify_type String | Notification type
|
notify_id String | Notification ID
|
sign_type String | Sign type. RSA, RSA2 and MD5 are supported. Use uppercase.
|
sign String | Sign value
|
notify_action_type String | Notification action type. The value can be one of the following items:
|
Business parameter | |
out_trade_no String | Unique order ID in the order system in corresponding merchant's website other than Alipay trade number. Uniqueness of this parameter in merchant's website shall be guaranteed.
|
subject String(256) | Brief description of the transaction. This parameter is in the first column of Alipay trade details and is important for account checking. This parameter is transmitted by the corresponding request and needs to be returned with its original value.
|
trade_no String | The serial number of the trade in Alipay system
|
trade_status String | Transaction status. See Trade status for details.
|
gmt_create Date | The time when the trade transaction is created. Format: yyyy-MM-dd HH:mm:ss. Use GMT+8.
|
gmt_payment Date | The time when the payment is completed. Format: yyyy-MM-dd HH:mm:ss. Use GMT+8.
|
seller_email String | Alipay ID of the seller, with a format of email address or phone number
|
buyer_email String | Buyer’s Alipay ID, which can be an email address or phone number.
|
seller_id String | Seller's unique Alipay user ID, which consists of 16 digits and begins with 2088.
|
buyer_id String | Buyer's unique Alipay user ID consists of 16 digits and begins with 2088.
|
price Number | Goods price. This parameter is transmitted by the corresponding request and needs to be returned with its original value.
|
quantity Number | The quantity of goods. This parameter is transmitted by the corresponding request and needs to be returned with its original value.
|
total_fee Number | Total transaction amount in CNY, converted from the value of total_fee in the request
|
body String(400) | Detailed description about the goods. This parameter is transmitted by the corresponding request and needs to be returned with its original value.
|
refund_fee Number | The refund amount. The unit is Yuan.
|
out_biz_no String | Merchant's business ID, which is the serial number of the refund request in the refund notification for most cases.
|
paytools_pay_amount String | Payment amount information of all successful payments in various channels.
|
extra_common_param String | This parameter is returned with the value of passback_parameters in the corresponding request.
|
m_discount_forex_amount Number | If coupons/vouchers are used in the transaction, the discount amount redeemed in the settlement currency will be returned. Otherwise, no return.
|
paytools_pay_amount
Parameter | Description |
ALIPAYACCOUNT String | The money amount paid by the balance of Alipay account. The unit is Yuan.
|
MCARD String | The money amount paid by the merchant's prepaid card. The unit is Yuan.
|
MDISCOUNT String | The money amount paid by the merchant's discount coupon. The unit is Yuan.
|
TMPOINT String | The money amount paid by the Tmall points. The unit is Yuan.
|
COUPON String | The money amount paid by coupons. The unit is Yuan.
|
POINT String | The money amount paid by points. The unit is Yuan.
|
DISCOUNT String | The money amount paid by the discount. The unit is Yuan.
|
BANKCARD String | The money amount paid by the money fund. The unit is Yuan.
|
MONEYFUND String | The money amount paid by the money fund. The unit is Yuan.
|
BAITIAO String | The money amount paid by BAITIAO. The unit is Yuan.
|
PCARD String | The money amount paid by the Alipay card. The unit is Yuan.
|
PCREDIT String | The money amount paid by the consumption credit card. The unit is Yuan.
|
MCOUPON String | The money amount paid by the merchants issued coupons. The unit is Yuan.
|
Error codes
Business errors
Error code | Description |
TRADE_SETTLE_ERROR | Settlement verification fails. |
TRADE_BUYER_NOT_MATCH | The buyer doesn’t match. |
CONTEXT_INCONSISTENT | The trade context is inconsistent. |
TRADE_HAS_SUCCESS | The trade is already paid. |
TRADE_HAS_CLOSE | The trade is closed. |
REASON_ILLEGAL_STATUS | The trade status is illegal. |
EXIST_FORBIDDEN_WORD | Forbidden words exist in the order information. |
ACCESS_FORBIDDEN | No access to use this product. |
SELLER_NOT_EXIST | The seller doesn’t exist. |
BUYER_NOT_EXIST | The buyer doesn’t exist. |
BUYER_ENABLE_STATUS_FORBID | The trade is forbidden because the buyer’s status is illegal. |
BUYER_SELLER_EQUAL | The trade is forbidden because the seller and the buyer’s ID is the same. |
INVALID_PARAMETER | The parameter is invalid. |
INVALID_RECEIVE_ACCOUNT | The seller’s account is not in the list of valid receivers. |
ERROR_BUYER_CERTIFY_LEVEL_LIMIT | The buyer account not certified. |
ERROR_SELLER_CERTIFY_LEVEL_LIMIT | The seller account not certified. |
SELLER_BEEN_BLOCKED | The seller’s account is blocked. |
BEYOND_PER_RECEIPT_RESTRICTION | The amount that the seller receives is beyond the up limit of that month. |
TOTAL_FEE_EXCEED | The amount of the order is beyond the limit. |
BUYER_PAYMENT_COUNT_DAY_LIMIT_ERROR | The buyer’s number of payment is beyond the limit of one day. |
BUYER_PAYMENT_COUNT_MONTH_LIMIT_ERROR | The The buyer’s number of payment is beyond the limit of one month. |
TRADE_STATUS_ERROR | Trade status error. |
BUYER_PAYMENT_AMOUNT_MONTH_LIMIT_ERROR | The The buyer’s amount of payment is beyond the limit of one month. |
PRODUCT_AMOUNT_LIMIT_ERROR | The amount of the product is beyond the limit. |
DUPLICATE_PAY_CURRENCY_NOT_EQUAL | The currency is inconsistent. |
USER_LOGONID_DUP | Can’t do the payment or receipt because the account name of your phone is duplicated. We suggest you to inform he/she to modify the account name and update his/her account name after you check together. |
EXCHANGE_AMOUNT_OR_CURRENCY_ERROR | The currency of the price or of the settlement is not supported. |
BUYER_ENABLE_STATUS_FORBID | The buyer’s status is illegal, mostly it’s because the buyer’s certification level is not enough. |
SECONDARY_MERCHANT_ID_BLANK | The secondary merchant ID is not provided to Alipay. |
SECONDARY_MERCHANT_ID_INVALID | The secondary merchant is not registered with Alipay. |
STORE_NOT_MATCH | The secondary merchant is not registered with Alipay. |
SECONDARY_MERCHANT_STATUS_ERROR | The status of secondary merchant is abnormal in the Alipay system. |
Access errors
Error code | Description |
ILLEGAL_SIGN | Illegal signature. |
ILLEGAL_DYN_MD5_KEY | Dynamic key information is incorrect. |
ILLEGAL_ENCRYPT | Encryption is incorrect. |
ILLEGAL_ARGUMENT | Parameter is incorrect. |
ILLEGAL_SERVICE | Service parameter is incorrect. |
ILLEGAL_USER | User ID is incorrect. |
ILLEGAL_PARTNER | Partner ID is incorrect. |
ILLEGAL_EXTERFACE | Interface configuration is incorrect. |
ILLEGAL_PARTNER_EXTERFACE | Partner’s interface information is incorrect. |
ILLEGAL_SECURITY_PROFILE | Matching private key configuration has not been found. |
ILLEGAL_AGENT | Agency ID is incorrect. |
ILLEGAL_SIGN_TYPE | The signature type is incorrect. |
ILLEGAL_CHARSET | The character set is illegal. |
HAS_NO_PRIVILEGE | Has no right to visit. |
INVALID_CHARACTER_SET | The character set is invalid. |
System errors
Error code | 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
https://intlmapi.alipay.com/gateway.do?operator_id=sky&subject=%E5%88%86%E8%B4%A6%E6%B5%8B%E8%AF%95-sky&sign_type=MD5¬ify_url=http%3A%2F%2Fapi.test.alipay.net%2Fatinterface%2Freceive_notify.htm&out_trade_no=205211376305670&sign=9aae99502a8dd70e67d3d3575f7176cd&_input_charset=UTF-8&price=0.01&it_b_pay=1d&product_code=OVERSEAS_MBARCODE_PAY&total_fee=0.01&service=alipay.acquire.create&seller_id=2088101106499364&quantity=1&partner=2088101106499364&extend_params=%7B%22STORE_ID%22%3A%22323231%22%2C%22STORE_TYPE%22%3A%221%22%7D&alipay_ca_request=2&ref_ids=%5b%7b%26quot%3bid_type%26quot%3b%3a%26quot%3borig_out_request_no%26quot%3b%2c%26quot%3bid%26quot%3b%3a%26quot%3bHZ0001%26quot%3b%7d%2c%7b%26quot%3bid_type%26quot%3b%3a%26quot%3borig_out_order_no%26quot%3b%2c%26quot%3bid%26quot%3b%3a%26quot%3bHZ0001%26quot%3b%7d%5d
Response
Synchronous response
Business acceptance is normal and query is successful:
<?xml version="1.0" encoding="utf-8"?>
<alipay>
<is_success>T</is_success>
<request>
<param name="body">Jewellery</param>
<param name="operator_id">8888</param>
<param name="subject">test</param>
<param name="sign_type">MD5</param>
<param name="out_trade_no">3618810634349901</param>
<param name="total_fee">20.00</param>
<param name="partner">2088101126765726</param>
<param name="quantity">2</param>
<param name="alipay_ca_request">2</param>
<param name="sign">42fff1757f72510e2027bf03879f03a9</param>
<param name="goods_detail">
[{"goodsName":"ipad","price":"2000.00","quantity":"1"},{"goodsName":"ipad2","price":"2000.00", "quantity":"1"}]</param>
<param name="_input_charset">UTF-8</param>
<param name="price">10</param>
<param name="it_b_pay">50m</param>
<param name="product_code">WAP_CREATE_TRADE</param>
<param name="service">alipay.acquire.create</param>
<param name="seller_id">2088101126765726</param>
<param name="seller_email">yuezhuzhanghu@alitest.com</param>
<param name="extend_params">{"STORE_ID":"323231","STORE_TYPE":"1"}</param>
</request>
<response>
<alipay>
<out_trade_no>6409624505322427</out_trade_no>
<trade_no>2013111811001004410070187794</trade_no>
<result_code>SUCCESS</result_code>
</alipay>
</response>
<sign>97ef60dd5015aa311058fcaf2d2ac8e3</sign>
<sign_type>MD5</sign_type>
</alipay>
Request succeeds, but the business processing fails:
<?xml version="1.0" encoding="utf-8"?>
<alipay>
<is_success>T</is_success>
<request>
<param name="body">Jewellery</param>
<param name="operator_id">8888</param>
<param name="subject">test</param>
<param name="sign_type">MD5</param>
<param name="out_trade_no">3618810634349901</param>
<param name="total_fee">20.00</param>
<param name="partner">2088101126765726</param>
<param name="quantity">2</param>
<param name="alipay_ca_request">2</param>
<param name="sign">42fff1757f72510e2027bf03879f03a9</param>
<param name="goods_detail">
[{"goodsName":"ipad","price":"2000.00","quantity":"1"},{"goodsName":"ipad2","price":"2000.00", "quantity":"1"}]</param>
<param name="_input_charset">UTF-8</param>
<param name="price">10</param>
<param name="it_b_pay">50m</param>
<param name="product_code">WAP_CREATE_TRADE</param>
<param name="service">alipay.acquire.create</param>
<param name="seller_id">2088101126765726</param>
<param name="seller_email">yuezhuzhanghu@alitest.com</param>
<param name="extend_params">{"STORE_ID":"323231","STORE_TYPE":"1"}</param>
</request>
<response>
<alipay>
<result_code>FAIL</result_code>
<detail_error_code>TRADE_BUYER_NOT_MATCH</detail_error_code>
<detail_error_des>Buyer not matched</detail_error_des>
</alipay>
</response>
<sign>97ef60dd5015aa311058fcaf2d2ac8e3</sign>
<sign_type>MD5</sign_type>
</alipay>
Request fails or the request data are incorrect:
<?xml version="1.0" encoding="utf-8"?>
<alipay>
<is_success>F</is_success>
<error>ILLEGAL_SIGN</error>
</alipay>
Asynchronous response
http://some_domain/alipay/notify_url.php?notify_id=ac05099524730693a8b330c5ecf72da978&seller_email
notify_time=2013-11-27 15:45:58
notify_type=trade_status_sync
notify_id=ac05099524730693a8b330c5ecf72da978
sign_type=MD5
sign=601510b7970e52cc63db0f44997cf70e
notify_action_type=payByAccountAction
out_trade_no=990xxxxxxx8989
subject=kids clothing
trade_no=2013112711001004940000394507
trade_status=WAIT_BUYER_PAY
gmt_create=2013-11-27 15:45:57
gmt_payment=2013-11-27 15:45:57
seller_email=zhuzhanghu@alitest.com
buyer_email=138*****011
seller_id=2088101106499364
buyer_id=2088102105236945
price=1.00
quantity=10
total_fee=10.00
body=Glitter leggings
refund_fee=1.00
out_biz_no=HZRF001
paytools_pay_amount=[{"MCARD":"7.94"},{"TMPOINT":"1.69"},{"BANKCARD":"5.55"}]
extra_common_param={"qrcode":"https://qr.alipay.com/9446219319446735"}
m_discount_forex_amount=2.19