-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates lookup call to use mobile endpoint on verified flows
- Loading branch information
1 parent
7cf4405
commit 07645d0
Showing
23 changed files
with
282 additions
and
63 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 27 additions & 7 deletions
34
...connections/src/main/java/com/stripe/android/financialconnections/domain/LookupAccount.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,41 @@ | ||
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.android.model.EmailSource | ||
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, | ||
) { | ||
|
||
suspend operator fun invoke( | ||
email: String | ||
): ConsumerSessionLookup = requireNotNull( | ||
consumerSessionRepository.lookupConsumerSession( | ||
email = email.lowercase().trim(), | ||
clientSecret = configuration.financialConnectionsSessionClientSecret | ||
) | ||
) | ||
email: String, | ||
emailSource: EmailSource, | ||
verifiedFlow: Boolean | ||
): ConsumerSessionLookup { | ||
return if (verifiedFlow) { | ||
requireNotNull( | ||
consumerSessionRepository.mobileLookupConsumerSession( | ||
email = email.lowercase().trim(), | ||
emailSource = emailSource, | ||
verificationToken = integrityRequestManager.requestToken().getOrThrow(), | ||
appId = application.packageName | ||
) | ||
) | ||
} else { | ||
requireNotNull( | ||
consumerSessionRepository.postConsumerSession( | ||
email = email.lowercase().trim(), | ||
clientSecret = configuration.financialConnectionsSessionClientSecret | ||
) | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...nections/src/main/java/com/stripe/android/financialconnections/features/error/ErrorExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.stripe.android.financialconnections.features.error | ||
|
||
import com.stripe.android.core.exception.APIException | ||
import com.stripe.attestation.AttestationError | ||
|
||
internal fun Throwable.isAttestationError(): Boolean = when (this) { | ||
// Stripe backend could not verify the intregrity of the request | ||
is APIException -> stripeError?.code == "link_failed_to_attest_request" | ||
// Interaction with Integrity API to generate tokens resulted in a failure | ||
is AttestationError -> true | ||
else -> false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,14 @@ internal class NetworkingLinkSignupPreviewParameterProvider : | |
payload = Success( | ||
NetworkingLinkSignupState.Payload( | ||
merchantName = "Test", | ||
prefilledEmail = null, | ||
emailController = EmailConfig.createController(""), | ||
phoneController = PhoneNumberController.createPhoneNumberController( | ||
initialValue = "", | ||
initiallySelectedCountryCode = null, | ||
), | ||
isInstantDebits = false, | ||
appVerificationEnabled = false, | ||
content = networkingLinkSignupPane(), | ||
) | ||
), | ||
|
@@ -43,12 +45,14 @@ internal class NetworkingLinkSignupPreviewParameterProvider : | |
payload = Success( | ||
NetworkingLinkSignupState.Payload( | ||
merchantName = "Test", | ||
prefilledEmail = null, | ||
emailController = EmailConfig.createController("[email protected]"), | ||
phoneController = PhoneNumberController.createPhoneNumberController( | ||
initialValue = "", | ||
initiallySelectedCountryCode = null, | ||
), | ||
isInstantDebits = false, | ||
appVerificationEnabled = false, | ||
content = networkingLinkSignupPane(), | ||
) | ||
), | ||
|
@@ -68,12 +72,14 @@ internal class NetworkingLinkSignupPreviewParameterProvider : | |
payload = Success( | ||
NetworkingLinkSignupState.Payload( | ||
merchantName = "Test", | ||
prefilledEmail = null, | ||
emailController = EmailConfig.createController("invalid_email.com"), | ||
phoneController = PhoneNumberController.createPhoneNumberController( | ||
initialValue = "", | ||
initiallySelectedCountryCode = null, | ||
), | ||
isInstantDebits = false, | ||
appVerificationEnabled = false, | ||
content = networkingLinkSignupPane(), | ||
) | ||
), | ||
|
@@ -93,12 +99,14 @@ internal class NetworkingLinkSignupPreviewParameterProvider : | |
payload = Success( | ||
NetworkingLinkSignupState.Payload( | ||
merchantName = "Test", | ||
prefilledEmail = null, | ||
emailController = EmailConfig.createController(initialValue = null), | ||
phoneController = PhoneNumberController.createPhoneNumberController( | ||
initialValue = "", | ||
initiallySelectedCountryCode = null, | ||
), | ||
isInstantDebits = true, | ||
appVerificationEnabled = false, | ||
content = linkLoginPane(), | ||
) | ||
), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.