Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BraintreeFragment to child FragmentManager #252

Closed
moia-zsolt opened this issue May 15, 2019 · 5 comments
Closed

BraintreeFragment to child FragmentManager #252

moia-zsolt opened this issue May 15, 2019 · 5 comments

Comments

@moia-zsolt
Copy link

General information

  • SDK/Library version: 2.22.0
  • Environment: all
  • Android Version and Device: n/a
  • Braintree dependencies:
  • com.braintreepayments.api:braintree:2.22.0

Issue description

Our application in general works with representing scenes with Fragments which are hosted by a single activity. As the customer navigates in the app, the scene Fragments are replaced in the Activity.

One of such Fragment is our 'checkout experience'. On this Fragment, we take care of using BraintreeFragment. The SDK only allows attaching the BraintreeFragment to the FragmentManager of the host Activity. As a result, when the customer leaves the checkout scene, the BraintreeFragment is still there.

We'd like to be able to attach BraintreeFragment to Fragment.getChildFragmentManager so that we don't have to be concerned about what remains there on the Activity when the customer leaves the checkout scene.

  • Question 1) Would you be able to provide a BraintreeFragment.newInstance overload that accepts a Fragment instead of Activity and attaches to the child FragmentManager?
  • Question 2) Would you be able to provide means of removing the attached BraintreeFragment? Or shall we simply use BraintreeFragment.TAG, still somewhat relying on what newInstance does internally?

I found #245 somewhat connected because of #245 (comment)

@moia-zsolt moia-zsolt changed the title BraintreeFragment to childFragmentManager BraintreeFragment to child FragmentManager May 15, 2019
@quinnjn
Copy link
Contributor

quinnjn commented May 15, 2019

Question 1) Would you be able to provide a BraintreeFragment.newInstance overload that accepts a Fragment instead of Activity and attaches to the child FragmentManager?

I think this is a reasonable ask, we can add the overloaded method! We'll do some investigation and get back to you, unless you're willing to open a PR!

I think this would be the signature to solve this request.

BraintreeFragment#newInstance(Context applicationContext, FragmentManager fragmentManager, String authorization)

Question 2) Would you be able to provide means of removing the attached BraintreeFragment? Or shall we simply use BraintreeFragment.TAG, still somewhat relying on what newInstance does internally?

I think this is also reasonable, but it may cause some confusion for integrators which means we may not want it added at this time.

BraintreeFragment depends heavily on being recreated payment methods that show UI. An example is PayPal browser switch, switching from the Activity to CCT to authorize PayPal, and then coming back to the merchant activity, intercepting the browser switch result.

I could see the fragment being accidentally removed and not re-attached for these cross app flows. I can play around with it though and see what happens!

Regardless, you can remove BraintreeFragment by the tag as you wish! Just caution that flows away from your app may depend on BraintreeFragment being available when resuming.

@moia-zsolt
Copy link
Author

unless you're willing to open a PR!

I definitely want to. (I expect early next week.)

@zsoltvilagos
Copy link
Contributor

@quinnjn Bit later but here's the pull request: #253

zsoltvilagos added a commit to zsoltvilagos/braintree_android that referenced this issue May 28, 2019
zsoltvilagos added a commit to zsoltvilagos/braintree_android that referenced this issue May 28, 2019
zsoltvilagos added a commit to zsoltvilagos/braintree_android that referenced this issue May 30, 2019
quinnjn added a commit that referenced this issue Jun 5, 2019
Issue #252 - BraintreeFragment with child FragmentManager.
@quinnjn
Copy link
Contributor

quinnjn commented Jun 5, 2019

Released in 3.1.0. Thanks again for the PR!

@quinnjn quinnjn closed this as completed Jun 5, 2019
@zsoltvilagos
Copy link
Contributor

Was my pleasure. Thx for the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants