Customer Verification
Introduction
The customer verification service exposes operations for verifying customers:
- Start Customer Verification
- Get a Customer KYC (Know Your Customer) Status
Use the following code to obtain an instance of CustomerVerificationService
:
- Kotlin
- Swift
val customerVerificationService = Wallet.getInstance().getCustomerVerificationService()
It is responsibility of the client application to request the camera permission that is required for the customer verification flow.
import PaysafeWallet
let customerVerificationService = Wallet.instance.customerVerificationService
NSCameraUsageDescription should be added in client application Info.plist.
Starts Customer Verification
Use startCustomerVerification
method to start a screen for result of the customer verification flow. After the
verification flow has finished, a result of type VerificationResult
is returned to the client application.
Customer Verification Request
Parameter | Data type | Description | Example |
---|---|---|---|
merchantRefNum | String | Required parameter, representing a generated string that is unique for each session. | "oidfjsdkljfh2131" |
language | String | Optional parameter. Displays content for the customer in the specified language. | "en" |
- Kotlin
- Swift
In Android there are two ways to open a screen by using startActivityForResult
method or registerForActivityResult
:
val customerVerificationRequest = CustomerVerificationRequest(
merchantRefNum = "oidfjsdkljfh2131",
language = "en"
)
// Start the verification screen for result
customerVerificationService.startCustomerVerification(this, 100, customerVerificationRequest)
// Then, obtain the verification result in onActivityResult
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == 100 && data != null) {
val result = IntentCompat.getParcelableExtra(data, "EXTRA_CUSTOMER_VERIFICATION_RESULT", VerificationResult::class.java)
when (result) {
VerificationResult.COMPLETE -> handleComplete()
VerificationResult.FAILED -> handleFailed()
VerificationResult.CANCELLED -> handleCancelled()
VerificationResult.MISSING_CAMERA_PERMISSION -> handleMissingPermission()
else -> handleOtherError()
}
}
}
// Alternatively, the registerForActivityResult API can be used
val launcher = registerForActivityResult(OpenCustomerVerification()) { result ->
when (result) {
VerificationResult.COMPLETE -> handleComplete()
VerificationResult.FAILED -> handleFailed()
VerificationResult.CANCELLED -> handleCancelled()
VerificationResult.MISSING_CAMERA_PERMISSION -> handleMissingPermission()
else -> handleOtherError()
}
}
launcher.launch(customerVerificationRequest)
let request = Wallet.CustomerVerificationRequest(merchantRefNum: "oidfjsdkljfh2131",
language: "en")
let customerVerificationViewController = customerVerificationService.startCustomerVerification(request: request)
navigationController?.pushViewController(customerVerificationViewController, animated: true)
customerVerificationViewController.completion = { [weak self] verificationResult in
// Handle verification result
self?.navigationController?.popViewController(animated: true)
}
Get KYC Status
Use getKycStatus
method to retrieve the KYC status of the user. The result is a KycVerification
object, containing
the customer ID and the current status - completed, in progress or incomplete.
- Kotlin
- Swift
try {
val kycStatus = customerVerificationService.getKycStatus()
Log.d(TAG, kycStatus.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
customerVerificationService.getKycStatus(completion: { result in
switch result {
case .success(let kycVerification):
// Display status
case .failure(let error):
// Handle error
}
})