stripe / stripe-android

Stripe Android SDK
https://stripe.com/docs/mobile/android
MIT License
1.3k stars 651 forks source link

[BUG] PaymentSheet does not call back PaymentSheetResult.Failed in case card information is wrong #5697

Closed mehdisatei closed 2 years ago

mehdisatei commented 2 years ago

Summary

PaymentSheet does not call back PaymentSheetResult.Failed in case card information is wrong

Code to reproduce

  1. Initialize the PaymentSheet
    context?.let {
    stripePaymentSheet = PaymentSheet(fragment = this, callback = this)
    PaymentConfiguration.init(
        context = it,
        publishableKey = BuildConfig.STRIPE_PUBLISH_KEY
    )
    }
  2. Let the fragment extend PaymentSheetResultCallback
  3. Present the sheet stripePaymentSheet?.presentWithPaymentIntent(paymentIntentClientSecret = reference)
  4. Start a transaction and enter the correct card number and correct expiration date but the wrong CVV
  5. Observe that nothing happens. i.e. PaymentSheetResult.Failed is not received in override fun onPaymentSheetResult
    override fun onPaymentSheetResult(paymentSheetResult: PaymentSheetResult) {
    when (paymentSheetResult) {
        is PaymentSheetResult.Completed -> {
            // works fine
        }
        is PaymentSheetResult.Canceled -> {
            // works fine
        }
        is PaymentSheetResult.Failed -> {
            // Isn't received
        }
    }
    }

Android version

12

Impacted devices

Samsung Galaxy S21 5G

Installation method

Gradle dependency

Dependency Versions

implementation 'trustly.android.library:trustly-android-library:3.0.1'

SDK classes

import com.stripe.android.PaymentConfiguration
import com.stripe.android.paymentsheet.PaymentSheet
import com.stripe.android.paymentsheet.PaymentSheetResult
import com.stripe.android.paymentsheet.PaymentSheetResultCallback

Other information

I am testing in Sweden. I tested with a transaction of 500kr value so I was asked for bank id verification and after that no PaymentSheetResult.Failed was received. The flow:

  1. Enter correct card information with wrong CVV
  2. Press the continue button
  3. Observe you are directed to a web view to approve with bank id
  4. Observe you are directed back to the app with no callback received
brnunes-stripe commented 2 years ago

Hi @mehdisatei, That's the expected behavior. If the customer enters an invalid payment method, we'll show the error message in the PaymentSheet UI, and let them try again with a new payment method. You'll only receive a callback with PaymentSheetResult.Failed if the payment failed in some other part of flow and we couldn't recover from the failure. You'll receive the success/failed/canceled callback only once PaymentSheet has been dismissed. On the flow that you described, PaymentSheet remains open and the customer is able to try to complete the payment again, right?

brnunes-stripe commented 2 years ago

I'll close this as working as intended, please let us know if that's not the case.