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

Payment gets failed on back press. #5771

Closed
TalverseZaidi opened this issue Nov 2, 2022 · 4 comments · Fixed by #5789
Closed

Payment gets failed on back press. #5771

TalverseZaidi opened this issue Nov 2, 2022 · 4 comments · Fixed by #5789
Assignees
Labels

Comments

@TalverseZaidi
Copy link

TalverseZaidi commented Nov 2, 2022

Hi there, I have a payment method of card whenever I do payment it shows a progress bar for processing and while showing progress bar If I presses the back button, it cancels my payment in the middle of processing, but it creates that payment on the backend successfully because confirmPayment is working fine and it is the PaymentResult which shows me the PaymentResult.Failed. I do not know why this is cancelling my payment.

I'm using latest version of the library 'com.stripe:stripe-android:20.15.3'

Android Version: all Android versions.

val paymentLauncher = PaymentLauncher.Companion.create(
            context,
            paymentConfiguration.publishableKey,
            paymentConfiguration.stripeAccountId,
            ::onPaymentResult
        )

 private fun onPaymentResult(paymentResult: PaymentResult) {
        when (paymentResult) {
            is PaymentResult.Completed -> {
                paymentProcessed(true, context.getString(R.string.SdqLblPaymentCompleted), mClientSecret)
            }
            is PaymentResult.Canceled -> {
                paymentProcessed(false, context.getString(R.string.SdqLblPaymentCancelled), null)
            }
            is PaymentResult.Failed -> {
                // This string comes from the PaymentIntent's error message.
                // See here: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-last_payment_error-message
                paymentProcessed(false, context.getString(R.string.SdqLblPaymentFailed).localize(paymentResult.throwable.message), null)            }
        }
    }
Record_2022-11-02-11-47-37_91b7eef251bde9b671e13dbeb083102a.mp4
@tillh-stripe
Copy link
Collaborator

Hi @TalverseZaidi 👋 Thanks for sending this in. I can understand the confusion.

For some context: When you call paymentLauncher.confirm(), we launch a transparent activity to confirm the intent and handle any authentication that might be required. Pressing the back button during intent confirmation closes that activity, and it reports back a failed payment result (even if the payment goes through on the backend).

This is admittedly not a great behavior. Let me check in with the team and figure out how we can best improve it.

@tillh-stripe tillh-stripe self-assigned this Nov 7, 2022
@TalverseZaidi
Copy link
Author

Hi @tillh-stripe 👋 Thanks for your understanding.
It's been a major issue for our release, and it is in pending with this issue. Because, in some way, if user cancels his payment while it is being processed, it will appear to have been cancelled even though the money has already been processed on the backend. Please make sure to find a solution as soon as you can so we can release our product.

@tillh-stripe
Copy link
Collaborator

Hi @TalverseZaidi, I merged a fix just now. It’ll be part of the next release (presumably 20.15.5) next week. Feel free to reach out again if other issues come up.

@TalverseZaidi
Copy link
Author

Hi @TalverseZaidi, I merged a fix just now. It’ll be part of the next release (presumably 20.15.5) next week. Feel free to reach out again if other issues come up.

Thank you so much for understanding the problem and to find a better solution in no time. Really appreciated 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants