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

Fix an STPURLCallbackListener retain cycle. #846

Merged
merged 4 commits into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ env:
- TEST_TYPE=installation_carthage
- TEST_TYPE=installation_cocoapods
- TEST_TYPE=installation_cocoapods_frameworks
- TEST_TYPE=lint
# Fauxpas 1.7.2 does not build our project correctly https://bitbucket.org/ali_rantakari/faux-pas/issues/117/unrecoverable-compiler-error-translation
# - TEST_TYPE=lint
- TEST_TYPE=tests
- TEST_TYPE=analyzer
- TEST_TYPE=documentation
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 12.0.0 2017-12-XX
* `STPRedirectContext` will no longer retain itself for the duration of the redirect, you must explicitly maintain a reference to it yourself. If you
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incomplete :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh weird. I typed more stuff locally into Atom and it seems to not have saved the file before I comitted -_- Will fix


## 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)
* Silences spurious availability warnings when using Xcode9 [#823](https://github.com/stripe/stripe-ios/pull/823)
Expand Down
3 changes: 3 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Migration Guides

### Migrating from versions < 12.0.0
* `STPRedirectContext` will no longer retain itself for the duration of the redirect. If you were relying on this functionality, you must change your code to explicitly maintain a reference to it.

### Migrating from versions < 11.4.0
* The `STPBackendAPIAdapter` protocol and all associated methods are no longer deprecated. We still recommend using `STPCustomerContext` to update a Stripe customer object on your behalf, rather than using your own implementation of `STPBackendAPIAdapter`.

Expand Down
13 changes: 6 additions & 7 deletions Stripe/PublicHeaders/STPRedirectContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ typedef void (^STPRedirectContextCompletionBlock)(NSString *sourceID, NSString *
/**
This is a helper class for handling redirect sources.

Init an instance with the redirect flow source you want to handle,
Init and retain an instance with the redirect flow source you want to handle,
then choose a redirect method. The context will fire the completion handler
when the redirect completes.

Expand All @@ -64,13 +64,12 @@ typedef void (^STPRedirectContextCompletionBlock)(NSString *sourceID, NSString *
However, it is possible the when the redirect is "completed", the user may
have not actually completed the necessary actions to authorize the charge.

You can use `STPAPIClient` to listen for state changes on the source
object as a way to identify whether the user action succeeded or not.
@see `[STPAPIClient startPollingSourceWithId:clientSecret:timeout:completion:]`

You should not use either this class, nor `STPAPIClient`, as a way
to determine when you should charge the source. Use Stripe webhooks on your
backend server to listen for source state changes and to make the charge.
to determine when you should charge the source or to determine if the redirect
was successful. Use Stripe webhooks on your backend server to listen for source
state changes and to make the charge.

See https://stripe.com/docs/sources/best-practices
*/
NS_EXTENSION_UNAVAILABLE("Redirect based sources are not available in extensions")
@interface STPRedirectContext : NSObject
Expand Down
2 changes: 2 additions & 0 deletions Stripe/STPRedirectContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ - (void)performAppRedirectIfPossibleWithCompletion:(STPBoolCompletionBlock)onCom
- (void)startRedirectFlowFromViewController:(UIViewController *)presentingViewController {
FAUXPAS_IGNORED_IN_METHOD(APIAvailability)

WEAK(self)
[self performAppRedirectIfPossibleWithCompletion:^(BOOL success) {
if (!success) {
STRONG(self)
if ([SFSafariViewController class] != nil) {
[self startSafariViewControllerRedirectFlowFromViewController:presentingViewController];
}
Expand Down
2 changes: 1 addition & 1 deletion Stripe/STPURLCallbackHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ + (BOOL)handleStripeURLCallbackWithURL:(NSURL *)url FAUXPAS_IGNORED_ON_LINE(Unus

@interface STPURLCallback : NSObject
@property (nonatomic) NSURLComponents *urlComponents;
@property (nonatomic) id<STPURLCallbackListener> listener;
@property (nonatomic, weak) id<STPURLCallbackListener> listener;
@end

@implementation STPURLCallback
Expand Down