Skip to content

Commit

Permalink
Merge pull request #98 from wbetterdev/wb
Browse files Browse the repository at this point in the history
Update Braintree dependencies, fix iOS autolinking, add new methods
  • Loading branch information
wgltony authored Apr 4, 2023
2 parents ceaf620 + af0ee48 commit 0e788e0
Show file tree
Hide file tree
Showing 10 changed files with 355 additions and 297 deletions.
73 changes: 54 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ npm install react-native-braintree-dropin-ui --save

## Configurate Payment Method(For ALL RN VERSIONS)
See Braintree's documentation, [Apple Pay][8], [Google Pay][9], [Paypal][10], [Venmo][11]
Once you have finished setting up all the configurations, it will shows in the dropin UI.
Once you have finished setting up all the configurations, it will show in the dropin UI.


For React Native versions < 0.60
Expand All @@ -38,7 +38,7 @@ react-native link react-native-braintree-dropin-ui

#### iOS specific

You must have a iOS deployment target \>= 9.0.
You must have a iOS deployment target \>= 12.0.

If you don't have a Podfile or are unsure on how to proceed, see the [CocoaPods][1] usage guide.

Expand All @@ -58,7 +58,7 @@ pod 'Braintree'
pod 'BraintreeDropIn'
# comment the next line to disable Apple pay
pod 'Braintree/Apple-Pay'
pod 'Braintree/ApplePay'
# comment the next line to disable PayPal
pod 'Braintree/PayPal'
Expand All @@ -84,18 +84,29 @@ The Drop-in will show Apple Pay as a payment option as long as you've completed

#### PayPal

To enable paypal payments in iOS, you will need to add `setReturnURLScheme` to `launchOptions` of your `AppDelegate.m`
To enable paypal payments in iOS, you will need to add `setReturnURLScheme` to `launchOptions` of your `AppDelegate.m` / `AppDelegate.mm`

```objective-c
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[BTAppSwitch setReturnURLScheme:@"com.your-company-name.your-app-name.payments"]; // ADD THIS LINE
[BTAppContextSwitcher setReturnURLScheme:@"com.your-company-name.your-app-name.payments"]; // ADD THIS LINE
return YES;
}
```

#### Android specific

Note: Only complete these steps if using React Native versions < 0.60, autolinking will do these steps automatically.
Add in your `MainActivity.java`:
```
import tech.power.RNBraintreeDropIn.RNBraintreeDropInModule;
@Override
protected void onCreate(Bundle savedInstanceState) {
// ...
RNBraintreeDropInModule.initDropInClient(this);
}
```

Note: Only complete the next steps if using React Native versions < 0.60, autolinking will do these steps automatically.

Add in your `app/build.gradle`:

Expand Down Expand Up @@ -182,7 +193,7 @@ In your `AppDelegate.m`:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[BTAppSwitch setReturnURLScheme:self.paymentsURLScheme];
[BTAppContextSwitcher setReturnURLScheme:self.paymentsURLScheme];
...
}

Expand All @@ -191,7 +202,7 @@ In your `AppDelegate.m`:
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 All @@ -210,13 +221,13 @@ import Braintree

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
...
BTAppSwitch.setReturnURLScheme(self.paymentsURLScheme)
BTAppContextSwitcher.setReturnURLScheme(self.paymentsURLScheme)
...
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if let scheme = url.scheme, scheme.localizedCaseInsensitiveCompare(self.paymentsURLScheme) == .orderedSame {
return BTAppSwitch.handleOpen(url, options: options)
return BTAppContextSwitcher.handleOpen(url)
}
return RCTLinkingManager.application(app, open: url, options: options)
}
Expand Down Expand Up @@ -300,6 +311,36 @@ BraintreeDropIn.show({
});
```

### Fetch more recent payment method

```javascript
import BraintreeDropIn from 'react-native-braintree-dropin-ui';

BraintreeDropIn.fetchMostRecentPaymentMethod(clientToken)
.then(result => console.log(result))
.catch((error) => {
// Handle error
});
```

### Tokenize card

```javascript
import BraintreeDropIn from 'react-native-braintree-dropin-ui';

BraintreeDropIn.tokenizeCard(clientToken, {
number: '4111111111111111',
expirationMonth: '10',
expirationYear: '23',
cvv: '123',
postalCode: '12345',
})
.then(cardNonce => console.log(cardNonce))
.catch((error) => {
// Handle error
});
```

### Custom Fonts
```
BraintreeDropIn.show({
Expand All @@ -309,20 +350,14 @@ BraintreeDropIn.show({
})
```

### Potential Fix

This version contains updated BraintreeDropIn 5.+. BraintreeDropIn 5.0.2 contains some security fixes that resolves Play store rejection fix. Read more -

Unsafe implementation of the HostnameVerifier interface - vulnerability ( https://github.com/braintree/braintree-android-drop-in/issues/208 )

[1]: http://guides.cocoapods.org/using/using-cocoapods.html
[2]: https://github.com/braintree/braintree-ios-drop-in
[3]: https://github.com/braintree/braintree-android-drop-in
[4]: https://developers.braintreepayments.com/guides/client-sdk/setup/android/v2#browser-switch-setup
[4]: https://developers.braintreepayments.com/guides/client-sdk/setup/android/v4#browser-switch-setup
[5]: ./index.js.flow
[6]: https://developers.braintreepayments.com/guides/apple-pay/configuration/ios/v4
[6]: https://developers.braintreepayments.com/guides/apple-pay/configuration/ios/v5
[7]: https://articles.braintreepayments.com/guides/payment-methods/apple-pay#compatibility
[8]: https://developers.braintreepayments.com/guides/apple-pay/overview
[9]: https://developers.braintreepayments.com/guides/google-pay/overview
[10]: https://developers.braintreepayments.com/guides/paypal/overview/ios/v4
[10]: https://developers.braintreepayments.com/guides/paypal/overview/ios/v5
[11]: https://developers.braintreepayments.com/guides/venmo/overview
18 changes: 9 additions & 9 deletions ios/RNBraintreeDropIn.podspec → RNBraintreeDropIn.podspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
Pod::Spec.new do |s|
s.name = "RNBraintreeDropIn"
s.version = "1.0.0"
s.version = "1.1.3"
s.summary = "RNBraintreeDropIn"
s.description = <<-DESC
RNBraintreeDropIn
DESC
s.homepage = "https://github.com/bamlab/react-native-braintree-payments-drop-in"
s.license = "MIT"
# s.license = { :type => "MIT", :file => "../LICENSE" }
# s.license = { :type => "MIT", :file => "./LICENSE" }
s.author = { "author" => "[email protected]" }
s.platform = :ios, "9.0"
s.platform = :ios, "12.0"
s.source = { :git => "https://github.com/BradyShober/react-native-braintree-dropin-ui.git", :tag => "master" }
s.source_files = "*.{h,m}"
s.source_files = "ios/**/*.{h,m}"
s.requires_arc = true
s.dependency 'React'
s.dependency 'Braintree'
s.dependency 'BraintreeDropIn'
s.dependency 'Braintree/DataCollector'
s.dependency 'Braintree/Apple-Pay'
s.dependency 'Braintree/Venmo'
s.dependency 'Braintree', '5.20.1'
s.dependency 'BraintreeDropIn', '9.8.1'
s.dependency 'Braintree/DataCollector', '5.20.1'
s.dependency 'Braintree/ApplePay', '5.20.1'
s.dependency 'Braintree/Venmo', '5.20.1'
end
15 changes: 6 additions & 9 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
buildscript {
repositories {
jcenter()
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:7.3.1'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 33
buildToolsVersion '33.0.1'

defaultConfig {
minSdkVersion 21
targetSdkVersion 27
targetSdkVersion 33
versionCode 1
versionName "1.0"
}
Expand All @@ -32,10 +32,7 @@ repositories {
}

dependencies {
implementation 'com.braintreepayments.api:google-payment:3.2.0'
implementation 'com.google.android.gms:play-services-wallet:16.0.1'
implementation 'com.braintreepayments.api:data-collector:2.+'
implementation 'com.braintreepayments.api:drop-in:5.+'
implementation 'com.braintreepayments.api:drop-in:6.8.1'
implementation 'com.facebook.react:react-native:+'
}

Expand Down
Loading

0 comments on commit 0e788e0

Please sign in to comment.