#StevenBrown

1 messages · Page 1 of 1 (latest)

normal parcelBOT
austere mural
#

Which screen that you pressing back? Is it PaymentSheet?

austere mural
#

That doesn't look like PaymentSheet. How are you integrating that screen?

#

It seem to completely under your control since you code that screen

remote violet
#

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

austere mural
#

When you press the back button, do you observe this confirmPayment got cancelled midway? And by "cancelling my payment" where do you see it?

remote violet
#

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.

austere mural
#

Okie I think it's the default behaviour of the paymentLauncher here. Sorry but I don't think the behaviour is customizable

remote violet
#

Is there any alternative to avoid this thing?

tired python
#

Hi @remote violet I'm taking over, let me take a look.

remote violet
#

Hi there, thanks.

#

@tired python any help?

tired python
#

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.

remote violet
#

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
)

tired python
#

Can you share with me the PaymentIntent ID?

remote violet
#

pi_3LzbU9GaGNgvuGEK1TvmQsQC

#

My backend got the payment successfully but not my app, while pressing back during payment.

tired python
#

Did you get PaymentResult.Canceled or PaymentResult.Failed?

remote violet
#

PaymentResult.Failed

tired python
#

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?

remote violet
#

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.

tired python
#

Did the breakpoint stop?

remote violet
#

Yes on Failed

tired python
remote violet
#

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

tired python
#

OK, so it didn't stop at finishWithResult(PaymentResult.Failed(it)) ?

remote violet
#

yes right

tired python
remote violet
#

Sure thanks for your time