diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/flowcontroller/DefaultFlowController.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/flowcontroller/DefaultFlowController.kt index c2ee23abdd1..981bb6dbce2 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/flowcontroller/DefaultFlowController.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/flowcontroller/DefaultFlowController.kt @@ -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 -> { diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/flowcontroller/DefaultFlowControllerTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/flowcontroller/DefaultFlowControllerTest.kt index ec5ceabbae6..9e1654c8dd3 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/flowcontroller/DefaultFlowControllerTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/flowcontroller/DefaultFlowControllerTest.kt @@ -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 } ) }