Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashed on pressing double back key on 3DS 2.0 UI #1517

Closed
msimar opened this issue Sep 11, 2019 · 2 comments · Fixed by #1518
Closed

App crashed on pressing double back key on 3DS 2.0 UI #1517

msimar opened this issue Sep 11, 2019 · 2 comments · Fixed by #1518
Assignees
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally

Comments

@msimar
Copy link

msimar commented Sep 11, 2019

Summary

App crashed on pressing double back key on 3DS 2.0 UI, 3DS 1.0 UI work as usual.

3DS 2.0 Card with Error:
4000 0000 0000 3220 3DS 2.0 UI (latest version of 3DS)

3DS 1.0 Card with working ok:
4000 0000 0000 3063 3DS 1.0 UI (old version of 3DS)

Code to reproduce

Since, it is related to payments, and there are many blocks which tied to our backend, it is hard to provide sample app. Snippets as follows:

class PurchaseDialogFragment : DialogFragment() {

  @Inject
  lateinit var stripe: Stripe

  /**
   * Booking created with state as PENDING
   **/
  fun onBookingCreated(clientSecret: String) {
    confirmPayment(
      ConfirmPaymentIntentParams.create(
        clientSecret,
        PurchaseDialogFragment.PAYMENT_INTENT_RETURN_URL
      )
    )
  }

  private fun confirmPayment(params: ConfirmPaymentIntentParams) {
    stripe.confirmPayment(this, params.buildUiCustomization())
  }

/**
   * Build UI customization for payment auth flow for Stripe (extension utility)
   */
  fun ConfirmPaymentIntentParams.buildUiCustomization(): ConfirmPaymentIntentParams {
    // Optional: customize the payment authentication experience
    val uiCustomization = PaymentAuthConfig.Stripe3ds2UiCustomization.Builder().build()
    PaymentAuthConfig.init(
      PaymentAuthConfig.Builder()
        .set3ds2Config(
          PaymentAuthConfig.Stripe3ds2Config.Builder()
            // set a 5 minute timeout for challenge flow
            .setTimeout(5)
            // customize the UI of the challenge flow
            .setUiCustomization(uiCustomization)
            .build()
        )
        .build()
    )
    return this
  }

  override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    // Stripe listener
    stripe.onPaymentResult(requestCode, data,
      object : ApiResultCallback<PaymentIntentResult> {
        override fun onSuccess(result: PaymentIntentResult) {
          // handle success
        }

        override fun onError(e: Exception) {
          // handle error
        }
      })
  }
}

Crash logs:

java.lang.IllegalStateException: Fragment PurchaseDialogFragment{dfab8f4 (b3b14291-9d45-4fb7-b0e2-a8bbc4bc9733)} not attached to Activity
        at androidx.fragment.app.Fragment.startActivityForResult(Fragment.java:1195)
        at androidx.fragment.app.Fragment.startActivityForResult(Fragment.java:1185)
        at com.stripe.android.view.AuthActivityStarter$Host.startActivityForResult(AuthActivityStarter.kt:29)
        at com.stripe.android.Stripe3ds2CompletionStarter.start(Stripe3ds2CompletionStarter.kt:20)
        at com.stripe.android.PaymentController$PaymentAuth3ds2ChallengeStatusReceiver$Companion$createComplete3ds2AuthCallbackFactory$1$create$1.onSuccess(PaymentController.kt:642)
        at com.stripe.android.PaymentController$PaymentAuth3ds2ChallengeStatusReceiver$Companion$createComplete3ds2AuthCallbackFactory$1$create$1.onSuccess(PaymentController.kt:640)
        at com.stripe.android.ApiOperation.onPostExecute(ApiOperation.java:33)
        at com.stripe.android.ApiOperation.onPostExecute(ApiOperation.java:12)
        at android.os.AsyncTask.finish(AsyncTask.java:755)
        at android.os.AsyncTask.access$900(AsyncTask.java:192)
        at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)

Android version

Android 10

Impacted devices

Google Pixel 2

Installation method

Gradle - 'com.stripe:stripe-android:11.0.0'

SDK version

minSdkVersion = 21
targetSdkVersion = 28

Other information

@msimar msimar changed the title 3DS 2.0 UI crashing app on double back App crashed on pressing double back key on 3DS 2.0 UI Sep 11, 2019
@mshafrir-stripe
Copy link
Collaborator

@msimar thanks for filing. I was able to reproduce this crash. It looks like it only happens with Fragments, not Activities. I'll post a fix shortly.

mshafrir-stripe added a commit that referenced this issue Sep 11, 2019
Check that the fragment is attached before calling
`startActivityForResult()`.

Fixes #1517
@mshafrir-stripe mshafrir-stripe added the triaged Issue has been reviewed by Stripe and is being tracked internally label Sep 11, 2019
@mshafrir-stripe mshafrir-stripe self-assigned this Sep 11, 2019
@msimar
Copy link
Author

msimar commented Sep 11, 2019

Awesome, Thanks @mshafrir-stripe for quick fix

mshafrir-stripe added a commit that referenced this issue Sep 11, 2019
Check that the fragment is attached before calling
`startActivityForResult()`.

Fixes #1517
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants