├── .npmrc ├── example ├── .npmrc ├── .ruby-version ├── .watchmanconfig ├── ios │ ├── .xcode.env │ ├── reactNativeBraintreeExample │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── AppDelegate.mm │ │ ├── Info.plist │ │ └── LaunchScreen.storyboard │ ├── reactNativeBraintreeExample.xcworkspace │ │ └── contents.xcworkspacedata │ ├── _xcode.env │ ├── reactNativeBraintreeExampleTests │ │ ├── Info.plist │ │ └── reactNativeBraintreeExampleTests.m │ ├── Podfile │ ├── reactNativeBraintreeExample.xcodeproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── reactNativeBraintreeExample.xcscheme │ └── Podfile.lock ├── jest.config.js ├── _bundle │ └── config ├── tsconfig.json ├── .eslintrc.js ├── babel.config.js ├── app.json ├── android │ ├── app │ │ ├── debug.keystore │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── values │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.xml │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ └── drawable │ │ │ │ │ │ └── rn_edit_text_material.xml │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── reactnativebraintreeexample │ │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ │ └── MainApplication.java │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── reactnativebraintreeexample │ │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── release │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── reactnativebraintreeexample │ │ │ │ └── ReactNativeFlipper.java │ │ ├── proguard-rules.pro │ │ └── build.gradle │ ├── settings.gradle │ ├── build.gradle │ ├── gradle.properties │ ├── gradlew.bat │ └── gradlew ├── .prettierrc.js ├── Gemfile ├── index.js ├── metro.config.js ├── __tests__ │ └── App.test.tsx ├── package.json ├── .gitignore ├── Gemfile.lock ├── App.tsx └── README.md ├── .eslintignore ├── .prettierignore ├── .all-contributorsrc ├── android ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── ekreative │ │ └── reactnativebraintree │ │ ├── RNBraintreePackage.java │ │ └── RNBraintreeModule.java ├── README.md └── build.gradle ├── ios ├── RNBraintreeApplePay.h ├── RNBraintree.h ├── RNBraintree.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── RNBraintreeApplePay.m ├── RNBraintree.xcodeproj │ └── project.pbxproj └── RNBraintree.m ├── .prettierrc.js ├── branch-name-lint.config.js ├── .eslintrc.js ├── index.js ├── .gitignore ├── react-native-braintree.podspec ├── package.json ├── index.d.ts ├── CONTRIBUTING.uk-UA.md ├── CONTRIBUTING.md ├── README.uk-UA.md ├── README.md └── docs └── migration-objc-to-swift-guide.md /.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true -------------------------------------------------------------------------------- /example/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true -------------------------------------------------------------------------------- /example/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.6.10 2 | -------------------------------------------------------------------------------- /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | android 2 | ios 3 | example 4 | -------------------------------------------------------------------------------- /example/ios/.xcode.env: -------------------------------------------------------------------------------- 1 | export NODE_BINARY=$(command -v node) 2 | -------------------------------------------------------------------------------- /example/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'react-native', 3 | }; 4 | -------------------------------------------------------------------------------- /example/_bundle/config: -------------------------------------------------------------------------------- 1 | BUNDLE_PATH: "vendor/bundle" 2 | BUNDLE_FORCE_RUBY_PLATFORM: 1 3 | -------------------------------------------------------------------------------- /example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/react-native/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | android 2 | ios 3 | example 4 | .all-contributorsrc 5 | *.md 6 | *.yml 7 | *.yaml 8 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native', 4 | }; 5 | -------------------------------------------------------------------------------- /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "react-native-braintree", 3 | "projectOwner": "eKreative" 4 | } -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reactNativeBraintreeExample", 3 | "displayName": "reactNativeBraintreeExample" 4 | } 5 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekreative/react-native-braintree/HEAD/example/android/app/debug.keystore -------------------------------------------------------------------------------- /ios/RNBraintreeApplePay.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface RNBraintreeApplePay : NSObject 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | reactNativeBraintreeExample 3 | 4 | -------------------------------------------------------------------------------- /example/ios/reactNativeBraintreeExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ios/RNBraintree.h: -------------------------------------------------------------------------------- 1 | // RNBraintree.h 2 | 3 | #import 4 | 5 | @interface RNBraintree : NSObject 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /example/ios/reactNativeBraintreeExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : RCTAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | arrowParens: 'avoid', 3 | bracketSameLine: true, 4 | bracketSpacing: false, 5 | singleQuote: true, 6 | trailingComma: 'all', 7 | }; 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekreative/react-native-braintree/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekreative/react-native-braintree/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | arrowParens: 'avoid', 3 | bracketSameLine: true, 4 | bracketSpacing: false, 5 | singleQuote: true, 6 | trailingComma: 'all', 7 | }; 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekreative/react-native-braintree/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekreative/react-native-braintree/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version 4 | ruby ">= 2.6.10" 5 | 6 | gem 'cocoapods', '~> 1.12' 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekreative/react-native-braintree/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekreative/react-native-braintree/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekreative/react-native-braintree/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekreative/react-native-braintree/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekreative/react-native-braintree/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekreative/react-native-braintree/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ios/RNBraintree.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import App from './App'; 7 | import {name as appName} from './app.json'; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /branch-name-lint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | 'branch-name': [ 4 | 2, 5 | { 6 | format: 7 | /^(feature|publish|release|hotfix|develop|master)\/[a-z0-9._-]+$/, 8 | }, 9 | ], 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /example/ios/reactNativeBraintreeExample/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | @autoreleasepool { 8 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'reactNativeBraintreeExample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | includeBuild('../node_modules/@react-native/gradle-plugin') 5 | -------------------------------------------------------------------------------- /ios/RNBraintree.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/reactNativeBraintreeExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config'); 2 | 3 | /** 4 | * Metro configuration 5 | * https://facebook.github.io/metro/docs/configuration 6 | * 7 | * @type {import('metro-config').MetroConfig} 8 | */ 9 | const config = {}; 10 | 11 | module.exports = mergeConfig(getDefaultConfig(__dirname), config); 12 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: 'eslint:recommended', 3 | env: { 4 | es2023: true, 5 | node: true, 6 | }, 7 | parserOptions: { 8 | ecmaVersion: 'latest', 9 | sourceType: 'module', 10 | ecmaFeatures: { 11 | jsx: true, 12 | }, 13 | }, 14 | settings: { 15 | react: { 16 | version: 'detect', 17 | }, 18 | }, 19 | }; 20 | -------------------------------------------------------------------------------- /example/__tests__/App.test.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../App'; 8 | 9 | // Note: import explicitly to use the types shiped with jest. 10 | import {it} from '@jest/globals'; 11 | 12 | // Note: test renderer must be required after react-native. 13 | import renderer from 'react-test-renderer'; 14 | 15 | it('renders correctly', () => { 16 | renderer.create(); 17 | }); 18 | -------------------------------------------------------------------------------- /example/ios/_xcode.env: -------------------------------------------------------------------------------- 1 | # This `.xcode.env` file is versioned and is used to source the environment 2 | # used when running script phases inside Xcode. 3 | # To customize your local environment, you can create an `.xcode.env.local` 4 | # file that is not versioned. 5 | 6 | # NODE_BINARY variable contains the PATH to the node executable. 7 | # 8 | # Customize the NODE_BINARY variable here. 9 | # For example, to use nvm with brew, add the following line 10 | # . "$(brew --prefix nvm)/nvm.sh" --no-use 11 | export NODE_BINARY=$(command -v node) 12 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // main index.js 2 | 3 | import {NativeModules} from 'react-native'; 4 | 5 | const {RNBraintree} = NativeModules; 6 | const {RNBraintreeApplePay} = NativeModules; 7 | 8 | export default { 9 | showPayPalModule: RNBraintree.showPayPalModule, 10 | runGooglePay: RNBraintree.runGooglePay, 11 | run3DSecureCheck: RNBraintree.run3DSecureCheck, 12 | tokenizeCard: RNBraintree.tokenizeCard, 13 | runApplePay: RNBraintreeApplePay && RNBraintreeApplePay.runApplePay, 14 | requestPayPalBillingAgreement: RNBraintree.requestPayPalBillingAgreement, 15 | getDeviceData: RNBraintree.getDeviceData, 16 | }; 17 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # node.js 6 | # 7 | node_modules/ 8 | npm-debug.log 9 | yarn-error.log 10 | 11 | # Xcode 12 | # 13 | build/ 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata 23 | *.xccheckout 24 | *.moved-aside 25 | DerivedData 26 | *.hmap 27 | *.ipa 28 | *.xcuserstate 29 | project.xcworkspace 30 | 31 | # Android/IntelliJ 32 | # 33 | build/ 34 | .idea 35 | .gradle 36 | gradle/ 37 | local.properties 38 | *.iml 39 | 40 | # BUCK 41 | buck-out/ 42 | \.buckd/ 43 | *.keystore 44 | -------------------------------------------------------------------------------- /android/README.md: -------------------------------------------------------------------------------- 1 | README 2 | ====== 3 | 4 | If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm: 5 | 6 | 1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed 7 | 2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK 8 | ``` 9 | ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle 10 | sdk.dir=/Users/{username}/Library/Android/sdk 11 | ``` 12 | 3. Delete the `maven` folder 13 | 4. Run `./gradlew installArchives` 14 | 5. Verify that latest set of generated files is in the maven folder with the correct version number 15 | -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # https://github.com/ekreative/react-native-braintree#android-specific 13 | -keep class com.cardinalcommerce.dependencies.internal.bouncycastle.** 14 | -keep class com.cardinalcommerce.dependencies.internal.nimbusds.** 15 | -keep class com.cardinalcommerce.shared.** 16 | -------------------------------------------------------------------------------- /example/android/app/src/release/java/com/reactnativebraintreeexample/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.reactnativebraintreeexample; 8 | 9 | import android.content.Context; 10 | import com.facebook.react.ReactInstanceManager; 11 | 12 | /** 13 | * Class responsible of loading Flipper inside your React Native application. This is the release 14 | * flavor of it so it's empty as we don't want to load Flipper. 15 | */ 16 | public class ReactNativeFlipper { 17 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 18 | // Do nothing as we don't want to initialize Flipper on Release. 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /example/ios/reactNativeBraintreeExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/ios/reactNativeBraintreeExample/AppDelegate.mm: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | 5 | @implementation AppDelegate 6 | 7 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 8 | { 9 | self.moduleName = @"reactNativeBraintreeExample"; 10 | // You can add your custom initial props in the dictionary below. 11 | // They will be passed down to the ViewController used by React Native. 12 | self.initialProps = @{}; 13 | 14 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 15 | } 16 | 17 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 18 | { 19 | #if DEBUG 20 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; 21 | #else 22 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 23 | #endif 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /android/src/main/java/com/ekreative/reactnativebraintree/RNBraintreePackage.java: -------------------------------------------------------------------------------- 1 | // RNBraintreePackage.java 2 | 3 | package com.ekreative.reactnativebraintree; 4 | 5 | import java.util.Arrays; 6 | import java.util.Collections; 7 | import java.util.List; 8 | 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.bridge.NativeModule; 11 | import com.facebook.react.bridge.ReactApplicationContext; 12 | import com.facebook.react.uimanager.ViewManager; 13 | import com.facebook.react.bridge.JavaScriptModule; 14 | 15 | public class RNBraintreePackage implements ReactPackage { 16 | @Override 17 | public List createNativeModules(ReactApplicationContext reactContext) { 18 | return Arrays.asList(new RNBraintreeModule(reactContext)); 19 | } 20 | 21 | @Override 22 | public List createViewManagers(ReactApplicationContext reactContext) { 23 | return Collections.emptyList(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reactNativeBraintreeExample", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "lint": "eslint .", 9 | "start": "react-native start", 10 | "test": "jest" 11 | }, 12 | "dependencies": { 13 | "@ekreative/react-native-braintree": "^2.1.0", 14 | "react": "18.2.0", 15 | "react-native": "0.72.3" 16 | }, 17 | "devDependencies": { 18 | "@babel/core": "^7.20.0", 19 | "@babel/preset-env": "^7.20.0", 20 | "@babel/runtime": "^7.20.0", 21 | "@react-native/eslint-config": "^0.72.2", 22 | "@react-native/metro-config": "^0.72.9", 23 | "@tsconfig/react-native": "^3.0.0", 24 | "@types/react": "^18.0.24", 25 | "@types/react-test-renderer": "^18.0.0", 26 | "babel-jest": "^29.2.1", 27 | "eslint": "^8.19.0", 28 | "jest": "^29.2.1", 29 | "metro-react-native-babel-preset": "0.76.7", 30 | "prettier": "^2.4.1", 31 | "react-test-renderer": "18.2.0", 32 | "typescript": "4.8.4" 33 | }, 34 | "engines": { 35 | "node": ">=16" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /example/ios/reactNativeBraintreeExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "scale" : "1x", 46 | "size" : "1024x1024" 47 | } 48 | ], 49 | "info" : { 50 | "author" : "xcode", 51 | "version" : 1 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /react-native-braintree.podspec: -------------------------------------------------------------------------------- 1 | # react-native-braintree.podspec 2 | 3 | require "json" 4 | 5 | package = JSON.parse(File.read(File.join(__dir__, "package.json"))) 6 | 7 | Pod::Spec.new do |s| 8 | s.name = "react-native-braintree" 9 | s.version = package["version"] 10 | s.summary = package["description"] 11 | s.description = <<-DESC 12 | react-native-braintree 13 | DESC 14 | s.homepage = "https://github.com/ekreative/react-native-braintree" 15 | # brief license entry: 16 | s.license = "MIT" 17 | # optional - use expanded license entry instead: 18 | # s.license = { :type => "MIT", :file => "LICENSE" } 19 | s.authors = "Ekreative" 20 | s.platforms = { :ios => "9.0" } 21 | s.source = { :git => "https://github.com/ekreative/react-native-braintree.git", :tag => "#{s.version}" } 22 | 23 | s.source_files = "ios/**/*.{h,c,cc,cpp,m,mm,swift}" 24 | s.requires_arc = true 25 | 26 | s.dependency "React" 27 | s.dependency "Braintree" 28 | s.dependency "Braintree/DataCollector" 29 | s.dependency "Braintree/PaymentFlow" 30 | s.dependency "Braintree/ApplePay" 31 | s.dependency "Braintree/ThreeDSecure" 32 | 33 | end 34 | 35 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "33.0.0" 6 | minSdkVersion = 21 7 | compileSdkVersion = 33 8 | targetSdkVersion = 33 9 | 10 | // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. 11 | ndkVersion = "23.1.7779620" 12 | } 13 | repositories { 14 | google() 15 | mavenCentral() 16 | } 17 | dependencies { 18 | classpath("com.android.tools.build:gradle") 19 | classpath("com.facebook.react:react-native-gradle-plugin") 20 | } 21 | } 22 | 23 | allprojects { 24 | repositories { 25 | maven { 26 | // Braintree 3D Secure 27 | // https://developers.braintreepayments.com/guides/3d-secure/client-side/android/v3#generate-a-client-token 28 | url "https://cardinalcommerceprod.jfrog.io/artifactory/android" 29 | credentials { 30 | username 'braintree_team_sdk' 31 | password 'AKCp8jQcoDy2hxSWhDAUQKXLDPDx6NYRkqrgFLRc3qDrayg6rrCbJpsKKyMwaykVL8FWusJpp' 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | ios/.xcode.env.local 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | *.hprof 33 | .cxx/ 34 | *.keystore 35 | !debug.keystore 36 | 37 | # node.js 38 | # 39 | node_modules/ 40 | npm-debug.log 41 | yarn-error.log 42 | 43 | # fastlane 44 | # 45 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 46 | # screenshots whenever they are needed. 47 | # For more information about the recommended setup visit: 48 | # https://docs.fastlane.tools/best-practices/source-control/ 49 | 50 | **/fastlane/report.xml 51 | **/fastlane/Preview.html 52 | **/fastlane/screenshots 53 | **/fastlane/test_output 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # Ruby / CocoaPods 59 | /ios/Pods/ 60 | /vendor/bundle/ 61 | 62 | # Temporary files created by Metro to check the health of the file watcher 63 | .metro-health-check* 64 | 65 | # testing 66 | /coverage 67 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/reactnativebraintreeexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.reactnativebraintreeexample; 2 | 3 | import com.facebook.react.ReactActivity; 4 | import com.facebook.react.ReactActivityDelegate; 5 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; 6 | import com.facebook.react.defaults.DefaultReactActivityDelegate; 7 | 8 | public class MainActivity extends ReactActivity { 9 | 10 | /** 11 | * Returns the name of the main component registered from JavaScript. This is used to schedule 12 | * rendering of the component. 13 | */ 14 | @Override 15 | protected String getMainComponentName() { 16 | return "reactNativeBraintreeExample"; 17 | } 18 | 19 | /** 20 | * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link 21 | * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React 22 | * (aka React 18) with two boolean flags. 23 | */ 24 | @Override 25 | protected ReactActivityDelegate createReactActivityDelegate() { 26 | return new DefaultReactActivityDelegate( 27 | this, 28 | getMainComponentName(), 29 | // If you opted-in for the New Architecture, we enable the Fabric Renderer. 30 | DefaultNewArchitectureEntryPoint.getFabricEnabled()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ekreative/react-native-braintree", 3 | "title": "React Native Braintree", 4 | "version": "2.6.1", 5 | "node": ">=16", 6 | "description": "A react native interface for integrating payments using Braintree", 7 | "main": "index.js", 8 | "files": [ 9 | "README.md", 10 | "android", 11 | "index.js", 12 | "index.d.ts", 13 | "ios", 14 | "react-native-braintree.podspec" 15 | ], 16 | "scripts": { 17 | "lint": "eslint .", 18 | "prettier:check": "prettier . -c --log-level=warn", 19 | "prettier:format": "prettier --log-level=warn --write \"**/*.{jsx,js,ts,tsx}\"" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "git+https://github.com/ekreative/react-native-braintree.git", 24 | "baseUrl": "https://github.com/ekreative/react-native-braintree" 25 | }, 26 | "keywords": [ 27 | "react-native" 28 | ], 29 | "author": { 30 | "name": "Vasyl Nahuliak", 31 | "email": "vasyl.nahuliak@gmail.com" 32 | }, 33 | "license": "MIT", 34 | "licenseFilename": "LICENSE", 35 | "readmeFilename": "README.md", 36 | "peerDependencies": { 37 | "react": ">=16.8.1", 38 | "react-native": ">=0.60.0-rc.0 <1.0.x" 39 | }, 40 | "husky": { 41 | "hooks": { 42 | "pre-push": "branch-name-lint" 43 | } 44 | }, 45 | "devDependencies": { 46 | "branch-name-lint": "^2.1.1", 47 | "eslint": "^8.52.0", 48 | "husky": "^8.0.3", 49 | "prettier": "^3.0.3", 50 | "react": "^16.9.0", 51 | "react-native": "^0.61.5" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /example/ios/reactNativeBraintreeExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | reactNativeBraintreeExample 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(MARKETING_VERSION) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(CURRENT_PROJECT_VERSION) 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSExceptionDomains 30 | 31 | localhost 32 | 33 | NSExceptionAllowsInsecureHTTPLoads 34 | 35 | 36 | 37 | 38 | NSLocationWhenInUseUsageDescription 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UIViewControllerBasedStatusBarAppearance 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/rn_edit_text_material.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 21 | 22 | 23 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m 13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.182.0 29 | 30 | # Use this property to specify which architecture you want to build. 31 | # You can also override it from the CLI using 32 | # ./gradlew -PreactNativeArchitectures=x86_64 33 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 34 | 35 | # Use this property to enable support to the new architecture. 36 | # This will allow you to use TurboModules and the Fabric render in 37 | # your application. You should enable this flag either if you want 38 | # to write custom TurboModules/Fabric components OR use libraries that 39 | # are providing them. 40 | newArchEnabled=false 41 | 42 | # Use this property to enable or disable the Hermes JS engine. 43 | # If set to false, you will be using JSC instead. 44 | hermesEnabled=true 45 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/reactnativebraintreeexample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.reactnativebraintreeexample; 2 | 3 | import android.app.Application; 4 | import com.facebook.react.PackageList; 5 | import com.facebook.react.ReactApplication; 6 | import com.facebook.react.ReactNativeHost; 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; 9 | import com.facebook.react.defaults.DefaultReactNativeHost; 10 | import com.facebook.soloader.SoLoader; 11 | import java.util.List; 12 | 13 | public class MainApplication extends Application implements ReactApplication { 14 | 15 | private final ReactNativeHost mReactNativeHost = 16 | new DefaultReactNativeHost(this) { 17 | @Override 18 | public boolean getUseDeveloperSupport() { 19 | return BuildConfig.DEBUG; 20 | } 21 | 22 | @Override 23 | protected List getPackages() { 24 | @SuppressWarnings("UnnecessaryLocalVariable") 25 | List packages = new PackageList(this).getPackages(); 26 | // Packages that cannot be autolinked yet can be added manually here, for example: 27 | // packages.add(new MyReactNativePackage()); 28 | return packages; 29 | } 30 | 31 | @Override 32 | protected String getJSMainModuleName() { 33 | return "index"; 34 | } 35 | 36 | @Override 37 | protected boolean isNewArchEnabled() { 38 | return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; 39 | } 40 | 41 | @Override 42 | protected Boolean isHermesEnabled() { 43 | return BuildConfig.IS_HERMES_ENABLED; 44 | } 45 | }; 46 | 47 | @Override 48 | public ReactNativeHost getReactNativeHost() { 49 | return mReactNativeHost; 50 | } 51 | 52 | @Override 53 | public void onCreate() { 54 | super.onCreate(); 55 | SoLoader.init(this, /* native exopackage */ false); 56 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { 57 | // If you opted-in for the New Architecture, we load the native entry point for this app. 58 | DefaultNewArchitectureEntryPoint.load(); 59 | } 60 | ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@ekreative/react-native-braintree' { 2 | export interface BraintreeResponse { 3 | nonce: string; 4 | deviceData: string; 5 | } 6 | 7 | export interface BraintreeOptions { 8 | clientToken: string; 9 | amount: string; 10 | currencyCode: string; 11 | } 12 | 13 | export interface Run3DSecureCheckOptions 14 | extends Omit { 15 | nonce: string; 16 | /* Pass clientToken if previously no RNBraintree methods were run. */ 17 | clientToken?: string; 18 | /* Provide as many of the following fields as possible. */ 19 | email?: string; 20 | firstname?: string; 21 | lastname?: string; 22 | phoneNumber?: string; 23 | streetAddress?: string; 24 | streetAddress2?: string; 25 | city?: string; 26 | region?: string; 27 | postalCode?: string; 28 | countryCode?: string; 29 | } 30 | 31 | export interface TokenizeCardOptions { 32 | clientToken: string; 33 | number: string; 34 | expirationMonth: string; 35 | expirationYear: string; 36 | cvv: string; 37 | postalCode?: string; 38 | } 39 | 40 | export interface RunApplePayOptions extends BraintreeOptions { 41 | companyName: string; 42 | } 43 | 44 | export interface PayPalOptions extends BraintreeOptions { 45 | userAction?: 'commit'; 46 | appLinkReturnUrl?: string, 47 | } 48 | 49 | export interface PayPalBillingAgreementOptions { 50 | clientToken: string; 51 | description?: string; 52 | localeCode?: string; 53 | } 54 | 55 | // Export 56 | 57 | interface RNBraintreeModule { 58 | showPayPalModule(options: PayPalOptions): Promise; 59 | runGooglePay(options: BraintreeOptions): Promise; 60 | run3DSecureCheck( 61 | options: Run3DSecureCheckOptions, 62 | ): Promise; 63 | tokenizeCard(options: TokenizeCardOptions): Promise; 64 | runApplePay(options: RunApplePayOptions): Promise; 65 | requestPayPalBillingAgreement( 66 | options: PayPalBillingAgreementOptions, 67 | ): Promise; 68 | getDeviceData(clientToken: string): Promise; 69 | } 70 | 71 | const RNBraintree: RNBraintreeModule; 72 | 73 | export default RNBraintree; 74 | } 75 | -------------------------------------------------------------------------------- /example/ios/reactNativeBraintreeExampleTests/reactNativeBraintreeExampleTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface reactNativeBraintreeExampleTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation reactNativeBraintreeExampleTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL (^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction( 38 | ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 39 | if (level >= RCTLogLevelError) { 40 | redboxError = message; 41 | } 42 | }); 43 | #endif 44 | 45 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 46 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 48 | 49 | foundElement = [self findSubviewInView:vc.view 50 | matching:^BOOL(UIView *view) { 51 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 52 | return YES; 53 | } 54 | return NO; 55 | }]; 56 | } 57 | 58 | #ifdef DEBUG 59 | RCTSetLogFunction(RCTDefaultLogFunction); 60 | #endif 61 | 62 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 63 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Resolve react_native_pods.rb with node to allow for hoisting 2 | require Pod::Executable.execute_command('node', ['-p', 3 | 'require.resolve( 4 | "react-native/scripts/react_native_pods.rb", 5 | {paths: [process.argv[1]]}, 6 | )', __dir__]).strip 7 | 8 | platform :ios, min_ios_version_supported 9 | prepare_react_native_project! 10 | 11 | # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. 12 | # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded 13 | # 14 | # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` 15 | # ```js 16 | # module.exports = { 17 | # dependencies: { 18 | # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), 19 | # ``` 20 | flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled 21 | 22 | linkage = ENV['USE_FRAMEWORKS'] 23 | if linkage != nil 24 | Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green 25 | use_frameworks! :linkage => linkage.to_sym 26 | end 27 | 28 | target 'reactNativeBraintreeExample' do 29 | config = use_native_modules! 30 | 31 | # Flags change depending on the env values. 32 | flags = get_default_flags() 33 | 34 | use_react_native!( 35 | :path => config[:reactNativePath], 36 | # Hermes is now enabled by default. Disable by setting this flag to false. 37 | :hermes_enabled => flags[:hermes_enabled], 38 | :fabric_enabled => flags[:fabric_enabled], 39 | # Enables Flipper. 40 | # 41 | # Note that if you have use_frameworks! enabled, Flipper will not work and 42 | # you should disable the next line. 43 | :flipper_configuration => flipper_config, 44 | # An absolute path to your application root. 45 | :app_path => "#{Pod::Config.instance.installation_root}/.." 46 | ) 47 | 48 | target 'reactNativeBraintreeExampleTests' do 49 | inherit! :complete 50 | # Pods for testing 51 | end 52 | 53 | post_install do |installer| 54 | # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202 55 | react_native_post_install( 56 | installer, 57 | config[:reactNativePath], 58 | :mac_catalyst_enabled => false 59 | ) 60 | __apply_Xcode_12_5_M1_post_install_workaround(installer) 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /example/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | CFPropertyList (3.0.6) 5 | rexml 6 | activesupport (6.1.7.4) 7 | concurrent-ruby (~> 1.0, >= 1.0.2) 8 | i18n (>= 1.6, < 2) 9 | minitest (>= 5.1) 10 | tzinfo (~> 2.0) 11 | zeitwerk (~> 2.3) 12 | addressable (2.8.5) 13 | public_suffix (>= 2.0.2, < 6.0) 14 | algoliasearch (1.27.5) 15 | httpclient (~> 2.8, >= 2.8.3) 16 | json (>= 1.5.1) 17 | atomos (0.1.3) 18 | claide (1.1.0) 19 | cocoapods (1.12.1) 20 | addressable (~> 2.8) 21 | claide (>= 1.0.2, < 2.0) 22 | cocoapods-core (= 1.12.1) 23 | cocoapods-deintegrate (>= 1.0.3, < 2.0) 24 | cocoapods-downloader (>= 1.6.0, < 2.0) 25 | cocoapods-plugins (>= 1.0.0, < 2.0) 26 | cocoapods-search (>= 1.0.0, < 2.0) 27 | cocoapods-trunk (>= 1.6.0, < 2.0) 28 | cocoapods-try (>= 1.1.0, < 2.0) 29 | colored2 (~> 3.1) 30 | escape (~> 0.0.4) 31 | fourflusher (>= 2.3.0, < 3.0) 32 | gh_inspector (~> 1.0) 33 | molinillo (~> 0.8.0) 34 | nap (~> 1.0) 35 | ruby-macho (>= 2.3.0, < 3.0) 36 | xcodeproj (>= 1.21.0, < 2.0) 37 | cocoapods-core (1.12.1) 38 | activesupport (>= 5.0, < 8) 39 | addressable (~> 2.8) 40 | algoliasearch (~> 1.0) 41 | concurrent-ruby (~> 1.1) 42 | fuzzy_match (~> 2.0.4) 43 | nap (~> 1.0) 44 | netrc (~> 0.11) 45 | public_suffix (~> 4.0) 46 | typhoeus (~> 1.0) 47 | cocoapods-deintegrate (1.0.5) 48 | cocoapods-downloader (1.6.3) 49 | cocoapods-plugins (1.0.0) 50 | nap 51 | cocoapods-search (1.0.1) 52 | cocoapods-trunk (1.6.0) 53 | nap (>= 0.8, < 2.0) 54 | netrc (~> 0.11) 55 | cocoapods-try (1.2.0) 56 | colored2 (3.1.2) 57 | concurrent-ruby (1.2.2) 58 | escape (0.0.4) 59 | ethon (0.16.0) 60 | ffi (>= 1.15.0) 61 | ffi (1.15.5) 62 | fourflusher (2.3.1) 63 | fuzzy_match (2.0.4) 64 | gh_inspector (1.1.3) 65 | httpclient (2.8.3) 66 | i18n (1.14.1) 67 | concurrent-ruby (~> 1.0) 68 | json (2.6.3) 69 | minitest (5.19.0) 70 | molinillo (0.8.0) 71 | nanaimo (0.3.0) 72 | nap (1.1.0) 73 | netrc (0.11.0) 74 | public_suffix (4.0.7) 75 | rexml (3.2.6) 76 | ruby-macho (2.5.1) 77 | typhoeus (1.4.0) 78 | ethon (>= 0.9.0) 79 | tzinfo (2.0.6) 80 | concurrent-ruby (~> 1.0) 81 | xcodeproj (1.22.0) 82 | CFPropertyList (>= 2.3.3, < 4.0) 83 | atomos (~> 0.1.3) 84 | claide (>= 1.0.2, < 2.0) 85 | colored2 (~> 3.1) 86 | nanaimo (~> 0.3.0) 87 | rexml (~> 3.2.4) 88 | zeitwerk (2.6.11) 89 | 90 | PLATFORMS 91 | ruby 92 | 93 | DEPENDENCIES 94 | cocoapods (~> 1.12) 95 | 96 | RUBY VERSION 97 | ruby 2.6.10p210 98 | 99 | BUNDLED WITH 100 | 1.17.2 101 | -------------------------------------------------------------------------------- /example/App.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | import React from 'react'; 9 | import type {PropsWithChildren} from 'react'; 10 | import { 11 | SafeAreaView, 12 | ScrollView, 13 | StatusBar, 14 | StyleSheet, 15 | Text, 16 | useColorScheme, 17 | View, 18 | } from 'react-native'; 19 | 20 | import { 21 | Colors, 22 | DebugInstructions, 23 | Header, 24 | LearnMoreLinks, 25 | ReloadInstructions, 26 | } from 'react-native/Libraries/NewAppScreen'; 27 | 28 | type SectionProps = PropsWithChildren<{ 29 | title: string; 30 | }>; 31 | 32 | function Section({children, title}: SectionProps): JSX.Element { 33 | const isDarkMode = useColorScheme() === 'dark'; 34 | return ( 35 | 36 | 43 | {title} 44 | 45 | 52 | {children} 53 | 54 | 55 | ); 56 | } 57 | 58 | function App(): JSX.Element { 59 | const isDarkMode = useColorScheme() === 'dark'; 60 | 61 | const backgroundStyle = { 62 | backgroundColor: isDarkMode ? Colors.darker : Colors.lighter, 63 | }; 64 | 65 | return ( 66 | 67 | 71 | 74 |

75 | 79 |
80 | Edit App.tsx to change this 81 | screen and then come back to see your edits. 82 |
83 |
84 | 85 |
86 |
87 | 88 |
89 |
90 | Read the docs to discover what to do next: 91 |
92 | 93 |
94 | 95 | 96 | ); 97 | } 98 | 99 | const styles = StyleSheet.create({ 100 | sectionContainer: { 101 | marginTop: 32, 102 | paddingHorizontal: 24, 103 | }, 104 | sectionTitle: { 105 | fontSize: 24, 106 | fontWeight: '600', 107 | }, 108 | sectionDescription: { 109 | marginTop: 8, 110 | fontSize: 18, 111 | fontWeight: '400', 112 | }, 113 | highlight: { 114 | fontWeight: '700', 115 | }, 116 | }); 117 | 118 | export default App; 119 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli). 2 | 3 | # Getting Started 4 | 5 | >**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding. 6 | 7 | ## Step 1: Start the Metro Server 8 | 9 | First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native. 10 | 11 | To start Metro, run the following command from the _root_ of your React Native project: 12 | 13 | ```bash 14 | # using npm 15 | npm start 16 | 17 | # OR using Yarn 18 | yarn start 19 | ``` 20 | 21 | ## Step 2: Start your Application 22 | 23 | Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app: 24 | 25 | ### For Android 26 | 27 | ```bash 28 | # using npm 29 | npm run android 30 | 31 | # OR using Yarn 32 | yarn android 33 | ``` 34 | 35 | ### For iOS 36 | 37 | ```bash 38 | # using npm 39 | npm run ios 40 | 41 | # OR using Yarn 42 | yarn ios 43 | ``` 44 | 45 | If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly. 46 | 47 | This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively. 48 | 49 | ## Step 3: Modifying your App 50 | 51 | Now that you have successfully run the app, let's modify it. 52 | 53 | 1. Open `App.tsx` in your text editor of choice and edit some lines. 54 | 2. For **Android**: Press the R key twice or select **"Reload"** from the **Developer Menu** (Ctrl + M (on Window and Linux) or Cmd ⌘ + M (on macOS)) to see your changes! 55 | 56 | For **iOS**: Hit Cmd ⌘ + R in your iOS Simulator to reload the app and see your changes! 57 | 58 | ## Congratulations! :tada: 59 | 60 | You've successfully run and modified your React Native App. :partying_face: 61 | 62 | ### Now what? 63 | 64 | - If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps). 65 | - If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started). 66 | 67 | # Troubleshooting 68 | 69 | If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page. 70 | 71 | # Learn More 72 | 73 | To learn more about React Native, take a look at the following resources: 74 | 75 | - [React Native Website](https://reactnative.dev) - learn more about React Native. 76 | - [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment. 77 | - [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**. 78 | - [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts. 79 | - [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native. 80 | -------------------------------------------------------------------------------- /CONTRIBUTING.uk-UA.md: -------------------------------------------------------------------------------- 1 | 2 | # Пакт про участь - Кодекс поведінки 3 | 4 | ## Наші зобов'язання 5 | 6 | В інтересах зміцнення відкритого і дружнього середовища, ми, як учасники та 7 | супроводжувачі, зобов'язуємось приймати участь в розбудові нашого проєкту та 8 | спільноти навколо нього, уникаючи будь-яких образ та притискань в залежності 9 | від віку, статури, особливих потреб, етнічної та гендерної приналежності, 10 | самовираження, досвіду, національності, зовнішнього вигляду, раси, сексуальної 11 | самоідентифікації та орієнтації. 12 | 13 | ## Наші стандарти 14 | 15 | Приклади поведінки, які сприяють створенню сприятливих умов: 16 | 17 | * Використання доброзичливої та зрозумілої мови 18 | * Повага до різних точок зору та досвіду 19 | * Ввічливе сприйняття конструктивної критики 20 | * Зосередження уваги на тому, що краще для спільноти 21 | * Демонстрація співпереживання по відношенню до інших членів спільноти 22 | 23 | Приклади неприпустимої поведінки до інших учасників: 24 | 25 | * Використання виразів і зображень сексуального характеру, небажана увага 26 | сексуального характеру чи вислови 27 | * Тролінг, образливі/принизливі коментарі або персональні чи політичні 28 | випади 29 | * Публічні чи приватні домагання 30 | * Оприлюднення приватної інформації інших осіб, наприклад поштової чи 31 | електронної адреси, без явної на те згоди 32 | * Інша поведінка, яка обґрунтовано може вважатись недоречною в професійному оточенні 33 | 34 | ## Наші обов'язки 35 | 36 | Супроводжувачі проєкту несуть відповідальність за роз'яснення стандартів 37 | прийнятної поведінки, і від них очікується належне і справедливе 38 | виправлення у відповідь на будь-які випадки неприйнятної поведінки. 39 | 40 | Супроводжувачі проєкту несуть відповідальність та мають право вилучати, 41 | змінювати або відхиляти коментарі, коміти, код, зміни у вікі, записи 42 | та інший вклад в проєкт, що не відповідає Кодексу поведінки, чи блокувати 43 | тимчасово або назавжди будь-якого учасника за його поведінку, якщо вони 44 | вважають такі дії недоцільними, загрозливими, образливими або шкідливими. 45 | 46 | ## Сфера застосування 47 | 48 | Цей Кодекс поведінки застосовується як в середині проєкту, так і публічно, 49 | коли особа представляє проєкт або його спільноту. Приклади представлення 50 | проєкту або його спільноти включають використання офіційної адреси 51 | електронної пошти, публікації в соціальних мережах від імені проєкта, або виступи 52 | на онлайн чи оффлайн подіях в якості представника проєкту. Способи 53 | представництва можуть бути уточнені супроводжувачами проєкта. 54 | 55 | ## Правозастосування 56 | 57 | Про випадки образливого або іншого неприпустимого поводження можна повідомити, 58 | надіславши листа до команди проєкта. Всі скарги 59 | будуть розглянуті та перевірені, що призведе до реакції, що вважається 60 | необхідною і доцільною відповідно до обставин. Команда проєкту зобов'язується 61 | зберігати конфіденційність позивача. Інші деталі щодо правозастосування можуть 62 | оприлюднюватись окремо. 63 | 64 | Супроводжувачі проєкту, які не дотримуються або порушують Кодекс поведінки, 65 | можуть зіткнутися з тимчасовими або постійними наслідками, які визначені членами 66 | керівництва проєкту. 67 | 68 | ## Посилання 69 | 70 | Цей Кодекс поведінки заснований на [Пакті про участь][homepage], версії 1.4, 71 | що знаходиться за адресою https://www.contributor-covenant.org/uk/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributor Covenant Code of Conduct 3 | 4 | ## Our Pledge 5 | 6 | In the interest of fostering an open and welcoming environment, we as 7 | contributors and maintainers pledge to make participation in our project and 8 | our community a harassment-free experience for everyone, regardless of age, body 9 | size, disability, ethnicity, sex characteristics, gender identity and expression, 10 | level of experience, education, socio-economic status, nationality, personal 11 | appearance, race, religion, or sexual identity and orientation. 12 | 13 | ## Our Standards 14 | 15 | Examples of behavior that contributes to creating a positive environment 16 | include: 17 | 18 | * Using welcoming and inclusive language 19 | * Being respectful of differing viewpoints and experiences 20 | * Gracefully accepting constructive criticism 21 | * Focusing on what is best for the community 22 | * Showing empathy towards other community members 23 | 24 | Examples of unacceptable behavior by participants include: 25 | 26 | * The use of sexualized language or imagery and unwelcome sexual attention or 27 | advances 28 | * Trolling, insulting/derogatory comments, and personal or political attacks 29 | * Public or private harassment 30 | * Publishing others' private information, such as a physical or electronic 31 | address, without explicit permission 32 | * Other conduct which could reasonably be considered inappropriate in a 33 | professional setting 34 | 35 | ## Our Responsibilities 36 | 37 | Project maintainers are responsible for clarifying the standards of acceptable 38 | behavior and are expected to take appropriate and fair corrective action in 39 | response to any instances of unacceptable behavior. 40 | 41 | Project maintainers have the right and responsibility to remove, edit, or 42 | reject comments, commits, code, wiki edits, issues, and other contributions 43 | that are not aligned to this Code of Conduct, or to ban temporarily or 44 | permanently any contributor for other behaviors that they deem inappropriate, 45 | threatening, offensive, or harmful. 46 | 47 | ## Scope 48 | 49 | This Code of Conduct applies within all project spaces, and it also applies when 50 | an individual is representing the project or its community in public spaces. 51 | Examples of representing a project or community include using an official 52 | project e-mail address, posting via an official social media account, or acting 53 | as an appointed representative at an online or offline event. Representation of 54 | a project may be further defined and clarified by project maintainers. 55 | 56 | ## Enforcement 57 | 58 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 59 | reported by contacting the project team. All complaints will be reviewed and 60 | investigated and will result in a response that 61 | is deemed necessary and appropriate to the circumstances. The project team is 62 | obligated to maintain confidentiality with regard to the reporter of an incident. 63 | Further details of specific enforcement policies may be posted separately. 64 | 65 | Project maintainers who do not follow or enforce the Code of Conduct in good 66 | faith may face temporary or permanent repercussions as determined by other 67 | members of the project's leadership. 68 | 69 | ## Attribution 70 | 71 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 72 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 73 | 74 | [homepage]: https://www.contributor-covenant.org 75 | 76 | For answers to common questions about this code of conduct, see 77 | https://www.contributor-covenant.org/faq 78 | -------------------------------------------------------------------------------- /example/android/app/src/debug/java/com/reactnativebraintreeexample/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.reactnativebraintreeexample; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 21 | import com.facebook.react.ReactInstanceEventListener; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | /** 28 | * Class responsible of loading Flipper inside your React Native application. This is the debug 29 | * flavor of it. Here you can add your own plugins and customize the Flipper setup. 30 | */ 31 | public class ReactNativeFlipper { 32 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 33 | if (FlipperUtils.shouldEnableFlipper(context)) { 34 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 35 | 36 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 37 | client.addPlugin(new DatabasesFlipperPlugin(context)); 38 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 39 | client.addPlugin(CrashReporterPlugin.getInstance()); 40 | 41 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 42 | NetworkingModule.setCustomClientBuilder( 43 | new NetworkingModule.CustomClientBuilder() { 44 | @Override 45 | public void apply(OkHttpClient.Builder builder) { 46 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 47 | } 48 | }); 49 | client.addPlugin(networkFlipperPlugin); 50 | client.start(); 51 | 52 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 53 | // Hence we run if after all native modules have been initialized 54 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 55 | if (reactContext == null) { 56 | reactInstanceManager.addReactInstanceEventListener( 57 | new ReactInstanceEventListener() { 58 | @Override 59 | public void onReactContextInitialized(ReactContext reactContext) { 60 | reactInstanceManager.removeReactInstanceEventListener(this); 61 | reactContext.runOnNativeModulesQueueThread( 62 | new Runnable() { 63 | @Override 64 | public void run() { 65 | client.addPlugin(new FrescoFlipperPlugin()); 66 | } 67 | }); 68 | } 69 | }); 70 | } else { 71 | client.addPlugin(new FrescoFlipperPlugin()); 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /example/ios/reactNativeBraintreeExample.xcodeproj/xcshareddata/xcschemes/reactNativeBraintreeExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /example/ios/reactNativeBraintreeExample/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // android/build.gradle 2 | 3 | // based on: 4 | // 5 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle 6 | // previous location: 7 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle 8 | // 9 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle 10 | // previous location: 11 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle 12 | 13 | // These defaults should reflect the SDK versions used by 14 | // the minimum React Native version supported. 15 | def DEFAULT_COMPILE_SDK_VERSION = 28 16 | def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3' 17 | def DEFAULT_MIN_SDK_VERSION = 16 18 | def DEFAULT_TARGET_SDK_VERSION = 28 19 | 20 | def safeExtGet(prop, fallback) { 21 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 22 | } 23 | 24 | apply plugin: 'com.android.library' 25 | apply plugin: 'maven-publish' 26 | 27 | buildscript { 28 | // The Android Gradle plugin is only required when opening the android folder stand-alone. 29 | // This avoids unnecessary downloads and potential conflicts when the library is included as a 30 | // module dependency in an application project. 31 | // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies 32 | if (project == rootProject) { 33 | repositories { 34 | google() 35 | jcenter() 36 | } 37 | dependencies { 38 | // This should reflect the Gradle plugin version used by 39 | // the minimum React Native version supported. 40 | classpath 'com.android.tools.build:gradle:3.4.3' 41 | } 42 | } 43 | } 44 | 45 | android { 46 | compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) 47 | buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) 48 | defaultConfig { 49 | minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION) 50 | targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION) 51 | versionCode 1 52 | versionName "1.0" 53 | } 54 | lintOptions { 55 | abortOnError false 56 | } 57 | compileOptions { 58 | sourceCompatibility JavaVersion.VERSION_1_8 59 | targetCompatibility JavaVersion.VERSION_1_8 60 | } 61 | } 62 | 63 | repositories { 64 | // ref: https://www.baeldung.com/maven-local-repository 65 | mavenLocal() 66 | maven { 67 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 68 | url "$rootDir/../node_modules/react-native/android" 69 | } 70 | maven { 71 | // Android JSC is installed from npm 72 | url "$rootDir/../node_modules/jsc-android/dist" 73 | } 74 | maven { 75 | url "https://cardinalcommerceprod.jfrog.io/artifactory/android" 76 | credentials { 77 | username 'braintree_team_sdk' 78 | password 'AKCp8jQcoDy2hxSWhDAUQKXLDPDx6NYRkqrgFLRc3qDrayg6rrCbJpsKKyMwaykVL8FWusJpp' 79 | } 80 | } 81 | google() 82 | jcenter() 83 | } 84 | 85 | dependencies { 86 | //noinspection GradleDynamicVersion 87 | implementation 'com.facebook.react:react-native:+' // From node_modules 88 | implementation 'com.google.android.gms:play-services-wallet:19.4.0' 89 | implementation 'com.braintreepayments.api:data-collector:4.49.1' 90 | implementation 'com.braintreepayments.api:google-pay:4.49.1' 91 | implementation 'com.braintreepayments.api:paypal:4.49.1' 92 | implementation 'com.braintreepayments.api:three-d-secure:4.49.1' 93 | implementation 'com.braintreepayments.api:card:4.49.1' 94 | } 95 | 96 | def configureReactNativePom(def pom) { 97 | def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text) 98 | 99 | pom.project { 100 | name packageJson.title 101 | artifactId packageJson.name 102 | version = packageJson.version 103 | group = "com.ekreative.reactnativebraintree" 104 | description packageJson.description 105 | url packageJson.repository.baseUrl 106 | 107 | licenses { 108 | license { 109 | name packageJson.license 110 | url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename 111 | distribution 'repo' 112 | } 113 | } 114 | 115 | developers { 116 | developer { 117 | id packageJson.author.username 118 | name packageJson.author.name 119 | } 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | apply plugin: "com.facebook.react" 3 | 4 | /** 5 | * This is the configuration block to customize your React Native Android app. 6 | * By default you don't need to apply any configuration, just uncomment the lines you need. 7 | */ 8 | react { 9 | /* Folders */ 10 | // The root of your project, i.e. where "package.json" lives. Default is '..' 11 | // root = file("../") 12 | // The folder where the react-native NPM package is. Default is ../node_modules/react-native 13 | // reactNativeDir = file("../node_modules/react-native") 14 | // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen 15 | // codegenDir = file("../node_modules/@react-native/codegen") 16 | // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js 17 | // cliFile = file("../node_modules/react-native/cli.js") 18 | 19 | /* Variants */ 20 | // The list of variants to that are debuggable. For those we're going to 21 | // skip the bundling of the JS bundle and the assets. By default is just 'debug'. 22 | // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. 23 | // debuggableVariants = ["liteDebug", "prodDebug"] 24 | 25 | /* Bundling */ 26 | // A list containing the node command and its flags. Default is just 'node'. 27 | // nodeExecutableAndArgs = ["node"] 28 | // 29 | // The command to run when bundling. By default is 'bundle' 30 | // bundleCommand = "ram-bundle" 31 | // 32 | // The path to the CLI configuration file. Default is empty. 33 | // bundleConfig = file(../rn-cli.config.js) 34 | // 35 | // The name of the generated asset file containing your JS bundle 36 | // bundleAssetName = "MyApplication.android.bundle" 37 | // 38 | // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' 39 | // entryFile = file("../js/MyApplication.android.js") 40 | // 41 | // A list of extra flags to pass to the 'bundle' commands. 42 | // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle 43 | // extraPackagerArgs = [] 44 | 45 | /* Hermes Commands */ 46 | // The hermes compiler command to run. By default it is 'hermesc' 47 | // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" 48 | // 49 | // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" 50 | // hermesFlags = ["-O", "-output-source-map"] 51 | } 52 | 53 | /** 54 | * Set this to true to Run Proguard on Release builds to minify the Java bytecode. 55 | */ 56 | def enableProguardInReleaseBuilds = false 57 | 58 | /** 59 | * The preferred build flavor of JavaScriptCore (JSC) 60 | * 61 | * For example, to use the international variant, you can use: 62 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 63 | * 64 | * The international variant includes ICU i18n library and necessary data 65 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 66 | * give correct results when using with locales other than en-US. Note that 67 | * this variant is about 6MiB larger per architecture than default. 68 | */ 69 | def jscFlavor = 'org.webkit:android-jsc:+' 70 | 71 | android { 72 | ndkVersion rootProject.ext.ndkVersion 73 | 74 | compileSdkVersion rootProject.ext.compileSdkVersion 75 | 76 | namespace "com.reactnativebraintreeexample" 77 | defaultConfig { 78 | applicationId "com.reactnativebraintreeexample" 79 | minSdkVersion rootProject.ext.minSdkVersion 80 | targetSdkVersion rootProject.ext.targetSdkVersion 81 | versionCode 1 82 | versionName "1.0" 83 | } 84 | signingConfigs { 85 | debug { 86 | storeFile file('debug.keystore') 87 | storePassword 'android' 88 | keyAlias 'androiddebugkey' 89 | keyPassword 'android' 90 | } 91 | } 92 | buildTypes { 93 | debug { 94 | signingConfig signingConfigs.debug 95 | } 96 | release { 97 | // Caution! In production, you need to generate your own keystore file. 98 | // see https://reactnative.dev/docs/signed-apk-android. 99 | signingConfig signingConfigs.debug 100 | minifyEnabled enableProguardInReleaseBuilds 101 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 102 | } 103 | } 104 | } 105 | 106 | dependencies { 107 | // The version of react-native is set by the React Native Gradle Plugin 108 | implementation("com.facebook.react:react-android") 109 | 110 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") 111 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 112 | exclude group:'com.squareup.okhttp3', module:'okhttp' 113 | } 114 | 115 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") 116 | if (hermesEnabled.toBoolean()) { 117 | implementation("com.facebook.react:hermes-android") 118 | } else { 119 | implementation jscFlavor 120 | } 121 | } 122 | 123 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 124 | -------------------------------------------------------------------------------- /ios/RNBraintreeApplePay.m: -------------------------------------------------------------------------------- 1 | @import PassKit; 2 | #import "RNBraintreeApplePay.h" 3 | #import "BraintreeCore.h" 4 | #import "BTDataCollector.h" 5 | #import "BraintreePaymentFlow.h" 6 | #import "BraintreeApplePay.h" 7 | 8 | @interface RNBraintreeApplePay() 9 | 10 | @property (nonatomic, strong) BTAPIClient *apiClient; 11 | @property (nonatomic, strong) BTDataCollector *dataCollector; 12 | @property (nonatomic, strong) RCTPromiseResolveBlock resolve; 13 | @property (nonatomic, strong) RCTPromiseRejectBlock reject; 14 | @property (nonatomic, assign) BOOL isApplePaymentAuthorized; 15 | 16 | @end 17 | 18 | @implementation RNBraintreeApplePay 19 | 20 | RCT_EXPORT_MODULE() 21 | 22 | RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isApplePayAvailable) { 23 | BOOL canMakePayments = [PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks: 24 | @[PKPaymentNetworkVisa, PKPaymentNetworkMasterCard, PKPaymentNetworkAmex, PKPaymentNetworkDiscover]]; 25 | return [NSNumber numberWithBool:canMakePayments]; 26 | } 27 | 28 | RCT_EXPORT_METHOD(runApplePay: (NSDictionary *)options 29 | resolver: (RCTPromiseResolveBlock)resolve 30 | rejecter: (RCTPromiseRejectBlock)reject) { 31 | NSString *companyName = options[@"companyName"]; 32 | NSString *amount = options[@"amount"]; 33 | NSString *clientToken = options[@"clientToken"]; 34 | NSString *currencyCode = options[@"currencyCode"]; 35 | if (!companyName) { 36 | reject(@"NO_COMPANY_NAME", @"You must provide a `companyName`", nil); 37 | return; 38 | } 39 | if (!amount) { 40 | reject(@"NO_TOTAL_PRICE", @"You must provide a `amount`", nil); 41 | return; 42 | } 43 | 44 | self.apiClient = [[BTAPIClient alloc] initWithAuthorization: clientToken]; 45 | self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient]; 46 | 47 | BTApplePayClient *applePayClient = [[BTApplePayClient alloc] initWithAPIClient: self.apiClient]; 48 | 49 | [applePayClient paymentRequest:^(PKPaymentRequest * _Nullable paymentRequest, NSError * _Nullable error) { 50 | if (error) { 51 | reject(@"APPLE_PAY_PAYMENT_REQUEST_FAILED", error.localizedDescription, nil); 52 | return; 53 | } 54 | 55 | if (@available(iOS 11.0, *)) { 56 | paymentRequest.requiredBillingContactFields = [NSSet setWithObject:PKContactFieldPostalAddress]; 57 | } 58 | paymentRequest.merchantCapabilities = PKMerchantCapability3DS; 59 | paymentRequest.paymentSummaryItems = @[ 60 | [PKPaymentSummaryItem summaryItemWithLabel:companyName amount:[NSDecimalNumber decimalNumberWithString:amount]] 61 | ]; 62 | paymentRequest.currencyCode = currencyCode; 63 | self.resolve = resolve; 64 | self.reject = reject; 65 | [self setIsApplePaymentAuthorized:NO]; 66 | PKPaymentAuthorizationViewController *paymentController = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:paymentRequest]; 67 | paymentController.delegate = self; 68 | [[self reactRoot] presentViewController:paymentController animated:YES completion:NULL]; 69 | }]; 70 | } 71 | 72 | - (void)handleTokenizationResult: (BTApplePayCardNonce *)tokenizedApplePayPayment 73 | error: (NSError *)error 74 | completion: (void (^)(PKPaymentAuthorizationStatus))completion{ 75 | if (!tokenizedApplePayPayment && self.reject) { 76 | self.reject(error.localizedDescription, error.localizedDescription, error); 77 | completion(PKPaymentAuthorizationStatusFailure); 78 | [self resetPaymentResolvers]; 79 | return; 80 | } 81 | [self.dataCollector collectDeviceData:^(NSString * _Nonnull deviceData) { 82 | if (self.resolve) { 83 | self.resolve(@{@"deviceData": deviceData, 84 | @"nonce": tokenizedApplePayPayment.nonce}); 85 | completion(PKPaymentAuthorizationStatusSuccess); 86 | [self resetPaymentResolvers]; 87 | } 88 | }]; 89 | } 90 | 91 | - (void)resetPaymentResolvers { 92 | self.resolve = NULL; 93 | self.reject = NULL; 94 | } 95 | 96 | #pragma mark - PKPaymentAuthorizationViewControllerDelegate 97 | - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller 98 | didAuthorizePayment:(PKPayment *)payment 99 | completion:(void (^)(PKPaymentAuthorizationStatus))completion { 100 | [self setIsApplePaymentAuthorized: YES]; 101 | BTApplePayClient *applePayClient = [[BTApplePayClient alloc] initWithAPIClient:self.apiClient]; 102 | [applePayClient tokenizeApplePayPayment:payment 103 | completion:^(BTApplePayCardNonce *tokenizedApplePayPayment, NSError *error) { 104 | [self handleTokenizationResult:tokenizedApplePayPayment error:error completion:completion]; 105 | }]; 106 | } 107 | 108 | - (void)paymentAuthorizationViewControllerDidFinish:(nonnull PKPaymentAuthorizationViewController *)controller { 109 | [controller dismissViewControllerAnimated:YES completion:NULL]; 110 | if (self.reject && [self isApplePaymentAuthorized]) { 111 | self.reject(@"APPLE_PAY_FAILED", @"Apple Pay failed", nil); 112 | } 113 | if (self.isApplePaymentAuthorized == NO) { 114 | self.reject(@"USER_CANCELLATION", @"The user cancelled", nil); 115 | } 116 | [self resetPaymentResolvers]; 117 | self.isApplePaymentAuthorized = NULL; 118 | } 119 | 120 | #pragma mark - RootController 121 | - (UIViewController*)reactRoot { 122 | UIViewController *topViewController = [UIApplication sharedApplication].keyWindow.rootViewController; 123 | if (topViewController.presentedViewController) { 124 | topViewController = topViewController.presentedViewController; 125 | } 126 | return topViewController; 127 | } 128 | 129 | @end 130 | -------------------------------------------------------------------------------- /README.uk-UA.md: -------------------------------------------------------------------------------- 1 | # @ekreative/react-native-braintree 2 | 3 | ## Початок роботи 4 | 5 | ## Специфічно для Android 6 | Додайте це до свого `build.gradle` 7 | 8 | ```groovy 9 | allprojects { 10 | repositories { 11 | maven { 12 | // Braintree 3D Secure 13 | // https://developer.paypal.com/braintree/docs/guides/3d-secure/client-side/android/v4#generate-a-client-token 14 | url "https://cardinalcommerceprod.jfrog.io/artifactory/android" 15 | credentials { 16 | username 'braintree_team_sdk' 17 | password 'AKCp8jQcoDy2hxSWhDAUQKXLDPDx6NYRkqrgFLRc3qDrayg6rrCbJpsKKyMwaykVL8FWusJpp' 18 | } 19 | } 20 | } 21 | } 22 | ``` 23 | 24 | У вашому `AndroidManifest.xml`, `android:allowBackup="false"` можна замінити `android:allowBackup="true"`, він відповідає за резервне копіювання програми. 25 | 26 | Крім того, додайте наступний intent-filter до основного activity в `AndroidManifest.xml` 27 | 28 | ```xml 29 | 30 | ... 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | ``` 40 | **ПРИМІТКА: Платежі карткою не працюють на пристроях з рутованим доступом і емуляторах Android** 41 | 42 | Якщо ваш проект використовує Proguard, додайте наступні рядки у `proguard-rules.pro` файл 43 | ``` 44 | -keep class com.cardinalcommerce.dependencies.internal.bouncycastle.** 45 | -keep class com.cardinalcommerce.dependencies.internal.nimbusds.** 46 | -keep class com.cardinalcommerce.shared.** 47 | ``` 48 | 49 | ## Специфічно для iOS 50 | ```bash 51 | cd ios 52 | pod install 53 | ``` 54 | ###### Налаштуйте нову схему URL-адреси 55 | Додайте схему URL-адреси пакета {BUNDLE_IDENTIFIER}.payments в Info свого додатка через XCode або вручну в Info.plist. У вашому Info.plist ви повинні мати щось на кшталт: 56 | 57 | ```xml 58 | CFBundleURLTypes 59 | 60 | 61 | CFBundleTypeRole 62 | Editor 63 | CFBundleURLName 64 | com.myapp 65 | CFBundleURLSchemes 66 | 67 | com.myapp.payments 68 | 69 | 70 | 71 | ``` 72 | ###### Оновіть свій код 73 | У вашому `AppDelegate.m`: 74 | 75 | ```objective-c 76 | #import "BraintreeCore.h" 77 | 78 | ... 79 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 80 | { 81 | ... 82 | [BTAppContextSwitcher setReturnURLScheme:self.paymentsURLScheme]; 83 | } 84 | 85 | - (BOOL)application:(UIApplication *)application 86 | openURL:(NSURL *)url 87 | options:(NSDictionary *)options { 88 | 89 | if ([url.scheme localizedCaseInsensitiveCompare:self.paymentsURLScheme] == NSOrderedSame) { 90 | return [BTAppContextSwitcher handleOpenURL:url]; 91 | } 92 | 93 | return [RCTLinkingManager application:application openURL:url options:options]; 94 | } 95 | 96 | - (NSString *)paymentsURLScheme { 97 | NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; 98 | return [NSString stringWithFormat:@"%@.%@", bundleIdentifier, @"payments"]; 99 | } 100 | ``` 101 | 102 | 103 | ## Використання 104 | 105 | ##### Показати модуль PayPal 106 | 107 | ```javascript 108 | import RNBraintree from '@ekreative/react-native-braintree'; 109 | 110 | RNBraintree.showPayPalModule({ 111 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 112 | amount: '1.0', 113 | currencyCode: 'EUR' 114 | }) 115 | .then(result => console.log(result)) 116 | .catch((error) => console.log(error)); 117 | 118 | 119 | ``` 120 | 121 | ##### Токенізація картки 122 | ```javascript 123 | import RNBraintree from '@ekreative/react-native-braintree'; 124 | 125 | RNBraintree.tokenizeCard({ 126 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 127 | number: '1111222233334444', 128 | expirationMonth: '11', 129 | expirationYear: '24', 130 | cvv: '123', 131 | postalCode: '', 132 | }) 133 | .then(result => console.log(result)) 134 | .catch((error) => console.log(error)); 135 | 136 | ``` 137 | ##### Здійснити оплату 138 | ```javascript 139 | import RNBraintree from '@ekreative/react-native-braintree'; 140 | 141 | RNBraintree.run3DSecureCheck({ 142 | // Optional if you ran `tokenizeCard()` or other Braintree methods before 143 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 144 | nonce: 'CARD_NONCE', 145 | amount: '122.00', 146 | // Pass as many of the following fields as possible, but they're optional 147 | email: 'email@mail.com', 148 | firstname: '', 149 | lastname: '', 150 | phoneNumber: '', 151 | streetAddress: '', 152 | streetAddress2: '', 153 | city: '', 154 | region: '', 155 | postalCode: '', 156 | countryCode: '' 157 | }) 158 | .then(result => console.log(result)) 159 | .catch((error) => console.log(error)); 160 | ``` 161 | 162 | ##### Запит на платіжну угоду PayPal 163 | ```javascript 164 | import RNBraintree from '@ekreative/react-native-braintree'; 165 | 166 | RNBraintree.requestPayPalBillingAgreement({ 167 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 168 | description: 'BILLING_AGRREEMENT_DESCRIPTION', 169 | localeCode: 'LOCALE_CODE' 170 | }) 171 | .then(result => console.log(result)) 172 | .catch((error) => console.log(error)); 173 | ``` 174 | ### iOS 175 | ##### Перевірте, чи доступний Apple Pay 176 | ```javascript 177 | import RNBraintree from '@ekreative/react-native-braintree'; 178 | 179 | console.log(RNBraintree.isApplePayAvailable()) 180 | ``` 181 | ##### Здійсніть оплату за допомогою Apple Pay 182 | ```javascript 183 | import RNBraintree from '@ekreative/react-native-braintree'; 184 | 185 | RNBraintree.runApplePay({ 186 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 187 | companyName: 'Company', 188 | amount: '100.0', 189 | currencyCode: 'EUR' 190 | }) 191 | .then(result => console.log(result)) 192 | .catch((error) => console.log(error)); 193 | ``` 194 | ### Android 195 | ##### Здійсніть оплату за допомогою Google Pay 196 | ```javascript 197 | import RNBraintree from '@ekreative/react-native-braintree'; 198 | 199 | RNBraintree.runGooglePay({ 200 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 201 | amount: '100.0', 202 | currencyCode: 'EUR' 203 | }) 204 | .then(result => console.log(result)) 205 | .catch((error) => console.log(error)); 206 | ``` 207 | 208 | ## ЗРОБИТИ 209 | 210 | - [ ] Android. Перевірте, чи можемо ми розділити логіку в `getDeviceData` методі, щоб викликати `new DataCollector(mBraintreeClient).collectDeviceData()` лише один раз (схоже, що зараз його можна викликати вдруге з `setup` методу) https://github.com/ekreative/react-native-braintree/pull/37#issuecomment-1752470507 211 | - [ ] iOS. Спробуйте використати новий`getDeviceData` метод в інших методах, наприклад `tokenizeCard`, `showPayPalModule` https://github.com/ekreative/react-native-braintree/pull/37#issuecomment-1752470507 212 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Take a look at the https://github.com/msasinowski/react-native-expo-braintree 2 | 3 | ## Getting started 4 | 5 | ## Android Specific 6 | Add this to your `build.gradle` 7 | 8 | ```groovy 9 | allprojects { 10 | repositories { 11 | maven { 12 | // Braintree 3D Secure 13 | // https://developer.paypal.com/braintree/docs/guides/3d-secure/client-side/android/v4#generate-a-client-token 14 | url "https://cardinalcommerceprod.jfrog.io/artifactory/android" 15 | credentials { 16 | username 'braintree_team_sdk' 17 | password 'AKCp8jQcoDy2hxSWhDAUQKXLDPDx6NYRkqrgFLRc3qDrayg6rrCbJpsKKyMwaykVL8FWusJpp' 18 | } 19 | } 20 | } 21 | } 22 | ``` 23 | 24 | In Your `AndroidManifest.xml`, `android:allowBackup="false"` can be replaced `android:allowBackup="true"`, it is responsible for app backup. 25 | 26 | Also, add this intent-filter to your main activity in `AndroidManifest.xml`: 27 | 28 | ```xml 29 | 30 | ... 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | ``` 39 | 40 | If you need to specify a custom `appLinkReturnUrl`, you may do so: 41 | 42 | ```xml 43 | 44 | ... 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ``` 53 | 54 | You will need to pass this value to to `RNBraintree.showPayPalModule` as an option (see **Show PayPall module** below). 55 | 56 | **NOTE: Card payments do not work on rooted devices and Android Emulators** 57 | 58 | If your project uses Progurad, add the following lines into `proguard-rules.pro` file 59 | ``` 60 | -keep class com.cardinalcommerce.dependencies.internal.bouncycastle.** 61 | -keep class com.cardinalcommerce.dependencies.internal.nimbusds.** 62 | -keep class com.cardinalcommerce.shared.** 63 | ``` 64 | 65 | ## iOS Specific 66 | ```bash 67 | cd ios 68 | pod install 69 | ``` 70 | ###### Configure a new URL scheme 71 | Add a bundle url scheme {BUNDLE_IDENTIFIER}.payments in your app Info via XCode or manually in the Info.plist. In your Info.plist, you should have something like: 72 | 73 | ```xml 74 | CFBundleURLTypes 75 | 76 | 77 | CFBundleTypeRole 78 | Editor 79 | CFBundleURLName 80 | com.myapp 81 | CFBundleURLSchemes 82 | 83 | com.myapp.payments 84 | 85 | 86 | 87 | ``` 88 | ###### Update your code 89 | In your `AppDelegate.m`: 90 | 91 | ```objective-c 92 | #import "BraintreeCore.h" 93 | 94 | ... 95 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 96 | { 97 | ... 98 | [BTAppContextSwitcher setReturnURLScheme:self.paymentsURLScheme]; 99 | } 100 | 101 | - (BOOL)application:(UIApplication *)application 102 | openURL:(NSURL *)url 103 | options:(NSDictionary *)options { 104 | 105 | if ([url.scheme localizedCaseInsensitiveCompare:self.paymentsURLScheme] == NSOrderedSame) { 106 | return [BTAppContextSwitcher handleOpenURL:url]; 107 | } 108 | 109 | return [RCTLinkingManager application:application openURL:url options:options]; 110 | } 111 | 112 | - (NSString *)paymentsURLScheme { 113 | NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; 114 | return [NSString stringWithFormat:@"%@.%@", bundleIdentifier, @"payments"]; 115 | } 116 | ``` 117 | 118 | 119 | ## Usage 120 | 121 | ##### Show PayPall module 122 | 123 | ```javascript 124 | import RNBraintree from '@ekreative/react-native-braintree'; 125 | 126 | RNBraintree.showPayPalModule({ 127 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 128 | amount: '1.0', 129 | currencyCode: 'EUR', 130 | // Change button text to “Complete Purchase", optional 131 | userAction: 'commit', 132 | // Define a custom return URL for Android, optional 133 | appLinkReturnUrl: 'com.application.braintree.custom', 134 | }) 135 | .then(result => console.log(result)) 136 | .catch((error) => console.log(error)); 137 | 138 | 139 | ``` 140 | 141 | ##### Card tokenization 142 | ```javascript 143 | import RNBraintree from '@ekreative/react-native-braintree'; 144 | 145 | RNBraintree.tokenizeCard({ 146 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 147 | number: '1111222233334444', 148 | expirationMonth: '11', 149 | expirationYear: '24', 150 | cvv: '123', 151 | postalCode: '', 152 | }) 153 | .then(result => console.log(result)) 154 | .catch((error) => console.log(error)); 155 | 156 | ``` 157 | ##### Make Payment 158 | ```javascript 159 | import RNBraintree from '@ekreative/react-native-braintree'; 160 | 161 | RNBraintree.run3DSecureCheck({ 162 | // Optional if you ran `tokenizeCard()` or other Braintree methods before 163 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 164 | nonce: 'CARD_NONCE', 165 | amount: '122.00', 166 | // Pass as many of the following fields as possible, but they're optional 167 | email: 'email@mail.com', 168 | firstname: '', 169 | lastname: '', 170 | phoneNumber: '', 171 | streetAddress: '', 172 | streetAddress2: '', 173 | city: '', 174 | region: '', 175 | postalCode: '', 176 | countryCode: '' 177 | }) 178 | .then(result => console.log(result)) 179 | .catch((error) => console.log(error)); 180 | ``` 181 | 182 | ##### Request PayPal billing agreement 183 | ```javascript 184 | import RNBraintree from '@ekreative/react-native-braintree'; 185 | 186 | RNBraintree.requestPayPalBillingAgreement({ 187 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 188 | description: 'BILLING_AGRREEMENT_DESCRIPTION', 189 | localeCode: 'LOCALE_CODE' 190 | }) 191 | .then(result => console.log(result)) 192 | .catch((error) => console.log(error)); 193 | ``` 194 | ### iOS 195 | ##### Check if Apple Pay is available 196 | ```javascript 197 | import RNBraintree from '@ekreative/react-native-braintree'; 198 | 199 | console.log(RNBraintree.isApplePayAvailable()) 200 | ``` 201 | ##### Make payment using Apple Pay 202 | ```javascript 203 | import RNBraintree from '@ekreative/react-native-braintree'; 204 | 205 | RNBraintree.runApplePay({ 206 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 207 | companyName: 'Company', 208 | amount: '100.0', 209 | currencyCode: 'EUR' 210 | }) 211 | .then(result => console.log(result)) 212 | .catch((error) => console.log(error)); 213 | ``` 214 | ### Android 215 | ##### Make payment using Google Pay 216 | ```javascript 217 | import RNBraintree from '@ekreative/react-native-braintree'; 218 | 219 | RNBraintree.runGooglePay({ 220 | clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE', 221 | amount: '100.0', 222 | currencyCode: 'EUR' 223 | }) 224 | .then(result => console.log(result)) 225 | .catch((error) => console.log(error)); 226 | ``` 227 | 228 | ## TODO 229 | 230 | - [ ] Android. Check if we can split the logic in the `getDeviceData` method to call `new DataCollector(mBraintreeClient).collectDeviceData()` only once (it seems like it's currently may be called a second time from the `setup` method) https://github.com/ekreative/react-native-braintree/pull/37#issuecomment-1752470507 231 | - [ ] iOS. Try to use the new `getDeviceData` method in other methods, such as `tokenizeCard`, `showPayPalModule` https://github.com/ekreative/react-native-braintree/pull/37#issuecomment-1752470507 232 | 233 | ## Useful Links and Resources 234 | If you want to read further you can follow these links 235 | 236 | - https://reactnative.directory/?search=react-native-braintree 237 | - https://reintech.io/blog/tutorial-for-react-developers-what-are-the-best-react-native-libraries-for-creating-mobile-payments 238 | - https://reactnativeexample.com/a-react-native-interface-for-integrating-payments-using-braintree/ 239 | - https://www.npmjs.com/package/@ekreative/react-native-braintree 240 | 241 | 242 | ## Contributors 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 147 | # shellcheck disable=SC3045 148 | MAX_FD=$( ulimit -H -n ) || 149 | warn "Could not query maximum file descriptor limit" 150 | esac 151 | case $MAX_FD in #( 152 | '' | soft) :;; #( 153 | *) 154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 155 | # shellcheck disable=SC3045 156 | ulimit -n "$MAX_FD" || 157 | warn "Could not set maximum file descriptor limit to $MAX_FD" 158 | esac 159 | fi 160 | 161 | # Collect all arguments for the java command, stacking in reverse order: 162 | # * args from the command line 163 | # * the main class name 164 | # * -classpath 165 | # * -D...appname settings 166 | # * --module-path (only if needed) 167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 168 | 169 | # For Cygwin or MSYS, switch paths to Windows format before running java 170 | if "$cygwin" || "$msys" ; then 171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 173 | 174 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 175 | 176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 177 | for arg do 178 | if 179 | case $arg in #( 180 | -*) false ;; # don't mess with options #( 181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 182 | [ -e "$t" ] ;; #( 183 | *) false ;; 184 | esac 185 | then 186 | arg=$( cygpath --path --ignore --mixed "$arg" ) 187 | fi 188 | # Roll the args list around exactly as many times as the number of 189 | # args, so each arg winds up back in the position where it started, but 190 | # possibly modified. 191 | # 192 | # NB: a `for` loop captures its iteration list before it begins, so 193 | # changing the positional parameters here affects neither the number of 194 | # iterations, nor the values presented in `arg`. 195 | shift # remove old arg 196 | set -- "$@" "$arg" # push replacement arg 197 | done 198 | fi 199 | 200 | # Collect all arguments for the java command; 201 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 202 | # shell script including quotes and variable substitutions, so put them in 203 | # double quotes to make sure that they get re-expanded; and 204 | # * put everything else in single quotes, so that it's not re-expanded. 205 | 206 | set -- \ 207 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 208 | -classpath "$CLASSPATH" \ 209 | org.gradle.wrapper.GradleWrapperMain \ 210 | "$@" 211 | 212 | # Stop when "xargs" is not available. 213 | if ! command -v xargs >/dev/null 2>&1 214 | then 215 | die "xargs is not available" 216 | fi 217 | 218 | # Use "xargs" to parse quoted args. 219 | # 220 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 221 | # 222 | # In Bash we could simply go: 223 | # 224 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 225 | # set -- "${ARGS[@]}" "$@" 226 | # 227 | # but POSIX shell has neither arrays nor command substitution, so instead we 228 | # post-process each arg (as a line of input to sed) to backslash-escape any 229 | # character that might be a shell metacharacter, then use eval to reverse 230 | # that process (while maintaining the separation between arguments), and wrap 231 | # the whole thing up as a single "set" statement. 232 | # 233 | # This will of course break if any of these variables contains a newline or 234 | # an unmatched quote. 235 | # 236 | 237 | eval "set -- $( 238 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 239 | xargs -n1 | 240 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 241 | tr '\n' ' ' 242 | )" '"$@"' 243 | 244 | exec "$JAVACMD" "$@" 245 | -------------------------------------------------------------------------------- /ios/RNBraintree.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXCopyFilesBuildPhase section */ 10 | 58B511D91A9E6C8500147676 /* CopyFiles */ = { 11 | isa = PBXCopyFilesBuildPhase; 12 | buildActionMask = 2147483647; 13 | dstPath = "include/$(PRODUCT_NAME)"; 14 | dstSubfolderSpec = 16; 15 | files = ( 16 | ); 17 | runOnlyForDeploymentPostprocessing = 0; 18 | }; 19 | /* End PBXCopyFilesBuildPhase section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 134814201AA4EA6300B7C361 /* libRNBraintree.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNBraintree.a; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | /* End PBXFileReference section */ 24 | 25 | /* Begin PBXFrameworksBuildPhase section */ 26 | 58B511D81A9E6C8500147676 /* Frameworks */ = { 27 | isa = PBXFrameworksBuildPhase; 28 | buildActionMask = 2147483647; 29 | files = ( 30 | ); 31 | runOnlyForDeploymentPostprocessing = 0; 32 | }; 33 | /* End PBXFrameworksBuildPhase section */ 34 | 35 | /* Begin PBXGroup section */ 36 | 134814211AA4EA7D00B7C361 /* Products */ = { 37 | isa = PBXGroup; 38 | children = ( 39 | 134814201AA4EA6300B7C361 /* libRNBraintree.a */, 40 | ); 41 | name = Products; 42 | sourceTree = ""; 43 | }; 44 | 58B511D21A9E6C8500147676 = { 45 | isa = PBXGroup; 46 | children = ( 47 | 134814211AA4EA7D00B7C361 /* Products */, 48 | ); 49 | sourceTree = ""; 50 | }; 51 | /* End PBXGroup section */ 52 | 53 | /* Begin PBXNativeTarget section */ 54 | 58B511DA1A9E6C8500147676 /* RNBraintree */ = { 55 | isa = PBXNativeTarget; 56 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNBraintree" */; 57 | buildPhases = ( 58 | 58B511D71A9E6C8500147676 /* Sources */, 59 | 58B511D81A9E6C8500147676 /* Frameworks */, 60 | 58B511D91A9E6C8500147676 /* CopyFiles */, 61 | ); 62 | buildRules = ( 63 | ); 64 | dependencies = ( 65 | ); 66 | name = RNBraintree; 67 | productName = RCTDataManager; 68 | productReference = 134814201AA4EA6300B7C361 /* libRNBraintree.a */; 69 | productType = "com.apple.product-type.library.static"; 70 | }; 71 | /* End PBXNativeTarget section */ 72 | 73 | /* Begin PBXProject section */ 74 | 58B511D31A9E6C8500147676 /* Project object */ = { 75 | isa = PBXProject; 76 | attributes = { 77 | LastUpgradeCheck = 0920; 78 | ORGANIZATIONNAME = Facebook; 79 | TargetAttributes = { 80 | 58B511DA1A9E6C8500147676 = { 81 | CreatedOnToolsVersion = 6.1.1; 82 | }; 83 | }; 84 | }; 85 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNBraintree" */; 86 | compatibilityVersion = "Xcode 3.2"; 87 | developmentRegion = en; 88 | hasScannedForEncodings = 0; 89 | knownRegions = ( 90 | en, 91 | Base, 92 | ); 93 | mainGroup = 58B511D21A9E6C8500147676; 94 | productRefGroup = 58B511D21A9E6C8500147676; 95 | projectDirPath = ""; 96 | projectRoot = ""; 97 | targets = ( 98 | 58B511DA1A9E6C8500147676 /* RNBraintree */, 99 | ); 100 | }; 101 | /* End PBXProject section */ 102 | 103 | /* Begin PBXSourcesBuildPhase section */ 104 | 58B511D71A9E6C8500147676 /* Sources */ = { 105 | isa = PBXSourcesBuildPhase; 106 | buildActionMask = 2147483647; 107 | files = ( 108 | ); 109 | runOnlyForDeploymentPostprocessing = 0; 110 | }; 111 | /* End PBXSourcesBuildPhase section */ 112 | 113 | /* Begin XCBuildConfiguration section */ 114 | 58B511ED1A9E6C8500147676 /* Debug */ = { 115 | isa = XCBuildConfiguration; 116 | buildSettings = { 117 | ALWAYS_SEARCH_USER_PATHS = NO; 118 | CLANG_ANALYZER_NONNULL = YES; 119 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 120 | CLANG_CXX_LIBRARY = "libc++"; 121 | CLANG_ENABLE_MODULES = YES; 122 | CLANG_ENABLE_OBJC_ARC = YES; 123 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 124 | CLANG_WARN_BOOL_CONVERSION = YES; 125 | CLANG_WARN_COMMA = YES; 126 | CLANG_WARN_CONSTANT_CONVERSION = YES; 127 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 128 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 129 | CLANG_WARN_EMPTY_BODY = YES; 130 | CLANG_WARN_ENUM_CONVERSION = YES; 131 | CLANG_WARN_INFINITE_RECURSION = YES; 132 | CLANG_WARN_INT_CONVERSION = YES; 133 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 134 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 135 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 136 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 137 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 138 | CLANG_WARN_STRICT_PROTOTYPES = YES; 139 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 140 | CLANG_WARN_UNREACHABLE_CODE = YES; 141 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 142 | COPY_PHASE_STRIP = NO; 143 | ENABLE_STRICT_OBJC_MSGSEND = YES; 144 | ENABLE_TESTABILITY = YES; 145 | GCC_C_LANGUAGE_STANDARD = gnu99; 146 | GCC_DYNAMIC_NO_PIC = NO; 147 | GCC_NO_COMMON_BLOCKS = YES; 148 | GCC_OPTIMIZATION_LEVEL = 0; 149 | GCC_PREPROCESSOR_DEFINITIONS = ( 150 | "DEBUG=1", 151 | "$(inherited)", 152 | ); 153 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 154 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 155 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 156 | GCC_WARN_UNDECLARED_SELECTOR = YES; 157 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 158 | GCC_WARN_UNUSED_FUNCTION = YES; 159 | GCC_WARN_UNUSED_VARIABLE = YES; 160 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 161 | LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)"; 162 | LIBRARY_SEARCH_PATHS = ( 163 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", 164 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"", 165 | "\"$(inherited)\"", 166 | ); 167 | MTL_ENABLE_DEBUG_INFO = YES; 168 | ONLY_ACTIVE_ARCH = YES; 169 | SDKROOT = iphoneos; 170 | }; 171 | name = Debug; 172 | }; 173 | 58B511EE1A9E6C8500147676 /* Release */ = { 174 | isa = XCBuildConfiguration; 175 | buildSettings = { 176 | ALWAYS_SEARCH_USER_PATHS = NO; 177 | CLANG_ANALYZER_NONNULL = YES; 178 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 179 | CLANG_CXX_LIBRARY = "libc++"; 180 | CLANG_ENABLE_MODULES = YES; 181 | CLANG_ENABLE_OBJC_ARC = YES; 182 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 183 | CLANG_WARN_BOOL_CONVERSION = YES; 184 | CLANG_WARN_COMMA = YES; 185 | CLANG_WARN_CONSTANT_CONVERSION = YES; 186 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 187 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 188 | CLANG_WARN_EMPTY_BODY = YES; 189 | CLANG_WARN_ENUM_CONVERSION = YES; 190 | CLANG_WARN_INFINITE_RECURSION = YES; 191 | CLANG_WARN_INT_CONVERSION = YES; 192 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 193 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 194 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 195 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 196 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 197 | CLANG_WARN_STRICT_PROTOTYPES = YES; 198 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 199 | CLANG_WARN_UNREACHABLE_CODE = YES; 200 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 201 | COPY_PHASE_STRIP = YES; 202 | ENABLE_NS_ASSERTIONS = NO; 203 | ENABLE_STRICT_OBJC_MSGSEND = YES; 204 | GCC_C_LANGUAGE_STANDARD = gnu99; 205 | GCC_NO_COMMON_BLOCKS = YES; 206 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 207 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 208 | GCC_WARN_UNDECLARED_SELECTOR = YES; 209 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 210 | GCC_WARN_UNUSED_FUNCTION = YES; 211 | GCC_WARN_UNUSED_VARIABLE = YES; 212 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 213 | LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)"; 214 | LIBRARY_SEARCH_PATHS = ( 215 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", 216 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"", 217 | "\"$(inherited)\"", 218 | ); 219 | MTL_ENABLE_DEBUG_INFO = NO; 220 | SDKROOT = iphoneos; 221 | VALIDATE_PRODUCT = YES; 222 | }; 223 | name = Release; 224 | }; 225 | 58B511F01A9E6C8500147676 /* Debug */ = { 226 | isa = XCBuildConfiguration; 227 | buildSettings = { 228 | HEADER_SEARCH_PATHS = ( 229 | "$(inherited)", 230 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 231 | "$(SRCROOT)/../../../React/**", 232 | "$(SRCROOT)/../../react-native/React/**", 233 | ); 234 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 235 | OTHER_LDFLAGS = "-ObjC"; 236 | PRODUCT_NAME = RNBraintree; 237 | SKIP_INSTALL = YES; 238 | }; 239 | name = Debug; 240 | }; 241 | 58B511F11A9E6C8500147676 /* Release */ = { 242 | isa = XCBuildConfiguration; 243 | buildSettings = { 244 | HEADER_SEARCH_PATHS = ( 245 | "$(inherited)", 246 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 247 | "$(SRCROOT)/../../../React/**", 248 | "$(SRCROOT)/../../react-native/React/**", 249 | ); 250 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 251 | OTHER_LDFLAGS = "-ObjC"; 252 | PRODUCT_NAME = RNBraintree; 253 | SKIP_INSTALL = YES; 254 | }; 255 | name = Release; 256 | }; 257 | /* End XCBuildConfiguration section */ 258 | 259 | /* Begin XCConfigurationList section */ 260 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNBraintree" */ = { 261 | isa = XCConfigurationList; 262 | buildConfigurations = ( 263 | 58B511ED1A9E6C8500147676 /* Debug */, 264 | 58B511EE1A9E6C8500147676 /* Release */, 265 | ); 266 | defaultConfigurationIsVisible = 0; 267 | defaultConfigurationName = Release; 268 | }; 269 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNBraintree" */ = { 270 | isa = XCConfigurationList; 271 | buildConfigurations = ( 272 | 58B511F01A9E6C8500147676 /* Debug */, 273 | 58B511F11A9E6C8500147676 /* Release */, 274 | ); 275 | defaultConfigurationIsVisible = 0; 276 | defaultConfigurationName = Release; 277 | }; 278 | /* End XCConfigurationList section */ 279 | }; 280 | rootObject = 58B511D31A9E6C8500147676 /* Project object */; 281 | } 282 | -------------------------------------------------------------------------------- /ios/RNBraintree.m: -------------------------------------------------------------------------------- 1 | #import "RNBraintree.h" 2 | #import "BraintreeCore.h" 3 | #import "BTCardClient.h" 4 | #import "BraintreePayPal.h" 5 | #import "BTDataCollector.h" 6 | #import "BraintreePaymentFlow.h" 7 | #import "BraintreeThreeDSecure.h" 8 | 9 | @interface RNBraintree() 10 | @property (nonatomic, strong) BTAPIClient *apiClient; 11 | @property (nonatomic, strong) BTDataCollector *dataCollector; 12 | @end 13 | 14 | @implementation RNBraintree 15 | 16 | RCT_EXPORT_MODULE() 17 | 18 | RCT_EXPORT_METHOD(showPayPalModule: (NSDictionary *)options 19 | resolver: (RCTPromiseResolveBlock)resolve 20 | rejecter: (RCTPromiseRejectBlock)reject) { 21 | NSString *clientToken = options[@"clientToken"]; 22 | NSString *amount = options[@"amount"]; 23 | NSString *currencyCode = options[@"currencyCode"]; 24 | NSString *userAction = options[@"userAction"]; 25 | 26 | self.apiClient = [[BTAPIClient alloc] initWithAuthorization: clientToken]; 27 | self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient]; 28 | BTPayPalDriver *payPalDriver = [[BTPayPalDriver alloc] initWithAPIClient: self.apiClient]; 29 | 30 | BTPayPalCheckoutRequest *request= [[BTPayPalCheckoutRequest alloc] initWithAmount:amount]; 31 | request.currencyCode = currencyCode; 32 | if (userAction && [@"commit" isEqualToString:userAction]) { 33 | request.userAction = BTPayPalRequestUserActionCommit; 34 | } 35 | [payPalDriver tokenizePayPalAccountWithPayPalRequest:request completion:^(BTPayPalAccountNonce * _Nullable tokenizedPayPalAccount, NSError * _Nullable error) { 36 | if (error) { 37 | reject(@"ONE_TIME_PAYMENT_FAILED", error.localizedDescription, nil); 38 | return; 39 | } 40 | if (!tokenizedPayPalAccount) { 41 | reject(@"ONE_TIME_PAYMENT_CANCELLED", @"Payment has been cancelled", nil); 42 | return; 43 | } 44 | [self.dataCollector collectDeviceData:^(NSString * _Nonnull deviceData) { 45 | resolve(@{@"deviceData": deviceData, 46 | @"email": tokenizedPayPalAccount.email, 47 | @"nonce": tokenizedPayPalAccount.nonce,}); 48 | }]; 49 | }]; 50 | } 51 | 52 | RCT_EXPORT_METHOD(requestPayPalBillingAgreement: (NSDictionary *)options 53 | resolver: (RCTPromiseResolveBlock)resolve 54 | rejecter: (RCTPromiseRejectBlock)reject) { 55 | NSString *clientToken = options[@"clientToken"]; 56 | NSString *description = options[@"description"]; 57 | 58 | self.apiClient = [[BTAPIClient alloc] initWithAuthorization: clientToken]; 59 | self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient]; 60 | BTPayPalDriver *payPalDriver = [[BTPayPalDriver alloc] initWithAPIClient: self.apiClient]; 61 | 62 | BTPayPalVaultRequest *request= [[BTPayPalVaultRequest alloc] init]; 63 | if (description) { 64 | request.billingAgreementDescription = description; 65 | } 66 | [payPalDriver tokenizePayPalAccountWithPayPalRequest:request completion:^(BTPayPalAccountNonce * _Nullable tokenizedPayPalAccount, NSError * _Nullable error) { 67 | if (error) { 68 | reject(@"REQUEST_BILLING_AGREEMENT_FAILED", error.localizedDescription, nil); 69 | return; 70 | } 71 | if (!tokenizedPayPalAccount) { 72 | reject(@"REQUEST_BILLING_AGREEMENT_CANCELLED", @"Request billing agreement has been cancelled", nil); 73 | return; 74 | } 75 | [self.dataCollector collectDeviceData:^(NSString * _Nonnull deviceData) { 76 | resolve(@{@"deviceData": deviceData, 77 | @"nonce": tokenizedPayPalAccount.nonce,}); 78 | }]; 79 | }]; 80 | } 81 | 82 | RCT_EXPORT_METHOD(tokenizeCard: (NSDictionary *)parameters 83 | resolver: (RCTPromiseResolveBlock)resolve 84 | rejecter: (RCTPromiseRejectBlock)reject) { 85 | 86 | NSString *clientToken = parameters[@"clientToken"]; 87 | self.apiClient = [[BTAPIClient alloc] initWithAuthorization: clientToken]; 88 | self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient]; 89 | BTCardClient *cardClient = [[BTCardClient alloc] initWithAPIClient: self.apiClient]; 90 | 91 | BTCard *card = [[BTCard alloc] init]; 92 | card.number = parameters[@"number"]; 93 | card.expirationMonth = parameters[@"expirationMonth"]; 94 | card.expirationYear = parameters[@"expirationYear"]; 95 | card.cvv = parameters[@"cvv"]; 96 | card.postalCode = parameters[@"postalCode"]; 97 | card.shouldValidate = NO; 98 | 99 | [cardClient tokenizeCard:card completion:^(BTCardNonce * _Nullable tokenizedCard, NSError * _Nullable error) { 100 | if (error) { 101 | reject(@"TOKENIZE_FAILED", error.localizedDescription, nil); 102 | return; 103 | } 104 | [self.dataCollector collectDeviceData:^(NSString * _Nonnull deviceData) { 105 | resolve(@{@"deviceData": deviceData, 106 | @"nonce": tokenizedCard.nonce,}); 107 | }]; 108 | }]; 109 | } 110 | 111 | RCT_EXPORT_METHOD(run3DSecureCheck: (NSDictionary *)parameters 112 | resolver: (RCTPromiseResolveBlock)resolve 113 | rejecter: (RCTPromiseRejectBlock)reject) { 114 | [self startPaymentFlow:parameters 115 | resolver:resolve 116 | rejecter:reject]; 117 | } 118 | 119 | RCT_EXPORT_METHOD(getDeviceData: (NSString *) clientToken 120 | resolver: (RCTPromiseResolveBlock)resolve 121 | rejecter: (RCTPromiseRejectBlock)reject) { 122 | self.apiClient = [[BTAPIClient alloc] initWithAuthorization: clientToken]; 123 | self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient]; 124 | [self.dataCollector collectDeviceData:^(NSString * _Nonnull deviceData) { 125 | resolve(deviceData); 126 | }]; 127 | } 128 | 129 | #pragma mark - 3D Secure 130 | - (void)startPaymentFlow: (NSDictionary *)parameters 131 | resolver: (RCTPromiseResolveBlock)resolve 132 | rejecter: (RCTPromiseRejectBlock)reject { 133 | NSString *clientToken = parameters[@"clientToken"]; 134 | if (self.apiClient == NULL) { 135 | if (clientToken == NULL) { 136 | reject(@"MISSING_CLIENT_TOKEN", @"clientToken must be passed if Braintree methods weren't run before", nil); 137 | } 138 | self.apiClient = [[BTAPIClient alloc] initWithAuthorization: clientToken]; 139 | } 140 | self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient]; 141 | 142 | BTThreeDSecureRequest *threeDSecureRequest = [[BTThreeDSecureRequest alloc] init]; 143 | threeDSecureRequest.amount = [NSDecimalNumber decimalNumberWithString: parameters[@"amount"]]; 144 | threeDSecureRequest.nonce = parameters[@"nonce"]; 145 | threeDSecureRequest.threeDSecureRequestDelegate = self; 146 | threeDSecureRequest.email = parameters[@"email"]; 147 | threeDSecureRequest.versionRequested = BTThreeDSecureVersion2; 148 | 149 | BTThreeDSecurePostalAddress *address = [BTThreeDSecurePostalAddress new]; 150 | address.givenName = parameters[@"firstname"]; // ASCII-printable characters required, else will throw a validation error 151 | address.surname = parameters[@"lastname"]; // ASCII-printable characters required, else will throw a validation error 152 | address.phoneNumber = parameters[@"phoneNumber"]; 153 | address.streetAddress = parameters[@"streetAddress"]; 154 | address.extendedAddress = parameters[@"streetAddress2"]; 155 | address.locality = parameters[@"city"]; 156 | address.region = parameters[@"region"]; 157 | address.postalCode = parameters[@"postalCode"]; 158 | address.countryCodeAlpha2 = parameters[@"countryCode"]; 159 | 160 | BTThreeDSecureAdditionalInformation *additionalInformation = [BTThreeDSecureAdditionalInformation new]; 161 | additionalInformation.shippingAddress = address; 162 | 163 | threeDSecureRequest.additionalInformation = additionalInformation; 164 | threeDSecureRequest.billingAddress = address; 165 | 166 | BTPaymentFlowDriver *paymentFlowDriver = [[BTPaymentFlowDriver alloc] initWithAPIClient:self.apiClient]; 167 | paymentFlowDriver.viewControllerPresentingDelegate = self; 168 | 169 | [paymentFlowDriver startPaymentFlow:threeDSecureRequest completion:^(BTPaymentFlowResult * _Nonnull result, NSError * _Nonnull error) { 170 | if (error) { 171 | reject(@"PAYMENT_FAILED", error.localizedDescription, nil); 172 | return; 173 | } 174 | BTThreeDSecureResult *threeDSecureResult = (BTThreeDSecureResult *)result; 175 | if (!threeDSecureResult.tokenizedCard.threeDSecureInfo.liabilityShiftPossible && threeDSecureResult.tokenizedCard.threeDSecureInfo.wasVerified) { 176 | reject(@"3DSECURE_NOT_ABLE_TO_SHIFT_LIABILITY", @"3D Secure liability cannot be shifted", nil); 177 | return; 178 | } 179 | if (!threeDSecureResult.tokenizedCard.threeDSecureInfo.liabilityShifted && threeDSecureResult.tokenizedCard.threeDSecureInfo.wasVerified) { 180 | reject(@"3DSECURE_LIABILITY_NOT_SHIFTED", @"3D Secure liability was not shifted", nil); 181 | } 182 | if (!threeDSecureResult.tokenizedCard.nonce) { 183 | reject(@"PAYMENT_3D_SECURE_FAILED", @"Something went wrong", nil); 184 | return; 185 | } 186 | [self.dataCollector collectDeviceData:^(NSString * _Nonnull deviceData) { 187 | resolve(@{@"deviceData": deviceData, 188 | @"nonce": threeDSecureResult.tokenizedCard.nonce}); 189 | }]; 190 | return; 191 | }]; 192 | } 193 | 194 | #pragma mark - BTViewControllerPresentingDelegate 195 | - (void)paymentDriver:(nonnull id)driver requestsPresentationOfViewController:(nonnull UIViewController *)viewController { 196 | [self.reactRoot presentViewController:viewController animated:YES completion:nil]; 197 | } 198 | 199 | - (void)paymentDriver:(nonnull id)driver requestsDismissalOfViewController:(nonnull UIViewController *)viewController { 200 | [viewController dismissViewControllerAnimated:YES completion:nil]; 201 | } 202 | 203 | #pragma mark - BTThreeDSecureRequestDelegate 204 | 205 | - (void)onLookupComplete:(BTThreeDSecureRequest *)request lookupResult:(BTThreeDSecureResult *)result next:(void (^)(void))next { 206 | next(); 207 | } 208 | 209 | #pragma mark - RootController 210 | - (UIViewController*)reactRoot { 211 | UIViewController *topViewController = [UIApplication sharedApplication].keyWindow.rootViewController; 212 | if (topViewController.presentedViewController) { 213 | topViewController = topViewController.presentedViewController; 214 | } 215 | return topViewController; 216 | } 217 | 218 | @end 219 | -------------------------------------------------------------------------------- /docs/migration-objc-to-swift-guide.md: -------------------------------------------------------------------------------- 1 | # Objective-C to Swift Codebase Migration Guide 2 | 3 | ## Introduction 4 | This document serves as a guide to migrate an existing codebase written in Objective-C to Swift. Migrating to Swift offers several benefits, including improved safety, readability, and maintainability of your code. This guide will provide an overview of the migration process and best practices to follow. 5 | 6 | **Note:** This guide assumes that you have a basic understanding of both Objective-C and Swift. 7 | 8 | ## Table of Contents 9 | 1. [Preparation](#preparation) 10 | 2. [Xcode Project Configuration](#xcode-project-configuration) 11 | 3. [Migration Steps](#migration-steps) 12 | - [RNBraintree] (#RNBraintree) 13 | - [RNBraintreeApplePay] 14 | 4. [Common Migration Challenges](#common-migration-challenges) 15 | 5. [Resources](#resources) 16 | 17 | ## 1. Preparation 18 | 19 | Before you start the migration, it's important to make sure you have the following in place: 20 | 21 | - **Back Up Your Code:** Create a backup of your Objective-C codebase to ensure you can return to it if needed. 22 | 23 | - **Version Control:** Ensure that your codebase is under version control (e.g., Git). This will help track changes and collaborate effectively. 24 | 25 | - **Latest Xcode Version:** Make sure you are using the latest version of Xcode with support for both Objective-C and Swift. 26 | 27 | ## 2. Xcode Project Configuration 28 | 29 | - Open your Xcode project. 30 | 31 | - Set your project's build settings to use Swift as the primary language. 32 | 33 | - Configure your project settings to use a Bridging Header for Objective-C to Swift interoperability. 34 | 35 | ## 3. Migration Steps 36 | 37 | ### RNBrainTree 38 | 39 | Create new Swift file with the name `RNBrainTree.swift` and paste the migrated code: 40 | ```swift 41 | // RNBrainTree.swift 42 | import Foundation 43 | import React 44 | import BraintreeCore 45 | import BraintreeCard 46 | import BraintreeApplePay 47 | import BraintreePayPal 48 | 49 | @objc(RNBraintree) 50 | class RNBraintree: NSObject, BTViewControllerPresentingDelegate, BTThreeDSecureRequestDelegate { 51 | private var apiClient: BTAPIClient? 52 | private var dataCollector: BTDataCollector? 53 | 54 | @objc 55 | func showPayPalModule( 56 | _ options: NSDictionary, 57 | resolver resolve: @escaping RCTPromiseResolveBlock, 58 | rejecter reject: @escaping RCTPromiseRejectBlock 59 | ) { 60 | guard let clientToken = options["clientToken"] as? String, 61 | let amount = options["amount"] as? String, 62 | let currencyCode = options["currencyCode"] as? String 63 | else { 64 | reject("INVALID_PARAMETERS", "Invalid parameters", nil) 65 | return 66 | } 67 | 68 | // You may want to check if apiClient and dataCollector are already initialized. 69 | if self.apiClient == nil { 70 | self.apiClient = BTAPIClient(authorization: clientToken) 71 | self.dataCollector = BTDataCollector(apiClient: self.apiClient!) 72 | } 73 | 74 | let payPalDriver = BTPayPalDriver(apiClient: self.apiClient!) 75 | let request = BTPayPalCheckoutRequest(amount: amount) 76 | request.currencyCode = currencyCode 77 | 78 | payPalDriver.tokenizePayPalAccount(with: request) { tokenizedPayPalAccount, error in 79 | if let error = error { 80 | reject("ONE_TIME_PAYMENT_FAILED", error.localizedDescription, nil) 81 | return 82 | } 83 | 84 | if tokenizedPayPalAccount == nil { 85 | reject("ONE_TIME_PAYMENT_CANCELLED", "Payment has been cancelled", nil) 86 | return 87 | } 88 | 89 | self.dataCollector.collectDeviceData { deviceData in 90 | resolve(["deviceData": deviceData, "email": tokenizedPayPalAccount.email, "nonce": tokenizedPayPalAccount?.nonce]) 91 | } 92 | } 93 | } 94 | 95 | @objc 96 | func requestPayPalBillingAgreement( 97 | _ options: NSDictionary, 98 | resolver resolve: @escaping RCTPromiseResolveBlock, 99 | rejecter reject: @escaping RCTPromiseRejectBlock 100 | ) { 101 | 102 | guard let clientToken = options["clientToken"] as? String, 103 | let description = options["description"] as? String 104 | else { 105 | reject("INVALID_PARAMETERS", "Invalid parameters", nil) 106 | return 107 | } 108 | 109 | // You may want to check if apiClient and dataCollector are already initialized. 110 | if self.apiClient == nil { 111 | self.apiClient = BTAPIClient(authorization: clientToken) 112 | self.dataCollector = BTDataCollector(apiClient: self.apiClient!) 113 | } 114 | 115 | let payPalDriver = BTPayPalDriver(apiClient: self.apiClient!) 116 | let request = BTPayPalVaultRequest() 117 | 118 | if description { 119 | request.billingAgreementDescription = description; 120 | } 121 | 122 | payPalDriver.tokenizePayPalAccount(with: request) { tokenizedPayPalAccount, error in 123 | if let error = error { 124 | reject("REQUEST_BILLING_AGREEMENT_FAILED", error.localizedDescription, nil) 125 | return 126 | } 127 | 128 | if tokenizedPayPalAccount == nil { 129 | reject("REQUEST_BILLING_AGREEMENT_CANCELLED", "Request billing agreement has been cancelled", nil) 130 | return 131 | } 132 | 133 | self.dataCollector.collectDeviceData { deviceData in 134 | resolve(["deviceData": deviceData, "nonce": tokenizedPayPalAccount.nonce]) 135 | } 136 | } 137 | } 138 | 139 | @objc 140 | func tokenizeCard( 141 | _ parameters: NSDictionary, 142 | resolver resolve: @escaping RCTPromiseResolveBlock, 143 | rejecter reject: @escaping RCTPromiseRejectBlock 144 | ) { 145 | guard let clientToken = parameters["clientToken"] as? String, 146 | let number = parameters["number"] as? String, 147 | let expirationMonth = parameters["expirationMonth"] as? String, 148 | let expirationYear = parameters["expirationYear"] as? String, 149 | let cvv = parameters["cvv"] as? String 150 | else { 151 | reject("INVALID_PARAMETERS", "Invalid parameters", nil) 152 | return 153 | } 154 | 155 | // Initialize the Braintree API client and data collector 156 | self.apiClient = BTAPIClient(authorization: clientToken) 157 | self.dataCollector = BTDataCollector(apiClient: self.apiClient!) 158 | 159 | // Initialize the card client 160 | let cardClient = BTCardClient(apiClient: self.apiClient) 161 | 162 | // Create a BTCard instance and set its properties 163 | let card = BTCard() 164 | card.number = number 165 | card.expirationMonth = expirationMonth 166 | card.expirationYear = expirationYear 167 | card.cvv = cvv 168 | card.postalCode = parameters["postalCode"] as? String 169 | card.shouldValidate = false 170 | 171 | cardClient.tokenizeCard(card) { tokenizedCard, error in 172 | if let error = error || tokenizedCard == nil { 173 | reject("TOKENIZE_FAILED", error.localizedDescription, nil) 174 | return 175 | } 176 | 177 | self.dataCollector.collectDeviceData { deviceData in 178 | resolve(["deviceData": deviceData, "nonce": tokenizedCard.nonce]) 179 | } 180 | } 181 | } 182 | 183 | @objc 184 | func run3DSecureCheck( 185 | _ parameters: NSDictionary, 186 | resolver resolve: @escaping RCTPromiseResolveBlock, 187 | rejecter reject: @escaping RCTPromiseRejectBlock 188 | ) { 189 | self.startPaymentFlow(parameters, resolver: resolve, rejecter: reject) 190 | } 191 | 192 | @objc 193 | func getDeviceData( 194 | _ clientToken: String, 195 | resolver resolve: @escaping RCTPromiseResolveBlock, 196 | rejecter reject: @escaping RCTPromiseRejectBlock 197 | ) { 198 | if self.apiClient == nil { 199 | self.apiClient = BTAPIClient(authorization: clientToken) 200 | self.dataCollector = BTDataCollector(apiClient: self.apiClient!) 201 | } 202 | 203 | self.dataCollector.collectDeviceData { deviceData in 204 | resolve(deviceData) 205 | } 206 | } 207 | 208 | // MARK: - 3D Secure 209 | private func startPaymentFlow( 210 | _ parameters: NSDictionary, 211 | resolver resolve: @escaping RCTPromiseResolveBlock, 212 | rejecter reject: @escaping RCTPromiseRejectBlock 213 | ) { 214 | guard let clientToken = parameters["clientToken"] as? String 215 | else { 216 | reject("MISSING_CLIENT_TOKEN", "clientToken must be passed if Braintree methods weren't run before", nil) 217 | } 218 | 219 | if self.apiClient == nil { 220 | self.apiClient = BTAPIClient(authorization: clientToken) 221 | self.dataCollector = BTDataCollector(apiClient: self.apiClient!) 222 | } 223 | 224 | let threeDSecureRequest = BTThreeDSecureRequest() 225 | threeDSecureRequest.amount = NSDecimalNumber(string: parameters["amount"] as? String ?? "") 226 | threeDSecureRequest.nonce = parameters["nonce"] as? String 227 | threeDSecureRequest.threeDSecureRequestDelegate = self 228 | threeDSecureRequest.email = parameters["email"] as? String 229 | threeDSecureRequest.versionRequested = .version2 230 | 231 | let address = BTThreeDSecurePostalAddress() 232 | address.givenName = parameters["firstname"] as? String // ASCII-printable characters required, else will throw a validation error 233 | address.surname = parameters["lastname"] as? String // ASCII-printable characters required, else will throw a validation error 234 | address.phoneNumber = parameters["phoneNumber"] as? String 235 | address.streetAddress = parameters["streetAddress"] as? String 236 | address.extendedAddress = parameters["streetAddress2"] as? String 237 | address.locality = parameters["city"] as? String 238 | address.region = parameters["region"] as? String 239 | address.postalCode = parameters["postalCode"] as? String 240 | address.countryCodeAlpha2 = parameters["countryCode"] as? String 241 | 242 | let additionalInformation = BTThreeDSecureAdditionalInformation() 243 | additionalInformation.shippingAddress = address 244 | 245 | threeDSecureRequest.additionalInformation = additionalInformation 246 | threeDSecureRequest.billingAddress = address 247 | 248 | let paymentFlowDriver = BTPaymentFlowDriver(apiClient: apiClient) 249 | paymentFlowDriver.viewControllerPresentingDelegate = self 250 | 251 | paymentFlowDriver.startPaymentFlow(with: threeDSecureRequest) { result, error in 252 | if let error = error { 253 | reject("PAYMENT_FAILED", error.localizedDescription, nil) 254 | return 255 | } 256 | 257 | if let threeDSecureResult = result as? BTThreeDSecureResult, 258 | let tokenizedCard = threeDSecureResult.tokenizedCard, 259 | let nonce = tokenizedCard.nonce { 260 | if !tokenizedCard.threeDSecureInfo.liabilityShiftPossible && tokenizedCard.threeDSecureInfo.wasVerified { 261 | reject("3DSECURE_NOT_ABLE_TO_SHIFT_LIABILITY", "3D Secure liability cannot be shifted", nil) 262 | return 263 | } 264 | if !tokenizedCard.threeDSecureInfo.liabilityShifted && tokenizedCard.threeDSecureInfo.wasVerified { 265 | reject("3DSECURE_LIABILITY_NOT_SHIFTED", "3D Secure liability was not shifted", nil) 266 | } 267 | resolve(["deviceData": deviceData, "nonce": nonce]) 268 | } else { 269 | reject("PAYMENT_3D_SECURE_FAILED", "Something went wrong", nil) 270 | } 271 | } 272 | } 273 | 274 | // MARK: - BTViewControllerPresentingDelegate 275 | func paymentDriver(_ driver: Any, requestsPresentationOf viewController: UIViewController) { 276 | reactRoot.present(viewController, animated: true, completion: nil) 277 | } 278 | 279 | func paymentDriver(_ driver: Any, requestsDismissalOf viewController: UIViewController) { 280 | viewController.dismiss(animated: true, completion: nil) 281 | } 282 | 283 | // MARK: - BTThreeDSecureRequestDelegate 284 | func onLookupComplete(_ request: BTThreeDSecureRequest, lookupResult result: BTThreeDSecureResult, next: @escaping () -> Void) { 285 | next() 286 | } 287 | 288 | // MARK: - RootController 289 | var reactRoot: UIViewController? { 290 | var topViewController = UIApplication.shared.keyWindow?.rootViewController 291 | if let presentedViewController = topViewController?.presentedViewController { 292 | topViewController = presentedViewController 293 | } 294 | return topViewController 295 | } 296 | } 297 | ``` 298 | 299 | Replace the content of `RNBraintree.m` with the following 300 | ```objective-c 301 | // RNBraintree.m 302 | 303 | #import 304 | 305 | // Export a native module 306 | @interface RCT_EXTERN_MODULE(RNBraintree, NSObject) 307 | 308 | // Export methods to a native module 309 | RCT_EXTERN_METHOD(showPayPalModule: (NSDictionary *)options 310 | resolver: (RCTPromiseResolveBlock)resolve 311 | rejecter: (RCTPromiseRejectBlock)reject) 312 | 313 | RCT_EXTERN_METHOD(requestPayPalBillingAgreement: (NSDictionary *)options 314 | resolver: (RCTPromiseResolveBlock)resolve 315 | rejecter: (RCTPromiseRejectBlock)reject) 316 | 317 | RCT_EXTERN_METHOD(tokenizeCard: (NSDictionary *)parameters 318 | resolver: (RCTPromiseResolveBlock)resolve 319 | rejecter: (RCTPromiseRejectBlock)reject) 320 | 321 | RCT_EXTERN_METHOD(run3DSecureCheck: (NSDictionary *)parameters 322 | resolver: (RCTPromiseResolveBlock)resolve 323 | rejecter: (RCTPromiseRejectBlock)reject) 324 | 325 | RCT_EXTERN_METHOD(getDeviceData: (NSString *) clientToken 326 | resolver: (RCTPromiseResolveBlock)resolve 327 | rejecter: (RCTPromiseRejectBlock)reject) 328 | @end 329 | ``` 330 | 331 | 332 | ### RNBrainTreeApplePay 333 | - TODO 334 | 335 | ## 4. Common Migration Challenges 336 | 337 | - TODO 338 | 339 | ## 5. Resources 340 | 341 | - https://reactnative.dev/docs/native-modules-ios#exporting-swift 342 | - https://gist.github.com/JofArnold/31dfa8edcc3b8a42bbd86fbd44dad804 343 | - https://gaitatzis.medium.com/react-native-native-modules-in-ios-swift-97eb9073f5a2 344 | -------------------------------------------------------------------------------- /android/src/main/java/com/ekreative/reactnativebraintree/RNBraintreeModule.java: -------------------------------------------------------------------------------- 1 | // RNBraintreeModule.java 2 | 3 | package com.ekreative.reactnativebraintree; 4 | 5 | import android.app.Activity; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | 9 | import androidx.annotation.Nullable; 10 | import androidx.fragment.app.FragmentActivity; 11 | 12 | import com.braintreepayments.api.BraintreeClient; 13 | import com.braintreepayments.api.BraintreeRequestCodes; 14 | import com.braintreepayments.api.BrowserSwitchResult; 15 | import com.braintreepayments.api.Card; 16 | import com.braintreepayments.api.CardClient; 17 | import com.braintreepayments.api.DataCollector; 18 | import com.braintreepayments.api.GooglePayClient; 19 | import com.braintreepayments.api.GooglePayRequest; 20 | import com.braintreepayments.api.PayPalAccountNonce; 21 | import com.braintreepayments.api.PayPalCheckoutRequest; 22 | import com.braintreepayments.api.PayPalClient; 23 | import com.braintreepayments.api.PayPalPaymentIntent; 24 | import com.braintreepayments.api.PayPalVaultRequest; 25 | import com.braintreepayments.api.PaymentMethodNonce; 26 | import com.braintreepayments.api.ThreeDSecureAdditionalInformation; 27 | import com.braintreepayments.api.ThreeDSecureClient; 28 | import com.braintreepayments.api.ThreeDSecurePostalAddress; 29 | import com.braintreepayments.api.ThreeDSecureRequest; 30 | import com.braintreepayments.api.ThreeDSecureResult; 31 | import com.braintreepayments.api.UserCanceledException; 32 | import com.facebook.react.bridge.ActivityEventListener; 33 | import com.facebook.react.bridge.Arguments; 34 | import com.facebook.react.bridge.LifecycleEventListener; 35 | import com.facebook.react.bridge.Promise; 36 | import com.facebook.react.bridge.ReactApplicationContext; 37 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 38 | import com.facebook.react.bridge.ReactMethod; 39 | import com.facebook.react.bridge.ReadableMap; 40 | import com.facebook.react.bridge.WritableMap; 41 | import com.google.android.gms.wallet.TransactionInfo; 42 | import com.google.android.gms.wallet.WalletConstants; 43 | 44 | public class RNBraintreeModule extends ReactContextBaseJavaModule 45 | implements ActivityEventListener, LifecycleEventListener { 46 | 47 | private final Context mContext; 48 | private FragmentActivity mCurrentActivity; 49 | private Promise mPromise; 50 | private String mDeviceData; 51 | private String mToken; 52 | private BraintreeClient mBraintreeClient; 53 | private PayPalClient mPayPalClient; 54 | private GooglePayClient mGooglePayClient; 55 | private ThreeDSecureClient mThreeDSecureClient; 56 | 57 | @Override 58 | public String getName() { 59 | return "RNBraintree"; 60 | } 61 | 62 | public RNBraintreeModule(ReactApplicationContext reactContext) { 63 | super(reactContext); 64 | 65 | mContext = reactContext; 66 | 67 | reactContext.addLifecycleEventListener(this); 68 | reactContext.addActivityEventListener(this); 69 | } 70 | 71 | @Override 72 | public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent intent) { 73 | switch (requestCode) { 74 | case BraintreeRequestCodes.GOOGLE_PAY: 75 | if (mGooglePayClient != null) { 76 | mGooglePayClient.onActivityResult( 77 | resultCode, 78 | intent, 79 | this::handleGooglePayResult 80 | ); 81 | } 82 | break; 83 | case BraintreeRequestCodes.THREE_D_SECURE: 84 | if (mThreeDSecureClient != null) { 85 | mThreeDSecureClient.onActivityResult( 86 | resultCode, 87 | intent, 88 | this::handleThreeDSecureResult 89 | ); 90 | } 91 | break; 92 | } 93 | } 94 | 95 | @Override 96 | public void onNewIntent(Intent intent) { 97 | if (mCurrentActivity != null) { 98 | mCurrentActivity.setIntent(intent); 99 | } 100 | } 101 | 102 | @Override 103 | public void onHostResume() { 104 | if (mBraintreeClient != null && mCurrentActivity != null) { 105 | BrowserSwitchResult browserSwitchResult = 106 | mBraintreeClient.deliverBrowserSwitchResult(mCurrentActivity); 107 | if (browserSwitchResult != null) { 108 | switch (browserSwitchResult.getRequestCode()) { 109 | case BraintreeRequestCodes.PAYPAL: 110 | if (mPayPalClient != null) { 111 | mPayPalClient.onBrowserSwitchResult( 112 | browserSwitchResult, 113 | this::handlePayPalResult 114 | ); 115 | } 116 | break; 117 | case BraintreeRequestCodes.THREE_D_SECURE: 118 | if (mThreeDSecureClient != null) { 119 | mThreeDSecureClient.onBrowserSwitchResult( 120 | browserSwitchResult, 121 | this::handleThreeDSecureResult 122 | ); 123 | } 124 | break; 125 | } 126 | } 127 | } 128 | } 129 | 130 | @ReactMethod 131 | public void showPayPalModule(final ReadableMap parameters, final Promise promise) { 132 | mPromise = promise; 133 | 134 | if (!parameters.hasKey("clientToken")) { 135 | promise.reject("You must provide a clientToken"); 136 | } else { 137 | if (parameters.hasKey("appLinkReturnUrl")) { 138 | setup(parameters.getString("clientToken"), parameters.getString("appLinkReturnUrl")); 139 | } else { 140 | setup(parameters.getString("clientToken")); 141 | } 142 | 143 | String currency = "USD"; 144 | if (!parameters.hasKey("amount")) { 145 | promise.reject("You must provide a amount"); 146 | } 147 | if (parameters.hasKey("currencyCode")) { 148 | currency = parameters.getString("currencyCode"); 149 | } 150 | if (mCurrentActivity != null) { 151 | mPayPalClient = new PayPalClient(mBraintreeClient); 152 | PayPalCheckoutRequest request = new PayPalCheckoutRequest( 153 | parameters.getString("amount") 154 | ); 155 | request.setCurrencyCode(currency); 156 | request.setIntent(PayPalPaymentIntent.AUTHORIZE); 157 | if (parameters.hasKey("userAction") && PayPalCheckoutRequest.USER_ACTION_COMMIT.equals(parameters.getString("userAction"))) { 158 | request.setUserAction(PayPalCheckoutRequest.USER_ACTION_COMMIT); 159 | } 160 | mPayPalClient.tokenizePayPalAccount( 161 | mCurrentActivity, 162 | request, 163 | e -> handlePayPalResult(null, e)); 164 | } 165 | } 166 | } 167 | 168 | @ReactMethod 169 | public void requestPayPalBillingAgreement( 170 | final ReadableMap parameters, 171 | final Promise promise 172 | ) { 173 | mPromise = promise; 174 | 175 | if (!parameters.hasKey("clientToken")) { 176 | promise.reject("MISSING_CLIENT_TOKEN", "You must provide a clientToken"); 177 | } 178 | 179 | setup(parameters.getString("clientToken")); 180 | 181 | String description = parameters.hasKey("description") ? 182 | parameters.getString("description") : 183 | ""; 184 | String localeCode = parameters.hasKey("localeCode") ? 185 | parameters.getString("localeCode") : 186 | "US"; 187 | 188 | if (mCurrentActivity != null) { 189 | mPayPalClient = new PayPalClient(mBraintreeClient); 190 | PayPalVaultRequest request = new PayPalVaultRequest(); 191 | request.setLocaleCode(localeCode); 192 | request.setBillingAgreementDescription(description); 193 | 194 | mPayPalClient.tokenizePayPalAccount( 195 | mCurrentActivity, 196 | request, 197 | e -> handlePayPalResult(null, e)); 198 | } 199 | 200 | } 201 | 202 | private void handlePayPalResult( 203 | @Nullable PayPalAccountNonce payPalAccountNonce, 204 | @Nullable Exception error 205 | ) { 206 | if (error != null) { 207 | handleError(error); 208 | return; 209 | } 210 | if (payPalAccountNonce != null) { 211 | sendPaymentMethodNonceResult(payPalAccountNonce.getString()); 212 | } 213 | } 214 | 215 | @ReactMethod 216 | public void runGooglePay(final ReadableMap parameters, final Promise promise) { 217 | mPromise = promise; 218 | 219 | if (!parameters.hasKey("clientToken")) { 220 | promise.reject("You must provide a clientToken"); 221 | } else { 222 | setup(parameters.getString("clientToken")); 223 | 224 | String currency = "USD"; 225 | if (!parameters.hasKey("amount")) { 226 | promise.reject("You must provide a amount"); 227 | } 228 | if (parameters.hasKey("currencyCode")) { 229 | currency = parameters.getString("currencyCode"); 230 | } 231 | if (mCurrentActivity != null) { 232 | mGooglePayClient = new GooglePayClient(mBraintreeClient); 233 | 234 | GooglePayRequest googlePayRequest = new GooglePayRequest(); 235 | googlePayRequest.setTransactionInfo(TransactionInfo.newBuilder() 236 | .setCurrencyCode(currency) 237 | .setTotalPrice(parameters.getString("amount")) 238 | .setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL) 239 | .build()); 240 | googlePayRequest.setBillingAddressRequired(true); 241 | 242 | if (parameters.hasKey("merchantId")) { 243 | String merchantId = parameters.getString("merchantId"); 244 | googlePayRequest.setGoogleMerchantId(merchantId); 245 | String env = "test".equals(merchantId) ? "TEST" : "PRODUCTION"; 246 | googlePayRequest.setEnvironment(env); 247 | } 248 | 249 | mGooglePayClient.requestPayment( 250 | mCurrentActivity, 251 | googlePayRequest, 252 | e -> handleGooglePayResult(null, e)); 253 | } 254 | } 255 | } 256 | 257 | private void handleGooglePayResult(PaymentMethodNonce nonce, Exception error) { 258 | if (error != null) { 259 | handleError(error); 260 | return; 261 | } 262 | if (nonce != null) { 263 | sendPaymentMethodNonceResult(nonce.getString()); 264 | } 265 | } 266 | 267 | @ReactMethod 268 | public void tokenizeCard(final ReadableMap parameters, final Promise promise) { 269 | mPromise = promise; 270 | 271 | if (!parameters.hasKey("clientToken")) { 272 | promise.reject("You must provide a clientToken"); 273 | } else { 274 | setup(parameters.getString("clientToken")); 275 | 276 | CardClient cardClient = new CardClient(mBraintreeClient); 277 | 278 | Card card = new Card(); 279 | 280 | if (parameters.hasKey("number")) { 281 | card.setNumber(parameters.getString("number")); 282 | } 283 | 284 | if (parameters.hasKey("expirationMonth")) { 285 | card.setExpirationMonth(parameters.getString("expirationMonth")); 286 | } 287 | 288 | if (parameters.hasKey("expirationYear")) { 289 | card.setExpirationYear(parameters.getString("expirationYear")); 290 | } 291 | 292 | if (parameters.hasKey("cvv")) { 293 | card.setCvv(parameters.getString("cvv")); 294 | } 295 | 296 | if (parameters.hasKey("postalCode")) { 297 | card.setPostalCode(parameters.getString("postalCode")); 298 | } 299 | 300 | cardClient.tokenize(card, (cardNonce, error) -> { 301 | if (error != null) { 302 | handleError(error); 303 | return; 304 | } 305 | if (cardNonce != null) { 306 | sendPaymentMethodNonceResult(cardNonce.getString()); 307 | } 308 | }); 309 | } 310 | } 311 | 312 | @ReactMethod 313 | public void run3DSecureCheck(final ReadableMap parameters, final Promise promise) { 314 | mPromise = promise; 315 | 316 | if (mBraintreeClient == null) { 317 | String clientToken = parameters.getString("clientToken"); 318 | if (!parameters.hasKey("clientToken")) { 319 | promise.reject("You must provide a clientToken"); 320 | } 321 | setup(parameters.getString("clientToken")); 322 | } 323 | 324 | setup(parameters.getString("clientToken")); 325 | 326 | ThreeDSecurePostalAddress address = new ThreeDSecurePostalAddress(); 327 | 328 | if (parameters.hasKey("firstname")) { 329 | address.setGivenName(parameters.getString("firstname")); 330 | } 331 | 332 | if (parameters.hasKey("lastname")) { 333 | address.setSurname(parameters.getString("lastname")); 334 | } 335 | 336 | if (parameters.hasKey("phoneNumber")) { 337 | address.setPhoneNumber(parameters.getString("phoneNumber")); 338 | } 339 | 340 | if (parameters.hasKey("countryCode")) { 341 | address.setCountryCodeAlpha2(parameters.getString("countryCode")); 342 | } 343 | 344 | if (parameters.hasKey("city")) { 345 | address.setLocality(parameters.getString("city")); 346 | } 347 | 348 | if (parameters.hasKey("postalCode")) { 349 | address.setPostalCode(parameters.getString("postalCode")); 350 | } 351 | 352 | if (parameters.hasKey("region")) { 353 | address.setRegion(parameters.getString("region")); 354 | } 355 | 356 | if (parameters.hasKey("streetAddress")) { 357 | address.setStreetAddress(parameters.getString("streetAddress")); 358 | } 359 | 360 | if (parameters.hasKey("streetAddress2")) { 361 | address.setExtendedAddress(parameters.getString("streetAddress2")); 362 | } 363 | 364 | if (mCurrentActivity != null) { 365 | mThreeDSecureClient = new ThreeDSecureClient(mBraintreeClient); 366 | 367 | // For best results, provide as many additional elements as possible. 368 | ThreeDSecureAdditionalInformation additionalInformation = 369 | new ThreeDSecureAdditionalInformation(); 370 | additionalInformation.setShippingAddress(address); 371 | 372 | final ThreeDSecureRequest threeDSecureRequest = new ThreeDSecureRequest(); 373 | threeDSecureRequest.setNonce(parameters.getString("nonce")); 374 | threeDSecureRequest.setEmail(parameters.getString("email")); 375 | threeDSecureRequest.setBillingAddress(address); 376 | threeDSecureRequest.setVersionRequested(ThreeDSecureRequest.VERSION_2); 377 | threeDSecureRequest.setAdditionalInformation(additionalInformation); 378 | threeDSecureRequest.setAmount(parameters.getString("amount")); 379 | 380 | mThreeDSecureClient.performVerification( 381 | mCurrentActivity, 382 | threeDSecureRequest, 383 | (threeDSecureResult, error) -> { 384 | if (error != null) { 385 | handleError(error); 386 | return; 387 | } 388 | if (threeDSecureResult != null) { 389 | mThreeDSecureClient.continuePerformVerification( 390 | mCurrentActivity, 391 | threeDSecureRequest, 392 | threeDSecureResult, 393 | this::handleThreeDSecureResult); 394 | } 395 | }); 396 | } 397 | } 398 | 399 | @ReactMethod 400 | public void getDeviceData(final String clientToken, final Promise promise) { 401 | setup(clientToken); 402 | new DataCollector(mBraintreeClient).collectDeviceData( 403 | mContext, 404 | (result, e) -> promise.resolve(result)); 405 | } 406 | 407 | 408 | private void handleThreeDSecureResult(ThreeDSecureResult threeDSecureResult, Exception error) { 409 | if (error != null) { 410 | handleError(error); 411 | return; 412 | } 413 | if (threeDSecureResult != null && threeDSecureResult.getTokenizedCard() != null) { 414 | sendPaymentMethodNonceResult(threeDSecureResult.getTokenizedCard().getString()); 415 | } 416 | } 417 | 418 | 419 | private void setup(final String token) { 420 | if (mBraintreeClient == null || !token.equals(mToken)) { 421 | mCurrentActivity = (FragmentActivity) getCurrentActivity(); 422 | mBraintreeClient = new BraintreeClient(mContext, token); 423 | 424 | new DataCollector(mBraintreeClient).collectDeviceData( 425 | mContext, 426 | (result, e) -> mDeviceData = result); 427 | mToken = token; 428 | 429 | } 430 | } 431 | 432 | private void setup(final String token, final String appLinkReturnUrl) { 433 | if (mBraintreeClient == null || !token.equals(mToken)) { 434 | mCurrentActivity = (FragmentActivity) getCurrentActivity(); 435 | mBraintreeClient = new BraintreeClient(mContext, token, appLinkReturnUrl); 436 | 437 | new DataCollector(mBraintreeClient).collectDeviceData( 438 | mContext, 439 | (result, e) -> mDeviceData = result); 440 | mToken = token; 441 | 442 | } 443 | } 444 | 445 | private void handleError(Exception error) { 446 | if (mPromise != null) { 447 | if (error instanceof UserCanceledException) { 448 | mPromise.reject("USER_CANCELLATION", "The user cancelled"); 449 | } 450 | mPromise.reject(error.getMessage()); 451 | } 452 | } 453 | 454 | private void sendPaymentMethodNonceResult(String nonce) { 455 | if (mPromise != null) { 456 | WritableMap result = Arguments.createMap(); 457 | result.putString("deviceData", mDeviceData); 458 | result.putString("nonce", nonce); 459 | mPromise.resolve(result); 460 | } 461 | } 462 | 463 | @Override 464 | public void onHostPause() { 465 | //NOTE: empty implementation 466 | } 467 | 468 | @Override 469 | public void onHostDestroy() { 470 | //NOTE: empty implementation 471 | } 472 | } 473 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - boost (1.76.0) 3 | - Braintree (5.22.0): 4 | - Braintree/Card (= 5.22.0) 5 | - Braintree/Core (= 5.22.0) 6 | - Braintree/PayPal (= 5.22.0) 7 | - Braintree/ApplePay (5.22.0): 8 | - Braintree/Core 9 | - Braintree/Card (5.22.0): 10 | - Braintree/Core 11 | - Braintree/Core (5.22.0) 12 | - Braintree/DataCollector (5.22.0): 13 | - Braintree/Core 14 | - Braintree/PaymentFlow (5.22.0): 15 | - Braintree/Core 16 | - Braintree/PayPalDataCollector 17 | - Braintree/PayPal (5.22.0): 18 | - Braintree/Core 19 | - Braintree/PayPalDataCollector 20 | - Braintree/PayPalDataCollector (5.22.0) 21 | - Braintree/ThreeDSecure (5.22.0): 22 | - Braintree/Card 23 | - Braintree/PaymentFlow 24 | - CocoaAsyncSocket (7.6.5) 25 | - DoubleConversion (1.1.6) 26 | - FBLazyVector (0.72.3) 27 | - FBReactNativeSpec (0.72.3): 28 | - RCT-Folly (= 2021.07.22.00) 29 | - RCTRequired (= 0.72.3) 30 | - RCTTypeSafety (= 0.72.3) 31 | - React-Core (= 0.72.3) 32 | - React-jsi (= 0.72.3) 33 | - ReactCommon/turbomodule/core (= 0.72.3) 34 | - Flipper (0.182.0): 35 | - Flipper-Folly (~> 2.6) 36 | - Flipper-Boost-iOSX (1.76.0.1.11) 37 | - Flipper-DoubleConversion (3.2.0.1) 38 | - Flipper-Fmt (7.1.7) 39 | - Flipper-Folly (2.6.10): 40 | - Flipper-Boost-iOSX 41 | - Flipper-DoubleConversion 42 | - Flipper-Fmt (= 7.1.7) 43 | - Flipper-Glog 44 | - libevent (~> 2.1.12) 45 | - OpenSSL-Universal (= 1.1.1100) 46 | - Flipper-Glog (0.5.0.5) 47 | - Flipper-PeerTalk (0.0.4) 48 | - FlipperKit (0.182.0): 49 | - FlipperKit/Core (= 0.182.0) 50 | - FlipperKit/Core (0.182.0): 51 | - Flipper (~> 0.182.0) 52 | - FlipperKit/CppBridge 53 | - FlipperKit/FBCxxFollyDynamicConvert 54 | - FlipperKit/FBDefines 55 | - FlipperKit/FKPortForwarding 56 | - SocketRocket (~> 0.6.0) 57 | - FlipperKit/CppBridge (0.182.0): 58 | - Flipper (~> 0.182.0) 59 | - FlipperKit/FBCxxFollyDynamicConvert (0.182.0): 60 | - Flipper-Folly (~> 2.6) 61 | - FlipperKit/FBDefines (0.182.0) 62 | - FlipperKit/FKPortForwarding (0.182.0): 63 | - CocoaAsyncSocket (~> 7.6) 64 | - Flipper-PeerTalk (~> 0.0.4) 65 | - FlipperKit/FlipperKitHighlightOverlay (0.182.0) 66 | - FlipperKit/FlipperKitLayoutHelpers (0.182.0): 67 | - FlipperKit/Core 68 | - FlipperKit/FlipperKitHighlightOverlay 69 | - FlipperKit/FlipperKitLayoutTextSearchable 70 | - FlipperKit/FlipperKitLayoutIOSDescriptors (0.182.0): 71 | - FlipperKit/Core 72 | - FlipperKit/FlipperKitHighlightOverlay 73 | - FlipperKit/FlipperKitLayoutHelpers 74 | - YogaKit (~> 1.18) 75 | - FlipperKit/FlipperKitLayoutPlugin (0.182.0): 76 | - FlipperKit/Core 77 | - FlipperKit/FlipperKitHighlightOverlay 78 | - FlipperKit/FlipperKitLayoutHelpers 79 | - FlipperKit/FlipperKitLayoutIOSDescriptors 80 | - FlipperKit/FlipperKitLayoutTextSearchable 81 | - YogaKit (~> 1.18) 82 | - FlipperKit/FlipperKitLayoutTextSearchable (0.182.0) 83 | - FlipperKit/FlipperKitNetworkPlugin (0.182.0): 84 | - FlipperKit/Core 85 | - FlipperKit/FlipperKitReactPlugin (0.182.0): 86 | - FlipperKit/Core 87 | - FlipperKit/FlipperKitUserDefaultsPlugin (0.182.0): 88 | - FlipperKit/Core 89 | - FlipperKit/SKIOSNetworkPlugin (0.182.0): 90 | - FlipperKit/Core 91 | - FlipperKit/FlipperKitNetworkPlugin 92 | - fmt (6.2.1) 93 | - glog (0.3.5) 94 | - hermes-engine (0.72.3): 95 | - hermes-engine/Pre-built (= 0.72.3) 96 | - hermes-engine/Pre-built (0.72.3) 97 | - libevent (2.1.12) 98 | - OpenSSL-Universal (1.1.1100) 99 | - RCT-Folly (2021.07.22.00): 100 | - boost 101 | - DoubleConversion 102 | - fmt (~> 6.2.1) 103 | - glog 104 | - RCT-Folly/Default (= 2021.07.22.00) 105 | - RCT-Folly/Default (2021.07.22.00): 106 | - boost 107 | - DoubleConversion 108 | - fmt (~> 6.2.1) 109 | - glog 110 | - RCT-Folly/Futures (2021.07.22.00): 111 | - boost 112 | - DoubleConversion 113 | - fmt (~> 6.2.1) 114 | - glog 115 | - libevent 116 | - RCTRequired (0.72.3) 117 | - RCTTypeSafety (0.72.3): 118 | - FBLazyVector (= 0.72.3) 119 | - RCTRequired (= 0.72.3) 120 | - React-Core (= 0.72.3) 121 | - React (0.72.3): 122 | - React-Core (= 0.72.3) 123 | - React-Core/DevSupport (= 0.72.3) 124 | - React-Core/RCTWebSocket (= 0.72.3) 125 | - React-RCTActionSheet (= 0.72.3) 126 | - React-RCTAnimation (= 0.72.3) 127 | - React-RCTBlob (= 0.72.3) 128 | - React-RCTImage (= 0.72.3) 129 | - React-RCTLinking (= 0.72.3) 130 | - React-RCTNetwork (= 0.72.3) 131 | - React-RCTSettings (= 0.72.3) 132 | - React-RCTText (= 0.72.3) 133 | - React-RCTVibration (= 0.72.3) 134 | - React-callinvoker (0.72.3) 135 | - React-Codegen (0.72.3): 136 | - DoubleConversion 137 | - FBReactNativeSpec 138 | - glog 139 | - hermes-engine 140 | - RCT-Folly 141 | - RCTRequired 142 | - RCTTypeSafety 143 | - React-Core 144 | - React-jsi 145 | - React-jsiexecutor 146 | - React-NativeModulesApple 147 | - React-rncore 148 | - ReactCommon/turbomodule/bridging 149 | - ReactCommon/turbomodule/core 150 | - React-Core (0.72.3): 151 | - glog 152 | - hermes-engine 153 | - RCT-Folly (= 2021.07.22.00) 154 | - React-Core/Default (= 0.72.3) 155 | - React-cxxreact 156 | - React-hermes 157 | - React-jsi 158 | - React-jsiexecutor 159 | - React-perflogger 160 | - React-runtimeexecutor 161 | - React-utils 162 | - SocketRocket (= 0.6.1) 163 | - Yoga 164 | - React-Core/CoreModulesHeaders (0.72.3): 165 | - glog 166 | - hermes-engine 167 | - RCT-Folly (= 2021.07.22.00) 168 | - React-Core/Default 169 | - React-cxxreact 170 | - React-hermes 171 | - React-jsi 172 | - React-jsiexecutor 173 | - React-perflogger 174 | - React-runtimeexecutor 175 | - React-utils 176 | - SocketRocket (= 0.6.1) 177 | - Yoga 178 | - React-Core/Default (0.72.3): 179 | - glog 180 | - hermes-engine 181 | - RCT-Folly (= 2021.07.22.00) 182 | - React-cxxreact 183 | - React-hermes 184 | - React-jsi 185 | - React-jsiexecutor 186 | - React-perflogger 187 | - React-runtimeexecutor 188 | - React-utils 189 | - SocketRocket (= 0.6.1) 190 | - Yoga 191 | - React-Core/DevSupport (0.72.3): 192 | - glog 193 | - hermes-engine 194 | - RCT-Folly (= 2021.07.22.00) 195 | - React-Core/Default (= 0.72.3) 196 | - React-Core/RCTWebSocket (= 0.72.3) 197 | - React-cxxreact 198 | - React-hermes 199 | - React-jsi 200 | - React-jsiexecutor 201 | - React-jsinspector (= 0.72.3) 202 | - React-perflogger 203 | - React-runtimeexecutor 204 | - React-utils 205 | - SocketRocket (= 0.6.1) 206 | - Yoga 207 | - React-Core/RCTActionSheetHeaders (0.72.3): 208 | - glog 209 | - hermes-engine 210 | - RCT-Folly (= 2021.07.22.00) 211 | - React-Core/Default 212 | - React-cxxreact 213 | - React-hermes 214 | - React-jsi 215 | - React-jsiexecutor 216 | - React-perflogger 217 | - React-runtimeexecutor 218 | - React-utils 219 | - SocketRocket (= 0.6.1) 220 | - Yoga 221 | - React-Core/RCTAnimationHeaders (0.72.3): 222 | - glog 223 | - hermes-engine 224 | - RCT-Folly (= 2021.07.22.00) 225 | - React-Core/Default 226 | - React-cxxreact 227 | - React-hermes 228 | - React-jsi 229 | - React-jsiexecutor 230 | - React-perflogger 231 | - React-runtimeexecutor 232 | - React-utils 233 | - SocketRocket (= 0.6.1) 234 | - Yoga 235 | - React-Core/RCTBlobHeaders (0.72.3): 236 | - glog 237 | - hermes-engine 238 | - RCT-Folly (= 2021.07.22.00) 239 | - React-Core/Default 240 | - React-cxxreact 241 | - React-hermes 242 | - React-jsi 243 | - React-jsiexecutor 244 | - React-perflogger 245 | - React-runtimeexecutor 246 | - React-utils 247 | - SocketRocket (= 0.6.1) 248 | - Yoga 249 | - React-Core/RCTImageHeaders (0.72.3): 250 | - glog 251 | - hermes-engine 252 | - RCT-Folly (= 2021.07.22.00) 253 | - React-Core/Default 254 | - React-cxxreact 255 | - React-hermes 256 | - React-jsi 257 | - React-jsiexecutor 258 | - React-perflogger 259 | - React-runtimeexecutor 260 | - React-utils 261 | - SocketRocket (= 0.6.1) 262 | - Yoga 263 | - React-Core/RCTLinkingHeaders (0.72.3): 264 | - glog 265 | - hermes-engine 266 | - RCT-Folly (= 2021.07.22.00) 267 | - React-Core/Default 268 | - React-cxxreact 269 | - React-hermes 270 | - React-jsi 271 | - React-jsiexecutor 272 | - React-perflogger 273 | - React-runtimeexecutor 274 | - React-utils 275 | - SocketRocket (= 0.6.1) 276 | - Yoga 277 | - React-Core/RCTNetworkHeaders (0.72.3): 278 | - glog 279 | - hermes-engine 280 | - RCT-Folly (= 2021.07.22.00) 281 | - React-Core/Default 282 | - React-cxxreact 283 | - React-hermes 284 | - React-jsi 285 | - React-jsiexecutor 286 | - React-perflogger 287 | - React-runtimeexecutor 288 | - React-utils 289 | - SocketRocket (= 0.6.1) 290 | - Yoga 291 | - React-Core/RCTSettingsHeaders (0.72.3): 292 | - glog 293 | - hermes-engine 294 | - RCT-Folly (= 2021.07.22.00) 295 | - React-Core/Default 296 | - React-cxxreact 297 | - React-hermes 298 | - React-jsi 299 | - React-jsiexecutor 300 | - React-perflogger 301 | - React-runtimeexecutor 302 | - React-utils 303 | - SocketRocket (= 0.6.1) 304 | - Yoga 305 | - React-Core/RCTTextHeaders (0.72.3): 306 | - glog 307 | - hermes-engine 308 | - RCT-Folly (= 2021.07.22.00) 309 | - React-Core/Default 310 | - React-cxxreact 311 | - React-hermes 312 | - React-jsi 313 | - React-jsiexecutor 314 | - React-perflogger 315 | - React-runtimeexecutor 316 | - React-utils 317 | - SocketRocket (= 0.6.1) 318 | - Yoga 319 | - React-Core/RCTVibrationHeaders (0.72.3): 320 | - glog 321 | - hermes-engine 322 | - RCT-Folly (= 2021.07.22.00) 323 | - React-Core/Default 324 | - React-cxxreact 325 | - React-hermes 326 | - React-jsi 327 | - React-jsiexecutor 328 | - React-perflogger 329 | - React-runtimeexecutor 330 | - React-utils 331 | - SocketRocket (= 0.6.1) 332 | - Yoga 333 | - React-Core/RCTWebSocket (0.72.3): 334 | - glog 335 | - hermes-engine 336 | - RCT-Folly (= 2021.07.22.00) 337 | - React-Core/Default (= 0.72.3) 338 | - React-cxxreact 339 | - React-hermes 340 | - React-jsi 341 | - React-jsiexecutor 342 | - React-perflogger 343 | - React-runtimeexecutor 344 | - React-utils 345 | - SocketRocket (= 0.6.1) 346 | - Yoga 347 | - React-CoreModules (0.72.3): 348 | - RCT-Folly (= 2021.07.22.00) 349 | - RCTTypeSafety (= 0.72.3) 350 | - React-Codegen (= 0.72.3) 351 | - React-Core/CoreModulesHeaders (= 0.72.3) 352 | - React-jsi (= 0.72.3) 353 | - React-RCTBlob 354 | - React-RCTImage (= 0.72.3) 355 | - ReactCommon/turbomodule/core (= 0.72.3) 356 | - SocketRocket (= 0.6.1) 357 | - React-cxxreact (0.72.3): 358 | - boost (= 1.76.0) 359 | - DoubleConversion 360 | - glog 361 | - hermes-engine 362 | - RCT-Folly (= 2021.07.22.00) 363 | - React-callinvoker (= 0.72.3) 364 | - React-debug (= 0.72.3) 365 | - React-jsi (= 0.72.3) 366 | - React-jsinspector (= 0.72.3) 367 | - React-logger (= 0.72.3) 368 | - React-perflogger (= 0.72.3) 369 | - React-runtimeexecutor (= 0.72.3) 370 | - React-debug (0.72.3) 371 | - React-hermes (0.72.3): 372 | - DoubleConversion 373 | - glog 374 | - hermes-engine 375 | - RCT-Folly (= 2021.07.22.00) 376 | - RCT-Folly/Futures (= 2021.07.22.00) 377 | - React-cxxreact (= 0.72.3) 378 | - React-jsi 379 | - React-jsiexecutor (= 0.72.3) 380 | - React-jsinspector (= 0.72.3) 381 | - React-perflogger (= 0.72.3) 382 | - React-jsi (0.72.3): 383 | - boost (= 1.76.0) 384 | - DoubleConversion 385 | - glog 386 | - hermes-engine 387 | - RCT-Folly (= 2021.07.22.00) 388 | - React-jsiexecutor (0.72.3): 389 | - DoubleConversion 390 | - glog 391 | - hermes-engine 392 | - RCT-Folly (= 2021.07.22.00) 393 | - React-cxxreact (= 0.72.3) 394 | - React-jsi (= 0.72.3) 395 | - React-perflogger (= 0.72.3) 396 | - React-jsinspector (0.72.3) 397 | - React-logger (0.72.3): 398 | - glog 399 | - react-native-braintree (2.1.0): 400 | - Braintree 401 | - Braintree/ApplePay 402 | - Braintree/DataCollector 403 | - Braintree/PaymentFlow 404 | - Braintree/ThreeDSecure 405 | - React 406 | - React-NativeModulesApple (0.72.3): 407 | - hermes-engine 408 | - React-callinvoker 409 | - React-Core 410 | - React-cxxreact 411 | - React-jsi 412 | - React-runtimeexecutor 413 | - ReactCommon/turbomodule/bridging 414 | - ReactCommon/turbomodule/core 415 | - React-perflogger (0.72.3) 416 | - React-RCTActionSheet (0.72.3): 417 | - React-Core/RCTActionSheetHeaders (= 0.72.3) 418 | - React-RCTAnimation (0.72.3): 419 | - RCT-Folly (= 2021.07.22.00) 420 | - RCTTypeSafety (= 0.72.3) 421 | - React-Codegen (= 0.72.3) 422 | - React-Core/RCTAnimationHeaders (= 0.72.3) 423 | - React-jsi (= 0.72.3) 424 | - ReactCommon/turbomodule/core (= 0.72.3) 425 | - React-RCTAppDelegate (0.72.3): 426 | - RCT-Folly 427 | - RCTRequired 428 | - RCTTypeSafety 429 | - React-Core 430 | - React-CoreModules 431 | - React-hermes 432 | - React-NativeModulesApple 433 | - React-RCTImage 434 | - React-RCTNetwork 435 | - React-runtimescheduler 436 | - ReactCommon/turbomodule/core 437 | - React-RCTBlob (0.72.3): 438 | - hermes-engine 439 | - RCT-Folly (= 2021.07.22.00) 440 | - React-Codegen (= 0.72.3) 441 | - React-Core/RCTBlobHeaders (= 0.72.3) 442 | - React-Core/RCTWebSocket (= 0.72.3) 443 | - React-jsi (= 0.72.3) 444 | - React-RCTNetwork (= 0.72.3) 445 | - ReactCommon/turbomodule/core (= 0.72.3) 446 | - React-RCTImage (0.72.3): 447 | - RCT-Folly (= 2021.07.22.00) 448 | - RCTTypeSafety (= 0.72.3) 449 | - React-Codegen (= 0.72.3) 450 | - React-Core/RCTImageHeaders (= 0.72.3) 451 | - React-jsi (= 0.72.3) 452 | - React-RCTNetwork (= 0.72.3) 453 | - ReactCommon/turbomodule/core (= 0.72.3) 454 | - React-RCTLinking (0.72.3): 455 | - React-Codegen (= 0.72.3) 456 | - React-Core/RCTLinkingHeaders (= 0.72.3) 457 | - React-jsi (= 0.72.3) 458 | - ReactCommon/turbomodule/core (= 0.72.3) 459 | - React-RCTNetwork (0.72.3): 460 | - RCT-Folly (= 2021.07.22.00) 461 | - RCTTypeSafety (= 0.72.3) 462 | - React-Codegen (= 0.72.3) 463 | - React-Core/RCTNetworkHeaders (= 0.72.3) 464 | - React-jsi (= 0.72.3) 465 | - ReactCommon/turbomodule/core (= 0.72.3) 466 | - React-RCTSettings (0.72.3): 467 | - RCT-Folly (= 2021.07.22.00) 468 | - RCTTypeSafety (= 0.72.3) 469 | - React-Codegen (= 0.72.3) 470 | - React-Core/RCTSettingsHeaders (= 0.72.3) 471 | - React-jsi (= 0.72.3) 472 | - ReactCommon/turbomodule/core (= 0.72.3) 473 | - React-RCTText (0.72.3): 474 | - React-Core/RCTTextHeaders (= 0.72.3) 475 | - React-RCTVibration (0.72.3): 476 | - RCT-Folly (= 2021.07.22.00) 477 | - React-Codegen (= 0.72.3) 478 | - React-Core/RCTVibrationHeaders (= 0.72.3) 479 | - React-jsi (= 0.72.3) 480 | - ReactCommon/turbomodule/core (= 0.72.3) 481 | - React-rncore (0.72.3) 482 | - React-runtimeexecutor (0.72.3): 483 | - React-jsi (= 0.72.3) 484 | - React-runtimescheduler (0.72.3): 485 | - glog 486 | - hermes-engine 487 | - RCT-Folly (= 2021.07.22.00) 488 | - React-callinvoker 489 | - React-debug 490 | - React-jsi 491 | - React-runtimeexecutor 492 | - React-utils (0.72.3): 493 | - glog 494 | - RCT-Folly (= 2021.07.22.00) 495 | - React-debug 496 | - ReactCommon/turbomodule/bridging (0.72.3): 497 | - DoubleConversion 498 | - glog 499 | - hermes-engine 500 | - RCT-Folly (= 2021.07.22.00) 501 | - React-callinvoker (= 0.72.3) 502 | - React-cxxreact (= 0.72.3) 503 | - React-jsi (= 0.72.3) 504 | - React-logger (= 0.72.3) 505 | - React-perflogger (= 0.72.3) 506 | - ReactCommon/turbomodule/core (0.72.3): 507 | - DoubleConversion 508 | - glog 509 | - hermes-engine 510 | - RCT-Folly (= 2021.07.22.00) 511 | - React-callinvoker (= 0.72.3) 512 | - React-cxxreact (= 0.72.3) 513 | - React-jsi (= 0.72.3) 514 | - React-logger (= 0.72.3) 515 | - React-perflogger (= 0.72.3) 516 | - SocketRocket (0.6.1) 517 | - Yoga (1.14.0) 518 | - YogaKit (1.18.1): 519 | - Yoga (~> 1.14) 520 | 521 | DEPENDENCIES: 522 | - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) 523 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) 524 | - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) 525 | - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) 526 | - Flipper (= 0.182.0) 527 | - Flipper-Boost-iOSX (= 1.76.0.1.11) 528 | - Flipper-DoubleConversion (= 3.2.0.1) 529 | - Flipper-Fmt (= 7.1.7) 530 | - Flipper-Folly (= 2.6.10) 531 | - Flipper-Glog (= 0.5.0.5) 532 | - Flipper-PeerTalk (= 0.0.4) 533 | - FlipperKit (= 0.182.0) 534 | - FlipperKit/Core (= 0.182.0) 535 | - FlipperKit/CppBridge (= 0.182.0) 536 | - FlipperKit/FBCxxFollyDynamicConvert (= 0.182.0) 537 | - FlipperKit/FBDefines (= 0.182.0) 538 | - FlipperKit/FKPortForwarding (= 0.182.0) 539 | - FlipperKit/FlipperKitHighlightOverlay (= 0.182.0) 540 | - FlipperKit/FlipperKitLayoutPlugin (= 0.182.0) 541 | - FlipperKit/FlipperKitLayoutTextSearchable (= 0.182.0) 542 | - FlipperKit/FlipperKitNetworkPlugin (= 0.182.0) 543 | - FlipperKit/FlipperKitReactPlugin (= 0.182.0) 544 | - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.182.0) 545 | - FlipperKit/SKIOSNetworkPlugin (= 0.182.0) 546 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) 547 | - hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`) 548 | - libevent (~> 2.1.12) 549 | - OpenSSL-Universal (= 1.1.1100) 550 | - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) 551 | - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) 552 | - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) 553 | - React (from `../node_modules/react-native/`) 554 | - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) 555 | - React-Codegen (from `build/generated/ios`) 556 | - React-Core (from `../node_modules/react-native/`) 557 | - React-Core/DevSupport (from `../node_modules/react-native/`) 558 | - React-Core/RCTWebSocket (from `../node_modules/react-native/`) 559 | - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) 560 | - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) 561 | - React-debug (from `../node_modules/react-native/ReactCommon/react/debug`) 562 | - React-hermes (from `../node_modules/react-native/ReactCommon/hermes`) 563 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) 564 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) 565 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) 566 | - React-logger (from `../node_modules/react-native/ReactCommon/logger`) 567 | - "react-native-braintree (from `../node_modules/@ekreative/react-native-braintree`)" 568 | - React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`) 569 | - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) 570 | - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) 571 | - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) 572 | - React-RCTAppDelegate (from `../node_modules/react-native/Libraries/AppDelegate`) 573 | - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) 574 | - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) 575 | - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) 576 | - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) 577 | - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) 578 | - React-RCTText (from `../node_modules/react-native/Libraries/Text`) 579 | - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) 580 | - React-rncore (from `../node_modules/react-native/ReactCommon`) 581 | - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) 582 | - React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`) 583 | - React-utils (from `../node_modules/react-native/ReactCommon/react/utils`) 584 | - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) 585 | - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) 586 | 587 | SPEC REPOS: 588 | trunk: 589 | - Braintree 590 | - CocoaAsyncSocket 591 | - Flipper 592 | - Flipper-Boost-iOSX 593 | - Flipper-DoubleConversion 594 | - Flipper-Fmt 595 | - Flipper-Folly 596 | - Flipper-Glog 597 | - Flipper-PeerTalk 598 | - FlipperKit 599 | - fmt 600 | - libevent 601 | - OpenSSL-Universal 602 | - SocketRocket 603 | - YogaKit 604 | 605 | EXTERNAL SOURCES: 606 | boost: 607 | :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" 608 | DoubleConversion: 609 | :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" 610 | FBLazyVector: 611 | :path: "../node_modules/react-native/Libraries/FBLazyVector" 612 | FBReactNativeSpec: 613 | :path: "../node_modules/react-native/React/FBReactNativeSpec" 614 | glog: 615 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" 616 | hermes-engine: 617 | :podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec" 618 | :tag: hermes-2023-03-20-RNv0.72.0-49794cfc7c81fb8f69fd60c3bbf85a7480cc5a77 619 | RCT-Folly: 620 | :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" 621 | RCTRequired: 622 | :path: "../node_modules/react-native/Libraries/RCTRequired" 623 | RCTTypeSafety: 624 | :path: "../node_modules/react-native/Libraries/TypeSafety" 625 | React: 626 | :path: "../node_modules/react-native/" 627 | React-callinvoker: 628 | :path: "../node_modules/react-native/ReactCommon/callinvoker" 629 | React-Codegen: 630 | :path: build/generated/ios 631 | React-Core: 632 | :path: "../node_modules/react-native/" 633 | React-CoreModules: 634 | :path: "../node_modules/react-native/React/CoreModules" 635 | React-cxxreact: 636 | :path: "../node_modules/react-native/ReactCommon/cxxreact" 637 | React-debug: 638 | :path: "../node_modules/react-native/ReactCommon/react/debug" 639 | React-hermes: 640 | :path: "../node_modules/react-native/ReactCommon/hermes" 641 | React-jsi: 642 | :path: "../node_modules/react-native/ReactCommon/jsi" 643 | React-jsiexecutor: 644 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor" 645 | React-jsinspector: 646 | :path: "../node_modules/react-native/ReactCommon/jsinspector" 647 | React-logger: 648 | :path: "../node_modules/react-native/ReactCommon/logger" 649 | react-native-braintree: 650 | :path: "../node_modules/@ekreative/react-native-braintree" 651 | React-NativeModulesApple: 652 | :path: "../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios" 653 | React-perflogger: 654 | :path: "../node_modules/react-native/ReactCommon/reactperflogger" 655 | React-RCTActionSheet: 656 | :path: "../node_modules/react-native/Libraries/ActionSheetIOS" 657 | React-RCTAnimation: 658 | :path: "../node_modules/react-native/Libraries/NativeAnimation" 659 | React-RCTAppDelegate: 660 | :path: "../node_modules/react-native/Libraries/AppDelegate" 661 | React-RCTBlob: 662 | :path: "../node_modules/react-native/Libraries/Blob" 663 | React-RCTImage: 664 | :path: "../node_modules/react-native/Libraries/Image" 665 | React-RCTLinking: 666 | :path: "../node_modules/react-native/Libraries/LinkingIOS" 667 | React-RCTNetwork: 668 | :path: "../node_modules/react-native/Libraries/Network" 669 | React-RCTSettings: 670 | :path: "../node_modules/react-native/Libraries/Settings" 671 | React-RCTText: 672 | :path: "../node_modules/react-native/Libraries/Text" 673 | React-RCTVibration: 674 | :path: "../node_modules/react-native/Libraries/Vibration" 675 | React-rncore: 676 | :path: "../node_modules/react-native/ReactCommon" 677 | React-runtimeexecutor: 678 | :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" 679 | React-runtimescheduler: 680 | :path: "../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler" 681 | React-utils: 682 | :path: "../node_modules/react-native/ReactCommon/react/utils" 683 | ReactCommon: 684 | :path: "../node_modules/react-native/ReactCommon" 685 | Yoga: 686 | :path: "../node_modules/react-native/ReactCommon/yoga" 687 | 688 | SPEC CHECKSUMS: 689 | boost: 57d2868c099736d80fcd648bf211b4431e51a558 690 | Braintree: e154d3a5ebf17ceff4d8e704239e18afcd45cc81 691 | CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 692 | DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 693 | FBLazyVector: 4cce221dd782d3ff7c4172167bba09d58af67ccb 694 | FBReactNativeSpec: c6bd9e179757b3c0ecf815864fae8032377903ef 695 | Flipper: 6edb735e6c3e332975d1b17956bcc584eccf5818 696 | Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c 697 | Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 698 | Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b 699 | Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 700 | Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 701 | Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 702 | FlipperKit: 2efad7007d6745a3f95e4034d547be637f89d3f6 703 | fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 704 | glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b 705 | hermes-engine: 10fbd3f62405c41ea07e71973ea61e1878d07322 706 | libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 707 | OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c 708 | RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 709 | RCTRequired: a2faf4bad4e438ca37b2040cb8f7799baa065c18 710 | RCTTypeSafety: cb09f3e4747b6d18331a15eb05271de7441ca0b3 711 | React: 13109005b5353095c052f26af37413340ccf7a5d 712 | React-callinvoker: c8c87bce983aa499c13cb06d4447c025a35274d6 713 | React-Codegen: 712d523524d89d71f1cf7cc624854941be983c4d 714 | React-Core: 688f88b7f3a3d30b4848036223f8b07102c687e5 715 | React-CoreModules: 63c063a3ade8fb3b1bec5fd9a50f17b0421558c6 716 | React-cxxreact: 37765b4975541105b2a3322a4b473417c158c869 717 | React-debug: 51f11ef8db14b47f24e71c42a4916d4192972156 718 | React-hermes: 935ae71fb3d7654e947beba8498835cd5e479707 719 | React-jsi: ec628dc7a15ffea969f237b0ea6d2fde212b19dd 720 | React-jsiexecutor: 59d1eb03af7d30b7d66589c410f13151271e8006 721 | React-jsinspector: b511447170f561157547bc0bef3f169663860be7 722 | React-logger: c5b527272d5f22eaa09bb3c3a690fee8f237ae95 723 | react-native-braintree: e0ba711b07b43ba536f337ee4703188142b299f4 724 | React-NativeModulesApple: c57f3efe0df288a6532b726ad2d0322a9bf38472 725 | React-perflogger: 6bd153e776e6beed54c56b0847e1220a3ff92ba5 726 | React-RCTActionSheet: c0b62af44e610e69d9a2049a682f5dba4e9dff17 727 | React-RCTAnimation: f9bf9719258926aea9ecb8a2aa2595d3ff9a6022 728 | React-RCTAppDelegate: e5ac35d4dbd1fae7df3a62b47db04b6a8d151592 729 | React-RCTBlob: c4f1e69a6ef739aa42586b876d637dab4e3b5bed 730 | React-RCTImage: e5798f01aba248416c02a506cf5e6dfcba827638 731 | React-RCTLinking: f5b6227c879e33206f34e68924c458f57bbb96d9 732 | React-RCTNetwork: d5554fbfac1c618da3c8fa29933108ea22837788 733 | React-RCTSettings: 189c71e3e6146ba59f4f7e2cbeb494cf2ad42afa 734 | React-RCTText: 19425aea9d8b6ccae55a27916355b17ab577e56e 735 | React-RCTVibration: 388ac0e1455420895d1ca2548401eed964b038a6 736 | React-rncore: 755a331dd67b74662108f2d66a384454bf8dc1a1 737 | React-runtimeexecutor: 369ae9bb3f83b65201c0c8f7d50b72280b5a1dbc 738 | React-runtimescheduler: 837c1bebd2f84572db17698cd702ceaf585b0d9a 739 | React-utils: bcb57da67eec2711f8b353f6e3d33bd8e4b2efa3 740 | ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9 741 | SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 742 | Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce 743 | YogaKit: f782866e155069a2cca2517aafea43200b01fd5a 744 | 745 | PODFILE CHECKSUM: 1ad491d843bc0d68bd96158ec7fba22630d13386 746 | 747 | COCOAPODS: 1.12.1 748 | --------------------------------------------------------------------------------