prepareAlipay+ → MPP
The Mobile Payment Provider (MPP) uses the prepare API to provide an authorization URL for the Auto Debit payment. If the authorization succeeds, the authorization code is also returned to the Acquiring Service Provider (ACQP) in the redirection-back URL.
Note: In the following sections, Mobile Payment Partner (MPP) is also known as PSP. For example, pspId refers to the ID that identifies a 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 take one of the following actions:
- Exclude the parameters from the request body.
- Set the parameter 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
pspId String REQUIRED
The unique ID that is assigned by Alipay+ to identify an MPP.
More information:
- Maximum length: 64 characters
acquirerId String REQUIRED
The unique ID that is assigned by Alipay+ to identify an ACQP.
More information:
- Maximum length: 64 characters
authClientId String REQUIRED
The unique ID that is assigned by the ACQP to identify the auth client, which is usually the merchant.
More information:
- This field is an API idempotency field.See More information -- API idempotency for details.
- Maximum length: 64 characters
authClientName String REQUIRED
The registered legal name of the auth client. The name usually appears with the agreement on the authorization page.
More information:
- Maximum length: 256 characters
authClientDisplayName String REQUIRED
The trade name of the auth client. The name is usually displayed in the title of the authorization page.
More information:
- Maximum length: 64 characters
authRedirectUrl URL REQUIRED
The authorization redirection URL, of which the domain name is provided by the auth client. After receiving the value of this parameter, the MPP must append authCode and authState to it and reconstruct a complete URL that redirects the user back to the merchant when the user completes the authorization process at the wallet side. The authCode, which is used to obtain the access token later, must follow the Alipay+ coding standard and the length must be within 32 bytes. The first 8 digits of the authorization code must be in the format of 281***13
. The fourth to sixth digits are assigned by Alipay+.
The following example shows a format of the complete authorization redirection URL:
More information:
- Maximum length: 1024 characters
scopes Array<String> REQUIRED
The authorization scopes, which means what resources or capabilities are authorized to the auth client. Valid values are:
AGREEMENT_PAY
: indicates that the auth client can use an access token to deduct funds from the user's MPP account for Auto Debit payments.USER_LOGIN_ID
: indicates that the auth client can obtain the desensitized user login ID for the MPP platform by using the applyToken API.BASE_USER_INFO
: indicates that the auth client can obtain the unique user ID of the MPP platform.HASH_LOGIN_ID
: indicates that the auth client can obtain the hash user login ID of the MPP platform.SEND_OTP
: indicates that the auth client can send OTPs to the user.
customerBelongsTo String REQUIRED
This parameter specifies which MPP the user's account belongs to, which is specified as the MPP app name selected by the user. The MPP app name is obtained from the value of the walletName parameter that is returned in the response of the consultPayment API.
More information:
- Maximum length: 32 characters
authState String REQUIRED
A string that is generated by the auth client to represent the prepare API request. The consistency of this field and that in the redirection URL needs to be guaranteed if the authorization code is returned.
More information:
- Maximum length: 256 characters
terminalType String REQUIRED
The type of the auth client terminal that initiates the authorization. Valid values are:
WEB
: indicates that the auth client terminal is a PC browser.WAP
: indicates that the auth client terminal is a mobile browser.APP
: indicates that the auth client terminal is a mobile app.
osType String
The operating system type of the auth client device. Valid values are:
IOS
ANDROID
This parameter is specified by Alipay+ if the value of the teminalType parameter is APP
/WAP
.
osVersion String
The operating system version of the auth client device.
This parameter is specified by Alipay+ if the auth client has provided the OS version.
More information:
- Maximum length: 16 characters
authClientLogo URL
The URL for the MPP to display the auth client logo. The URL domain is provided by the auth client.
This parameter is specified by Alipay+ if the auth client has provided the logo.
More information:
- Maximum length: 2048 characters
userAgent String
The user agent of the auth client browser.
This parameter is specified by Alipay+ if the auth client has provided the user agent.
More information:
- Maximum length: 1024 characters
referenceAgreementId String REQUIRED
The unique ID that is assigned by the auth client to identify an authorization.
More information:
- This field is an API idempotency field.See More information -- API idempotency for details.
- Maximum length: 64 characters
authNotifyUrl URL
The URL that Alipay+ uses to notify the auth client of the authorization information via the authNotify API.
Important: The notification must be sent to the specified URL if this parameter is specified.
More information:
- Maximum length: 2048 characters
referenceMerchantId String REQUIRED
The unique ID that is assigned by the ACQP to identify a merchant.
More information:
- Maximum length: 32 characters
passThroughInfo String
The information that is passed through by the MPP to Alipay+. The value of this parameter is in the set of key-value pairs.
This parameter is specified by Alipay+ if the ACQP wants to pass information to the MPP.
More information:
- Maximum length: 20000 characters
Response parameters
result Result REQUIRED
The result of the business processing. If the value of the result.resultCode parameter is SUCCESS
, the authorization URL is sent to Alipay+ successfully. For more information about how to return the result, see How to return the result.
codeValue String
The value of the authorization QR code that the user scans with an MPP app to complete account binding. With this parameter, the merchant can render the authorization QR code on its web page.
Return this parameter if your app supports code scanning.
More information:
- Maximum length: 2048 characters
codeExpireTime Datetime
The expiration time of the authorization QR code. Return this parameter if the following two conditions are met:
- The codeValue parameter is returned.
- The authorization QR code has an expiration time.
If you return the codeValue parameter but not the codeExpireTime parameter, it means the authorization QR code is permanently valid.
schemeUrl URL
The authorization URL in the form of a URL scheme, which redirects users to an app.
Return this parameter if the value of the result.resultCode parameter is SUCCESS
.
More information:
- Maximum length: 2048 characters
applinkUrl URL
The authorization 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.
Return this parameter if the value of the result.resultCode parameter is SUCCESS
.
More information:
- Maximum length: 2048 characters
normalUrl URL
The authorization URL that redirects users to a WAP or Web page in the browser.
Return this parameter if the value of the result.resultCode parameter is SUCCESS
.
More information:
- Maximum length: 2048 characters
passThroughInfo String
The information that is passed through by Alipay+ to the MPP. The value of this parameter is in the set of key-value pairs.
Return this parameter if the MPP wants to pass information to the ACQP.
More information:
- Maximum length: 20000 characters
Request
Response
More information
How to return the result
According to the request processing result, the MPP needs to return the corresponding result (specified by the result parameter):
- If the business processing succeeds, set the value of result.resultStatus to
S
and the value of result.resultCode toSUCCESS
, and return the authorization URL to Alipay+. - If the business processing fails, set the value of result.resultStatus to
F
and the value of result.resultCode accordingly. - If the business processing result is unknown, set the value of result.resultStatus to
U
and the value of result.resultCode accordingly.
For more information about how to define your result codes, see the Result codes section below.
API idempotency
The authClientId parameter and the referenceAgreementId parameter are jointly used for idempotency control. For requests that are initiated with the same authClientId and referenceAgreementId, the MPP must return the same result.
The MPP is recommended to check the consistency of the following key request parameters: authClientName, referenceMerchantId, authRedirectUrl, and scopes. If any of their values is different from that in the previous request, the MPP needs to return the REPEAT_REQ_INCONSISTENT result code.
schemeUrl/applinkUrl/normalUrl
The values of the schemeUrl, applinkUrl, and normalUrl parameters are different depending on the value of the terminalType parameter.
Result/Error codes
Code | Value | Message |
---|---|---|
SUCCESS | S | Success |
ACCESS_DENIED | F | Access is denied. |
INVALID_CLIENT | F | The client is invalid. |
INVALID_SIGNATURE | F | The signature is invalid. |
KEY_NOT_FOUND | F | The key is not found. |
MEDIA_TYPE_NOT_ACCEPTABLE | F | The server does not implement the media type that is acceptable to the client. |
METHOD_NOT_SUPPORTED | F | The server does not implement the requested HTTPS method. |
NO_INTERFACE_DEF | F | API is not defined. |
PARAM_ILLEGAL | F | Illegal parameters. For example, non-numeric input, invalid date. |
PROCESS_FAIL | F | A general business failure occurred. Do not retry. |
REQUEST_TRAFFIC_EXCEED_LIMIT | U | The request traffic exceeds the limit. |
UNKNOWN_EXCEPTION | U | An API call failed, which is caused by unknown reasons. |