Updated on 2026-08-14
This commit is contained in:
parent
ebb5b5830e
commit
d1c13037e0
42 changed files with 246 additions and 80 deletions
|
|
@ -15,6 +15,10 @@ dependencies {
|
|||
/** Api */
|
||||
implementation(projects.features.kyc.api)
|
||||
|
||||
/** Domain */
|
||||
implementation(projects.domain.visa)
|
||||
implementation(projects.domain.wallets.models)
|
||||
|
||||
/** Core modules */
|
||||
implementation(projects.core.configToggles)
|
||||
implementation(projects.core.analytics)
|
||||
|
|
@ -25,6 +29,7 @@ dependencies {
|
|||
implementation(projects.core.decompose)
|
||||
implementation(projects.core.navigation)
|
||||
implementation(projects.core.datasource)
|
||||
implementation(projects.core.error)
|
||||
|
||||
/** Common */
|
||||
implementation(projects.common.ui)
|
||||
|
|
@ -47,6 +52,7 @@ dependencies {
|
|||
implementation(deps.timber)
|
||||
implementation(deps.firebase.crashlytics)
|
||||
implementation(deps.sumsub.sdk)
|
||||
implementation(deps.arrow.core)
|
||||
|
||||
/** DI */
|
||||
implementation(deps.hilt.android)
|
||||
|
|
|
|||
|
|
@ -1,35 +1,67 @@
|
|||
package com.tangem.features.kyc
|
||||
|
||||
import com.sumsub.sns.core.SNSMobileSDK
|
||||
import com.sumsub.sns.core.data.listener.SNSCompleteHandler
|
||||
import com.sumsub.sns.core.data.listener.TokenExpirationHandler
|
||||
import com.sumsub.sns.core.data.model.SNSCompletionResult
|
||||
import com.sumsub.sns.core.data.model.SNSSDKState
|
||||
import com.sumsub.sns.core.theme.SNSTheme
|
||||
import com.sumsub.sns.core.theme.SNSThemeMetric
|
||||
import com.sumsub.sns.core.theme.colors
|
||||
import com.sumsub.sns.core.theme.metrics
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.domain.pay.repository.KycRepository
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.util.Locale
|
||||
|
||||
class DefaultKycComponent @AssistedInject constructor(
|
||||
@Assisted appComponentContext: AppComponentContext,
|
||||
private val kycRepositoryFactory: KycRepository.Factory,
|
||||
) : KycComponent, AppComponentContext by appComponentContext {
|
||||
|
||||
private val kycRepository = kycRepositoryFactory.create(UserWalletId("0FFFFF"))
|
||||
|
||||
override fun launch() {
|
||||
val accessToken = "123456"
|
||||
componentScope.launch {
|
||||
// val startInfo = kycRepository.getKycStartInfo().getOrNull() ?: return@launch
|
||||
|
||||
val tokenExpirationHandler = object : TokenExpirationHandler {
|
||||
override fun onTokenExpired(): String? {
|
||||
// Access token expired
|
||||
// get a new one and pass it to the callback to re-initiate the SDK
|
||||
val newToken = "..." // get a new token from your backend
|
||||
return newToken
|
||||
val tokenExpirationHandler = object : TokenExpirationHandler {
|
||||
override fun onTokenExpired(): String? {
|
||||
val newToken = runBlocking { kycRepository.getKycStartInfo().getOrNull()?.token }
|
||||
return newToken
|
||||
}
|
||||
}
|
||||
|
||||
val snsSdk = SNSMobileSDK.Builder(activity)
|
||||
.withAccessToken(
|
||||
"TODO",
|
||||
onTokenExpiration = tokenExpirationHandler,
|
||||
)
|
||||
.withTheme(
|
||||
SNSTheme {
|
||||
colors {
|
||||
}
|
||||
metrics {
|
||||
this.screenHeaderAlignment = SNSThemeMetric.TextAlignment.CENTER
|
||||
}
|
||||
},
|
||||
)
|
||||
.withLocale(Locale("en"))
|
||||
.withCompleteHandler(
|
||||
object : SNSCompleteHandler {
|
||||
override fun onComplete(result: SNSCompletionResult, state: SNSSDKState) {
|
||||
}
|
||||
},
|
||||
)
|
||||
.build()
|
||||
|
||||
snsSdk.launch()
|
||||
}
|
||||
|
||||
val snsSdk = SNSMobileSDK.Builder(activity)
|
||||
.withAccessToken(accessToken, onTokenExpiration = tokenExpirationHandler)
|
||||
.withLocale(Locale("en"))
|
||||
.build()
|
||||
|
||||
snsSdk.launch()
|
||||
}
|
||||
|
||||
@AssistedFactory
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue