diff --git a/Braintree3DSecure/BTThreeDSecureAuthenticationViewController.m b/Braintree3DSecure/BTThreeDSecureAuthenticationViewController.m index 918cfaa856..b455c0bcd6 100644 --- a/Braintree3DSecure/BTThreeDSecureAuthenticationViewController.m +++ b/Braintree3DSecure/BTThreeDSecureAuthenticationViewController.m @@ -81,10 +81,10 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *) BTJSON *authBody = [[BTJSON alloc] initWithValue:[NSJSONSerialization JSONObjectWithData:[jsonAuthResponse dataUsingEncoding:NSUTF8StringEncoding] options:0 error:NULL]]; BTThreeDSecureResponse *authResponse = [[BTThreeDSecureResponse alloc] init]; - authResponse.success = authBody[@"success"].isTrue; - authResponse.threeDSecureInfo = authBody[@"threeDSecureInfo"].asDictionary; + authResponse.success = [authBody[@"success"] isTrue]; + authResponse.threeDSecureInfo = [authBody[@"threeDSecureInfo"] asDictionary]; authResponse.tokenizedCard = [BTThreeDSecureCardNonce cardNonceWithJSON:authBody[@"paymentMethod"]]; - authResponse.errorMessage = authBody[@"error"][@"message"].asString; + authResponse.errorMessage = [authBody[@"error"][@"message"] asString]; [self didCompleteAuthentication:authResponse]; diff --git a/Braintree3DSecure/BTThreeDSecureCardNonce.m b/Braintree3DSecure/BTThreeDSecureCardNonce.m index cb1af3fe10..d911b990b2 100644 --- a/Braintree3DSecure/BTThreeDSecureCardNonce.m +++ b/Braintree3DSecure/BTThreeDSecureCardNonce.m @@ -34,11 +34,11 @@ + (instancetype)cardNonceWithJSON:(BTJSON *)cardJSON { } - (BOOL)liabilityShifted { - return self.threeDSecureJSON[@"liabilityShifted"].isTrue; + return [self.threeDSecureJSON[@"liabilityShifted"] isTrue]; } - (BOOL)liabilityShiftPossible { - return self.threeDSecureJSON[@"liabilityShiftPossible"].isTrue; + return [self.threeDSecureJSON[@"liabilityShiftPossible"] isTrue]; } @end diff --git a/Braintree3DSecure/BTThreeDSecureDriver.m b/Braintree3DSecure/BTThreeDSecureDriver.m index 7129cd9bac..1d8190fd32 100644 --- a/Braintree3DSecure/BTThreeDSecureDriver.m +++ b/Braintree3DSecure/BTThreeDSecureDriver.m @@ -97,7 +97,7 @@ - (void)lookupThreeDSecureForNonce:(NSString *)nonce NSMutableDictionary *requestParameters = [@{ @"amount": amount } mutableCopy]; if (configuration.json[@"merchantAccountId"]) { - requestParameters[@"merchant_account_id"] = configuration.json[@"merchantAccountId"].asString; + requestParameters[@"merchant_account_id"] = [configuration.json[@"merchantAccountId"] asString]; } NSString *urlSafeNonce = [nonce stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; [self.apiClient POST:[NSString stringWithFormat:@"v1/payment_methods/%@/three_d_secure/lookup", urlSafeNonce] @@ -113,14 +113,14 @@ - (void)lookupThreeDSecureForNonce:(NSString *)nonce NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; BTJSON *errorBody = error.userInfo[BTHTTPJSONResponseBodyKey]; - if (errorBody[@"error"][@"message"].isString) { - userInfo[NSLocalizedDescriptionKey] = errorBody[@"error"][@"message"].asString; + if ([errorBody[@"error"][@"message"] isString]) { + userInfo[NSLocalizedDescriptionKey] = [errorBody[@"error"][@"message"] asString]; } - if (errorBody[@"threeDSecureInfo"].isObject) { - userInfo[BTThreeDSecureInfoKey] = errorBody[@"threeDSecureInfo"].asDictionary; + if ([errorBody[@"threeDSecureInfo"] isObject]) { + userInfo[BTThreeDSecureInfoKey] = [errorBody[@"threeDSecureInfo"] asDictionary]; } - if (errorBody[@"error"].isObject) { - userInfo[BTThreeDSecureValidationErrorsKey] = errorBody[@"error"].asDictionary; + if ([errorBody[@"error"] isObject]) { + userInfo[BTThreeDSecureValidationErrorsKey] = [errorBody[@"error"] asDictionary]; } error = [NSError errorWithDomain:BTThreeDSecureErrorDomain @@ -135,10 +135,10 @@ - (void)lookupThreeDSecureForNonce:(NSString *)nonce BTJSON *lookupJSON = body[@"lookup"]; BTThreeDSecureLookupResult *lookup = [[BTThreeDSecureLookupResult alloc] init]; - lookup.acsURL = lookupJSON[@"acsUrl"].asURL; - lookup.PAReq = lookupJSON[@"pareq"].asString; - lookup.MD = lookupJSON[@"md"].asString; - lookup.termURL = lookupJSON[@"termUrl"].asURL; + lookup.acsURL = [lookupJSON[@"acsUrl"] asURL]; + lookup.PAReq = [lookupJSON[@"pareq"] asString]; + lookup.MD = [lookupJSON[@"md"] asString]; + lookup.termURL = [lookupJSON[@"termUrl"] asURL]; lookup.tokenizedCard = [BTThreeDSecureCardNonce cardNonceWithJSON:body[@"paymentMethod"]]; completionBlock(lookup, nil); diff --git a/BraintreeApplePay/BTApplePayClient.m b/BraintreeApplePay/BTApplePayClient.m index 8815a3d98c..de1c6dbee4 100644 --- a/BraintreeApplePay/BTApplePayClient.m +++ b/BraintreeApplePay/BTApplePayClient.m @@ -18,8 +18,8 @@ @implementation BTApplePayClient + (void)load { if (self == [BTApplePayClient class]) { [[BTPaymentMethodNonceParser sharedParser] registerType:@"ApplePayCard" withParsingBlock:^BTPaymentMethodNonce * _Nullable(BTJSON * _Nonnull applePayCard) { - NSString *cardType = applePayCard[@"details"][@"cardType"] ? applePayCard[@"details"][@"cardType"].asString : @"ApplePayCard"; - return [[BTApplePayCardNonce alloc] initWithNonce:applePayCard[@"nonce"].asString localizedDescription:applePayCard[@"description"].asString type:cardType]; + NSString *cardType = applePayCard[@"details"][@"cardType"] ? [applePayCard[@"details"][@"cardType"] asString] : @"ApplePayCard"; + return [[BTApplePayCardNonce alloc] initWithNonce:[applePayCard[@"nonce"] asString] localizedDescription:[applePayCard[@"description"] asString] type:cardType]; }]; } } @@ -62,8 +62,8 @@ - (void)tokenizeApplePayPayment:(PKPayment *)payment completion:(void (^)(BTAppl return; } - if (!configuration.json[@"applePay"][@"status"].isString || - [configuration.json[@"applePay"][@"status"].asString isEqualToString:@"off"]) { + if (![configuration.json[@"applePay"][@"status"] isString] || + [[configuration.json[@"applePay"][@"status"] asString] isEqualToString:@"off"]) { NSError *error = [NSError errorWithDomain:BTApplePayErrorDomain code:BTApplePayErrorTypeUnsupported userInfo:@{ NSLocalizedDescriptionKey: @"Apple Pay is not enabled for this merchant. Please ensure that Apple Pay is enabled in the control panel and then try saving an Apple Pay payment method again." }]; @@ -90,8 +90,8 @@ - (void)tokenizeApplePayPayment:(PKPayment *)payment completion:(void (^)(BTAppl } BTJSON *applePayCard = body[@"applePayCards"][0]; - NSString *cardType = applePayCard[@"details"][@"cardType"] ? applePayCard[@"details"][@"cardType"].asString : @"ApplePayCard"; - BTApplePayCardNonce *tokenized = [[BTApplePayCardNonce alloc] initWithNonce:applePayCard[@"nonce"].asString localizedDescription:applePayCard[@"description"].asString type:cardType]; + NSString *cardType = applePayCard[@"details"][@"cardType"] ? [applePayCard[@"details"][@"cardType"] asString] : @"ApplePayCard"; + BTApplePayCardNonce *tokenized = [[BTApplePayCardNonce alloc] initWithNonce:[applePayCard[@"nonce"] asString] localizedDescription:[applePayCard[@"description"] asString] type:cardType]; completionBlock(tokenized, nil); [self.apiClient sendAnalyticsEvent:@"ios.apple-pay.success"]; diff --git a/BraintreeApplePay/BTConfiguration+ApplePay.m b/BraintreeApplePay/BTConfiguration+ApplePay.m index 6969eefb00..ed3633b8df 100644 --- a/BraintreeApplePay/BTConfiguration+ApplePay.m +++ b/BraintreeApplePay/BTConfiguration+ApplePay.m @@ -4,7 +4,7 @@ @implementation BTConfiguration (ApplePay) - (BOOL)isApplePayEnabled { BTJSON *applePayConfiguration = self.json[@"applePay"]; - return applePayConfiguration[@"status"].isString && ![applePayConfiguration[@"status"].asString isEqualToString:@"off"]; + return [applePayConfiguration[@"status"] isString] && ![[applePayConfiguration[@"status"] asString] isEqualToString:@"off"]; } @end diff --git a/BraintreeCard/BTCardNonce.m b/BraintreeCard/BTCardNonce.m index 46d85eaf38..07b8041d0f 100644 --- a/BraintreeCard/BTCardNonce.m +++ b/BraintreeCard/BTCardNonce.m @@ -49,9 +49,9 @@ + (NSString *)stringFromCardNetwork:(BTCardNetwork)cardNetwork { + (instancetype)cardNonceWithJSON:(BTJSON *)cardJSON { // Normalize the card network string in cardJSON to be lowercase so that our enum mapping is case insensitive - BTJSON *cardType = [[BTJSON alloc] initWithValue:cardJSON[@"details"][@"cardType"].asString.lowercaseString]; - return [[[self class] alloc] initWithNonce:cardJSON[@"nonce"].asString - description:cardJSON[@"description"].asString + BTJSON *cardType = [[BTJSON alloc] initWithValue:[cardJSON[@"details"][@"cardType"] asString].lowercaseString]; + return [[[self class] alloc] initWithNonce:[cardJSON[@"nonce"] asString] + description:[cardJSON[@"description"] asString] cardNetwork:[cardType asEnum:@{ @"american express": @(BTCardNetworkAMEX), @"diners club": @(BTCardNetworkDinersClub), @@ -66,7 +66,7 @@ + (instancetype)cardNonceWithJSON:(BTJSON *)cardJSON { @"uk maestro": @(BTCardNetworkUKMaestro), @"visa": @(BTCardNetworkVisa),} orDefault:BTCardNetworkUnknown] - lastTwo:cardJSON[@"details"][@"lastTwo"].asString]; + lastTwo:[cardJSON[@"details"][@"lastTwo"] asString]]; } @end diff --git a/BraintreeCore/BTAPIClient.m b/BraintreeCore/BTAPIClient.m index 3d8d4ab4e9..cddfa327e8 100644 --- a/BraintreeCore/BTAPIClient.m +++ b/BraintreeCore/BTAPIClient.m @@ -40,7 +40,7 @@ - (nullable instancetype)initWithAuthorization:(NSString *)authorization { return nil; } - NSURL *baseURL = self.clientToken.json[@"clientApiUrl"].asURL; + NSURL *baseURL = [self.clientToken.json[@"clientApiUrl"] asURL]; _http = [[BTHTTP alloc] initWithBaseURL:baseURL authorizationFingerprint:self.clientToken.authorizationFingerprint]; [self sendAnalyticsEvent:@"ios.started.client-token"]; @@ -210,7 +210,7 @@ - (void)sendAnalyticsEvent:(NSString *)eventKind completion:(void(^)(NSError *er return; } - NSURL *analyticsURL = configuration.json[@"analytics"][@"url"].asURL; + NSURL *analyticsURL = [configuration.json[@"analytics"][@"url"] asURL]; if (analyticsURL) { if (!self.analyticsHttp) { if (self.clientToken) { diff --git a/BraintreeCore/BTClientToken.m b/BraintreeCore/BTClientToken.m index 80196f031b..d0c1af1509 100644 --- a/BraintreeCore/BTClientToken.m +++ b/BraintreeCore/BTClientToken.m @@ -24,8 +24,8 @@ - (instancetype)initWithClientToken:(NSString *)clientToken error:(NSError * __a if (self = [super init]) { // Client token must be decoded first because the other values are retrieved from it _json = [self decodeClientToken:clientToken error:error]; - _authorizationFingerprint = _json[BTClientTokenKeyAuthorizationFingerprint].asString; - _configURL = _json[BTClientTokenKeyConfigURL].asURL; + _authorizationFingerprint = [_json[BTClientTokenKeyAuthorizationFingerprint] asString]; + _configURL = [_json[BTClientTokenKeyConfigURL] asURL]; _originalValue = clientToken; if (![self validateClientToken:error]) { diff --git a/BraintreeCore/BTHTTP.m b/BraintreeCore/BTHTTP.m index 61b2953698..85e8c18531 100644 --- a/BraintreeCore/BTHTTP.m +++ b/BraintreeCore/BTHTTP.m @@ -58,7 +58,7 @@ - (instancetype)initWithBaseURL:(nonnull NSURL *)URL tokenizationKey:(nonnull NS } - (instancetype)initWithClientToken:(BTClientToken *)clientToken { - return [self initWithBaseURL:clientToken.json[@"clientApiUrl"].asURL authorizationFingerprint:clientToken.authorizationFingerprint]; + return [self initWithBaseURL:[clientToken.json[@"clientApiUrl"] asURL] authorizationFingerprint:clientToken.authorizationFingerprint]; } - (instancetype)copyWithZone:(NSZone *)zone { diff --git a/BraintreeCore/BTPaymentMethodNonceParser.m b/BraintreeCore/BTPaymentMethodNonceParser.m index c4b64823b8..39dde31252 100644 --- a/BraintreeCore/BTPaymentMethodNonceParser.m +++ b/BraintreeCore/BTPaymentMethodNonceParser.m @@ -51,8 +51,8 @@ - (BTPaymentMethodNonce *)parseJSON:(BTJSON *)json withParsingBlockForType:(NSSt return block(json); } // Unregistered types should fall back to parsing basic nonce and description from JSON - if (!json[@"nonce"].isString) return nil; - return [[BTPaymentMethodNonce alloc] initWithNonce:json[@"nonce"].asString localizedDescription:json[@"description"].asString]; + if (![json[@"nonce"] isString]) return nil; + return [[BTPaymentMethodNonce alloc] initWithNonce:[json[@"nonce"] asString] localizedDescription:[json[@"description"] asString]]; } @end diff --git a/BraintreeCore/Public/BTJSON.h b/BraintreeCore/Public/BTJSON.h index d1ee05cceb..81113cf6cf 100644 --- a/BraintreeCore/Public/BTJSON.h +++ b/BraintreeCore/Public/BTJSON.h @@ -62,7 +62,7 @@ typedef NS_ENUM(NSInteger, BTJSONErrorCode) { /// Indexes into the JSON as if the current value is an object /// /// Notably, this method will always return successfully; however, if the value is not an object, the JSON will wrap an error. -- (BTJSON *)objectForKeyedSubscript:(NSString *)key; +- (id)objectForKeyedSubscript:(NSString *)key; /// Indexes into the JSON as if the current value is an array /// diff --git a/BraintreePayPal/BTConfiguration+PayPal.m b/BraintreePayPal/BTConfiguration+PayPal.m index 1f2f3abebd..d332c9ba6a 100644 --- a/BraintreePayPal/BTConfiguration+PayPal.m +++ b/BraintreePayPal/BTConfiguration+PayPal.m @@ -3,11 +3,11 @@ @implementation BTConfiguration (PayPal) - (BOOL)isPayPalEnabled { - return self.json[@"paypalEnabled"].isTrue; + return [self.json[@"paypalEnabled"] isTrue]; } - (BOOL)isBillingAgreementsEnabled { - return self.json[@"paypal"][@"billingAgreementsEnabled"].isTrue; + return [self.json[@"paypal"][@"billingAgreementsEnabled"] isTrue]; } @end diff --git a/BraintreePayPal/BTPayPalDriver.m b/BraintreePayPal/BTPayPalDriver.m index 8eca86f33e..8691c7ba19 100644 --- a/BraintreePayPal/BTPayPalDriver.m +++ b/BraintreePayPal/BTPayPalDriver.m @@ -101,8 +101,8 @@ - (void)authorizeAccountWithAdditionalScopes:(NSSet *)additionalScop PayPalOneTouchAuthorizationRequest *request = [self.requestFactory requestWithScopeValues:[self.defaultOAuth2Scopes setByAddingObjectsFromSet:(additionalScopes ? additionalScopes : [NSSet set])] - privacyURL:configuration.json[@"paypal"][@"privacyUrl"].asURL - agreementURL:configuration.json[@"paypal"][@"userAgreementUrl"].asURL + privacyURL:[configuration.json[@"paypal"][@"privacyUrl"] asURL] + agreementURL:[configuration.json[@"paypal"][@"userAgreementUrl"] asURL] clientID:[self paypalClientIdWithRemoteConfiguration:configuration.json] environment:[self payPalEnvironmentForRemoteConfiguration:configuration.json] callbackURLScheme:self.returnURLScheme]; @@ -205,7 +205,7 @@ - (void)requestExpressCheckout:(BTPayPalRequest *)request // Currency code should only be used for Hermes Checkout (one-time payment). // For BA, currency should not be used. - NSString *currencyCode = request.currencyCode ?: configuration.json[@"paypal"][@"currencyIsoCode"].asString; + NSString *currencyCode = request.currencyCode ?: [configuration.json[@"paypal"][@"currencyIsoCode"] asString]; if (!isBillingAgreement && currencyCode) { parameters[@"currency_iso_code"] = currencyCode; } @@ -271,15 +271,15 @@ - (void)requestExpressCheckout:(BTPayPalRequest *)request [self setExpressCheckoutAppSwitchReturnBlock:completionBlock]; } - NSString *payPalClientID = configuration.json[@"paypal"][@"clientId"].asString; + NSString *payPalClientID = [configuration.json[@"paypal"][@"clientId"] asString]; if (!payPalClientID && [self payPalEnvironmentForRemoteConfiguration:configuration.json] == PayPalEnvironmentMock) { payPalClientID = @"FAKE-PAYPAL-CLIENT-ID"; } - NSURL *approvalUrl = body[@"paymentResource"][@"redirectUrl"].asURL; + NSURL *approvalUrl = [body[@"paymentResource"][@"redirectUrl"] asURL]; if (approvalUrl == nil) { - approvalUrl = body[@"agreementSetup"][@"approvalUrl"].asURL; + approvalUrl = [body[@"agreementSetup"][@"approvalUrl"] asURL]; } PayPalOneTouchCheckoutRequest *request = nil; @@ -403,7 +403,7 @@ - (void)performSwitchRequest:(NSURL *)appSwitchURL { } - (NSString *)payPalEnvironmentForRemoteConfiguration:(BTJSON *)configuration { - NSString *btPayPalEnvironmentName = configuration[@"paypal"][@"environment"].asString; + NSString *btPayPalEnvironmentName = [configuration[@"paypal"][@"environment"] asString]; if ([btPayPalEnvironmentName isEqualToString:@"offline"]) { return PayPalEnvironmentMock; } else if ([btPayPalEnvironmentName isEqualToString:@"live"]) { @@ -416,10 +416,10 @@ - (NSString *)payPalEnvironmentForRemoteConfiguration:(BTJSON *)configuration { } - (NSString *)paypalClientIdWithRemoteConfiguration:(BTJSON *)configuration { - if ([configuration[@"paypal"][@"environment"].asString isEqualToString:@"offline"] && !configuration[@"paypal"][@"clientId"].isString) { + if ([[configuration[@"paypal"][@"environment"] asString] isEqualToString:@"offline"] && ![configuration[@"paypal"][@"clientId"] isString]) { return @"mock-paypal-client-id"; } else { - return configuration[@"paypal"][@"clientId"].asString; + return [configuration[@"paypal"][@"clientId"] asString]; } } @@ -445,13 +445,13 @@ + (BTPostalAddress *)accountAddressFromJSON:(BTJSON *)addressJSON { } BTPostalAddress *address = [[BTPostalAddress alloc] init]; - address.recipientName = addressJSON[@"recipientName"].asString; // Likely to be nil - address.streetAddress = addressJSON[@"street1"].asString; - address.extendedAddress = addressJSON[@"street2"].asString; - address.locality = addressJSON[@"city"].asString; - address.region = addressJSON[@"state"].asString; - address.postalCode = addressJSON[@"postalCode"].asString; - address.countryCodeAlpha2 = addressJSON[@"country"].asString; + address.recipientName = [addressJSON[@"recipientName"] asString]; // Likely to be nil + address.streetAddress = [addressJSON[@"street1"] asString]; + address.extendedAddress = [addressJSON[@"street2"] asString]; + address.locality = [addressJSON[@"city"] asString]; + address.region = [addressJSON[@"state"] asString]; + address.postalCode = [addressJSON[@"postalCode"] asString]; + address.countryCodeAlpha2 = [addressJSON[@"country"] asString]; return address; } @@ -462,32 +462,34 @@ + (BTPostalAddress *)shippingOrBillingAddressFromJSON:(BTJSON *)addressJSON { } BTPostalAddress *address = [[BTPostalAddress alloc] init]; - address.recipientName = addressJSON[@"recipientName"].asString; // Likely to be nil - address.streetAddress = addressJSON[@"line1"].asString; - address.extendedAddress = addressJSON[@"line2"].asString; - address.locality = addressJSON[@"city"].asString; - address.region = addressJSON[@"state"].asString; - address.postalCode = addressJSON[@"postalCode"].asString; - address.countryCodeAlpha2 = addressJSON[@"countryCode"].asString; + address.recipientName = [addressJSON[@"recipientName"] asString]; // Likely to be nil + address.streetAddress = [addressJSON[@"line1"] asString]; + address.extendedAddress = [addressJSON[@"line2"] asString]; + address.locality = [addressJSON[@"city"] asString]; + address.region = [addressJSON[@"state"] asString]; + address.postalCode = [addressJSON[@"postalCode"] asString]; + address.countryCodeAlpha2 = [addressJSON[@"countryCode"] asString]; return address; } + (BTPayPalAccountNonce *)payPalAccountFromJSON:(BTJSON *)payPalAccount { - NSString *nonce = payPalAccount[@"nonce"].asString; - NSString *description = payPalAccount[@"description"].asString; + NSString *nonce = [payPalAccount[@"nonce"] asString]; + NSString *description = [payPalAccount[@"description"] asString]; BTJSON *details = payPalAccount[@"details"]; - NSString *email = details[@"email"].asString; - NSString *clientMetadataId = details[@"correlationId"].asString; + NSString *email = [details[@"email"] asString]; + NSString *clientMetadataId = [details[@"correlationId"] asString]; // Allow email to be under payerInfo - if (details[@"payerInfo"][@"email"].isString) { email = details[@"payerInfo"][@"email"].asString; } + if ([details[@"payerInfo"][@"email"] isString]) { + email = [details[@"payerInfo"][@"email"] asString]; + } - NSString *firstName = details[@"payerInfo"][@"firstName"].asString; - NSString *lastName = details[@"payerInfo"][@"lastName"].asString; - NSString *phone = details[@"payerInfo"][@"phone"].asString; - NSString *payerId = details[@"payerInfo"][@"payerId"].asString; + NSString *firstName = [details[@"payerInfo"][@"firstName"] asString]; + NSString *lastName = [details[@"payerInfo"][@"lastName"] asString]; + NSString *phone = [details[@"payerInfo"][@"phone"] asString]; + NSString *payerId = [details[@"payerInfo"][@"payerId"] asString]; BTPostalAddress *shippingAddress = [self.class shippingOrBillingAddressFromJSON:details[@"payerInfo"][@"shippingAddress"]]; BTPostalAddress *billingAddress = [self.class shippingOrBillingAddressFromJSON:details[@"payerInfo"][@"billingAddress"]]; @@ -583,7 +585,7 @@ - (void)safariViewControllerDidFinish:(__unused SFSafariViewController *)control #pragma mark - Preflight check - (BOOL)verifyAppSwitchWithRemoteConfiguration:(BTJSON *)configuration error:(NSError * __autoreleasing *)error { - if (!configuration[@"paypalEnabled"].isTrue) { + if (![configuration[@"paypalEnabled"] isTrue]) { [self.apiClient sendAnalyticsEvent:@"ios.paypal-otc.preflight.disabled"]; if (error != NULL) { *error = [NSError errorWithDomain:BTPayPalDriverErrorDomain diff --git a/BraintreeUI/Drop-In/BTDropInViewController.m b/BraintreeUI/Drop-In/BTDropInViewController.m index 5d239af449..62ca219676 100644 --- a/BraintreeUI/Drop-In/BTDropInViewController.m +++ b/BraintreeUI/Drop-In/BTDropInViewController.m @@ -109,7 +109,7 @@ - (void)viewDidLoad { [errorAlert show]; } - NSArray *challenges = configuration.json[@"challenges"].asArray; + NSArray *challenges = [configuration.json[@"challenges"] asArray]; static NSString *cvvChallenge = @"cvv"; static NSString *postalCodeChallenge = @"postal_code"; @@ -585,7 +585,7 @@ - (void)fetchPaymentMethodsOnCompletion:(void(^)())completionBlock { BTDropInErrorAlert *errorAlert = [[BTDropInErrorAlert alloc] initWithPresentingViewController:self]; errorAlert.title = error.localizedDescription; BTJSON *errorBody = error.userInfo[BTHTTPJSONResponseBodyKey]; - errorAlert.message = errorBody[@"error"][@"message"].asString; + errorAlert.message = [errorBody[@"error"][@"message"] asString]; errorAlert.cancelBlock = ^{ [self informDelegateDidCancel]; if (completionBlock) completionBlock(); @@ -599,9 +599,9 @@ - (void)fetchPaymentMethodsOnCompletion:(void(^)())completionBlock { } NSMutableArray *paymentMethodNonces = [NSMutableArray array]; - for (NSDictionary *paymentInfo in body[@"paymentMethods"].asArray) { + for (NSDictionary *paymentInfo in [body[@"paymentMethods"] asArray]) { BTJSON *paymentInfoJSON = [[BTJSON alloc] initWithValue:paymentInfo]; - BTPaymentMethodNonce *paymentMethodNonce = [[BTPaymentMethodNonceParser sharedParser] parseJSON:paymentInfoJSON withParsingBlockForType:paymentInfoJSON[@"type"].asString]; + BTPaymentMethodNonce *paymentMethodNonce = [[BTPaymentMethodNonceParser sharedParser] parseJSON:paymentInfoJSON withParsingBlockForType:[paymentInfoJSON[@"type"] asString]]; if (paymentMethodNonce) [paymentMethodNonces addObject:paymentMethodNonce]; } self.paymentMethodNonces = [paymentMethodNonces copy]; diff --git a/BraintreeUI/Drop-In/BTPaymentButton.m b/BraintreeUI/Drop-In/BTPaymentButton.m index 50bcad40c4..c47e3eadde 100644 --- a/BraintreeUI/Drop-In/BTPaymentButton.m +++ b/BraintreeUI/Drop-In/BTPaymentButton.m @@ -178,7 +178,7 @@ - (NSOrderedSet *)filteredEnabledPaymentOptions { } if ([paymentOption isEqualToString:@"PayPal"]) { - return self.configuration.json[@"paypalEnabled"].isTrue; + return [self.configuration.json[@"paypalEnabled"] isTrue]; } else if ([paymentOption isEqualToString:@"Venmo"]) { // Directly from BTConfiguration+Venmo.m. Be sure to keep these files in sync! This // is intentionally not DRY so that BraintreeUI does not depend on BraintreeVenmo. diff --git a/BraintreeVenmo/BTConfiguration+Venmo.m b/BraintreeVenmo/BTConfiguration+Venmo.m index ea1106ad61..207411353e 100644 --- a/BraintreeVenmo/BTConfiguration+Venmo.m +++ b/BraintreeVenmo/BTConfiguration+Venmo.m @@ -11,7 +11,7 @@ - (BOOL)isVenmoEnabled { } - (NSString*)venmoAccessToken { - return self.json[@"payWithVenmo"][@"accessToken"].asString; + return [self.json[@"payWithVenmo"][@"accessToken"] asString]; } @end diff --git a/BraintreeVenmo/BTVenmoAccountNonce.m b/BraintreeVenmo/BTVenmoAccountNonce.m index 8c8ab9a52a..bef25f62fc 100644 --- a/BraintreeVenmo/BTVenmoAccountNonce.m +++ b/BraintreeVenmo/BTVenmoAccountNonce.m @@ -24,9 +24,9 @@ - (instancetype)initWithPaymentMethodNonce:(NSString *)nonce } + (instancetype)venmoAccountWithJSON:(BTJSON *)venmoAccountJSON { - return [[[self class] alloc] initWithPaymentMethodNonce:venmoAccountJSON[@"nonce"].asString - description:venmoAccountJSON[@"description"].asString - username:venmoAccountJSON[@"username"].asString]; + return [[[self class] alloc] initWithPaymentMethodNonce:[venmoAccountJSON[@"nonce"] asString] + description:[venmoAccountJSON[@"description"] asString] + username:[venmoAccountJSON[@"username"] asString]]; } @end diff --git a/BraintreeVenmo/BTVenmoDriver.m b/BraintreeVenmo/BTVenmoDriver.m index 005eefd9ec..4489938cc0 100644 --- a/BraintreeVenmo/BTVenmoDriver.m +++ b/BraintreeVenmo/BTVenmoDriver.m @@ -110,16 +110,16 @@ - (void)authorizeAccountWithCompletion:(void (^)(BTVenmoAccountNonce *venmoAccou metadata.source = BTClientMetadataSourceVenmoApp; NSString *bundleDisplayName = [self.bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"]; - if (configuration.json[@"merchantId"].isError) { - completionBlock(nil, configuration.json[@"merchantId"].asError); + if ([configuration.json[@"merchantId"] isError]) { + completionBlock(nil, [configuration.json[@"merchantId"] asError]); } - NSURL *appSwitchURL = [BTVenmoAppSwitchRequestURL appSwitchURLForMerchantID:configuration.json[@"merchantId"].asString + NSURL *appSwitchURL = [BTVenmoAppSwitchRequestURL appSwitchURLForMerchantID:[configuration.json[@"merchantId"] asString] accessToken:configuration.venmoAccessToken sdkVersion:BRAINTREE_VERSION returnURLScheme:self.returnURLScheme bundleDisplayName:bundleDisplayName - environment:configuration.json[@"environment"].asString]; + environment:[configuration.json[@"environment"] asString]]; [self informDelegateWillPerformAppSwitch]; BOOL success = [self.application openURL:appSwitchURL];