File tree Expand file tree Collapse file tree
main/java/com/stripe/android/checkout
test/java/com/stripe/android/checkout Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ internal class CheckoutConfirmationResultHandler @Inject constructor(
5555 onSucceeded : suspend (CheckoutSessionResponse ? ) -> Unit ,
5656 ) {
5757 // Synchronous confirmation carries the latest response. Next-action confirmation does not,
58- // so the controller retrieves the completed Checkout Session before delivering the result .
58+ // so the controller retrieves the completed Checkout Session before clearing its state .
5959 onSucceeded(result.metadata[CheckoutSessionResponseKey ])
6060 resultCallback.onResult(CheckoutController .Result .Completed ())
6161 }
Original file line number Diff line number Diff line change @@ -75,7 +75,8 @@ class CheckoutController @Inject internal constructor(
7575 }
7676
7777 /* *
78- * The latest [Session] data, or `null` until [configure] has completed successfully.
78+ * The latest [Session] data, or `null` until [configure] completes successfully and after a
79+ * payment flow completes.
7980 */
8081 val session: StateFlow <Session ?>
8182 get() = stateHolder.session
@@ -303,6 +304,7 @@ class CheckoutController @Inject internal constructor(
303304 ) {
304305 runSerialized {
305306 confirmationStateUpdater.update(checkoutSessionResponse)
307+ stateHolder.state = null
306308 kotlin.Result .success(Unit )
307309 }
308310 }
@@ -1006,7 +1008,8 @@ class CheckoutController @Inject internal constructor(
10061008 @RestrictTo(RestrictTo .Scope .LIBRARY_GROUP )
10071009 sealed interface Result {
10081010 /* *
1009- * The customer completed the payment flow.
1011+ * The customer completed the payment flow. The controller's loaded [session] is cleared
1012+ * before this result is delivered.
10101013 */
10111014 @CheckoutSessionPreview
10121015 @RestrictTo(RestrictTo .Scope .LIBRARY_GROUP )
Original file line number Diff line number Diff line change @@ -1024,7 +1024,7 @@ internal class CheckoutControllerTest {
10241024 }
10251025
10261026 @Test
1027- fun `successful confirmation waits for an in-flight mutation then refreshes state` () =
1027+ fun `successful confirmation waits for an in-flight mutation then clears state` () =
10281028 runMutationScenario(assertLoadingConsumed = true ) {
10291029 val holdMutation = CountDownLatch (1 )
10301030 networkRule.checkoutUpdate(
@@ -1056,8 +1056,8 @@ internal class CheckoutControllerTest {
10561056 confirmation.await()
10571057
10581058 assertThat(isUpdatingTurbine.awaitItem()).isFalse()
1059- assertThat(committedState().checkoutSessionResponse).isEqualTo(confirmedResponse )
1060- assertThat(controller.session.value).isNotNull ()
1059+ assertThat(committedStateOrNull()).isNull( )
1060+ assertThat(controller.session.value).isNull ()
10611061 }
10621062
10631063 @Test
You can’t perform that action at this time.
0 commit comments