Skip to content

Commit

Permalink
Passes app id.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmuvi-stripe committed Dec 23, 2024
1 parent f7829a4 commit 2cd4451
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.stripe.android.financialconnections.domain

import android.app.Application
import com.stripe.android.financialconnections.FinancialConnectionsSheet
import com.stripe.android.financialconnections.repository.FinancialConnectionsConsumerSessionRepository
import com.stripe.android.model.ConsumerSessionLookup
import com.stripe.attestation.IntegrityRequestManager
import javax.inject.Inject

internal class LookupAccount @Inject constructor(
private val application: Application,
private val integrityRequestManager: IntegrityRequestManager,
private val consumerSessionRepository: FinancialConnectionsConsumerSessionRepository,
val configuration: FinancialConnectionsSheet.Configuration,
Expand All @@ -17,11 +19,11 @@ internal class LookupAccount @Inject constructor(
verifiedFlow: Boolean
): ConsumerSessionLookup {
return if (verifiedFlow) {
val token = integrityRequestManager.requestToken()
requireNotNull(
consumerSessionRepository.mobileLookupConsumerSession(
email = email.lowercase().trim(),
verificationToken = token.getOrThrow(),
verificationToken = integrityRequestManager.requestToken().getOrThrow(),
appId = application.packageName
)
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ internal data class FinancialConnectionsSessionManifest(
@SerialName(value = "institution_search_disabled")
val institutionSearchDisabled: Boolean,

@SerialName(value = "app_verification_enabled")
val appVerificationEnabled: Boolean,
val appVerificationEnabled: Boolean = true,

@SerialName(value = "livemode")
val livemode: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import com.stripe.android.financialconnections.ui.toLocalTheme
import com.stripe.android.financialconnections.utils.UriUtils
import com.stripe.android.financialconnections.utils.get
import com.stripe.android.financialconnections.utils.updateWithNewEntry
import com.stripe.attestation.IntegrityRequestManager
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
Expand All @@ -86,6 +87,7 @@ internal class FinancialConnectionsSheetNativeViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
private val nativeAuthFlowCoordinator: NativeAuthFlowCoordinator,
private val uriUtils: UriUtils,
private val integrityRequestManager: IntegrityRequestManager,
private val completeFinancialConnectionsSession: CompleteFinancialConnectionsSession,
private val createInstantDebitsResult: CreateInstantDebitsResult,
private val eventTracker: FinancialConnectionsAnalyticsTracker,
Expand Down Expand Up @@ -124,6 +126,7 @@ internal class FinancialConnectionsSheetNativeViewModel @Inject constructor(
init {
savedStateHandle.registerSavedStateProvider()
setState { copy(firstInit = false) }
prepareIntegrityRequestManager()
viewModelScope.launch {
nativeAuthFlowCoordinator().collect { message ->
when (message) {
Expand All @@ -147,6 +150,12 @@ internal class FinancialConnectionsSheetNativeViewModel @Inject constructor(
}
}

private fun prepareIntegrityRequestManager() {
viewModelScope.launch {
integrityRequestManager.prepare()
}
}

private fun SavedStateHandle.registerSavedStateProvider() {
setSavedStateProvider(KEY_SAVED_STATE) {
val state = stateFlow.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ internal interface FinancialConnectionsConsumerSessionRepository {

suspend fun mobileLookupConsumerSession(
email: String,
verificationToken: String
verificationToken: String,
appId: String
): ConsumerSessionLookup

suspend fun signUp(
Expand Down Expand Up @@ -247,10 +248,12 @@ private class FinancialConnectionsConsumerSessionRepositoryImpl(

override suspend fun mobileLookupConsumerSession(
email: String,
verificationToken: String
verificationToken: String,
appId: String
): ConsumerSessionLookup = consumersApiService.mobileLookupConsumerSession(
email = email,
verificationToken = verificationToken,
appId = appId,
requestSurface = requestSurface,
requestOptions = provideApiRequestOptions(useConsumerPublishableKey = false),
).also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.stripe.android.model.parsers.ConsumerSessionLookupJsonParser
import com.stripe.android.model.parsers.ConsumerSessionSignupJsonParser
import com.stripe.android.model.parsers.SharePaymentDetailsJsonParser
import java.util.Locale
import java.util.UUID

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
interface ConsumersApiService {
Expand Down Expand Up @@ -54,6 +55,7 @@ interface ConsumersApiService {
email: String,
requestSurface: String,
verificationToken: String,
appId: String,
requestOptions: ApiRequest.Options
): ConsumerSessionLookup

Expand Down Expand Up @@ -190,6 +192,7 @@ class ConsumersApiServiceImpl(
email: String,
requestSurface: String,
verificationToken: String,
appId: String,
requestOptions: ApiRequest.Options
): ConsumerSessionLookup {
return executeRequestWithModelJsonParser(
Expand All @@ -201,7 +204,10 @@ class ConsumersApiServiceImpl(
mapOf(
"request_surface" to requestSurface,
"email_address" to email.lowercase(),
"verification_token" to verificationToken
"android_verification_token" to verificationToken,
"session_id" to "12345", // TODO (carlosmuvi): remove this when we have a real session id
"email_source" to "user_action", // TODO (carlosmuvi): remove this when we have a real app id
"app_id" to appId
)
),
responseJsonParser = ConsumerSessionLookupJsonParser()
Expand Down

0 comments on commit 2cd4451

Please sign in to comment.