|
@@ -0,0 +1,99 @@
|
|
|
+ 支付宝三要素授权对接文档20230615
|
|
|
+
|
|
|
+
|
|
|
+ 接入方跳转至服务商小程序
|
|
|
+ 跳转至服务商三要素授权小程序
|
|
|
+
|
|
|
+ 调用支付宝my.navigateToMiniProgram的api (具体参考支付宝官方api说明)
|
|
|
+ 服务商小程序appId: 2021003181682188
|
|
|
+ 页面路径path: pages/authorize_three/authorize_three
|
|
|
+ 参数query:
|
|
|
+ name:标识商户的小程序名称;
|
|
|
+ notify:授权成功后三要素数据回调地址;
|
|
|
+ token:认证分配的唯一token;
|
|
|
+ taskId:任务id ;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 跳转示例代码:
|
|
|
+ my.navigateToMiniProgram({
|
|
|
+ appId: "2021003181682188",
|
|
|
+ path: "pages/authorize_three/authorize_three",
|
|
|
+ query: {
|
|
|
+ name: "商户小程序名称",
|
|
|
+ notify: "http://www.test.com/xxx",
|
|
|
+ token: "xxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
|
+ taskId: "xxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
|
+ }
|
|
|
+ })
|
|
|
+ 备注:taskId不可重复,并请自行缓存,授权成功后回调地址会携带该参数。
|
|
|
+
|
|
|
+
|
|
|
+二.接入方开发notify接收接口
|
|
|
+ (4)三要素接收接口
|
|
|
+
|
|
|
+ 授权成功后的回调地址notify说明:
|
|
|
+ 服务商推送采用HTTPS协议的POST方法,数据格式为JSON, 编码为UTF8
|
|
|
+ 入参说明:
|
|
|
+ certName --- "用户姓名"
|
|
|
+ certNo ---- "身份证号"
|
|
|
+ certType --- "IDENTITY_CAR"
|
|
|
+ Phone --- "手机号"
|
|
|
+ taskId --- "xxxxxxxxx"
|
|
|
+ Token --- "xxxxxxxxxx"
|
|
|
+ userId --- "支付宝用户的userId"
|
|
|
+
|
|
|
+ 入参示例:
|
|
|
+ {
|
|
|
+ certName: "张三"
|
|
|
+ certNo: "330821xxxxxxxx0212"
|
|
|
+ certType: "IDENTITY_CAR"
|
|
|
+ phone: "130xxxxxxxx"
|
|
|
+ taskId: "xxxxxxxxx"
|
|
|
+ token: "xxxxxxxxxx"
|
|
|
+ userId: "1234567890"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 响应说明:
|
|
|
+ 只有收到code为200时,代表接入方已成功接收该条数据,服务商小程序才会自动返回接入方小程序.
|
|
|
+
|
|
|
+ 响应示例:
|
|
|
+ {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "成功",
|
|
|
+ "data": null
|
|
|
+ }
|
|
|
+
|
|
|
+三.支付宝小程序开发建议
|
|
|
+
|
|
|
+ 授权成功后,返回商户小程序的后续操作说明:
|
|
|
+ 有2种方式接收从授权小程序返回来的参数:
|
|
|
+ 在app.js中的onShow方法中从通过 options.referrerInfo.extraData 获取;
|
|
|
+ 在跳转页面中监听App.onShow,并及时取消监听。
|
|
|
+ 其中options.referrerInfo.extraData包含authStatus为true/false的值,该字段标识是否获取三要素成功,开发者可根据该字段判断是否需要查询该次授权的三要素信息。
|
|
|
+
|
|
|
+ 示例代码:
|
|
|
+ my.onAppShow(this.onAppShowHandler)
|
|
|
+ my.offAppShow(this.onAppShowHandler)
|
|
|
+
|
|
|
+ onAppShowHandler(options) {
|
|
|
+ if(options && options.referrerInfo) {
|
|
|
+ // 从三要素认证返回
|
|
|
+ if(options.referrerInfo.appId === `2021003181682188' && options.referrerInfo.extraData) {
|
|
|
+ const authStatus = options.referrerInfo.extraData.authStatus
|
|
|
+ if(authStatus) {
|
|
|
+ const authTaskId = my.getStorageSync({ key: 'auth-taskId' })
|
|
|
+ my.removeStorage({ key: 'auth-taskId' })
|
|
|
+ if(authTaskId && authTaskId.data) {
|
|
|
+ // 自行操作代码
|
|
|
+ // 说明:该监听的方法返回的this为undefined
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|