Closed OdinsPlasmaRifle closed 1 year ago
Crate documentation for this extension so it can be shared with interested clients.
The Onfido extension uses the Onfido services to perform document verification in Rehive. The current implementation only support document verification.
NOTE: This extension is using the new document-type resources instead of the static document types. This means it will only function in a company that has enabled this feature on the Platform.
The database models:
The extension has the following base endpoints:
The extension's primary functionality is handled via the following endpoints:
These endpoints are used to map Rehive document-types to Onfido document types. Clients may choose to name their documents anything and therefore manual mapping of types is required.
/admin/document-types/
/admin/document-types/<id>/
Each document type in the Onfido extensions consists of the following data:
{
"id": "string",
"platform_type": "string",
"onfido_type": "string",
"side": "string",
"created": 0,
"updated": 0
}
The platform_type
is the ID of the document-type in the Rehive Platform.
The onfido_type
currently supports the following values:
national_identity_card
driving_licence
passport
voter_id
work_permit
The side
must either be a null value or front
/back
value.
This endpoint is used to receive events from Rehive. The extension needs to know when certain Platform activity occurs in order to trigger Onfido logic.
/webhook/
Only the following webhook events need to be sent to this endpoint:
document.create
This documentation contain info on handling Rehive webhook events.
When a relevant event is received, it is saved to the database where an unique id
field on the table ensures that each webhook event is only saved once. Then, the specific event is added to a task queue.
The task queue processes events asynchronously. If the event is document.created
the following steps are taken:
After adding the check, some special logic needs to be performed in order to decide "when" to create the check in Onfido. The logic used for processing the addition of Onfido checks is as follows:
A ready check is any check that satisfies the multi-side document requirements of the documents in the check. This extension marks these shecks with the status PENDING.
This endpoint is used to receive events from Onfido. The extension needs to know when certain Onfido activity occurs in order to trigger extension logic.
/onfido/webhook/
Only the following webhook events need to be sent to this endpoint:
check.completed
This documentation contain info on handling Onfido webhook events.
When a relevant event is received, it is saved to the database where an unique id
field on the table ensures that each webhook event is only saved once. Then, the specific event is added to a task queue.
The task queue processes events asynchronously. If the event is check.completed
the following steps are taken:
NOTE: The current implementation only marks documents as "verified" in the Platform if Onfido marked them as "clear". The following Onfido statuses will be set to "declined" in the Platform: "rejected", "suspected", "caution".
There are some issues with using Onfido:
going forward this will be documented here:
It seems like implementing a KYC extension in Onfido should be viable. Initially it could be implemented to only do documents and addresses but it could be extended to support other features.
An initial design plan would be:
This may not be perfect but seems to match the resources in the Onfido API reference. There will probably be edge cases i am not seeing now that would come up during development.
Additionally, there are some situations we would need to consider:
API Reference: https://documentation.onfido.com Supported documents: https://onfido.com/supported-documents/