Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Identity] Support Identity test mode M1 #6642

Merged
merged 7 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* [CHANGED][6635](https://github.com/stripe/stripe-android/pull/6635) Use non transitive R classes.
* [CHANGED][6676](https://github.com/stripe/stripe-android/pull/6676) Updated Compose BOM to 2023.05.00.

### Identity
* [ADDED][6642](https://github.com/stripe/stripe-android/pull/6642) Support Test mode M1.

## 20.24.2 - 2023-05-03

### Payments
Expand Down
2 changes: 0 additions & 2 deletions identity/api/identity.api
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,10 @@ public final class com/stripe/android/identity/ui/ComposableSingletons$DebugScre
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public static field lambda-2 Lkotlin/jvm/functions/Function3;
public static field lambda-3 Lkotlin/jvm/functions/Function3;
public static field lambda-4 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$identity_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-2$identity_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-3$identity_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-4$identity_release ()Lkotlin/jvm/functions/Function3;
}

public final class com/stripe/android/identity/ui/ComposableSingletons$SelfieScreenKt {
Expand Down
2 changes: 2 additions & 0 deletions identity/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<ID>LongMethod:CameraScreenLaunchedEffect.kt$@Composable internal fun CameraScreenLaunchedEffect( identityViewModel: IdentityViewModel, identityScanViewModel: IdentityScanViewModel, verificationPage: VerificationPage, navController: NavController, cameraManager: IdentityCameraManager, onCameraReady: () -> Unit )</ID>
<ID>LongMethod:ConfirmationScreen.kt$@Composable internal fun ConfirmationScreen( navController: NavController, identityViewModel: IdentityViewModel, verificationFlowFinishable: VerificationFlowFinishable )</ID>
<ID>LongMethod:ConsentScreen.kt$@Composable private fun SuccessUI( merchantLogoUri: Uri, verificationPage: VerificationPage, onConsentAgreed: () -> Unit, onConsentDeclined: () -> Unit )</ID>
<ID>LongMethod:DebugScreen.kt$@Composable internal fun CompleteWithTestDataSection( onClickSubmit: (CompleteOption) -> Unit )</ID>
<ID>LongMethod:DebugScreen.kt$@Composable internal fun DebugScreen( navController: NavController, identityViewModel: IdentityViewModel, verificationFlowFinishable: VerificationFlowFinishable )</ID>
<ID>LongMethod:DocSelectionScreen.kt$@Composable internal fun DocSelectionScreen( navController: NavController, identityViewModel: IdentityViewModel, cameraPermissionEnsureable: CameraPermissionEnsureable )</ID>
<ID>LongMethod:DocumenetScanScreen.kt$@Composable internal fun DocumentScanScreen( navController: NavController, identityViewModel: IdentityViewModel, identityScanViewModel: IdentityScanViewModel, frontScanType: IdentityScanState.ScanType, backScanType: IdentityScanState.ScanType?, shouldStartFromBack: Boolean, messageRes: DocumentScanMessageRes, collectedDataParamType: CollectedDataParam.Type, route: String )</ID>
<ID>LongMethod:ErrorScreen.kt$@Composable internal fun ErrorScreen( identityViewModel: IdentityViewModel, title: String, modifier: Modifier = Modifier, message1: String? = null, message2: String? = null, topButton: ErrorScreenButton? = null, bottomButton: ErrorScreenButton? = null, )</ID>
Expand Down
20 changes: 1 addition & 19 deletions identity/res/values/totranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,5 @@
<string name="stripe_test_model_title">You\'re currently in testmode</string>
<string name="stripe_test_model_content">This page is only shown in testmode.</string>
<string name="stripe_complete_with_test_data">Complete with test data</string>
<string name="stripe_complete_with_test_data_details"><![CDATA[Save time by choosing a desired result and completing instantly with that outcome. The mobile SDK flow will return with result <b>Completed</b>.]]></string>

<string name="stripe_verification_success">Verification success</string>
<string name="stripe_verification_failure">Verification failure</string>
<string name="stripe_verification_success_async">Verification success async</string>
<string name="stripe_verification_failure_async">Verification failure async</string>
<string name="stripe_submit">SUBMIT</string>

<string name="stripe_finish_mobile_flow">Terminate mobile SDK flow</string>
<string name="stripe_finish_mobile_flow_details"><![CDATA[Terminate mobile SDK flow locally with <b>Completed</b>, <b>Canceled</b> or <b>Failed</b> without changing the verification session on server.]]></string>

<string name="stripe_failure_from_test_mode">Failure from test mode</string>
<string name="stripe_completed">COMPLETED</string>
<string name="stripe_cancelled">CANCELLED</string>
<string name="stripe_failed">FAILED</string>

<string name="stripe_preview_user_experience">Preview user experience</string>
<string name="stripe_preview_user_experience_details">Proceed to preview as an end user. Information provided will not be verified.</string>
<string name="stripe_proceed">PROCEED</string>
<string name="stripe_complete_with_test_data_details">Save time by choosing a desired result and completing instantly with that outcome. The mobile SDK flow will return with result Completed.</string>
</resources>
16 changes: 16 additions & 0 deletions identity/res/values/untranslatable.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
<string name="stripe_dob_placeholder" translatable="false">MM / DD / YYYY</string>
<string name="stripe_verification_success">Verification success</string>
<string name="stripe_verification_failure">Verification failure</string>
<string name="stripe_verification_success_async">Verification success async</string>
<string name="stripe_verification_failure_async">Verification failure async</string>
<string name="stripe_submit">SUBMIT</string>

<string name="stripe_finish_mobile_flow">Terminate mobile SDK flow</string>
<string name="stripe_finish_mobile_flow_details">Terminate the mobile SDK flow locally with Cancelled or Failed.</string>

<string name="stripe_failure_from_test_mode">Failure from test mode</string>
<string name="stripe_cancelled">CANCELLED</string>
<string name="stripe_failed">FAILED</string>

<string name="stripe_preview_user_experience">Preview user experience</string>
<string name="stripe_preview_user_experience_details">Proceed to preview as an end user. Information provided will not be verified.</string>
<string name="stripe_proceed">PROCEED</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ internal class ErrorDestination(
// If this happens, set the back button destination to [DEFAULT_BACK_BUTTON_DESTINATION]
const val UNEXPECTED_ROUTE = "UnexpectedRoute"

const val TAG = "ErrorDestination"

fun errorTitle(backStackEntry: NavBackStackEntry) =
backStackEntry.getStringArgument(ARG_ERROR_TITLE)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stripe.android.identity.navigation

import android.util.Log
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -321,6 +322,10 @@ internal fun IdentityNavGraph(
)
}
screen(ErrorDestination.ROUTE) {
Log.d(
ErrorDestination.TAG,
"About to show error screen with error caused by ${identityViewModel.errorCause.value}"
)
ErrorScreen(
identityViewModel = identityViewModel,
title = ErrorDestination.errorTitle(it),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,40 @@ internal class DefaultIdentityRepository @Inject constructor(
VerificationPageData.serializer()
)

override suspend fun verifyTestVerificationSession(
id: String,
ephemeralKey: String,
simulateDelay: Boolean
) = executeRequestWithKSerializer(
apiRequestFactory.createPost(
url = "$BASE_URL/$IDENTITY_VERIFICATION_PAGES/${urlEncode(id)}/$TESTING/$VERIFY",
options = ApiRequest.Options(
apiKey = ephemeralKey
),
params = mapOf(
SIMULATE_DELAY to simulateDelay
)
),
VerificationPageData.serializer()
)

override suspend fun unverifyTestVerificationSession(
id: String,
ephemeralKey: String, // todo - need to add this to the request
simulateDelay: Boolean
) = executeRequestWithKSerializer(
apiRequestFactory.createPost(
url = "$BASE_URL/$IDENTITY_VERIFICATION_PAGES/${urlEncode(id)}/$TESTING/$UNVERIFY",
options = ApiRequest.Options(
apiKey = ephemeralKey
),
params = mapOf(
SIMULATE_DELAY to simulateDelay
)
),
VerificationPageData.serializer()
)

override suspend fun uploadImage(
verificationId: String,
ephemeralKey: String,
Expand Down Expand Up @@ -252,8 +286,6 @@ internal class DefaultIdentityRepository @Inject constructor(
}

internal companion object {
const val SUBMIT = "submit"
const val DATA = "data"
val TAG: String = DefaultIdentityRepository::class.java.simpleName
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ internal interface IdentityRepository {
ephemeralKey: String
): VerificationPageData

@Throws(
APIConnectionException::class,
APIException::class
)
suspend fun verifyTestVerificationSession(
id: String,
ephemeralKey: String,
simulateDelay: Boolean
): VerificationPageData

@Throws(
APIConnectionException::class,
APIException::class
)
suspend fun unverifyTestVerificationSession(
id: String,
ephemeralKey: String,
simulateDelay: Boolean
): VerificationPageData

@Throws(
APIConnectionException::class,
APIException::class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ internal const val BASE_URL = "https://api.stripe.com/v1"
internal const val IDENTITY_VERIFICATION_PAGES = "identity/verification_pages"
internal const val IDENTITY_STRIPE_API_VERSION_WITH_BETA_HEADER =
"2020-08-27;identity_client_api=v3"

internal const val SUBMIT = "submit"
internal const val DATA = "data"
internal const val TESTING = "testing"
internal const val VERIFY = "verify"
internal const val UNVERIFY = "unverify"
internal const val SIMULATE_DELAY = "simulate_delay"
Loading