Skip to content

Commit

Permalink
Fix updated intent not being used with a complete action in `DefaultC…
Browse files Browse the repository at this point in the history
…onfirmationHandler`. (#9748)
  • Loading branch information
samer-stripe authored Dec 5, 2024
1 parent ff91194 commit 0f3628c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ internal class DefaultConfirmationHandler(
is ConfirmationMediator.Action.Complete -> {
onHandlerResult(
ConfirmationHandler.Result.Succeeded(
intent = intent,
intent = action.intent,
deferredIntentConfirmationType = action.deferredIntentConfirmationType,
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.stripe.android.payments.core.analytics.ErrorReporter
import com.stripe.android.paymentsheet.R
import com.stripe.android.testing.FakeErrorReporter
import com.stripe.android.testing.PaymentIntentFactory
import com.stripe.android.testing.PaymentMethodFactory
import com.stripe.android.utils.DummyActivityResultCaller
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -235,7 +236,7 @@ class DefaultConfirmationHandlerTest {
@Test
fun `On complete action, should complete with success result`() = test(
someDefinitionAction = ConfirmationDefinition.Action.Complete(
intent = PAYMENT_INTENT,
intent = UPDATED_PAYMENT_INTENT,
confirmationOption = SomeConfirmationDefinition.Option,
deferredIntentConfirmationType = DeferredIntentConfirmationType.Client,
),
Expand All @@ -256,7 +257,7 @@ class DefaultConfirmationHandlerTest {
val completeState = awaitCompleteState()
val successResult = completeState.result.assertSucceeded()

assertThat(successResult.intent).isEqualTo(PAYMENT_INTENT)
assertThat(successResult.intent).isEqualTo(UPDATED_PAYMENT_INTENT)
assertThat(successResult.deferredIntentConfirmationType)
.isEqualTo(DeferredIntentConfirmationType.Client)

Expand All @@ -275,13 +276,13 @@ class DefaultConfirmationHandlerTest {
@Test
fun `On success result from launched action, should complete with success result`() = launcherResultTest(
result = ConfirmationDefinition.Result.Succeeded(
intent = PAYMENT_INTENT,
intent = UPDATED_PAYMENT_INTENT,
deferredIntentConfirmationType = DeferredIntentConfirmationType.Server,
),
) { completeState ->
val successResult = completeState.result.assertSucceeded()

assertThat(successResult.intent).isEqualTo(PAYMENT_INTENT)
assertThat(successResult.intent).isEqualTo(UPDATED_PAYMENT_INTENT)
assertThat(successResult.deferredIntentConfirmationType).isEqualTo(DeferredIntentConfirmationType.Server)
}

Expand Down Expand Up @@ -979,5 +980,9 @@ class DefaultConfirmationHandlerTest {
const val AWAITING_CONFIRMATION_RESULT_KEY = "AwaitingConfirmationResult"

val PAYMENT_INTENT = PaymentIntentFactory.create()

val UPDATED_PAYMENT_INTENT = PAYMENT_INTENT.copy(
paymentMethod = PaymentMethodFactory.card(),
)
}
}

0 comments on commit 0f3628c

Please sign in to comment.