Apple Pay Custom Errors Implementation #1128
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this does
Since the SDK supports iOS 12 as a minimum right now, it was time to move away from Apple Pay iOS 10 delegate methods to iOS 11 delegate methods, this allows other developers to validate and provide custom errors through Apple Pay error objects such as
Instead of just showing "Shipping address is invalid", developers will be able to show specific error message which ultimately allows for a better customization when presenting Shopify's Apple Pay Modal.
This PR introduces breaking changes to
PaySessionDelegate
, all delegate methods now include extraerror
array inprovide
closures, and the final call which hascompleteTransaction
closure now has associated type on its failure case to include array of errors, in order to display them on the UI.PaySessionDelegate Changes
Incentive
While implementing Shopify's Apple Pay modal, a requirement was defined that I need to validate all the user inputs and display custom messages on the UI. There was no way except for forking this and rolling my own implementation. I suppose this will be helpful for other developers that would face the same challenge.
Code Design / Convention / Tests
The PR ensures that the new implementation does not break the design of the code, naming conventions and all tests are passing.