From f7bd4e527cae6c048152e99e1501774243fffef1 Mon Sep 17 00:00:00 2001 From: Aris Paskalov Date: Wed, 15 Feb 2023 17:13:37 +0200 Subject: [PATCH 1/2] feat: upgrade iOS braintree sdk to v5 --- README.md | 4 ++-- ios/RNBraintree.m | 23 +++++++++++------------ ios/RNBraintree.xcodeproj/project.pbxproj | 4 ++-- react-native-braintree.podspec | 3 ++- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index bae5909..fe0cd5d 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ In your `AppDelegate.m`: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... - [BTAppSwitch setReturnURLScheme:self.paymentsURLScheme]; + [BTAppContextSwitcher setReturnURLScheme:self.paymentsURLScheme]; } - (BOOL)application:(UIApplication *)application @@ -83,7 +83,7 @@ In your `AppDelegate.m`: options:(NSDictionary *)options { if ([url.scheme localizedCaseInsensitiveCompare:self.paymentsURLScheme] == NSOrderedSame) { - return [BTAppSwitch handleOpenURL:url options:options]; + return [BTAppContextSwitcher handleOpenURL:url]; } return [RCTLinkingManager application:application openURL:url options:options]; diff --git a/ios/RNBraintree.m b/ios/RNBraintree.m index 14e80c3..5d2b54f 100644 --- a/ios/RNBraintree.m +++ b/ios/RNBraintree.m @@ -4,6 +4,7 @@ #import "BraintreePayPal.h" #import "BTDataCollector.h" #import "BraintreePaymentFlow.h" +#import "BraintreeThreeDSecure.h" @interface RNBraintree() @property (nonatomic, strong) BTAPIClient *apiClient; @@ -24,11 +25,10 @@ @implementation RNBraintree self.apiClient = [[BTAPIClient alloc] initWithAuthorization: clientToken]; self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient]; BTPayPalDriver *payPalDriver = [[BTPayPalDriver alloc] initWithAPIClient: self.apiClient]; - payPalDriver.viewControllerPresentingDelegate = self; - BTPayPalRequest *request= [[BTPayPalRequest alloc] initWithAmount:amount]; + BTPayPalCheckoutRequest *request= [[BTPayPalCheckoutRequest alloc] initWithAmount:amount]; request.currencyCode = currencyCode; - [payPalDriver requestOneTimePayment:request completion:^(BTPayPalAccountNonce * _Nullable tokenizedPayPalAccount, NSError * _Nullable error) { + [payPalDriver tokenizePayPalAccountWithPayPalRequest:request completion:^(BTPayPalAccountNonce * _Nullable tokenizedPayPalAccount, NSError * _Nullable error) { if (error) { reject(@"ONE_TIME_PAYMENT_FAILED", error.localizedDescription, nil); return; @@ -54,13 +54,12 @@ @implementation RNBraintree self.apiClient = [[BTAPIClient alloc] initWithAuthorization: clientToken]; self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient]; BTPayPalDriver *payPalDriver = [[BTPayPalDriver alloc] initWithAPIClient: self.apiClient]; - payPalDriver.viewControllerPresentingDelegate = self; - BTPayPalRequest *request= [[BTPayPalRequest alloc] init]; + BTPayPalVaultRequest *request= [[BTPayPalVaultRequest alloc] init]; if (description) { request.billingAgreementDescription = description; } - [payPalDriver requestBillingAgreement:request completion:^(BTPayPalAccountNonce * _Nullable tokenizedPayPalAccount, NSError * _Nullable error) { + [payPalDriver tokenizePayPalAccountWithPayPalRequest:request completion:^(BTPayPalAccountNonce * _Nullable tokenizedPayPalAccount, NSError * _Nullable error) { if (error) { reject(@"REQUEST_BILLING_AGREEMENT_FAILED", error.localizedDescription, nil); return; @@ -85,11 +84,11 @@ @implementation RNBraintree self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient]; BTCardClient *cardClient = [[BTCardClient alloc] initWithAPIClient: self.apiClient]; - BTCard *card = [[BTCard alloc] initWithNumber:parameters[@"number"] - expirationMonth:parameters[@"expirationMonth"] - expirationYear:parameters[@"expirationYear"] - cvv:parameters[@"cvv"]]; - + BTCard *card = [[BTCard alloc] init]; + card.number = parameters[@"number"]; + card.expirationMonth = parameters[@"expirationMonth"]; + card.expirationYear = parameters[@"expirationYear"]; + card.cvv = parameters[@"cvv"]; card.postalCode = parameters[@"postalCode"]; card.shouldValidate = NO; @@ -184,7 +183,7 @@ - (void)paymentDriver:(nonnull id)driver requestsDismissalOfViewController:(nonn #pragma mark - BTThreeDSecureRequestDelegate -- (void)onLookupComplete:(BTThreeDSecureRequest *)request result:(BTThreeDSecureLookup *)result next:(void (^)(void))next { +- (void)onLookupComplete:(BTThreeDSecureRequest *)request lookupResult:(BTThreeDSecureResult *)result next:(void (^)(void))next { next(); } diff --git a/ios/RNBraintree.xcodeproj/project.pbxproj b/ios/RNBraintree.xcodeproj/project.pbxproj index ffb7b6e..531f915 100644 --- a/ios/RNBraintree.xcodeproj/project.pbxproj +++ b/ios/RNBraintree.xcodeproj/project.pbxproj @@ -157,7 +157,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)"; LIBRARY_SEARCH_PATHS = ( "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", @@ -209,7 +209,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)"; LIBRARY_SEARCH_PATHS = ( "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", diff --git a/react-native-braintree.podspec b/react-native-braintree.podspec index d54347c..d54ffd2 100644 --- a/react-native-braintree.podspec +++ b/react-native-braintree.podspec @@ -27,7 +27,8 @@ Pod::Spec.new do |s| s.dependency "Braintree" s.dependency "Braintree/DataCollector" s.dependency "Braintree/PaymentFlow" - s.dependency "Braintree/Apple-Pay" + s.dependency "Braintree/ApplePay" + s.dependency "Braintree/ThreeDSecure" end From 57090c277f445f34352c53cdfc015b858f4dd7fa Mon Sep 17 00:00:00 2001 From: Aris Paskalov Date: Wed, 15 Feb 2023 17:14:35 +0200 Subject: [PATCH 2/2] build: bump package version to 2.0.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9111ab2..6c2870f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@ekreative/react-native-braintree", - "version": "1.4.0", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a1b2801..a89bfe2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ekreative/react-native-braintree", "title": "React Native Braintree", - "version": "1.4.0", + "version": "2.0.0", "description": "TODO", "main": "index.js", "files": [