Skip to content

Commit

Permalink
Setup Callback URL (#233)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jumaallan authored Oct 18, 2023
1 parent f9902d8 commit 0c67e78
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 6 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 17 additions & 0 deletions lib/src/main/java/com/smileidentity/SmileID.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/java/com/smileidentity/models/EnhancedKyc.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/java/com/smileidentity/models/PrepUpload.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data class PrepUploadRequest(
@Json(name = "partner_params") val partnerParams: PartnerParams,
@Json(name = "model_parameters") val modelParameters: Map<String, Any> = 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ internal abstract class OrchestratedDocumentViewModel<T : Parcelable>(
val authResponse = SmileID.api.authenticate(authRequest)

val prepUploadRequest = PrepUploadRequest(
callbackUrl = "",
callbackUrl = SmileID.callbackUrl,
partnerParams = authResponse.partnerParams,
signature = authResponse.signature,
timestamp = authResponse.timestamp,
Expand Down

0 comments on commit 0c67e78

Please sign in to comment.