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

notifyAuthorization

Alipay uses notifyAuthorization to send the authorization result to the merchant when the authorization succeeds or when the authorization cancellation succeeds.

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

authorizationNotifyType String  REQUIRED

Authorization notification type. Valid values are:

  • AUTHCODE_CREATED (for Auto Debit only): Indicates that the user agrees to authorize an Auto Debit payment. After the user agrees to authorize, the wallet-generated authorization code can be obtained from this notification and be used in the applyToken API to obtain the access token.
  • TOKEN_CREATED (for Easy Pay only): Indicates that the user initiated authorization for an Easy Pay payment on the merchant's client successfully. 
  • TOKEN_CANCELED: Indicates that the authorization cancellation initiated from the merchant or wallet client succeeded.

More information about this field

  • Maximum length: 32 characters

authClientId String  

The unique ID of the secondary merchant to which the user grants resource access permission. The value is specified by the acquirer and needs to be registered in Alipay.  

Notes: 

  • This field is returned when the consult API is initiated by the Alipay+ MPP.
  • For an Alipay+ MPP, the value of this field is the same as the value of referenceMerchantId in the pay (Cashier Payment) API.  

More information about this field

  • Maximum length: 64 characters

accessToken String  

The access token that is used to access the corresponding scope of the user resource. 

Note: This field is returned when the value of authorizationNotifyType is TOKEN_CANCELED or TOKEN_CREATED. 

More information about this field

  • Maximum length: 128 characters

authState String  

A string that is generated by the acquirer to represent the consult request. The value of this field is to be used for validating whether being consistent with the value of authState specified in the consult request.

Note: This field is returned when authorizationNotifyType is AUTHCODE_CREATED and TOKEN_CREATED.

More information about this field

  • Maximum length: 256 characters

authCode String  

The authorization code, used for getting an access token. This value is obtained by the application from the reconstructed redirection URL returned by the wallet after the user is redirected to the reconstructed redirection URL.

Note: This field is returned when authorizationNotifyType is AUTHCODE_CREATED

More information about this field

  • Maximum length: 64 characters

reason String  

The reason why the authorization is canceled. This field is sent to the merchant when the user provides the reason for authorization cancellation.

Note: This field is returned when authorizationNotifyType is TOKEN_CANCELED

More information about this field

  • Maximum length: 256 characters

result Result object REQUIRED

The authorization result. Alipay returns the authorization notification only when the authorization succeeds or the authorization cancellation succeeds. Therefore, only the result of a successful authorization is provided.

Show child parameters

userLoginId String  

The login ID that the user used to register in the wallet. The login ID can be the user's email address or phone number.

Specify this parameter to remove the need for manual entry of the login ID by users.  

More information about this field

  • Maximum length: 64 characters

userId String  

The ID assigned by the payment method provider to identify a user.

More information about this field

  • Maximum length: 64 characters

Response parameters

result Result object REQUIRED

A fixed value that you need to send to Alipay to acknowledge that the notification is received.

Show child parameters
API Explorer

Request

Case
A canceled authorization result
Request Body

Response

Response Body

Result process logic

Send the following message with fixed values to Alipay after receiving the notification, to acknowledge that the notification from Alipay is received:

Sample Code

If no such message is returned to Alipay due to operation issues or network issues, Alipay will intermittently send the notification until the required message is returned by the merchant. Resending of the notification will be performed within 24 hours after the first notification is sent. The notification will be resent up to eight times, with an interval of 0s, 2min, 10min, 10min, 1h, 2h, 6h, and 15h.