# Financial Scenario API
Please Note
The Financial Scenario API builds upon the Common API list, focusing on financial-specific scenarios and collaborating with Mini-Program ecosystem partners to maintain commonly used API capabilities for the financial industry.
When using the following APIs, please ensure that the Host-App has already integrated the third-party SDK; otherwise, the Mini-Program will not be able to implement the related functionality. If you have any questions during use, please contact us.
# 1. Usage Background
The usage background of the Financial Scenario API is as follows:
- If the App has integrated the SDK + the SDK that has completed integration testing, the Mini-Program can directly call the API and achieve the related functional goals;
- If the App has only integrated the SDK but has not integrated the successfully tested functional SDK, the Mini-Program's call to the Financial Scenario API will be unresponsive;
- If the App has integrated the SDK + an SDK that has not been integration-tested, and the Host-App has implemented custom registration based on the API content (iOS Custom Registration API | Android Custom Registration API), the Mini-Program can call the related APIs to implement the specified functionality;
In summary, we recommend:
- For Mini-Program developers in the financial industry, you can directly use the APIs described on this page in your business code. By following the standardized API calls, developers can maximize the reduction of custom development workload;
- For Host-App vendors in the financial industry, you can integrate the SDK + other specified functional SDKs as needed. Through this specification, the workload of integration, development, and integration testing can be maximally reduced;
Collaboration Notice
Third-party SDK development vendors can follow the unified development specification to design the specific methods for integrating related functionality in Mini-Program scenarios. You may call 0755-86967467 or email contact@finogeeks.com for more information.
# 2. Identity Verification Related APIs
# 2.1 OCR Card Recognition (finCardOcr)
Interface name: finCardOcr
Interface dependency: None (can be called with any version of the SDK)
# Request Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| type | String | Non-empty | "BankCard": Bank card recognition "IDCard": ID card recognition "IDCardCheck": ID card photo quality check "BusiCert": Business license recognition |
| imagePath | String | Path where the photo file is located Mini-Program can extract this field via chooseImage iOS/Android should pass the absolute file path For iOS, writing the UIImage file to a temporary file can simply solve the file access issue |
# Return Results
| Name | Type | Default Value | Description |
|---|---|---|---|
| type | String | Non-empty | "BankCard": Bank card recognition "IDCard": ID card recognition "IDCardCheck": ID card photo quality check "BusiCert": Business license recognition |
| errorCode | Int | 0 | Recognition result, 0 indicates success |
| description | String | Recognition result description | |
| recogResult | Object | Recognition result {"cardNo": card number, ......} |
recogResult Field Description
ID Card Front
| Name | Description |
|---|---|
| face | 0: Front, 1: Back |
| nation | Ethnicity (front side only) |
| gender | Gender (front side only) |
| birthday | Birthday (front side only) |
| address | Address (front side only) |
| name | Name (front side only) |
| idNo | ID card number (front side only) |
| startDate | Validity start date (back side only) |
| endDate | Validity end date (back side only) |
| signOrg | Issuing authority (back side only) |
ID Card Quality Check
| Name | Description |
|---|---|
| risk | Image risk: 0=None 1=Photocopy 2=Screen capture 3=Fake document 4=Watermark 5=Occlusion 6=Edge cut 7=Card deformation 8=Light spot |
Bank Card
| Name | Description |
|---|---|
| cardNo | Card number |
| bankName | Bank |
| bankId | Bank identifier id |
| cardType | Card type: Debit card, Semi-credit card |
Business License
| Name | Description |
|---|---|
| regOrg | Registration authority |
| busiScrope | Business scope |
| certNo | Unified social credit code / Business license number |
| regDate | Registration date |
| capital | Registered capital |
| address | Address |
| expDate | Business term |
| represent | Legal representative |
| certType | Business license type: Original, Copy |
| corpName | Enterprise name |
| corpType | Enterprise type |
| foundDate | Date of establishment |
# 2.2 Online Face Identity Verification (finFaceAuth)
Interface name: finFaceAuth
Interface dependency: None (can be called with any version of the SDK)
# Request Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| idNo | String | ID card number | |
| name | String | Name | |
| imagePath | String | Path where the photo file is located |
# Return Results
| Name | Type | Default Value | Description |
|---|---|---|---|
| errorCode | Int | 0 | Recognition result, 0 indicates success |
| description | String | Recognition result description | |
| score | double | 0-1 | Similarity |
# 2.3 Liveness Detection (finLivenessCheck)
Interface name: finLivenessCheck
Interface dependency: None (can be called with any version of the SDK)
# Request Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| None |
# Return Results
| Name | Type | Default Value | Description |
|---|---|---|---|
| resultType | String | "success" Success, "back" User clicked back to cancel liveness detection | |
| faceImgStr | String | Image returned by liveness detection, Base64-encoded byte array. Only returned on success |
# 2.4 Open Third-Party App (finOpenOtherApp)
Interface name: finOpenOtherApp
Interface dependency: None (can be called with any version of the SDK)
# Request Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| package | String | App package name, used on Android to determine whether the App is installed, Android only | |
| url | String | App scheme plus url, used on iOS to determine whether the App is installed and for navigation; used on Android for navigation | |
| downloadUrl | String | App download address | |
| alertMsg | String | Download prompt dialog message; if not passed, no prompt dialog will appear and the page will be navigated to directly |
# 2.5 Two-Way Video Authentication (finOpenWitnessVideo)
Interface name: finOpenWitnessVideo
Interface dependency: None (can be called with any version of the SDK)
# Request Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| videoType | String | Video service type | |
| videoIp | String | Video service IP | |
| videoPort | String | Video service port | |
| loginName | String | Login name | |
| loginPwd | String | Login password (optional) | |
| roomId | String | Room id | |
| roomName | String | Room name | |
| roomPwd | String | Room password (optional) | |
| appId | String | anychat cluster appId |
# Return Results
| Name | Type | Default Value | Description |
|---|---|---|---|
| videoFlag | String | Non-empty | Return flag: 0 Success, 1 Failure, 2 Rejected |
| rejectReason | String | Rejection reason | |
| message | String | Detailed information |
# 2.6 One-Way Video Recording Mini-Program Implementation
Interface dependency: This component does not require any third-party SDK other than the SDK
Mini-Program One-Way Recording Component Usage
- Download the recording video component example code package
Recording demo v1.0.0 (opens new window)
The component code is located in the components directory at the root. You can also directly open the recording demo with the IDE tool to view the effect.
- In the json file of the page or component where it will be used, import the recording component
{
"usingComponents": {
"video-recognition": "../../components/video-recognition/index"
}
}
- In the fxml of the page or component, use the component
<view style="width: 100vw;height: 100vh;">
<video-recognition recordTime="{{recordTime}}"
top="{{top}}"
stepList="{{stepList}}"
buttonStyle="{{buttonStyle}}"
mask="../../assets/img_mask_person@3x.png"
resolution="low"
bind:onRecordReady="onRecordReady"
bind:onRecordStart="onRecordStart"
bind:onRecordEnd="onRecordEnd"
bind:onRecordError="onRecordError">
</video-recognition>
</view>
Note
The outer layer of the recording component needs to declare width and height dimensions. Inside the recording component, it will be displayed with width: 100%; height: 100%.
- Component Parameters Overview | Name | Type | Required | Default Value | Remarks | | ------------- | --------------- | -------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | resolution | String | No | medium | Resolution, optional values: low, medium, high. Only effective during initialization and cannot be dynamically changed | | mask | String | No | - | Mask resource path for the viewfinder area. It is recommended to use a relative path to resources within the Mini-Program. HTTPS addresses will have loading latency. The mask will be placed on the camera at width 100% height 100%. Make sure it matches the component dimensions | | recordTime | Number | No | 30000 | Recording duration in milliseconds | | top | Number | No | 20 | Unit: rpx. Distance from the top for text prompts. You can also modify the wxss inside the video-recognition component to customize the text position | | stepList | Array<Object> | No | - | Audio and prompt text configuration for each step. Maximum supported length is 3. Data element structure can be found in the description after the table | | buttonStyle | Object | No | - | Controls the style of the record button. Can be used to fine-tune the button position. Currently supports the following fields: width, height, left, top, bottom, right. Only effective during initialization and cannot be dynamically changed | | onRecordReady | EventHandler | No | - | Bound via onRecordReady. Before ready, some asynchronous resources will be downloaded. Triggered after resources are ready. Can be used in the page that uses the component to determine whether the recording component is ready, thereby controlling loading and component display | | onRecordStart | EventHandler | No | - | Bound via bind:onRecordStart. Triggered when recording starts | | onRecordEnd | EventHandler | No | - | Bound via bind:onRecordEnd. Triggered when recording ends. Callback method parameter res, res.tempVideoPath is the local file address of the recorded video | | onRecordError | EventHandler | No | - | Bound via bind:onRecordError. Triggered when a recording error occurs. Callback method parameter res, res.errMsg is the error message when the error occurs |
stepList Parameter Description
Audio and prompt text configuration for each step. Maximum supported length is 3.
Data element structure is as follows:
{
"audioSrc": "https://xxxxx.mp3",
"showTime": 0,
"textList": []
}
audioSrc - Audio link. HTTPS links are recommended. The component will download audio resources when attached. If the download fails, the error callback will be executed, reporting a resource loading error.
Note
The mp3 domain must be added to the whitelist in the Management Console; otherwise, the download will fail.
showTime - Display time for text prompts and audio, in milliseconds. 0 means initial display, 2000 means display 2 seconds after recording starts.
textList - Text prompts, array type.
textList parameter object is as follows:
{
"text": 'Please read aloud in Mandarin'
}
text - Text content
You can add style attributes such as width|height|padding|margin|color|fontSize|fontWeight|textAlign to simply control text styles:
{
"text": 'Text',
"color": 'red',
"fontWeight": 'bold',
"margin": '0 20rpx'
}
Note
A single textList child element will be displayed on a single line without wrapping. You can split it into multiple lines with multiple child elements as needed.
Additionally, if individual words within a single line need to be highlighted, the text attribute can accept an array with the same object parameters as above, as follows:
{
"text": [{
"text": 'Text'
}, {
"text": 'Highlighted text',
"color": 'red',
"fontWeight": 'bold',
"margin": '0 20rpx'
}, {
"text": 'Text'
}]
}
stepList is only effective during initialization and cannot be dynamically changed.
This component is developed using native Mini-Program syntax. In addition to the parameters described in the documentation, you can also modify the logic within the component to meet different business requirements.
# 3. WebRTC Related APIs
To support the use of WebRTC functionality in Mini-Programs, the Mini-Program SDK natively provides WebRTC-related APIs in the Base Library.
To reduce the cost of migrating from HTML5 to Mini-Programs, we have preserved the WebRTC-related API forms as much as possible. The Mini-Program related APIs are as follows:
Please Note
This feature is implemented based on the Google WebRTC library. You need to confirm that the Base Library and SDK versions support it.
# 3.1 MediaDevice
ft.webrtc.mediaDevices.enumerateDevices()
Retrieves information about audio and video hardware available for WebRTC. Returns a Promise object after execution.
Promise Return Value
| Property | Type | Description |
|---|---|---|
| devicesList | Array | Array containing device information objects |
Example Code
const devicesList = await ft.webrtc.mediaDevices.enumerateDevices()
// or
ft.webrtc.mediaDevices.enumerateDevices().then(devicesList => {
console.log(devicesList)
})
ft.webrtc.mediaDevices.getSupportedConstraints()
Gets the constraint properties supported by the current device (such as frame rate and window size). Returns a Promise object after execution.
Promise return value
| Property | Type | Description |
|---|---|---|
| info | Object | An object containing the current device's properties |
Sample code
const info = await ft.webrtc.mediaDevices.getSupportedConstraints()
// or
ft.webrtc.mediaDevices.getSupportedConstraints().then(info => {
console.log(info)
})
MediaStream.getUserMedia(Object object)
Requests media input from the user. Returns a Promise object after execution, and the Promise ultimately returns an Object.
Note
On mobile, getUserMedia has invocation restrictions. If getUserMedia has already obtained a stream and WebRTC is connected, calling getUserMedia again may throw an error. It is recommended to avoid duplicate invocation logic in your business code.
Parameters
Object object
| Property | Type | Default value | Required | Description |
|---|---|---|---|---|
| video | boolean | Yes | Whether to obtain the video stream | |
| audio | boolean | Yes | Whether to obtain the audio stream |
Promise return value
| Property | Type | Description |
|---|---|---|
| stream | Object | A regular media stream cannot be transferred to the Mini-Program. The stream here is only a simple wrapper object containing only a streamId and a getTracks method |
Sample code
const stream = await ft.webrtc.mediaDevices.getUserMedia({ audio: true, video: true })
// or
ft.webrtc.mediaDevices.mediaDevices().then(stream => {
console.log(stream)
console.log(stream.streamId)
})
stream.streamId
String
Pass the streamId to the webrtcVideo component to play the stream. For details, refer to the webrtcVideo component documentation.
stream.getTracks()
Gets the tracks array of the stream. Returns a Promise object after execution, and the Promise ultimately returns a tracks array.
Promise return value
| Property | Type | Description |
|---|---|---|
| tracks | Array | The obtained stream tracks array, generally containing a video track and an audio track |
Sample code
const stream = await ft.webrtc.mediaDevices.getUserMedia({ audio: true, video: true })
const tracks = await stream.getTracks()
tracks.forEach((track) => {
console.log(track)
})
track.stop()
Closes the track. Can be used in scenarios where the stream needs to be stopped.
Sample code
const stream = await ft.webrtc.mediaDevices.getUserMedia({ audio: true, video: true })
const tracks = await stream.getTracks()
tracks.forEach((track) => {
track.stop()
})
# 3.2 RTCPeerConnection
ft.webrtc.createRTCPeerConnection(Object options)
Creates an rtc connection instance. Returns a Promise after execution, and the Promise ultimately returns the instance object.
Object options
All parameters are passed through to createRTCPeerConnection.
For specific options parameters, refer to the WebRTC standard documentation (opens new window)
Sample code
const options = { iceServers: [{ urls: "stun:stun.stunprotocol.org" }] }
const pc = await ft.webrtc.createRTCPeerConnection(options)
RTCPeerConnection properties
Currently supported RTCPeerConnection properties
| Property | Description |
|---|---|
| canTrickleIceCandidates | |
| conectionState | |
| currentLocalDescription | |
| currentRemoteDescription | |
| iceConnectionState | |
| iceGatheringState | |
| localDescription | |
| peerIdentity | |
| remoteDescription | |
| signalingState |
Sample code
const options = { iceServers: [{ urls: "stun:stun.stunprotocol.org" }] }
const pc = await ft.webrtc.createRTCPeerConnection(options)
console.log(pc.canTrickleIceCandidates)
console.log(pc.currentLocalDescription)
console.log(pc.currentRemoteDescription)
console.log(pc.peerIdentity)
RTCPeerConnection event listeners
Currently supported RTCPeerConnection events
| Property | event | Description |
|---|---|---|
| icecandidate | { candidate: { ... }} | Returns icecandidate information when triggered, containing only the candidate field data |
| iceconnectionstatechange | { iceConnectionState, timeStamp } | |
| negotiationneeded | ||
| signalingstatechange | { signalingState } | |
| track | { streams } | Each item in the streams array is an object containing a streamId |
Sample code
const options = { iceServers: [{ urls: "stun:stun.stunprotocol.org" }] }
const pc = await ft.webrtc.createRTCPeerConnection(options)
pc.addEventListener('icecandidate', event => {
console.log(event.candidate)
console.log(event.candidate.address)
console.log(event.candidate.type)
console.log(event.candidate.sdpMLineIndex)
console.log(event.candidate.sdpMid)
})
pc.addEventListener('iceconnectionstatechange', event => {
console.log(event.iceConnectionState)
})
pc.addEventListener('negotiationneeded', event => {
console.log(event)
})
pc.addEventListener('signalingstatechange', event => {
console.log(event)
})
pc.addEventListener('track', event => {
console.log(event.streams)
// Pass the streamId to the webrtcVideo component to play the stream. For details, refer to the webrtcVideo component documentation.
this.setData({
remoteStreamId: e.streams[0].streamId
})
})
RTCPeerConnection.createOffer(Object object)
Creates an SDP offer. Returns a Promise object after execution, and the Promise ultimately returns an offer Object.
Parameters
Object object
| Property | Type | Default value | Required | Description |
|---|---|---|---|---|
| iceRestart | boolean | false | No | |
| offerToReceiveAudio | boolean | false | No | |
| offerToReceiveAudio | boolean | false | No | |
| voiceActivityDetection | boolean | true | No |
Promise return value
| Property | Type | Description |
|---|---|---|
| offer | Object | An Object containing the two fields sdp and type |
Sample code
const pc = await ft.webrtc.createRTCPeerConnection(options)
const offer = await pc.createOffer({
offerToReceiveAudio: true,
offerToReceiveVideo: true
})
await pc.setLocalDescription(offer)
RTCPeerConnection.createAnswer(Object object)
Creates an SDP answer. Returns a Promise object after execution, and the Promise ultimately returns an answer Object.
Parameters
Object object
| Property | Type | Default value | Required | Description |
|---|---|---|---|---|
| iceRestart | boolean | false | No | |
| offerToReceiveAudio | boolean | false | No | |
| offerToReceiveAudio | boolean | false | No | |
| voiceActivityDetection | boolean | true | No |
Promise return value
| Property | Type | Description |
|---|---|---|
| answer | Object | An Object containing the two fields sdp and type |
Sample code
const pc = await ft.webrtc.createRTCPeerConnection(options)
const answer = await pc.createAnswer({
offerToReceiveAudio: true,
offerToReceiveVideo: true
})
RTCPeerConnection.setLocalDescription(Object object)
Sets the offer/answer. Returns a Promise after execution.
Parameters
Object object
Pass in the obtained offer or answer.
Sample code
const pc = await ft.webrtc.createRTCPeerConnection(options)
const offer = await pc.createOffer({
offerToReceiveAudio: true,
offerToReceiveVideo: true
})
await pc.setLocalDescription(offer)
RTCPeerConnection.setRemoteDescription(Object object)
Sets the offer/answer and returns a Promise after execution.
Parameters
Object object
Pass in the obtained offer or answer
Sample Code
const pc = await ft.webrtc.createRTCPeerConnection(options)
// Pseudocode, offer is sent from the remote end
const offer = getFromRemote()
await pc.setRemoteDescription(offer)
const answer = await pc.createAnswer({
offerToReceiveAudio: true,
offerToReceiveVideo: true
})
await pc.setLocalDescription(answer)
RTCPeerConnection.addIceCandidate(Object object)
Adds a candidate to the connection
Parameters
Object object
The parameter must be a candidate object, that is, the candidate object obtained from the icecandidate event
Some properties have slight differences across different ends; the actual obtained values shall prevail
Sample Code
// Pseudocode
// End A
const pcA = await ft.webrtc.createRTCPeerConnection(options)
pcA.addEventListener('icecandidate', event => {
// Send to End B
sendToB(event.candidate)
})
// End B
const pcB = await ft.webrtc.createRTCPeerConnection(options)
const candidate = await getFromA()
await pcB.addIceCandidate(candidate)
RTCPeerConnection.getConfiguration()
Gets the configuration of the connection and returns a Promise after execution.
Sample Code
const pc = await ft.webrtc.createRTCPeerConnection(servers, mediaConstraints)
const configuration = await pc.getConfiguration()
RTCPeerConnection.addTrack(Object object)
Adds a track to the current connection. Note that this interface is asynchronous.
Parameters
Object object
The parameter must be a track object, where the track is obtained via getTracks from the stream obtained by getUserMedia.
Sample Code
const stream = await ft.webrtc.mediaDevices.getUserMedia({ audio: true, video: true })
const pc = await ft.webrtc.createRTCPeerConnection(servers, mediaConstraints)
const tracks = await stream.getTracks()
tracks.forEach(t => {
pc.addTrack(t)
})
RTCPeerConnection.close()
Closes the connection
Sample Code
const pc = await ft.webrtc.createRTCPeerConnection(servers, mediaConstraints)
pc.close()
# 3.3 WebRTC Related Components
WebRTC Video Component
A component for playing WebRTC media streams
Properties
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| src | string | No | Must be in the format webrtc://, where streamId can be obtained via getUserMedia or the connection track event | |
| muted | boolean | false | No | Whether the video is muted |
Sample Code
<webrtc-video muted
src="webrtc://{{localStreamId}}"></webrtc-video>
<webrtc-video src="webrtc://{{remoteStreamId}}"></webrtc-video>
// Local stream obtained via getUserMedia
const stream = await ft.webrtc.mediaDevices.getUserMedia({ audio: true, video: true })
const { streamId } = stream
this.setData({
localStreamId: streamId
})
// Remote video stream obtained from the webrtc connection track event
const pc = await ft.webrtc.createRTCPeerConnection()
pc.addEventListener('track', event => {
const { streams } = event
this.setData({
remoteStreamId: streams[0].streamId
})
})
WebRTC Audio Component
A component for playing WebRTC media streams. Unlike WebRTC Video, it only plays audio.
Properties
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| src | string | No | Must be in the format webrtc://, where streamId can be obtained via getUserMedia or the connection track event |
Sample Code
<webrtc-audio src="webrtc://{{localStreamId}}"></webrtc-audio>
<webrtc-audio src="webrtc://{{remoteStreamId}}"></webrtc-audio>
// Local stream obtained via getUserMedia
const stream = await ft.webrtc.mediaDevices.getUserMedia({ audio: true })
const { streamId } = stream
this.setData({
localStreamId: streamId
})
// Remote video stream obtained from the webrtc connection track event
const pc = await ft.webrtc.createRTCPeerConnection()
pc.addEventListener('track', event => {
const { streams } = event
this.setData({
remoteStreamId: streams[0].streamId
})
})