微信刷脸支付插件
【摘要】
本插件分装了微信刷脸支付Android SDK v2.21.114版本。
微信刷脸支付官方文档: https://pay.weixin.qq.com/wiki/doc/wxfacepay/develop...
本插件分装了微信刷脸支付Android SDK v2.21.114版本。
微信刷脸支付官方文档:
https://pay.weixin.qq.com/wiki/doc/wxfacepay/develop/android/facepay.html
本插件实现封装了SDK中的5个方法:
1、程序启动时初始化 initWxpayface
2、获取数据 getWxpayfaceRawdata
3、人脸识别 getWxpayfaceCode(获取用户信息)
4、释放资源 releaseWxpayface
5、启动防火墙配置 enableFirewall
有异步返回信息的方法会通过globalEvent的形式进行返回信息,具体请参考示例代码。
具体刷脸支付业务流程的实现,请参考官方文档。
<template>
<view>
<view>
<button @click="getversion()">getversion</button>
<button @click="initWxpayface()">initWxpayface</button>
<button @click="getWxpayfaceRawdata()">getWxpayfaceRawdata</button>
<button @click="getWxpayfaceCode()">getWxpayfaceCode</button>
<button @click="releaseWxpayface()">releaseWxpayface</button>
<button @click="enableFirewall()">enableFirewall</button>
<button @click="openfacepay()">完整流程</button>
</view>
<text v-for="(item,index) in msglist">{{item}}\n</text>
</view>
</template>
<script>
const wxfacepayzz = uni.requireNativePlugin('zzzili-wxfacepayzz');
export default {
data() {
return {
msglist: []
}
},
onLoad() {
this.msglist.push('start test print')
},
methods: {
getversion: function() {
this.msglist.push(wxfacepayzz.getVersion());
},
initWxpayface: function() {
var map = {
ip: "192.168.1.1", //若没有代理,则不需要此行
port: "8888", //若没有代理,则不需要此行
user: "mEtnUser", //若没有代理,则不需要此行
passwd: "mEtnPassword", //若没有代理,则不需要此行
proxy_type: 1, //若没有代理,则不需要此行
perform_mode: "LOW_PERFORM" //低性能表现,默认关闭美颜等
};
var that = this;
this.msglist.push('wxfacepayzz.getVersion()' + wxfacepayzz.initWxpayface(map, function(res) {
that.msglist.push(JSON.stringify(res));
}));
},
getWxpayfaceRawdata: function() {
var that = this;
this.msglist.push('wxfacepayzz.getWxpayfaceRawdata()' + wxfacepayzz.getWxpayfaceRawdata(function(res) {
that.msglist.push(JSON.stringify(res));
}));
},
getWxpayfaceCode: function() {
var map = {
appid: "123456",
mch_id: "123456",
store_id: "123456",
out_trade_no: "123456",
total_fee: "0.01",
face_authtype: "FACEPAY",
authinfo: "124156565",
face_code_type: "1"
};
var that = this;
this.msglist.push('wxfacepayzz.getWxpayfaceCode()' + wxfacepayzz.getWxpayfaceCode(map, function(res) {
//wxpayfaceCallBack
that.msglist.push(JSON.stringify(res));
}, function(res) {
//updateResultWxpayfaceCallBack
that.msglist.push(JSON.stringify(res));
}));
},
releaseWxpayface: function() {
this.msglist.push('wxfacepayzz.releaseWxpayface()' + wxfacepayzz.releaseWxpayface());
},
enableFirewall: function() {
var mchId = "123456";
var subMchId = "456789";
var that = this;
this.msglist.push('wxfacepayzz.enableFirewall()' + wxfacepayzz.enableFirewall(mchId, subMchId, function(res) {
that.msglist.push(JSON.stringify(res));
}));
},
openfacepay(){
var that = this;
//1.初始化
wxfacepayzz.initWxpayface({},function(res){
console.log(res);
//2.获取rawdata
wxfacepayzz.getWxpayfaceRawdata(function(res2){
console.log(res2);
/
//3.根据返回的rawdata数据,调用Api接口:获取调用凭证,得到参数authinfo
/
//4.进行人脸识别
var map = {
appid: "123456",
mch_id: "123456",
store_id: "123456",
out_trade_no: "123456",
total_fee: "0.01",
face_authtype: "FACEPAY",
authinfo: "124156565",
face_code_type: "1"
};
wxfacepayzz.getWxpayfaceCode(map, function(res3) {
//wxpayfaceCallBack
console.log(res3);
//5.释放资源
wxfacepayzz.releaseWxpayface()
}, function(res4) {
//updateResultWxpayfaceCallBack
console.log(res4);
//5.释放资源
wxfacepayzz.releaseWxpayface()
})
})
});
},
}
}
</script>
<style>
</style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
文章来源: zzzili.blog.csdn.net,作者:清雨小竹,版权归原作者所有,如需转载,请联系作者。
原文链接:zzzili.blog.csdn.net/article/details/117768168
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)