Alipay+ DocsAlipay+ Docs
APIs & SDKs

pay (Cashier Payment)ACQP → Alipay+

POST /aps/api/v1/payments/pay

The pay API is used by the Acquiring Service Provider (ACQP) to send a request to Alipay+ to place orders.

Note: In the following sections, Mobile Payment Provider (MPP) is also known as Payment Service Provider. For example, the pspId parameter specifies the ID that identifies an MPP.

Structure

A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see: 

Note: 

Set the data type of each field (except array) as String. This means that you must use double quotation marks (" ") to enclose the field value. Examples:

  • If the data type of a field is Integer and its value is 20, set it as "20".
  • If the data type of a field is Boolean and its value is true, set it as "true".

Request parameters

order Order object REQUIRED

The order details that are agreed upon by the buyer and the merchant, including the information about the buyer, the merchant, the goods, the initial order amount, and so on. The order details are displayed in purchase records and used for risk and regulatory reporting. 

Note

In this scenario, apart from the required child parameters, the following child parameters must be specified:

  • env.terminalType
  • env.osType if the value of the env.terminalType parameter is APP or WAP

It is recommended that you also specify the following child parameter:

  • buyer.referenceBuyerId
Show child parameters

paymentRequestId String  REQUIRED

The unique ID that is assigned by the ACQP to identify a payment order.

More information about this field

  • This field is an API idempotency field.For requests that are initiated with the same paymentRequestId, Alipay+ regards the requests as repeated and processes the requests only once. If the values for the key parameters such as paymentAmount, paymentFactor, settlementStrategy, and paymentMethod.paymentMethodType in repeated requests are different, Alipay+ returns the REPEAT_REQ_INCONSISTENT result code.
  • Maximum length: 64 characters

paymentAmount Amount object REQUIRED

The amount that the ACQP requests to receive from Alipay+. The currency of the amount must be specified to the one that the ACQP uses to create the payment order.

Note:

  • The paymentAmount and settlementStrategy parameters jointly affect the amount that Alipay+ settles to the ACQP (which is returned as the settlementAmount parameter) in the following ways:
    • If the payment currency (specified on the paymentAmount.currency parameter) is the same as the settlement currency (specified on the settlementStrategy.settlementCurrency parameter), the settlement amount is the same as the payment amount (specified on the paymentAmount.value parameter).
    • If the payment currency (specified on the paymentAmount.currency parameter) is different from the settlement currency (specified on the settlementStrategy.settlementCurrency parameter), the settlement amount is calculated based on the payment amount (specified on the paymentAmount.value parameter) and the exchange rate between the settlement currency and payment currency.
  • When you specify the paymentAmount parameter, ensure that the settlement amount is no less than the smallest amount in the settlement currency; otherwise, the API call fails.
Show child parameters

paymentMethod PaymentMethod object REQUIRED

The payment method that is used to collect the payment.

Note: In this scenario, the following child parameter must be set to the specific value as shown below:

  • paymentMethodType: set the value to CONNECT_WALLET if the value of the paymentFactor.presentmentMode parameter is BUNDLE; set the value to the name of the MPP that is selected by the user if the value of the paymentFactor.presentmentMode parameter is TILE. The MPP name is indicated by the value of the walletName parameter that is returned in the response of the consultPayment API.
Show child parameters

paymentFactor PaymentFactor object REQUIRED

Factors that impact payment-related items such as service fee, interchange fee (also known as interpartner fee), and regulatory reporting. This parameter is used to identify the payment scenario.

Note: In this scenario, the following child parameters must be set to the specific values as shown below:

  • isInStorePayment: set the value to false 
  • isCashierPayment: set the value to true
Show child parameters

paymentExpiryTime Datetime  

The time after which the payment order is expired. If the payment order is not completed before the time that is specified for this parameter, Alipay+ closes the order and calls the notifyPayment API to notify the ACQP of the payment result.

Note

  1. Required if the ACQP wants the payment order to be completed before a specific time.
  2. In this scenario, the default value of this parameter is 10 minutes.
  3. The specified expiration time must be shorter than the default expiration time; otherwise, the default expiration time takes effect instead of the specified expiration time.

More information about this field

  • The value follows the ISO 8601 standard format. For example, "2019-11-27T12:01:01+08:00".

paymentNotifyUrl URL  REQUIRED

The URL that is used to receive the payment result notification from Alipay+.

More information about this field

  • Maximum length: 2048 characters

paymentRedirectUrl URL  

The URL where the user is redirected from the MPP side to after the user proceeds with the payment order to a status of success, failure or unknown (for example, give up the payment order).

Specify this parameter if the user needs to be redirected from the MPP's payment result page to a predetermined page, for example, the merchant payment result page.  

More information about this field

  • Maximum length: 2048 characters

settlementStrategy SettlementStrategy object 

The settlement strategy that is applied to the payment order, for example, the currency that the ACQP wants to be settled against.

Note: Required if the settlement currency is different from the payment currency that is specified for the paymentAmount.currency parameter.

Show child parameters

userRegion String  

This parameter is used to sort the payment method list in descending order based on the relevance between the MPP and the user region on the Alipay+ checkout page. The value of this parameter is a 2-letter country/region code according to ISO 3166 Country Codes.

Note: Required if the ACQP wants to sort the payment method list on the Alipay+ checkout page based on the user region.

More information about this field

  • Maximum length: 2 characters

splitSettlementId String  

The unique ID that is assigned by Alipay+ to the ACQP for multi-batch reconciliation. For each unique value of this parameter, Alipay+ performs a batch of clearing and settlement, and transfers a batch of funds to the ACQP's bank account.

Note: Required if the ACQP needs to split its settlement for transactions in one region and one currency into multiple batches.

More information about this field

  • Maximum length: 16 characters

Response parameters

result Result object REQUIRED

The result of the business processing, including the result status, result code, and result message. For more information about how to handle the result of the pay API, see Result processing logic.

Show child parameters

acquirerId String  

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

Note: Returned by Alipay+ if the value of the result.resultCode parameter is PAYMENT_IN_PROCESS, which means that the request is accepted. 

More information about this field

  • Maximum length: 64 characters

paymentId String  

The unique ID that is assigned by Alipay+ to identify a payment order.

Note: Returned by Alipay+ if the value of the result.resultCode parameter is PAYMENT_IN_PROCESS, which means that the request is accepted. 

More information about this field

  • Maximum length: 64 characters

schemeUrl URL  

The payment URL in the form of a URL scheme, which redirects users to an app.

More information about this field

  • Maximum length: 2048 characters

applinkUrl URL  

The payment URL in the form of a link that redirects users to an app, or, if no APP is installed, to a WAP page. For Android, the link is the native App Link; and for iOS, the Universal Link.

More information about this field

  • Maximum length: 2048 characters

normalUrl URL  

The payment URL that redirects users to a WAP or Web page in the browser or in the WebView.

Note:

  • Returned by Alipay+ if the value of the result.resultCode parameter is PAYMENT_IN_PROCESS.
  • The auth client needs to trust all URLs returned by Alipay+, instead of adding them to the whitelist.

More information about this field

  • Maximum length: 2048 characters

appIdentifier String  

The Android package name. This parameter is used to identify which MPP app is to be invoked for the redirection.

Note: Returned if the value of the osType parameter is ANDROID and the value of the schemeUrl or applinkUrl parameter is specified.

More information about this field

  • Maximum length: 128 characters

paymentAmount Amount object 

The amount that the ACQP requests to receive from Alipay+. The currency of the amount is the one that the ACQP uses to create the payment order.

Note: Returned if the value of the result.resultCode parameter is PAYMENT_IN_PROCESS, which means that the request is accepted. 

Show child parameters

orderCodeForm OrderCodeForm object 

The order code that the user scans to confirm the payment.

Note:

In this scenario, apart from the required child parameters, the following optional child parameters are also returned by Alipay+ if result.resultCode is set to PAYMENT_IN_PROCESS, order.env.terminalType is set to WEB, paymentFactor.presentmentMode is set to TILE, and the wallet selected by the user supports code scanning. 

  • paymentMethodType
  • expireTime
Show child parameters

pspId String  

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

Note: Returned by Alipay+ if the value of the result.resultCode parameter is PAYMENT_IN_PROCESS and the value of the paymentMethod.paymentMethodType parameter is not CONNECT_WALLET.

More information about this field

  • Maximum length: 64 characters
API Explorer
Sample CodesRun in Sandbox

Request

URL
Request Body

Response

Response Body

More information

Response conditionality

  • If the value of the result.resultCode parameter is PAYMENT_IN_PROCESS, Alipay+ returns at least one of the following three parameters: schemeUrl, applinkUrl , and normalUrl. If more than one of the three parameters is returned, the following priority applies: schemeUrl > applinkUrl > normalUrl.
  • The auth client needs to trust all URLs returned by Alipay+, instead of adding them to the whitelist.
  • In case both the normalUrl and orderCodeForm parameters are returned, you can use either of them to render the QR code for the user to scan. The differences between the two parameters are as follows: 
    • With the normalUrl parameter, you directly open the normal URL to redirect the user to a QR code page rendered by Alipay+, where the user scans the QR code to confirm the payment.
    • With the orderCodeForm parameter, you obtain the QR code value in four formats: one text string (when displayType is TEXT) and three images of different sizes (when displayType is SMALLIMAGE, MIDDLEIMAGE, or BIGIMAGE). You can use either of the four formats to render the QR code page, where the user scans the QR code to confirm the payment.

Result processing logic

You might receive different results from Alipay+. Follow the instructions below to handle the result.

result.resultStatus

result.resultCode

Payment status

Actions

F

...

Payment fails.

Take actions according to the result code (specified on the result.resultCode parameter). For more information, see the Result code section.

U

PAYMENT_IN_PROCESS

Payment is in processing.

Redirect the user to the page that is specified by the schemeUrl/applinkUrl/normalUrl parameter to confirm the payment .

U

Values other than

PAYMENT_IN_PROCESS

Unknown.

Retry the same request. Ensure that the value specified on the paymentRequestId parameter is the same as the one specified in the previous request.

No result received

Unknown.

Retry the same request. Ensure that the value specified on the paymentRequestId parameter is the same as the one specified in the previous request.

Result/Error codes

CodeValueMessageFurther action
ACCESS_DENIEDFAccess is denied.

It is recommended that you contact connect_support@service.alipay.com to troubleshoot the issue.

BUSINESS_NOT_SUPPORTFThe payment business is not supported.

Check whether the parameter values in the request message, such as merchant ID and transaction currency, conform to the contract. If yes, it is recommended that you contact connect_support@service.alipay.com to troubleshoot the issue; otherwise, correct the parameters to align with the contract.

CURRENCY_NOT_SUPPORTFThe currency is not supported.

Ensure the currencies used in the request, such as payment currency and settlement currency, conform to the contract. If the issue persists, it is recommended that you contact connect_support@service.alipay.com to troubleshoot the issue.

INVALID_CLIENTFThe client is invalid.

It is recommended that you contact connect_support@service.alipay.com to troubleshoot the issue.

INVALID_CONTRACTFThe contract is invalid.

Check whether the parameter values in the request message, such as merchant ID and transaction currency, conform to the contract. If yes, it is recommended that you contact connect_support@service.alipay.com to troubleshoot the issue; otherwise, correct the parameters to align with the contract.

INVALID_SIGNATUREFThe signature is invalid.

Check whether the public key, signed message, and signature algorithm are as expected.

KEY_NOT_FOUNDFThe key is not found.

It is recommended that you contact connect_support@service.alipay.com to troubleshoot the issue.

MEDIA_TYPE_NOT_ACCEPTABLEFThe server does not implement the media type that is acceptable to the client.

Use a media type that is accepted by Alipay+.

MERCHANT_NOT_REGISTEREDFThe merchant is not registered.

It is recommended that you contact connect_support@service.alipay.com to troubleshoot the issue.

METHOD_NOT_SUPPORTEDFThe server does not implement the requested HTTPS method.

Ensure the HTTP method is POST.

NO_INTERFACE_DEFFAPI is not defined.

Check whether the request URL is correct. Ensure that the endpoint of the called API is correct.

ORDER_IS_CLOSEDFThe order is closed.

Close the order at the ACQP side.

PARAM_ILLEGALFIllegal parameters. For example, non-numeric input, invalid date.

Check whether the request parameters, including the header parameters and body parameters, are correct and valid. For more information about the parameters of each API, see the Structure section of the specific API reference topic.

PAYMENT_AMOUNT_EXCEED_LIMITFThe payment amount exceeds the limit that is specified by Alipay+.

It is recommended that you inform the user of the error.

PAYMENT_AMOUNT_INVALIDFPayment amount is invalid.

It is recommended that you contact connect_support@service.alipay.com to troubleshoot the issue.

PAYMENT_COUNT_EXCEED_LIMITFThe number of payments exceeds the limit.

Wait until the MPP server allows more requests.

PROCESS_FAILFA general business failure occurred. Do not retry.

It is recommended that you contact connect_support@service.alipay.com to troubleshoot the issue.

REPEAT_REQ_INCONSISTENTFRepeated requests are inconsistent.

Ensure that the values of the parameters in the repeated requests are the same.

RISK_REJECTFThe request is rejected because of the risk control.

It is recommended that you inform the user of the error.

UNAVAILABLE_PAYMENT_METHODFThe payment method is unavailable.

It is recommended that you inform the user of the error.

USER_AMOUNT_EXCEED_LIMITFThe payment amount exceeds the payment limit that is specified by the user's digital wallet.

It is recommended that you inform the user of the error.

USER_BALANCE_NOT_ENOUGHFThe user balance is not enough for the payment.

It is recommended that you inform the user of the error.

USER_KYC_NOT_QUALIFIEDFUser is not qualified for the KYC verification.

It is recommended that you inform the user of the error.

USER_NOT_EXISTFThe user does not exist.

It is recommended that you inform the user of the error.

USER_PAYMENT_VERIFICATION_FAILEDFUser fails to pass the payment verification in the methods like OTP, PIN and so on.

It is recommended that you inform the user of the error.

USER_STATUS_ABNORMALFThe user status is abnormal.

It is recommended that you inform the user of the error.

PAYMENT_IN_PROCESSUThe payment is being processed.

Redirect the user to the Alipay+ checkout page to confirm the payment.

REQUEST_TRAFFIC_EXCEED_LIMITUThe request traffic exceeds the limit.

Reduce the frequency of API calls.

UNKNOWN_EXCEPTIONUAn API call failed, which is caused by unknown reasons.

Try to recall the API.