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

[BUG] 3ds window not opening on Android when using payment intent #9659

Open
derynia opened this issue Nov 19, 2024 · 0 comments
Open

[BUG] 3ds window not opening on Android when using payment intent #9659

derynia opened this issue Nov 19, 2024 · 0 comments
Labels

Comments

@derynia
Copy link

derynia commented Nov 19, 2024

Summary

I have the following problem, processing payment with 3ds card. My app uses Jetpack compose I have a payment screen. So I create a payment intent with new or saved card. Then I check if I need 3ds and start 3ds processing the following way:

Code to reproduce

@Composable
fun ThreeDSScreen(
    publishableKey: String,
    secret: String,
    onSuccess: () -> Unit,
    onCancel: () -> Unit,
    onFail: () -> Unit
) {
    val paymentLauncher = rememberPaymentLauncher(
        publishableKey = publishableKey,
        stripeAccountId = null,
        callback = PaymentResultCallback(
            onSuccess = onSuccess,
            onCancel = onCancel,
            onFail = onFail
        )
    )
    val needLaunch = remember { mutableStateOf(true) }

    LaunchedEffect(secret) {
        if (needLaunch.value) {
            needLaunch.value = false
            delay(200)
            paymentLauncher.confirm(
                ConfirmPaymentIntentParams.create(
                    clientSecret = secret,
                    paymentMethodType = PaymentMethod.Type.CardPresent
                )
            )
        }
    }
}

class PaymentResultCallback(
    private val onSuccess: () -> Unit,
    private val onCancel: () -> Unit,
    private val onFail: () -> Unit
) : PaymentLauncher.PaymentResultCallback {
    override fun onPaymentResult(paymentResult: PaymentResult) {
        when (paymentResult) {
            is PaymentResult.Completed -> { onSuccess() }
            is PaymentResult.Canceled -> { onCancel() }
            is PaymentResult.Failed -> { onFail() }
        }
    }
}

So everything works if I'm doing it first time. I create a card or use saved, I create a payment intent and get it's secret and then I call this code above. And the screen works fine.
But then I'm stopping app on 3ds confirmation screen. I rerun app and go to the Store menu in my app. When starting it checks payment intent and if it exists and requires confirmation I ask user whether he wants to retry. User press yes and stripe confirmation window starts opening and closes at once.
I'm getting Fail from Stripe. So I'm trying to cancel intent. In my example cancelling didn't succeeded. So I entered my store once again. Again it checks for pending payment intents. It asked again if I want to retry and from the second attempt Stripe confirmation window opened successfully.

Android version

All versions

Impacted devices

All deviices

Installation method

Build from Android studio

Dependency Versions

21.0.1

SDK classes

all SDK

Video

https://drive.google.com/file/d/1utr0448QR_-Qp8xJYFz5FjNnXyzx4yIo/view?usp=sharing

Other information

I use stripe test card 4000 0025 0000 3155

@derynia derynia added the bug label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant