Alipay+ DocsAlipay+ Docs

pay (User-presented Mode 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 deduct funds from the user's MPP account.

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: 

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

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

2. For optional parameters that are not required in your case, you can:

  • exclude them from the request body. 
  • set the values as null (without the double quotation marks).

Do NOT leave the optional parameters empty by setting their values as ""; otherwise, an error might occur. 

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.  

Specify the following child parameter apart from the required child parameters:

  • merchant.store

It is recommended to specify the following child parameters:

  • env.storeTerminalId
  • env.storeTerminalRequestTime
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. Alipay+ checks the consistency of the following key request parameters: paymentAmount, paymentMethod.paymentMethodType, and order.orderAmount. If any of their values is different from that in the previous request, 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.

Important:

  • 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), also known as transaction currency, 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.

Specify the following child parameters as follows:

  • paymentMethodType: set the value to CONNECT_WALLET
  • paymentMethodId: set the value to the user payment code
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.

Specify the following child parameters as follows:

  • isInStorePayment: set the value to true 
  • inStorePaymentScenario: set the value to PaymentCode
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.

Specify this parameter if the ACQP wants the payment order to be completed before a specific time. The default expiration time is 1 minute. 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  

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

Specify this parameter if the ACQP integrates the notifyPayment API.

Important: For security reasons, The URL must be an HTTPS URL.  

More information about this field

  • Maximum length: 2048 characters

paymentRedirectUrl URL  

The URL where the user is redirected to after the payment order is completed.

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 result page.

Important: The URL must use HTTPS instead of HTTP for security reasons or the URL can also be in the form of a URL scheme. 

More information about this field

  • Maximum length: 2048 characters

settlementStrategy SettlementStrategy object 

The settlement strategy that is applied to the payment order. For example, specify the currency that the ACQP wants to be settled against on this parameter.

Important: If the settlement currency is different from the payment

 currency that is specified on the paymentAmount.currency parameter, you must specify this parameter correctly; otherwise, you can

  • set the value of this parameter to that of the paymentAmount.currency parameter.
  • set the value of this parameter to null (without double quotation marks). 
  • exclude this parameter from the request body.

In the latter case, the value of the paymentAmount.currency parameter is used as that of the settlementCurrency parameter.

Show child parameters

splitSettlementId String  

The 16-digit, 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.

Specify this parameter 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 How to handle the result.

Show child parameters

acquirerId String  

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

This parameter is returned by Alipay+ if the value of the result.resultCode parameter is SUCCESS, which means that the payment succeeds.

More information about this field

  • Maximum length: 64 characters

paymentId String  

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

This parameter is returned by Alipay+ if the value of the result.resultCode parameter is SUCCESS, which means that the payment succeeds.

More information about this field

  • Maximum length: 64 characters

paymentTime Datetime  

The date and time when the payment order reaches a final state.

This parameter is returned by Alipay+ if the value of the result.resultCode parameter is SUCCESS, which means that the payment succeeds.

More information about this field

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

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.

This parameter is returned by Alipay+ if the value of the result.resultCode parameter is SUCCESS, which means that the payment succeeds.

Show child parameters

customerId String  

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

This parameter is returned by Alipay+ if the value of the result.resultCode parameter is SUCCESS and the MPP provides a unique ID that identifies the user.

More information about this field

  • Maximum length: 64 characters

pspId String  

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

This parameter is returned by Alipay+ if the value of the result.resultCode parameter is SUCCESS, which means that the payment succeeds.

More information about this field

  • Maximum length: 64 characters

walletBrandName String  

The brand name of the MPP that is displayed to the customer.

This parameter is returned by Alipay+ if the value of the result.resultCode parameter is SUCCESS, which means that the payment succeeds.

More information about this field

  • Maximum length: 128 characters

settlementAmount Amount object 

The gross amount that Alipay+ settles to the ACQP. If the settlement currency (specified on the settlementAmount.currency parameter) is the same as the payment currency (specified on the paymentAmount.currency parameter), the settlement amount is the same as the payment amount (specified on the paymentAmount.value parameter); otherwise, the settlement amount is calculated based on the paymentAmount and settlementQuote parameters.

This parameter is returned by Alipay+ if the value of the result.resultCode parameter is SUCCESS, which means that the payment succeeds.

Show child parameters

settlementQuote Quote object 

The exchange rate between the settlement currency (specified on the settlementAmount.currency parameter) and the payment currency (specified on the paymentAmount.currency parameter).

This parameter is returned by Alipay+ if the value of the result.resultCode parameter is SUCCESS and the settlement currency is different from the payment currency.

Show child parameters

customsDeclarationAmount Amount object 

The maximum amount that is to be declared by the ACQP to customs. The currency of the amount is the currency used by the MPP's user. For example, if the user uses ALIPAY_CN to pay, the currency is CNY.

This parameter is returned by Alipay+ if the value of the result.resultCode parameter is SUCCESS and customs declaration is required by the MPP's local authority (for now this only includes the Chinese Mainland). 

Show child parameters

mppPaymentId String  

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

This parameter is returned by Alipay+ if the value of the result.resultCode parameter is SUCCESS, which means that the payment succeeds.

More information about this field

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

Request

URL
Request Body

Response

Response Body

More information

How to handle the result

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

result.resultStatus

result.resultCode

Payment status

Actions

S

SUCCESS

Payment succeeds.

Update the status at the ACQP side.

F

Multiple possible values exist, such as

ACCESS_DENIED,

BUSINESS_NOT_SUPPORT, etc.

Payment fails.

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

U

PAYMENT_IN_PROCESS

Payment is in processing.

Call the inquiryPayment API to inquire the payment result. You can send the inquiryPayment request 10 to 20 times within the payment expiry time, which is 60 seconds by default.

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.

Notes on result code

ORDER_IS_CLOSED

  • If a transaction is not completed at the MPP side after the payment expires, Alipay+ closes the order and returns ORDER_IS_CLOSED.
  • If a transaction is completed, but you receive the error code ORDER_IS_CLOSED, please take ORDER_IS_CLOSED as the final result. 

Result/Error codes

CodeValueMessageFurther action
SUCCESSSSuccess

Update the status from the ACQP side. 

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, for example, settlement 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_SUPPORT FThe 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. 

EXPIRED_CODEFThe code is expired.

Instruct the user to refresh the payment code. 

INVALID_CLIENTFThe client is invalid.

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

INVALID_CODEFThe code is invalid.

Ensure the payment code is valid. If invalid, instruct the user to refresh the payment code. 

INVALID_CONTRACTFThe contract is invalid.

Check whether the parameter values in the request message, for example, settlement 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 the technical support team at 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 Structure 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 digital wallet allows more payments.

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.

Call the inquiryPayment API to inquire about the payment result. 

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.