Menu

They closed checkout. That doesn’t mean the payment failed.
📰

They closed checkout. That doesn’t mean the payment failed.

DEV Community: android·Samya·about 8 hours ago
#U0yIFPJZ
#devtoandroid#devto#dev#purchase#payment
Reading 0:00
15s threshold

Someone opens the payment screen in your Android app, pauses, then closes it.

The app responds: “Payment failed.”

They may have simply changed their mind. Now the app is telling them something went wrong.

What did Google Play actually return?

Google Play Billing has a response for leaving the purchase flow: USER_CANCELED . Google lists it among the responses that do not indicate an error .

It tells you that the person left without completing the flow. It doesn’t tell you why.

The problem can start with a simple shortcut in the code: treating every non- OK response as a failed payment.

Give cancellation its own branch:

val purchasesUpdatedListener = PurchasesUpdatedListener { result , purchases -> setCheckoutLoading ( false )

when ( result . responseCode ) { BillingClient . BillingResponseCode . USER_CANCELED -> { recordCheckoutCanceled () // Leave the person free to browse. No payment-error alert. }

BillingClient . BillingResponseCode . OK -> { handlePurchaseUpdates ( purchases .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.