There was a lot of logic that's currently duplicated across views or using the same type. This PR overall reduces the number of states used in the PayPal Demo app. It also includes refactors that can be used or duplicated across other demo apps. As necessary we can extract out portions of this code to be reused as we refactor the other portions of the demo app.
Summary of changes
Create CurrentState enum - this should be able to be shared in other demo features
Rename PayPalWebView to PayPalWebDemoView to reduce confusion with using the term "web view" - this is the entry point to the feature
Rename PayPalTransactionView to PayPalWebButtonsView - this view contains the PayPal buttons so the name did not accurately represent the contents of the view
Rename CreateOrderPayPalWebView to PayPalWebCreateOrderView to match other file naming conventions
Removed unneeded PayPalWebOrderCompletionView and PayPalWebState
Singular PayPalWebResultView can now be used vs the previous PayPalWebApprovalResultView, OrderCreatePayPalWebResultView, PayPalWebOrderCompletionResultView
Created new PayPalWebStatusView that contains logic for what to display based on the status vs having this in multiple views
Created new PayPalWebTransactionView which contains the view for authorizing/capturing an order (replaces PayPalWebOrderActionButton)
PayPalWebViewModel changes
Moved logic into the ViewModel directly where views didn't need to control logic for certain pieces of code - dumb views down where possible
Update logic as needed to update state as expected
Cleanup method signatures where possible
Future Considerations / Improvements
For the most part aside from updating labels this PR keeps the UI 1:1 with what exists today - we should consider if we want to improve the UI further in a future update or if this is our desired flow
For the PayPal Web flow do we need to display 3 buttons with 3 different funding sources or are we okay just demo-ing 1 button (on BT we have all 3 so may make sense to leave as is)
There are likely pieces of code that can be extracted out and shared among other features such as buttons - most of them add the same attributes so we can consider this in a future refactor
Once all features are complete we should clean up the file structure of each feature and ensure the demo app is well organized and easy to navigate
There are some classes that can be removed entirely like CustomButton and CustomTestField these are UIKit Views and no longer used at all in the Demo app - there are likely other things we can also consider cleaning up
Adding the TransactionOrder in viewModel on auth/capture order works as well to distinguish the last step.
Great job renaming the files, and consolidating the views!
Reason for changes
There was a lot of logic that's currently duplicated across views or using the same type. This PR overall reduces the number of states used in the PayPal Demo app. It also includes refactors that can be used or duplicated across other demo apps. As necessary we can extract out portions of this code to be reused as we refactor the other portions of the demo app.
Summary of changes
CurrentState
enum - this should be able to be shared in other demo featuresPayPalWebView
toPayPalWebDemoView
to reduce confusion with using the term "web view" - this is the entry point to the featurePayPalTransactionView
toPayPalWebButtonsView
- this view contains the PayPal buttons so the name did not accurately represent the contents of the viewCreateOrderPayPalWebView
toPayPalWebCreateOrderView
to match other file naming conventionsPayPalWebOrderCompletionView
andPayPalWebState
PayPalWebResultView
can now be used vs the previousPayPalWebApprovalResultView
,OrderCreatePayPalWebResultView
,PayPalWebOrderCompletionResultView
PayPalWebStatusView
that contains logic for what to display based on the status vs having this in multiple viewsPayPalWebTransactionView
which contains the view for authorizing/capturing an order (replacesPayPalWebOrderActionButton
)PayPalWebViewModel
changesFuture Considerations / Improvements
CustomButton
andCustomTestField
these are UIKit Views and no longer used at all in the Demo app - there are likely other things we can also consider cleaning upNext Steps
Checklist
Authors