Learn how you can drive the Persona KYC flow manually instead of using the wrapped Cybrid SDK flow
Here is an overview of how to integrate the Persona SDK embedded flow, instead of using the Cybrid SDK:
Create an identity verification for a customer:
POST /api/identity_verificationsRequest:
{
"type": "kyc",
"method": "id_and_selfie",
"customer_guid": { customer_guid },
"country_code": { country_code }
}
Response:
{
"type": "kyc",
"guid": { identity_verification_guid },
"customer_guid": { customer_guid },
"created_at": "2023-10-03T14:32:52.317Z",
"method": "id_and_selfie",
"state": "storing",
"outcome": null,
"failure_codes": [],
"country_code": { country_code }
}
Get an identity verification for a customer:
GET /api/identity_verifications/{ identity_verifcation_guid }
- Generating an inquiry is async, so you will have to poll
- The persona_inquiry_id may be null
Response:
{
"type": "kyc",
"guid": { identity_verification_guid },
"customer_guid": { customer_guid },
"created_at": "2023-10-03T14:32:52.317Z",
"method": "id_and_selfie",
"state": "waiting",
"outcome": null,
"failure_codes": [],
"country_code": "US",
"persona_inquiry_id": { persona_inquiry_id },
"persona_state": "waiting"
}
Instantiate the Persona embedded client:
- Documentation: https://docs.withpersona.com/docs/quickstart-embedded-flow
- Pass the persona_inquiry_id
- The language here must be one of: https://docs.withpersona.com/docs/languages
- Subscribe to event handling callbacks. Documentation: https://docs.withpersona.com/docs/embedded-flow-event-handling
- Just because the Persona flow has completed it doesn’t mean that your customer is verified. It may take a period of time for additional handling in the customer verification process to complete in the Cybrid platform. You can poll on GET /api/customer/{ customer_guid } for the state
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Client</title>
<!-- Add this script tag to import Persona JavaScript library -->
<script src="https://cdn.withpersona.com/dist/persona-v4.9.0.js"></script>
</head>
<body></body>
<script>
let client = new Persona.Client({
inquiryId: { persona_inquiry_id },
language: { language },
onReady: () => client.open(),
onEvent: (eventName, metaData) => {
console.log(`Event: ${eventName}`);
},
onComplete: ({ inquiryId, status, fields }) => {
console.log(`Submitted: ${inquiryId}`);
},
onCancel: (inquiryId, sessionToken) =>
console.log(`Cancelled inquiry: ${inquiryId}`),
onError: (status, code) => {
console.log(`Error: ${status}`);
}
});
</script>
</html>