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.
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
Send and decode CPMs from elements/sessions #4637
Send and decode CPMs from elements/sessions #4637
Changes from 8 commits
8e28569
c37ae34
57cd75f
ce447f3
08c2071
da98f63
e237445
4112f88
be0ac9c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Noting that all these properties (besides type) are intentionally optional, see an example response here for why: https://github.com/stripe/stripe-ios/pull/4637/files#diff-c71d9097e968f7c5fd01a4cb9425c80f53998412b3026808eca160f1ca08b35fR139
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.
(Just a comment, no changes required, but something to think about for the future:)
I verified that you have modeled this correctly based on there response object, but feels like we need to add a layer of abstraction or something -- e.g. if error is nil, then i'd expect
displayName
, logoUrland
isPreset` not to be nil -- and if error has a value, then i'd expect those other values to be nil.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.
What does it mean for isPreset to be nil vs false?
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.
Good question, I touched on it in this comment: #4637 (comment)
For more of an explanation though, this is optional based on the behavior of the backend. There are instances where the backend may not return us "is_preset" in the response so our model client-side needs to handle that. The case where isPreset is nil, is the case where there is no value specified by the backend. The goal of
CustomPaymentMethod
is to match the backend definition/behavior.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.
Why do we need to check both
response[customPaymentMethodDataKey] != nil
and!(response[customPaymentMethodDataKey] is NSNull)
?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.
If you look higher up in this function you will see we do this for external payment methods and customer. The reason is b/c:
Here is an example:
Case 1: Key doesn't exist (nil check)
Case 2:
We need to be able to handle both scenarios just to be safe.