-
Notifications
You must be signed in to change notification settings - Fork 663
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
Fix crash when switching between LPMs. #4921
Conversation
Diffuse output:
APK
DEX
|
Is it possible to add a test for this? |
@@ -101,11 +105,18 @@ internal abstract class BaseAddPaymentMethodFragment : Fragment() { | |||
sheetViewModel.eventReporter.onShowNewPaymentOptionForm() | |||
} | |||
|
|||
override fun onStop() { | |||
super.onStop() | |||
composeFragmentFieldValues?.cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like we may not be scoping the job correctly. Is it possible to scope the lifecycle of the job to this fragment rather than manually canceling the job?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@awush-stripe I moved the BaseSheetViewModel so it is accessible from the ComposeFormDataCollectionFragment. It was slightly akward as the VIewModel could be a PaymentSheetActivityViewModel or a PaymentOptionsActivityViewModel. It seems to work calling activityViewModels from onViewCreated, but would be curious to hear if there was a better way to handle this.
paymentsheet/src/main/java/com/stripe/android/paymentsheet/BaseAddPaymentMethodFragment.kt
Outdated
Show resolved
Hide resolved
paymentsheet/src/main/java/com/stripe/android/paymentsheet/BaseAddPaymentMethodFragment.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, just one comment
Summary
When switching between LPMs the form view model was reported collected fields for the new LPM even though all fields were not filled out. This resulted in the PaymentMethodCreateParameters to be wrongly created (it should not be created until all fields on the new LPM are complete), and causing the access of the last 4 of the card number to cause a crash.
Testing
Changelog