alipay.intl.oauth.auth.prepareForRedirect
You can use this interface to redirect users to the URL that is specified by the authsiteurl field and allow users to enter payment password. In this case, AlipayHK generates a one-time-passcode Authcode that will be appended in the alipay.intl.oauth.auth.redirectAuthResultPage URL.
URL sample:
Request Parameters
Header
No | Name | Description | Type | Length | Required | Remarks | Sample |
1 | version | API version | string | 8 | Y | As per the respective API reference | 2.0.0 |
2 | function | API interface | string | 128 | Y | According to specifications defined by each business domain | alipay.intl.function |
3 | clientId | Client ID | string | 32 | Y | Provided by AlipayHK, used to identify partner and application system | 4Q5XPV2N361Y0600 |
4 | reqTime | Request time | datetime | / | Y | DateTime with timezone, which follows the ISO-8601 standard. | 2001-07-04T12:08:56+05:30 |
5 | reqMsgId | Request message ID | string | 64 | Y | Each request will be assigned with a unique id (uuid). | 1234567asdfasdf1123fda |
6 | reserve | Reserved for future implementation | string | 256 | N | Key/Value | {} |
Body
No | Name | Description | Type | Length | Required | Remarks | Sample |
1 | authMerchantId | Auth merchant ID. The auth merchant can be authorized by the user to access user resources. | string | 64 | Y | 2160400000002012 | |
2 | authSite | The site which can authorize the user. | enum<SiteEnum> | 64 | Y | ➹ | ALIPAY_HK |
3 | scopes | The scopes of the authorization. The scope vaule please refer to OAuthScopeEnum | list<string> | 256 | Y | ➹ | ["AUTH_AGREEMENTPAY"] |
4 | terminalType | Terminal type | enum<TerminalTypeEnum> | 32 | Y | Indicates the source terminal type and how the redirect will happen | WEB |
5 | merchantRedirectUrl | Merchant redirect url. It can be passed in each call, or configure it once on AlipayHK side. Note: This parameter is requiredwhen merchantRedirectUrlisPassedInEachCall = true | string | 512 | N | https://www.alipay.com/ | |
6 | state | When provided, this parameter would be posted back in the redirection to the redirectUrl. This is a mechanism to prevent the CRSF attack. Merchant is suggested to generate a dynamic value for the state, so that it could be used to authenticate a redirection from the auth site. | string | 256 | N | 4657DDUER323DK | |
7 | agreementPayAuthInfo | Agreement pay authorization information. If scope is AUTH_AGREEMENTPAY, agreementPayAuthInfo is mandatary. Note: This parameter is required when scopes[?] = AUTH_AGREEMENTPAY | / | N | { | ||
8 | extendInfo | Reserved for extended info | string | 2048 | N | Key/Value | {"agreementMark":"137352934538"} |
9 | riskInfo | Risk information. Highly recommend to provide. | / | N | { |
Request Sample
{
"request":{
"head":{
"version":"2.0.0",
"function":"alipay.intl.oauth.auth.prepareForRedirect",
"clientId":"4Q5XPV2N361Y0600",
"reqTime":"2001-07-04T12:08:56+05:30",
"reqMsgId":"1234567asdfasdf1123fda",
"reserve":"{}"
},
"body":{
"authMerchantId":"2160400000002012",
"authSite":"ALIPAY_HK",
"scopes":[
"AUTH_AGREEMENTPAY"
],
"terminalType":"WEB",
"state":"4657DDUER323DK",
"merchantRedirectUrl":"https://www.alipay.com/",
"agreementPayAuthInfo":{
"merchantAgreementId":"e8qdwl9casxor13",
"merchantUserId":"userId001",
"validPeriod":"2m"
},
"extendInfo":"{\"agreementMark\":\"137352934538\"}",
"riskInfo":{
"deviceInfo":{
"sessionId":"26daf780047938bf8d5b7ea8906003e9",
"serialNo":"f0c0ec9a",
"clientIp":"121.0.29.220",
"latitudeLongitude":"39.9151190000,116.4039630000",
"idfa":"5D08BADB6-B7D1-46DE-BDAB-B66468A1EFCC",
"terminalType":"APP",
"deviceName":"Mike's iPhone",
"deviceBrand":"APPLE",
"deviceModel":"iPhone 7 Plus",
"imei":"863360020885012",
"osName":"ios",
"osVersion":"9.1.1",
"wirelessNetwork":"merchant xxx",
"wirelessCarrier":"merchant xxx",
"flightMode":"enabled",
"fingerPrintEnabled":"enabled",
"deviceBootTime":"2001-07-04T12:08:56+05:30",
"lastUnlockTime":"2001-07-04T12:08:56+05:30",
"screenResolution":"1024*768",
"isJailbreaked":true,
"macAddress":"8c:be:be:71:1f:34",
"systemLanguage":"EN",
"timeZone":"UTC+11"
},
"userInfo":{
"signupTime":"2001-07-04T12:08:56+05:30",
"lastLoginTime":"2001-07-04T12:08:56+05:30",
"merchantUserId":"user0001"
},
"orderInfos":[
{
"productName":"iPhone 7",
"productCategory":"Phone",
"productSubCategory":"smart phone",
"itemPrice":{
"currency":"HKD",
"value":"239"
}
}
],
"riskExtendInfo":"{}"
}
}
},
"signature":
"jo4HAHQqjOomsCYtgqk7uinBmNqfOPuaM54soS2bWYfdZh/gZVF4I8VDVJBTRMuZ0RTAhloQv4eR90itWgbGY+4zGB3AZp795/wKy4VUY4atpeW7NiAn4drMk7lct/bAHU33lzfi93da4lkvKr96CBgrSgIk8pDW0VmDzXYIDXFQpNadWCqGSyHkoBnMNaNQ2Br0ONZmSR21cHYvWPzSEgR9H9+lVu2xoEQSXqPUkImMkMKcYtZMADyFXN9fL5j42saj0N17jel8wjMlDBh43jEgXga+opaYOS0TLniIpSHsHLYB32KPayADZeYtPRs2rWjJVwr+I0CdZyURIp9yuQ=="
}
Response Parameter
Header
No | Name | Description | Type | Length | Required | Remarks | Sample |
1 | version | API version | string | 8 | Y | As per the respective API reference | 2.0.0 |
2 | function | API interface | string | 128 | Y | According to specifications defined by each business domain | alipay.intl.function |
3 | clientId | Client ID | string | 32 | Y | Provided by AlipayHK, used to identify partner and application system | 4Q5XPV2N361Y0600 |
4 | respTime | Response time | datetime | / | Y | DateTime with timezone, which follows the ISO-8601 standard. | 2001-07-04T12:08:56+05:30 |
5 | reqMsgId | Request message ID | string | 64 | Y | Each request will be assigned with a unique id (uuid). | 1234567asdfasdf1123fda |
6 | reserve | Reserved for future implementation | string | 256 | N | Key/Value | {} |
Body
No | Name | Description | Type | Length | Required | Remarks | Sample |
1 | resultInfo | Result info | / | Y | { | ||
2 | authSiteUrl | Auth site URL Note: This parameter is required when resultInfo. resultCode= SUCCESS | string | 1024 | N | http://render-dev.site.alipay.net/p/h5_dev/hk-gka-sign-S901285058/www/index.html/#/cod/sign?merchantRedirectUrl=https%3A%2F%2Fwww.alipay.com%2F&merchantId=2160400000002012&merchantProductCode=MC400401000000000024&productCode=UR400401000000000025&eventCode=40130004&sceneCode=SIGN_AGREEMENT&externalAgreementNo=e8qdwl9casxor13&agreementMark=137352934538&clientId=4Q5XPV2N361Y0600&scopes=AUTH_AGREEMENTPAY&authSite=ALIPAY_HK&state=4657DDUER323DK&bizId=cff506f055a95e5fd4980226b0edbc4c |
Response sample
{
"response": {
"body": {
"authSiteUrl": "http://unitradeprod-platform.dl.alipaydev.com/p/h5_pre/hk-gka-sign/www/index.html#/sign?merchantRedirectUrl=https%3A%2F%2Fsbs-mobops.sandbox-payment.com%2Fdebug%2Ftc%2Fatd_result.html&merchantProductCode=MC400401000000000024&productCode=UR400401000000000025&eventCode=40130004&sceneCode=SIGN_AGREEMENT&externalAgreementNo=d60f45a9b5b74ba184013de1d21dc85a&scopes=AUTH_AGREEMENTPAY&authSite=ALIPAY_HK&state=5fc9dfee-d392-45bd-b087-c1217cec6d3e&isvClientId=&bizId=1212be49b1b8466233801e9fea88ebf0",
"resultInfo": {
"resultCode": "SUCCESS",
"resultCodeId": "00000000",
"resultMsg": "Success",
"resultStatus": "S"
}
},
"head": {
"clientId": "4Q5XSH6SSG02T006",
"function": "alipay.intl.oauth.auth.prepareForRedirect",
"reqMsgId": "b3645cc2-fe57-431a-a7ab-e705cbd1808c",
"respTime": "2019-01-30T00:07:38-08:00",
"version": "2.0.0"
}
},
"signature": "lDc+s1dbVdAhBnEzZ44uZthx82fFXFJl49qHqg+qucBeIxdWxgvVJPCnmPAqOEi7lCELPM66dGWQvPfwxwywaU4DpV3muzymUsd8cneKJe9YGVKdt3yEt3pxfuJbGhT83ybpq/GET0LlWvHY7VZY6XYv3QrSs/S1UhBiJqW0bCUrTof6G6QSFg7m4HUUN8n0g1wL/xvnNSdCDoUakHrdcMdKcPkxRZDTRIs7UVVo6oWhKITZXb3xVJtsoKE9GfpG4lnKV8OxZieNrTZ1Xy0a/cpeJKQBKNp1r4s9osn0u7fpryOtl9mMSMC4QtpQ/uBnODGe2gpaxaS4OtKIs68Z7w=="
}
Business Error code
Functional Logic Result Code
No | ResultCodeId | ResultCode | ResultStatus | Remarks |
1 | 00000013 | NO_INTERFACE_DEF | F | API is not defined |
2 | 00000901 | UNKNOWN_EXCEPTION | U | Unknown exception |
3 | 00000004 | PARAM_ILLEGAL | F | Illegal parameters |