Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #25 from aris-paskalov/feature/migrate_ios_braintr…
Browse files Browse the repository at this point in the history
…ee_sdk_to_v5

Feature: Migrate the iOS Braintree SDK to version 5
  • Loading branch information
vasylnahuliak authored Feb 16, 2023
2 parents c78c66a + 57090c2 commit f7581ca
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ In your `AppDelegate.m`:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[BTAppSwitch setReturnURLScheme:self.paymentsURLScheme];
[BTAppContextSwitcher setReturnURLScheme:self.paymentsURLScheme];
}

- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)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];
Expand Down
23 changes: 11 additions & 12 deletions ios/RNBraintree.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#import "BraintreePayPal.h"
#import "BTDataCollector.h"
#import "BraintreePaymentFlow.h"
#import "BraintreeThreeDSecure.h"

@interface RNBraintree() <BTViewControllerPresentingDelegate, BTThreeDSecureRequestDelegate>
@property (nonatomic, strong) BTAPIClient *apiClient;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions ios/RNBraintree.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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)\"",
Expand Down Expand Up @@ -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)\"",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
3 changes: 2 additions & 1 deletion react-native-braintree.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f7581ca

Please sign in to comment.