#StevenBrown
1 messages · Page 1 of 1 (latest)
Which screen that you pressing back? Is it PaymentSheet?
That doesn't look like PaymentSheet. How are you integrating that screen?
It seem to completely under your control since you code that screen
I'm using stripe's components
private fun confirmPayment(clientSecret: String, stripePaymentMethodId: String) {
val confirmParams = ConfirmPaymentIntentParams.createWithPaymentMethodId(stripePaymentMethodId, clientSecret)
mClientSecret = clientSecret
context.lifecycleScope.launch {
paymentLauncher.confirm(confirmParams)
}
}
This is how I am using it
When you press the back button, do you observe this confirmPayment got cancelled midway? And by "cancelling my payment" where do you see it?
Yes it got cancelled. PaymentResult throws Failed.
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 -> {
paymentProcessed(false, context.getString(R.string.SdqLblPaymentFailed).localize(paymentResult.throwable.message), null)
}
When I press back, it takes me to the PaymentResult.Failed.
Okie I think it's the default behaviour of the paymentLauncher here. Sorry but I don't think the behaviour is customizable
Is there any alternative to avoid this thing?
Hi @remote violet I'm taking over, let me take a look.
Thanks for the waiting. I just checked the source code of StripePaymentLauncher. It's using ActivityResultLauncher to start the PaymentLauncherConfirmationActivity, and it would invoke finishWithResult(PaymentResult.Failed(it)) if the starterArgs is null.
I'd suggest you to put a breakpoint in this line https://github.com/stripe/stripe-android/blob/master/payments-core/src/main/java/com/stripe/android/payments/paymentlauncher/PaymentLauncherConfirmationActivity.kt#L46
Yeah I got it but I want to avoid this thing because payment is getting successful on my backend but shows me failed in my app.
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 -> {
paymentProcessed(false, context.getString(R.string.SdqLblPaymentFailed).localize(paymentResult.throwable.message), null)
}
}
}
This is how I am getting my PaymentResult.
paymentLauncher = PaymentLauncher.Companion.create(
context,
paymentConfiguration.publishableKey,
paymentConfiguration.stripeAccountId,
::onPaymentResult
)
Can you share with me the PaymentIntent ID?
pi_3LzbU9GaGNgvuGEK1TvmQsQC
My backend got the payment successfully but not my app, while pressing back during payment.
Did you get PaymentResult.Canceled or PaymentResult.Failed?
PaymentResult.Failed
Are you using the latest version of Android SDK? Based on the code, the SDK will return PaymentResult.Failed if starterArgs is null or PaymentIntent is unsuccessful.
Did you get a chance to place the breakpoint in the line and see if the execution stops there?
Yes I'm using latest version of Android SDK.
I did and it throws me the failed payment result.
ConfirmPayment works fine. It is just the result which throws me the error.
Did the breakpoint stop?
Yes on Failed
Just to clarify, the breakpoint stopped at finishWithResult(PaymentResult.Failed(it)) ? https://github.com/stripe/stripe-android/blob/master/payments-core/src/main/java/com/stripe/android/payments/paymentlauncher/PaymentLauncherConfirmationActivity.kt#L46
Ok let me check
No it works fine
I successfully got starterArgs
implementation 'com.stripe:stripe-android:20.15.3' This is latest version I am using right now
pm_1Lx42rGaGNgvuGEKAj13nmcw PaymentMethodId
OK, so it didn't stop at finishWithResult(PaymentResult.Failed(it)) ?
yes right
Hmm. I can't think of a solution right now. Can you create a issue in https://github.com/stripe/stripe-android/issues to directly discuss it with the stripe android SDK team?
Sure thanks for your time