# Campus scene payment brush face mode
For some of the existing payment facial recognition devices, we additionally support the user's identity through Weixin Pay facial recognition to initiate calls.
There are the following limitations to pay for calls on the face brush device:
- Weixin Pay only supports the use of face scanning devices. Please refer to the relevant documents of Weixin Pay for the details.
- Android devices only, WMPF <= 2.0 version
- Only support device call, not support mobile phone WeChat call device.
# 1. Initiate a call
Payment for the face brush device is also made through the initByCaller Interface to initiate the call, but there are some differences in parameters. To pay for the face brush device, use the following businessType:
businessType | Type of business | caller.id | listener.id | VoipToken | Minimum version |
---|---|---|---|---|---|
0 | Face Brush Mode (Duration Billing) | Weixin Pay brush face return user_id | WeChat users openId | Weixin Pay brush face return voip_Token | |
3 | Face recognition mode (license Billing) | Ditto | Ditto | Ditto | 2.3.8 |
- Before use, it needs to be passed in advance in the Mini Program
wx.authorize
Give Way openId Corresponding user authorizationscope.voip
, otherwise it will returnerrCode: 8
, See Section for specific flow 2 section - listener Must be for caller Contacts. Otherwise it will return
errCode: 9
。
# 2. Contact Management
# 2.1 Contact Binding
In the campus scenario, developers need to access plug-insContact Binding RelationshipFunction, only after the parent completes the relationship binding operation, the child can dial the audio and video phone to the parent.
The contact binding is UserId (child) and OpenId (parent) mapping relationship, developers can also achieve the associated interface management function.
# Administrator binding
The first contact is the administrator and needs to wx.authorize
To grant authorization voip.scope
, and then call the plug-in interface wmpfVoip.bindVoipAdminContact
Complete the binding.
// Become an administrator.
try {
await wx.authorize({
scope: 'scope.voip',
})
const res = await wmpfVoip.bindVoipAdminContact({
userId: 'xxxxxx', // Weixin Pay into the brush face to return user_id
})
console.log(`bindVoipAdminContact`, res)
} catch (error) {
console.error('authorize scope voip', error)
wx.showToast({
title: 'please go to the settings page to authorize call alerts',
icon: 'none',
})
}
# Other Contact Binding
Other contacts are bound by the admin share page. That is, the administrator clicks in the Mini ProgramshareThe button, And through wmpfVoip.getBindContactPath
Get the plugin to share the page link and in the page's onShareAppMessage
Set in.
Once the binding is complete, it jumps to the setVoipEndPagePath
Set the page.
// Gets the path to the plug-in contact binding relationship page where the user performs the relationship binding operation.
// Share Binding Page: Get the Share Link in advance when the student administrator enters the page
wmpfVoip
.getBindContactPath({
userId: 'xxxx', // student id
userName: 'xxxx', // Name of student
User Avatar: 'xxxx', // Student Avatar
})
.then(path => {
// in onShareAppMessage Used in path
// Available at path Set the parameters, For example '&xxx=yyy', Through the Mini Program. getPluginEnterOptions Obtain
})
// Page in
Page({
onShareAppMessage () {
return {
title: `Invite you to be${userName} The contact person for`,
path: 'xxxx', // getBindContactPath Acquired path
}
},
})
// app.js
App({
onLoad() {
// Set the path to the page to jump to when the contact binding relationship page action is complete.
wmpfVoip.setVoipEndPagePath({
key: 'BindContact',
url: 'xxxxxx',
options: 'param1=xxx¶m2=xxx',
})
},
})
Be careful
- userName and userId (Face recognition returned by WeChat Pay user_Id) should be consistent with the caller (student) information input
- The caller should have access to the OpenId, name, For display on the Contact List page
- Upon completion of the binding, the corresponding event is triggered. Available through
onVoipEvent
And listen in. Specific referencebindContact
of type。
# 2.2 Query Contact List
# Plug-in interface
wmpfVoip.getVoipBindContactList({ userId: '学生userId' }).then(list => {
/**
[{
user_id: 'xxx',
is_ad: 0, // 0 Ordinary Contacts, 1 admins
Openid _list: [], // The administrator can get the child (user_ID) a list of all openIDs bound under the ID, including yourself.
}]
*/
})
# Backend interface
Request address
POST https://api.weixin.qq.com/wxa/business/getvoipcontactlist?access_token=ACCESS_TOKEN
Request parameters
attribute | type | Required | Introductions |
---|---|---|---|
access_Token / cloudbase_access_Token | string | yes | [Interface call credential]((auth.getAccessToken )) |
user_id | string | yes | student userId |
Return value
Object
Returned JSON Data packet
attribute | type | Introductions |
---|---|---|
Errcode | number | Error code |
errmsg | string | Error message |
contact_list | Contact Info [] | Contact List |
**Contact Info **
attribute | type | Introductions |
---|---|---|
open_id | string | Contacts Openid |
Role | number | Contact Identity, 0 For Ordinary Contacts, 1 For the administrator. |
errCode Legal value
errCode | Introductions |
---|---|
0 | success |
1 | User has no contact list |
# 2.3 Delete a contact
Only administrators can delete students (user_Id), the manager cannot delete himself.
wmpfVoip.deleteVoipBindContact ({
userId: 'xxx',
openidList: ['openId1', 'openId2' ],
})
# 2.4 Transfer Administrator
Only administrators can invoke the transfer interface.
wmpfVoip.transerAdmin ({
userId: 'xxx',
newAdminOpenid: 'Openid of the new manager ',
})
# 2.5 Listening events
In the process of binding a contact,onVoipEvent
Will receive bindContact
Event, get the Share Bound Contact Status:
Data parameter
attribute | type | Introductions |
---|---|---|
type | string | Binding results, see below for values |
errMsg | string | Error message |
userId | string | student user_id |
type Value
type | describe |
---|---|
success | Contact Binding Success |
unbind | Contact is not bound for this student |
binded | The contact has been tied to the student |
expire | Share Link Expired |
overload | The student's bound contacts have exceeded the limit |
invalid | Sharing a link is illegal, probably because the link was shared by a non-administrator |
auth | Contact Authorization scope.voip failure |
cancel | Contact Unbinding |