Skip to content

Allow processing browser switch redirect without requiring an Activity instance #941

@erawhctim

Description

@erawhctim

Is your feature request related to a problem? Please describe.

The problem is a scoping issue: PayPalClient is effective Activity-scoped, since it needs an Activity reference in its constructor, but onBrowserSwitchResult() doesn't actually need an Activity reference at all and could be Application-scoped.

Describe the solution you'd like.

I'd like to separate concerns of the PayPalClient (and it's underlying dependencies, BraintreeClient and BrowserSwitchClient) a bit so that I can call PayPalClient.onBrowserSwitchResult() without requiring an Activity instance.
From what I can tell, BraintreeClient and BrowserSwitchClient can both satisfy the needs of onBrowserSwitchResult() with only a Context reference (since they end up calling Context.getApplicationContext() internally), but since is routed through the PayPalClient, there's no way to call onBrowserSwitchResult() today without requiring an Activity.

If I could just construct a BraintreeClient and call BraintreeClient.onBrowserSwitchResult() directly, that would work (but that function is restricted/internal).

My use case revolves around certain UI screens that observe the results of the browser redirect being re-used in multiple Activities, depending on which app flow originated the PayPal account creation flow. I would prefer to handle the browser redirects and forward them into the SDK in one place (in a BroadcastReceiver or some other Application-scoped object) instead of configuring the browser redirect to work with multiple Activities, but that doesn't seem possible today.

My ideal solution(s):

  1. Separate out the onBrowserSwitchResult() part of the PayPayClient into some new object (e.g. PayPalBrowserRedirectClient) that only requires a Context
  2. Keep PayPalClient as-is, and offer a different way to send browser redirect results into the BraintreeClient or its underlying BrowserSwitchClient

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