From 0c67e78537dafcc838f88cd69df48426d4ec2ee4 Mon Sep 17 00:00:00 2001 From: Juma Allan Date: Wed, 18 Oct 2023 22:55:53 +0300 Subject: [PATCH] Setup Callback URL (#233) * added enhanced docv support * added support for enhanced doc v * fixed viewmodel params * setting up enhanced docv polling * renamed EnhancedDocV to EnhancedDocumentVerification * refactored DocumentVerificationViewModel and EnhancedDocumentVerificationViewModel * fixed enhanceddocv country selector * added more tests and fixed country picker * re-organize products * added selfieFile and livenessFiles in EnhancedDocumentVerificationResult * setting callback url * fixed url string to URL type * updated CHANGELOG.md * Fixed callbackUrl to URL * deleted duplicate EnhancedDocumentVerificationResult * fixed nullable callbackUrl --- CHANGELOG.md | 11 +++++++++++ lib/src/main/java/com/smileidentity/SmileID.kt | 17 +++++++++++++++++ .../com/smileidentity/models/Authentication.kt | 2 +- .../com/smileidentity/models/EnhancedKyc.kt | 2 +- .../java/com/smileidentity/models/PrepUpload.kt | 2 +- .../viewmodel/BiometricKycViewModel.kt | 2 +- .../smileidentity/viewmodel/SelfieViewModel.kt | 2 +- .../document/OrchestratedDocumentViewModel.kt | 2 +- 8 files changed, 34 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08ed76912..6415f5783 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,23 @@ # Changelog +## 10.0.0-beta10 (unreleased) + +### Added + +### Fixed + +### Changed + ## 10.0.0-beta09 (unreleased) ### Added - Added missing `colorScheme` and `typography` parameters on `SmileID.BvnConsentScreen` +- Added option to set callback URL using `setCallbackUrl(callbackUrl: URL?)` method +- Added EnhancedDocumentVerification support ### Fixed - Updated KDocs with missing parameter descriptions +- Fix Broken Country Selection on EnhancedKYC and BiometricKYC ### Changed - Show the normal consent screen as part of BVN Verification diff --git a/lib/src/main/java/com/smileidentity/SmileID.kt b/lib/src/main/java/com/smileidentity/SmileID.kt index 52d1cc645..423ab92e5 100644 --- a/lib/src/main/java/com/smileidentity/SmileID.kt +++ b/lib/src/main/java/com/smileidentity/SmileID.kt @@ -26,6 +26,7 @@ import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Retrofit import retrofit2.converter.moshi.MoshiConverterFactory import timber.log.Timber +import java.net.URL import java.util.concurrent.TimeUnit @Suppress("unused") @@ -42,6 +43,9 @@ object SmileID { var useSandbox: Boolean = true private set + var callbackUrl: String = "" + private set + internal var apiKey: String? = null internal lateinit var fileSavePath: String @@ -135,6 +139,19 @@ object SmileID { api = retrofit.create(SmileIDService::class.java) } + /** + * The callback mechanism allows for asynchronous job requests and responses. + * While the job_status API can be polled to get a result, a better method is to set up a + * callback url and let the system POST a JSON response. + * + * @param callbackUrl The callback url that will be used to asynchronously send results of your + * job requests + */ + @JvmStatic + fun setCallbackUrl(callbackUrl: URL?) { + SmileID.callbackUrl = callbackUrl?.toString() ?: "" + } + /** * Returns an [OkHttpClient.Builder] optimized for low bandwidth conditions. Use it as a * starting point if you need to customize an [OkHttpClient] for your own needs diff --git a/lib/src/main/java/com/smileidentity/models/Authentication.kt b/lib/src/main/java/com/smileidentity/models/Authentication.kt index 989a2f7d3..c7d502d99 100644 --- a/lib/src/main/java/com/smileidentity/models/Authentication.kt +++ b/lib/src/main/java/com/smileidentity/models/Authentication.kt @@ -61,7 +61,7 @@ data class AuthenticationResponse( @Json(name = "signature") val signature: String, @Json(name = "timestamp") val timestamp: String, @Json(name = "partner_params") val partnerParams: PartnerParams, - @Json(name = "callback_url") val callbackUrl: String? = null, + @Json(name = "callback_url") val callbackUrl: String? = SmileID.callbackUrl, @Json(name = "consent_info") val consentInfo: ConsentInfo? = null, ) : Parcelable diff --git a/lib/src/main/java/com/smileidentity/models/EnhancedKyc.kt b/lib/src/main/java/com/smileidentity/models/EnhancedKyc.kt index 0c4090a34..3cdaa2ad7 100644 --- a/lib/src/main/java/com/smileidentity/models/EnhancedKyc.kt +++ b/lib/src/main/java/com/smileidentity/models/EnhancedKyc.kt @@ -20,7 +20,7 @@ data class EnhancedKycRequest( @Json(name = "dob") val dob: String? = null, @Json(name = "phone_number") val phoneNumber: String? = null, @Json(name = "bank_code") val bankCode: String? = null, - @Json(name = "callback_url") val callbackUrl: String? = null, + @Json(name = "callback_url") val callbackUrl: String? = SmileID.callbackUrl, @Json(name = "partner_params") val partnerParams: PartnerParams, @Json(name = "partner_id") val partnerId: String = SmileID.config.partnerId, @Json(name = "source_sdk") val sourceSdk: String = "android", diff --git a/lib/src/main/java/com/smileidentity/models/PrepUpload.kt b/lib/src/main/java/com/smileidentity/models/PrepUpload.kt index da487adde..f199f5a18 100644 --- a/lib/src/main/java/com/smileidentity/models/PrepUpload.kt +++ b/lib/src/main/java/com/smileidentity/models/PrepUpload.kt @@ -13,7 +13,7 @@ data class PrepUploadRequest( @Json(name = "partner_params") val partnerParams: PartnerParams, @Json(name = "model_parameters") val modelParameters: Map = mapOf(), // Callback URL *must* be defined either within your Partner Portal or here - @Json(name = "callback_url") val callbackUrl: String? = null, + @Json(name = "callback_url") val callbackUrl: String? = SmileID.callbackUrl, @Json(name = "smile_client_id") val partnerId: String = SmileID.config.partnerId, @Json(name = "source_sdk") val sourceSdk: String = "android", @Json(name = "source_sdk_version") val sourceSdkVersion: String = BuildConfig.VERSION_NAME, diff --git a/lib/src/main/java/com/smileidentity/viewmodel/BiometricKycViewModel.kt b/lib/src/main/java/com/smileidentity/viewmodel/BiometricKycViewModel.kt index 343250aaa..da23c9fed 100644 --- a/lib/src/main/java/com/smileidentity/viewmodel/BiometricKycViewModel.kt +++ b/lib/src/main/java/com/smileidentity/viewmodel/BiometricKycViewModel.kt @@ -92,7 +92,7 @@ class BiometricKycViewModel( val authResponse = SmileID.api.authenticate(authRequest) val prepUploadRequest = PrepUploadRequest( - callbackUrl = "", + callbackUrl = SmileID.callbackUrl, partnerParams = authResponse.partnerParams, signature = authResponse.signature, timestamp = authResponse.timestamp, diff --git a/lib/src/main/java/com/smileidentity/viewmodel/SelfieViewModel.kt b/lib/src/main/java/com/smileidentity/viewmodel/SelfieViewModel.kt index 93cf48356..32d52c5f8 100644 --- a/lib/src/main/java/com/smileidentity/viewmodel/SelfieViewModel.kt +++ b/lib/src/main/java/com/smileidentity/viewmodel/SelfieViewModel.kt @@ -274,7 +274,7 @@ class SelfieViewModel( val authResponse = SmileID.api.authenticate(authRequest) val prepUploadRequest = PrepUploadRequest( - callbackUrl = "", + callbackUrl = SmileID.callbackUrl, partnerParams = authResponse.partnerParams, signature = authResponse.signature, timestamp = authResponse.timestamp, diff --git a/lib/src/main/java/com/smileidentity/viewmodel/document/OrchestratedDocumentViewModel.kt b/lib/src/main/java/com/smileidentity/viewmodel/document/OrchestratedDocumentViewModel.kt index 7b79a726e..52174dbe1 100644 --- a/lib/src/main/java/com/smileidentity/viewmodel/document/OrchestratedDocumentViewModel.kt +++ b/lib/src/main/java/com/smileidentity/viewmodel/document/OrchestratedDocumentViewModel.kt @@ -134,7 +134,7 @@ internal abstract class OrchestratedDocumentViewModel( val authResponse = SmileID.api.authenticate(authRequest) val prepUploadRequest = PrepUploadRequest( - callbackUrl = "", + callbackUrl = SmileID.callbackUrl, partnerParams = authResponse.partnerParams, signature = authResponse.signature, timestamp = authResponse.timestamp,