Skip to content

Commit

Permalink
Merge pull request #863 from stripe/bg-clearcachedcustomer
Browse files Browse the repository at this point in the history
Always recreate loadingPromise when calling retryLoading
  • Loading branch information
bg-stripe authored Dec 18, 2017
2 parents ce4ba96 + f5ca98e commit f07bc03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* See MIGRATING.md for more information on any of the previously mentioned breaking API changes.
* Pre-built view controllers now layout properly on iPhone X in landscape orientation, respecting `safeAreaInsets`.
* `STPPaymentContext` now has a `largeTitleDisplayMode` property, which you can use to control the title display mode in the navigation bar of our pre-built view controllers.
* Fixes a bug where `STPPaymentContext`'s `retryLoading` method would not re-retrieve the customer object, even after calling `STPCustomerContext`'s `clearCachedCustomer` method.
* `STPPaymentContext`'s `retryLoading` method will now always attempt to retrieve a new customer object, regardless of whether a cached customer object is available. Previously, this method was only intended for recovery from a loading error; if a customer had already been retrieved, `retryLoading` would do nothing.

## 11.5.0 2017-11-09
* Adds a new helper method to `STPSourceParams` for creating reusable Alipay sources. [#811](https://github.com/stripe/stripe-ios/pull/811)
Expand Down
6 changes: 4 additions & 2 deletions Stripe/STPPaymentContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ - (instancetype)initWithAPIAdapter:(id<STPBackendAPIAdapter>)apiAdapter
}

- (void)retryLoading {
if (self.loadingPromise && self.loadingPromise.value) {
return;
// Clear any cached customer object before refetching
if ([self.apiAdapter isKindOfClass:[STPCustomerContext class]]) {
STPCustomerContext *customerContext = (STPCustomerContext *)self.apiAdapter;
[customerContext clearCachedCustomer];
}
WEAK(self);
self.loadingPromise = [[[STPPromise<STPPaymentMethodTuple *> new] onSuccess:^(STPPaymentMethodTuple *tuple) {
Expand Down

0 comments on commit f07bc03

Please sign in to comment.