Skip to content
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

Remove response parameter from STPCustomer method to update Sources with/without Apple Pay #1020

Merged
merged 3 commits into from
Sep 18, 2018

Conversation

danj-stripe
Copy link
Contributor

@danj-stripe danj-stripe commented Sep 5, 2018

Summary

Looks like a copy/paste error from f3b2d72 in #864.

STPCustomerContext holds onto a STPCustomer. There are three places
where it retrieves a new STPCustomer - and when it does it needs to
update the sources of that customer based on the
STPCustomerContext.includeApplePaySources boolean.

The bug is that we were using the old STPCustomer.allResponseFields
(via self.customer) instead of the allResponseFields property on the newly
retrieved STPCustomer object.

So, instead of allowing the caller to pass in the NSDictionary representing the response, just use the one that's already on our STPCustomer object that's being updated via self.allResponseFields inside the method.

Motivation

IOS-870

Testing

Extended the existing unit test to catch this failure, and then fixed it.

Looks like a copy/paste error from f3b2d72 in #864.

`STPCustomerContext` holds onto a `STPCustomer`. There are three places where it retrieves
a new `STPCustomer` - and when it does it needs to update the `sources` of that customer
based on the `STPCustomerContext.includeApplePaySources` boolean.

The bug is that we were using the *old* `STPCustomer.allResponseFields` (via
`self.customer`) instead of the `allResponseFields` property on the newly retrieved
`STPCustomer` object.

In isolation, it's a pretty obvious bug (once you know to look for it). There's no reason
we'd want to retrieve a Customer, and then use the response data for the previous object
to update the `sources`/`defaultSource` properties of the new one.

There is a fourth place that updates the sources, and that's inside
`setIncludeApplePaySources:`. In that case, we're updating the existing customer, and
using the existing customer's `allResponseFields`, so `self.customer.allResponseFields`
is correct there.
…d, use `allResponseFields` directly

Better fix than the previous commit. Instead of allowing the caller to pass in the
response dictionary (it might be the wrong one!) use the one in `allResponseFields`.
@stripe-ci stripe-ci removed the approved label Sep 5, 2018
@danj-stripe danj-stripe changed the title Use response from new STPCustomer object instead of previous one Remove response parameter from STPCustomer method to update Sources with/without Apple Pay Sep 5, 2018
@danj-stripe danj-stripe merged commit 46e99bb into master Sep 18, 2018
@danj-stripe danj-stripe deleted the danj/bugfix/changing-selected-source branch September 18, 2018 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants