Commit 6940a665 by Rune Madsen

addressing comments

parent d90063d5
...@@ -196,11 +196,11 @@ NSString * const MerchantId = @""; ...@@ -196,11 +196,11 @@ NSString * const MerchantId = @"";
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller
{ {
[self getCompletedCheckout:^{ [self getCompletedCheckout:^{
dispatch_async(dispatch_get_main_queue(), ^{
if (self.checkout.order) { if (self.checkout.order) {
dispatch_async(dispatch_get_main_queue(), ^{
[self showCheckoutConfirmation]; [self showCheckoutConfirmation];
}
}); });
}
}]; }];
} }
...@@ -314,9 +314,7 @@ NSString * const MerchantId = @""; ...@@ -314,9 +314,7 @@ NSString * const MerchantId = @"";
[self.applePayHelper paymentAuthorizationViewController:controller didAuthorizePayment:payment completion:completion]; [self.applePayHelper paymentAuthorizationViewController:controller didAuthorizePayment:payment completion:completion];
self.checkout = self.applePayHelper.checkout; self.checkout = self.applePayHelper.checkout;
[self getCompletedCheckout:^{ [self getCompletedCheckout:NULL];
}];
} }
- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller - (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller
...@@ -366,9 +364,23 @@ NSString * const MerchantId = @""; ...@@ -366,9 +364,23 @@ NSString * const MerchantId = @"";
{ {
NSURL *url = notification.userInfo[@"url"]; NSURL *url = notification.userInfo[@"url"];
if ([self.presentedViewController isKindOfClass:[SFSafariViewController class]]) {
[self dismissViewControllerAnimated:self.presentedViewController completion:^{
[self getCompletionStatusAndCompletedCheckoutWithURL:url];
}];
} else {
[self getCompletionStatusAndCompletedCheckoutWithURL:url];
}
[[NSNotificationCenter defaultCenter] removeObserver:self name:CheckoutCallbackNotification object:nil];
}
- (void)getCompletionStatusAndCompletedCheckoutWithURL:(NSURL*)url
{
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
__weak CheckoutViewController *welf = self; __weak CheckoutViewController *welf = self;
void (^completionBlock)() = ^void() {
[self.client getCompletionStatusOfCheckoutURL:url completion:^(BUYStatus status, NSError *error) { [self.client getCompletionStatusOfCheckoutURL:url completion:^(BUYStatus status, NSError *error) {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
...@@ -385,17 +397,6 @@ NSString * const MerchantId = @""; ...@@ -385,17 +397,6 @@ NSString * const MerchantId = @"";
NSLog(@"Error completing checkout: %@", error); NSLog(@"Error completing checkout: %@", error);
} }
}]; }];
};
if ([self.presentedViewController isKindOfClass:[SFSafariViewController class]]) {
[self dismissViewControllerAnimated:self.presentedViewController completion:completionBlock];
} else {
completionBlock();
}
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
[[NSNotificationCenter defaultCenter] removeObserver:self name:CheckoutCallbackNotification object:nil];
} }
- (void)getCompletedCheckout:(void (^)(void))completionBlock - (void)getCompletedCheckout:(void (^)(void))completionBlock
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment