Skip to content

No callback when user closes browser via X button #399

@RicardoDS-Paydock

Description

@RicardoDS-Paydock

PayPal Android SDK Version

2.3.0

Environment

Sandbox

Android Version & Device

Google Pixel 8 Pro API 34

PayPal dependencies

gradle/libs.versions.toml

[versions]
paypalWebPayments = "2.3.0"

[libraries]
paypal-web-payments = { module = "com.paypal.android:paypal-web-payments", version.ref = "paypalWebPayments" }

Describe the bug

When users taps the X button in the Chrome Custom Tab toolbar to close the browser during the PayPal checkout/vault flow, there is no callback or indication that the user has abandoned the flow. The activity simply resumes with onResume() but with no way to distinguish this from normal app minimization (e.g., user pressing home button).

The problem:

Without a way to detect browser dismissal, we were are unable to detect/determine if the SDK has been closed or minimised etc

Attempted workaround:

We have created a workaround to compensate for this in the onResume():

// Handles default PayPal SDK intent callbacks)
override fun onNewIntent(intent: Intent) {
    super.onNewIntent(intent)
    setIntent(intent)
    viewModel.handleDeeplinkResult(this, intent)
}

// Workaround to cater for SDK browser closing
override fun onResume() {
    super.onResume()
    // Check if returning without deep link
    if (hasStartedCheckout && intent?.data == null) {
        finishWithCancellation() // Treat as user cancellation
    }
}

Why this doesn't work:

This approach incorrectly triggers cancellation when users simply minimize the app (press home) and later return to it, causing false cancellations and interrupting legitimate flows.

To reproduce

  1. Launch the PayPal checkout/vault flow
  2. Chrome Custom Tab opens with PayPal login/payment page
  3. Click the X button in the browser toolbar (top-left on Android)
  4. Browser closes, app resumes
  5. Observe: No callbacks triggered ie. onNewIntent() etc

Expected behavior

The expected behaviour is for this to work the same way we handle the "Cancel and Return to Store" flow.

SDK provides a callback or result when the browser is dismissed via X button (similar to how the "Cancel and Return to Store" flow is handled

Screenshots

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions