Skip to content

Commit

Permalink
Relay error message on PaymentResult.Failed (#4512)
Browse files Browse the repository at this point in the history
  • Loading branch information
brnunes-stripe authored Jan 20, 2022
1 parent c56ff15 commit 8bdd235
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,7 @@ internal class DefaultFlowController @Inject internal constructor(
}
is PaymentResult.Failed -> {
PaymentSheetResult.Failed(
IllegalArgumentException(
"Failed to confirm intent: ${paymentResult.throwable.message}"
)
paymentResult.throwable
)
}
else -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,13 +697,15 @@ internal class DefaultFlowControllerTest {
}

@Test
fun `onPaymentResult when error should invoke callback with Failed`() =
fun `onPaymentResult when error should invoke callback with Failed and relay error message`() =
runTest {
flowController.onPaymentResult(PaymentResult.Failed(Throwable("error")))
val errorMessage = "Original error message"
flowController.onPaymentResult(PaymentResult.Failed(Throwable(errorMessage)))

verify(paymentResultCallback).onPaymentSheetResult(
argWhere { paymentResult ->
paymentResult is PaymentSheetResult.Failed
paymentResult is PaymentSheetResult.Failed &&
errorMessage == paymentResult.error.localizedMessage
}
)
}
Expand Down

0 comments on commit 8bdd235

Please sign in to comment.