Commit 9e50f380 by Brent Gulanowski

Lift conditional out of method into call sites.

parent fd81b6e6
...@@ -135,13 +135,17 @@ typedef void (^AddressUpdateCompletion)(PKPaymentAuthorizationStatus, NSArray<PK ...@@ -135,13 +135,17 @@ typedef void (^AddressUpdateCompletion)(PKPaymentAuthorizationStatus, NSArray<PK
-(void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingAddress:(ABRecordRef)address completion:(AddressUpdateCompletion)completion -(void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingAddress:(ABRecordRef)address completion:(AddressUpdateCompletion)completion
{ {
self.checkout.shippingAddress = [self buyAddressWithABRecord:address]; self.checkout.shippingAddress = [self buyAddressWithABRecord:address];
if ([self.checkout.shippingAddress isValidAddressForShippingRates]) {
[self updateCheckoutWithAddressCompletion:completion]; [self updateCheckoutWithAddressCompletion:completion];
}
} }
-(void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingContact:(PKContact *)contact completion:(AddressUpdateCompletion)completion -(void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingContact:(PKContact *)contact completion:(AddressUpdateCompletion)completion
{ {
self.checkout.shippingAddress = [self buyAddressWithContact:contact]; self.checkout.shippingAddress = [self buyAddressWithContact:contact];
if ([self.checkout.shippingAddress isValidAddressForShippingRates]) {
[self updateCheckoutWithAddressCompletion:completion]; [self updateCheckoutWithAddressCompletion:completion];
}
} }
-(void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingMethod:(PKShippingMethod *)shippingMethod completion:(void (^)(PKPaymentAuthorizationStatus, NSArray<PKPaymentSummaryItem *> * _Nonnull))completion -(void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingMethod:(PKShippingMethod *)shippingMethod completion:(void (^)(PKPaymentAuthorizationStatus, NSArray<PKPaymentSummaryItem *> * _Nonnull))completion
...@@ -171,7 +175,6 @@ typedef void (^AddressUpdateCompletion)(PKPaymentAuthorizationStatus, NSArray<PK ...@@ -171,7 +175,6 @@ typedef void (^AddressUpdateCompletion)(PKPaymentAuthorizationStatus, NSArray<PK
self.checkout.partialAddresses = @YES; self.checkout.partialAddresses = @YES;
} }
if ([self.checkout.shippingAddress isValidAddressForShippingRates]) {
[self.client updateCheckout:self.checkout completion:^(BUYCheckout *checkout, NSError *error) { [self.client updateCheckout:self.checkout completion:^(BUYCheckout *checkout, NSError *error) {
if (checkout && !error) { if (checkout && !error) {
self.checkout = checkout; self.checkout = checkout;
...@@ -187,10 +190,6 @@ typedef void (^AddressUpdateCompletion)(PKPaymentAuthorizationStatus, NSArray<PK ...@@ -187,10 +190,6 @@ typedef void (^AddressUpdateCompletion)(PKPaymentAuthorizationStatus, NSArray<PK
completion(PKPaymentAuthorizationStatusSuccess, @[], [self.checkout buy_summaryItemsWithShopName:self.shopName]); completion(PKPaymentAuthorizationStatusSuccess, @[], [self.checkout buy_summaryItemsWithShopName:self.shopName]);
} }
}]; }];
}
else {
completion(PKPaymentAuthorizationStatusInvalidShippingPostalAddress, @[], [self.checkout buy_summaryItemsWithShopName:self.shopName]);
}
} }
- (void)updateShippingRatesCompletion:(AddressUpdateCompletion)completion - (void)updateShippingRatesCompletion:(AddressUpdateCompletion)completion
......
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