Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solution

alipay.trade.pay

Call the alipay.trade.pay interface to create a Alipay payment order and complete the payment with the pre-authorized funds.

Request

Service address

Environment

HTTPS request URL

Production environment

https://globalopenapi.alipay.com/gateway.do

Test environment

https://openapi.alipaydev.com/gateway.do

Request parameters

Parameter

Description

Basic parameter

app_id

String (32) Required

The unique ID that is assigned by Alipay to identify an application.

Example: 2014072300007148

method

String (128) Required

Interface name

Example: alipay.fund.auth.order.freeze

format

String (40)

Only JSON is supported.

Example: JSON

charset

String (10) Required

The charset with which the request data is encoded. GBK and UTF-8 are supported.

Example: UTF-8

sign_type

String (10) Required

Signature type. RSA and RSA2 are supported. Use uppercase.

Example: RSA2

sign

String (344) Required

Signature value

timestamp

String (19) Required

The time when the merchant server sends the request. The format is yyyy-mm-dd hh:mm:ss.

Example: 2020-07-24 03:07:50

version

String (3) Required

The API version. The value is fixed as 1.0.

Example: 1.0

notify_url

String (256)

The URL for receiving asynchronous notifications after the pre-auth is completed.

Example: http://api.test.alipay.net/atinterface/receive_notify.htm

app_auth_token

String (40)

To query authorization information. 

Example: 201510BBaabdb44d8fd04607abf8d5931ec75D84

Note: After a merchant authorizes an ISV to use certain APIs, Alipay will assign an app_auth_token to the ISV. The ISV can use this interface to query the authorization information such as the authorizer and authorized APIs corresponding to the app_auth_token. For more details, see Overview of the app authorization (in Mandarin).

biz_content

String Required

Collection of request parameters. The maximum length is not limited. Except for common parameters, all other request parameters must be passed in to this parameter.

Business parameter

out_trade_no

String (64) Required

The unique transaction ID that is assigned by the merchant.

Example:8077735255938023

total_amount

Price (11) Required

The total amount

Example:150.00

product_code

String (32) Required

The product code of the Alipay product that you use. The value for this field is OVERSEAS_INSTORE_AUTH.

Example: OVERSEAS_INSTORE_AUTH

auth_no

String (32) Required

Payment authorization code

Example: 287634438256649999

subject

String (100) Required

The description of the transaction.

Note: The value of this field is displayed to customers.

Example: Pre-auth transaction

buyer_id

String (32) Required

The payee's unique Alipay user ID, which is composed of 16 digits and begins with 2088.

Example: 2088102000275795

seller_id

String (32) Required

The unique partner ID assigned by Alipay. The partner ID is composed of 16 digits and begins with 2088.

Example: 2088102000275795

auth_confirm_mode

String (32) Required

Status of the pre-auth.

Example: COMPLETE/NOT_COMPLETE

store_id

String (32) Required

Store ID of the merchant

Example: 123abc

terminal_id

String (32)

Terminal ID of the merchant

Example: 11223344ABC

timeout_express

String (5)

The period before pre-auth timeout. The value of this field is 15m by default. The value of this field ranges from 1m to 15d.

Note:

The following abbreviations are used to present units of time:

  • m: minute
  • hhour
  • dday
  • 1ccurrent day

Example: 1d

trans_currency

String (8) Required

Pricing currency

Example: USD

settle_currency

String (8) Required

Merchant settlement currency

Example: USD

sub_merchant

SubMerchant Required

The sub-merchant information. See sub-merchant for details.

Example: {“merchant_id":"MerchantDavidTest01",  "merchant_type":"merchant"}

extend_params

ExtendParams

The additional parameters. See extend_params for details.

Example: { "sys_service_provider_id":"2088421609886161"}

trade_information

String (6000)

The trade industry Information. See trade_information for details.

Example: {"business_type":"1","hotel_name":"zlidu, sluhg-987, 889utng","check_in_time":"2020-10-20","check_out_time":"2020-10-22"}

sub-merchant

Parameter

Description

merchant_id

The sub-merchant ID. The ID must be uploaded to Alipay in advance via any of the following 2 ways:

  1. Upload the information through API. See alipay.overseas.secmerchant.offline.maintain for details.
  2. Upload the information with GM Portal.

Example:MerchantDavidTest01

merchant_name

Sub-merchant name

merchant_type

The type of the sub-merchants. Possible values include:

  • merchant: A merchant's secondary merchant, through an acquirer
  • Alipay: Alipay's secondary merchant, through an acquirer

Example: merchant

extend_params

Parameter

Description

sys_service_provider_id

The system service provider ID, which is used to extract commission return data. The value of this field is the PID that the system service providers use when they sign the agreement with Alipay.

Example: 2088421609886161

trade_information

Parameter

Description

business_type

String

The business type. The following five types are supported:

  1. Hotel
  2. AIR
  3. Overseas study consulting
  4. Sales of goods
  5. Others

Note: 

"Others" includes all other business types that do not fall into the first four categories. For example, mobile data service recharge, or airport pick up service.

If more than one type is involved, separate the type values with a vertical bar (|).

Example: 1|2|3|4|5 or 1

hotel_name

String

The hotel name that consists of numbers, letters, spaces, and special characters including:

< > ( ) [ ] / \ - , .

If more than one hotel name exists, separate the values with a vertical bar (|). Specify this field only when business_type is 1 (Hotel).

Example: zlidu, sluhg-987, 889utng

check_in_time

Date

The check-in time.

The format is yyyy-mm-dd, and the timezone is GMT+8. Specify this field only when business_type is 1 (Hotel).

Example: 2020-10-20

check_out_time

Date

The check-out time.

The format is yyyy-mm-dd, and the timezone is GMT+8. Specify this field only when business_type is 1 (Hotel).

Example: 2020-10-22

flight_number

String

The flight number.

If a flight transfer exists, separate the flight numbers with a vertical bar (|). Specify this field only when business_type is 2 (AIR).

Example: NWS 996|TWF 8854

departure_time

Date

The departure time.

The format is yyyy-mm-dd hh:mm, and the timezone is GMT+8. If flight transfer exists, separate the time values with a vertical bar (|). Specify this field only when business_type is 2 (AIR).

Example: 2020-10-22 20:49

admission_notice_url

String

The admission notice URL.

If business_type is 3 (Overseas study consulting), the URL of admission notice (image) must be specified.

Example: https://www.iconfont.cn/search/index?test

goods_info

String

The goods information that includes SKU names and corresponding quantities.

The format is SKU_name^quantity. If more than one type of goods exist, separate the values with a vertical bar (|). Specify this field only when business_type is 4 (Sales of goods).

Example: pencil^2|eraser^5|iPhone XS 256G^1

total_quantity

Number

The total quantities of all goods in one order.

Specify this field only when business_type is 4 Sales of goods).

Example: 8

other_business_type

String

If business_type is 5 (Others), specify the business type in detail.

Example: Airport pick up service

Response

Synchronous response

Parameter

Description

Basic parameter

code

String (16) Required

The gateway return code, which indicates whether the request is accepted by Alipay gateway.

Example:  10000

msg

String (32) Required

Description of the gateway return code

Example: Business Failed

sub_code

String (16)

Processing result of the request

Example: isv.invalid-signature

sub_msg

String (64)

Description of the processing result of the request

sign

String (344) Required

The sign value. See Signature for details.

Business parameter

trade_no

String(64) Required

The serial number assigned by Alipay to identify a trade in the Alipay system.

Example: 8077735255938023

out_trade_no

String (64) Required

The unique transaction ID that is assigned by the partner.

Example: 4977164666634053

buyer_logon_id

String(100) Required

Buyer's Alipay login ID

Example: 158****7723

buyer_user_id

String (32) Required

Buyer's unique Alipay user ID

Example: 2088622903359001

buyer_user_type

String (18)

Buyer type

Example: PRIVATE

total_amount

Price (11) Required

Total amount

Example: 100

point_amount

Price (11)

Total amount paid with user points

Example: 0.02

trans_currency

String (8)

The transaction currency. Use uppercase.

Example: USD

settle_currency

String (8)

The settlement currency. Use uppercase.

Example: USD

settle_amount

Price (11)

Settlement amount

Example: 50

pay_currency

String (8)

Payment currency

Example: CNY

pay_amount

Price (11)

Transaction amount

Example: 10

settle_trans_rate

String (11)

The exchange rate between the settlement currency and the transaction currency.

Example: 4.98

trans_pay_rate

String (11)

The exchange rate between the transaction currency and the payment currency.

Example: 4.98

gmt_payment

Date Required

Payment time

Example: 2020-01-12 21:10:10

Asynchronous response

Parameter

Description

app_id

String (64) Required

The unique ID that is assigned by Alipay to identify an application.

trade_no

String (64) Required

The serial number assigned by Alipay to identify a trade in the Alipay system.

out_trade_no

String (64) Required

The unique transaction ID that is assigned by the partner.

out_biz_no

String (64) Required

Business number in partner system

buyer_logon_id

String (100) Required

Buyer logon ID

buyer_id

String (32) Required

Buyer UID

seller_id

String (32) Required

Partner ID

seller_email

String (100) Required

Partner email

total_amount

Price (11) Required

Total transaction amount

trans_currency

String (8)

Transaction currency

settle_currency

String (8)

Settlement currency

settle_amount

Price (11)

Settlement amount

pay_currency

String (8)

Payment currency

pay_amount

Price (11)

Payment amount

settle_trans_rate

String (11)

The exchange rate between settlement currency and the transaction currency.

trans_pay_rate

String (11)

The exchange rate transaction currency and the payment currency.

trade_status

String (20) Required

The trade status. Possible values include:

  • TRADE_SUCCESS
  • TRADE_FINISHED
  • WAIT_BUYER_PAY
  • TRADE_CLOSED

subject

String (100) Required

Transaction description

body

String (100) Required

General information of the transaction

gmt_create

Date Required

Transaction creation time

gmt_payment

Date Required

Transaction payment time

gmt_refund

Date Required

Transaction refund time

gmt_close

Date Required

Transaction completion time

unfreeze_amount

Price (11) Required

After the pre-auth is completed, the remaining amount is returned to the buyer.

Notification trigger condition

Trigger condition name

Description

Note

tradeStatus.TRADE_CLOSED

Trade closed

false (does not trigger notification)

tradeStatus.TRADE_FINISHED

Trade finished

false (does not trigger notification)

tradeStatus.TRADE_SUCCESS

Trade completed successfully

true (triggers notification)

tradeStatus.WAIT_BUYER_PAY

Trade created

false (does not trigger notification)

Error codes

Error Code

Description

ACQ.SYSTEM_ERROR

System error

ACQ.INVALID_PARAMETER

Incorrect parameter

ACQ.ACCESS_FORBIDDEN

You have no permission to use the product.

ACQ.EXIST_FORBIDDEN_WORD

Prohibited words are included.

ACQ.PARTNER_ERROR

Incorrect APPID or abnormal status.

ACQ.TOTAL_FEE_EXCEED

The frozen amount exceeds the limit.

ACQ.PAYMENT_AUTH_CODE_INVALID

The user's payment code is invalid.

ACQ.CONTEXT_INCONSISTENT

The trade information has been modified.

ACQ.TRADE_HAS_SUCCESS

The trade is successful.

ACQ.TRADE_HAS_CLOSE

The trade is closed.

ACQ.BUYER_BALANCE_NOT_ENOUGH

The customer's balance is not enough.

ACQ.BUYER_BANKCARD_BALANCE_NOT_ENOUGH

The customer's bank account balance is not enough.

ACQ.ERROR_BALANCE_PAYMENT_DISABLE

The customer's balance is unavailable.

ACQ.BUYER_SELLER_EQUAL

The payer and payee cannot be the same.

ACQ.TRADE_BUYER_NOT_MATCH

The payment and pre-auth customer does not match.

ACQ.BUYER_ENABLE_STATUS_FORBID

The customer status is abnormal.

ACQ.BEYOND_PAY_RESTRICTION

The merchant's payment amount exceeds the limit.

ACQ.BEYOND_PER_RECEIPT_RESTRICTION

The merchant's payment amount exceeds the monthly limit.

ACQ.SELLER_BEEN_BLOCKED

The merchant account is frozen.

ACQ.INVALID_STORE_ID

The store ID is invalid.

ACQ.SUB_MERCHANT_CREATE_FAIL

The merchant failed to create.

ACQ.SUB_MERCHANT_TYPE_INVALID

The merchant type is invalid.

ACQ.MERCHANT_AGREEMENT_NOT_EXIST

The business contract does not exist.

ACQ.MERCHANT_AGREEMENT_INVALID

The business contract is invalid.

ACQ.MERCHANT_STATUS_NOT_NORMAL

The business contract status is abnormal.

ACQ.AMOUNT_OR_CURRENCY_ERROR

The transaction amount or currency is incorrect.

ACQ.CURRENCY_NOT_SUPPORT

The currency is not supported.

Sample

Request

copy
"biz_content": {
    "auth_no":"2018092610002001000225691613",
"out_trade_no":"PT20180909262008002",
    "subject":"TradePay001",
    "total_amount":"3000.00",
    "trans_currency":"THB",
    "settle_currency":"THB",
    "buyer_id":"2088622903359001",
    “seller_id":"2088621898856371",
    "auth_confirm_mode":"COMPLETE",
    "store_id":"StoreDavidTest01",
    "sub_merchant":{
                  "merchant_id":"MerchantDavidTest01",
                  "merchant_type":"merchant"
                  },
"extend_params":{ 
               "sys_service_provider _id":"2088421609886161"
}
    "product_code":"OVERSEAS_INSTORE_AUTH"
}