Forwarding apple pay presentation completion flag to the Stripe SDK client #1888
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.
Summary
Forwarding apple pay presentation completion boolean parameter to the top level
Motivation
There is a case (or many of them) when PKPaymentAuthorizationController will not be shown on a presentation attempt.
Apple docs have no clue about the underlying reason or how to determine the error description, but it may happen.
The problem with the current Stripe SDK wrapper around PKPaymentAuthorizationController is it hides this flag assuming the authorization controller will never fail to show.
The real-life example demonstrated the problems it lead to:
presentApplePay(completion:
) and locks its UI with some progress indicationapplePayContext(:didCompleteWith:error:)
applePayContext(:didCompleteWith:error:)
will never calledTesting
We have a physical device in the Stripe production environment where
applePayController.present
completion block returns a negative flag. We tested these changes within our app and verified it allow us to handle this case on the top level.Breaking changes
Clients who do not use completion closure are not affected.
Clients who rely on completion closure should update the current implementation either with a closure parameter placeholder or take the new flag into account and handle the negative case appropriately.
Other approaches
During implementation, we had two options
The first thought was to call
applePayContext(:didCompleteWith:error:)
wheneverapplePayController.present
sendsfalse
.The problem is - we have no information about the actual error since Apple never return one.
The second reason - this case stands out far away from
didAuthorizePayment
delegate call and there are should be reasons why the completion flag propagated separately in PassKit (besides the indifference). Looks like we should follow the same way.Notes and offtopic
Because it will mislead SDK users since it suggests there are maybe an error with a description but there are not