Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into carlosmuvi/eagerly-…
Browse files Browse the repository at this point in the history
…finish-activity-no-args
  • Loading branch information
carlosmuvi-stripe committed Dec 1, 2022
2 parents d2d573c + 4f98580 commit 5d1d954
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import com.stripe.android.camera.framework.util.FrameRateTracker
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
Expand Down Expand Up @@ -187,11 +186,11 @@ abstract class ResultAggregator<

aggregatorExecutionStats?.trackResult("frame_processed")

launch { listener.onInterimResult(interimResult) }
listener.onInterimResult(interimResult)

if (!isFinished && finalResult != null) {
isFinished = true
launch { listener.onResult(finalResult) }
listener.onResult(finalResult)
}
isFinished
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ internal abstract class IdentityDocumentScanFragment(
identityViewModel.observeForVerificationPage(
viewLifecycleOwner,
onSuccess = {
lifecycleScope.launch {
viewLifecycleOwner.lifecycleScope.launch {
runCatching {
postVerificationPageData(
identityViewModel = identityViewModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ internal class DefaultFlowController @Inject internal constructor(

paymentOptionActivityLauncher.launch(
PaymentOptionContract.Args(
state = state,
state = state.copy(
newPaymentSelection = viewModel.paymentSelection as? PaymentSelection.New,
),
statusBarColor = statusBarColor(),
injectorKey = injectorKey,
enableLogging = enableLogging,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,30 @@ internal class DefaultFlowControllerTest {
)
}

@Test
fun `Remembers previous new payment selection when presenting payment options again`() = runTest {
val flowController = createFlowController()

flowController.configureWithPaymentIntent(
paymentIntentClientSecret = PaymentSheetFixtures.CLIENT_SECRET,
callback = { _, _ -> },
)

val previousPaymentSelection = NEW_CARD_PAYMENT_SELECTION

flowController.onPaymentOptionResult(
paymentOptionResult = PaymentOptionResult.Succeeded(previousPaymentSelection),
)

flowController.presentPaymentOptions()

verify(paymentOptionActivityLauncher).launch(
argWhere {
it.state.newPaymentSelection == previousPaymentSelection
}
)
}

private fun createFlowController(
paymentMethods: List<PaymentMethod> = emptyList(),
savedSelection: SavedSelection = SavedSelection.None,
Expand Down

0 comments on commit 5d1d954

Please sign in to comment.