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)
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 10
Google Pixel 2
Gradle - 'com.stripe:stripe-android:11.0.0'
minSdkVersion = 21
targetSdkVersion = 28
@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.
Awesome, Thanks @mshafrir-stripe for quick fix
Most helpful comment
@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.