A react native interface for integrating payments using Braintree

Overview

@ekreative/react-native-braintree

Getting started

Android Specific

Add this to your build.gradle

    repositories {
        maven {
            url "https://cardinalcommerce.bintray.com/android"
            credentials {
                username 'braintree-team-sdk@cardinalcommerce'
                password '220cc9476025679c4e5c843666c27d97cfb0f951'
            }
        }
    }

In Your AndroidManifest.xml, android:allowBackup="false" can be replaced android:allowBackup="true", it is responsible for app backup.

iOS Specific

cd ios
pod install
Configure a new URL scheme

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:

<key>CFBundleURLTypeskey>
<array>
    <dict>
        <key>CFBundleTypeRolekey>
        <string>Editorstring>
        <key>CFBundleURLNamekey>
        <string>com.myappstring>
        <key>CFBundleURLSchemeskey>
        <array>
            <string>com.myapp.paymentsstring>
        array>
    dict>
array>
Update your code

In your AppDelegate.m:

*)options { if ([url.scheme localizedCaseInsensitiveCompare:self.paymentsURLScheme] == NSOrderedSame) { return [BTAppSwitch handleOpenURL:url options:options]; } return [RCTLinkingManager application:application openURL:url options:options]; } - (NSString *)paymentsURLScheme { NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; return [NSString stringWithFormat:@"%@.%@", bundleIdentifier, @"payments"]; } ">
#import "BraintreeCore.h"

...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    ...
    [BTAppSwitch setReturnURLScheme:self.paymentsURLScheme];
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionaryid> *)options {

    if ([url.scheme localizedCaseInsensitiveCompare:self.paymentsURLScheme] == NSOrderedSame) {
        return [BTAppSwitch handleOpenURL:url options:options];
    }
    
    return [RCTLinkingManager application:application openURL:url options:options];
}

- (NSString *)paymentsURLScheme {
    NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
    return [NSString stringWithFormat:@"%@.%@", bundleIdentifier, @"payments"];
}

Usage

Show PayPall module
import RNBraintree from '@ekreative/react-native-braintree';

RNBraintree.showPayPalModule({
    clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE',
    amount: '1.0',
    currencyCode: 'EUR'
    })
    .then(result => console.log(result))
    .catch((error) => console.log(error));
Card tokenization
import RNBraintree from '@ekreative/react-native-braintree';

RNBraintree.tokenizeCard({
    clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE',
    number: '1111222233334444',
    expirationMonth: '11',
    expirationYear: '24',
    cvv: '123',
    postalCode: '',
    })
    .then(result => console.log(result))
    .catch((error) => console.log(error));
Make Payment
import RNBraintree from '@ekreative/react-native-braintree';

RNBraintree.run3DSecureCheck({
    clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE',
    nonce: 'CARD_NONCE',
    amount: '122.00',
    email: '[email protected]',
    firstname: '',
    lastname: '',
    phoneNumber: '',
    streetAddress: '',
    streetAddress2: '',
    city: '',
    region: '',
    postalCode: '',
    countryCode: ''
    })
    .then(result => console.log(result))
    .catch((error) => console.log(error));
Request PayPal billing agreement
import RNBraintree from '@ekreative/react-native-braintree';

RNBraintree.requestPayPalBillingAgreement({
    clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE',
    description: 'BILLING_AGRREEMENT_DESCRIPTION',
    localeCode: 'LOCALE_CODE'
    })
    .then(result => console.log(result))
    .catch((error) => console.log(error));

iOS

Get if Apple Pay available
import RNBraintree from '@ekreative/react-native-braintree';

console.log(RNBraintree.isApplePayAvailable())
Make payment using Apple Pay
import RNBraintree from '@ekreative/react-native-braintree';

RNBraintree.runApplePay({
    clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE',
    companyName: 'Company',
    amount: '100.0',
    currencyCode: 'EUR'
    })
    .then(result => console.log(result))
    .catch((error) => console.log(error));

Android

Make payment using Google Pay
import RNBraintree from '@ekreative/react-native-braintree';

RNBraintree.runGooglePay({
    clientToken: 'CLIENT_TOKEN_GENERATED_ON_SERVER_SIDE',
    amount: '100.0',
    currencyCode: 'EUR'
    })
    .then(result => console.log(result))
    .catch((error) => console.log(error));
Comments
  • Google pay is not working in both platform (android and iOS)

    Google pay is not working in both platform (android and iOS)

    when ever I run the following code nothing happens

    RNBraintree.runGooglePay({ clientToken:token, amount: '100.0', currencyCode: 'EUR' }) .then(result => console.log(result)) .catch((error) => console.log(error));

    .

    opened by himanshuvats1996 3
  • Credentials for https://cardinalcommerceprod.jfrog.io/artifactory/android are not working

    Credentials for https://cardinalcommerceprod.jfrog.io/artifactory/android are not working

    May I please ask for the updated credentails for https://cardinalcommerceprod.jfrog.io/artifactory/android

    since the credentials provided is returning a wrong/locked user account. Thanks!

    opened by bll-manapulian 1
  • No visible @interface for 'BTDataCollector' declares the selector 'collectDeviceData:'

    No visible @interface for 'BTDataCollector' declares the selector 'collectDeviceData:'

    I need to implement Apple Pay in a Project React Native 0.62.2 in Xcode Version 13.2.1 (13C100)

    And I get this error:

    No visible @interface for 'BTDataCollector' declares the selector 'collectDeviceData:'

    how can I solve it? Thanks!!

    Captura de Pantalla 2022-02-21 a la(s) 23 13 19

    opened by pckz 1
  • not an object

    not an object

    Hi, i'm using your library witj expo react and that not work. I show you the error: TypeError: null is not an object (evaluating 'RNBraintree.showPayPalModule') at node_modules\react-native\Libraries\LogBox\LogBox.js:148:8 in registerError at node_modules\react-native\Libraries\LogBox\LogBox.js:59:8 in errorImpl at node_modules\react-native\Libraries\LogBox\LogBox.js:33:4 in console.error at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException at node_modules\react-native\Libraries\Core\ExceptionsManager.js:171:19 in handleException at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError at node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0 at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch at node_modules\regenerator-runtime\runtime.js:293:29 in invoke at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch at node_modules\regenerator-runtime\runtime.js:154:27 in invoke at node_modules\regenerator-runtime\runtime.js:164:18 in PromiseImpl.resolve.then$argument_0 at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0 at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0 at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue at [native code]:null in flushedQueue at [native code]:null in invokeCallbackAndReturnFlushedQueue

    opened by ajechenique1 1
  • UI doesn't appear on android

    UI doesn't appear on android

    I have no problem with iOS emulator, but if I try to run .run3DSecureCheck on an android device it doesn't show anything. I followed the instruction to install the module correctly with both the systems. Is there something I am missing? Maybe I have to change the credentials for maven url https://cardinalcommerceprod.jfrog.io/artifactory/android ?

    opened by SalvM 0
  • BrainTree/Apple uses deprecated fields

    BrainTree/Apple uses deprecated fields

    I believe this package is using an old version for Braintree/Apple which has some deprecated fields in it and that is crashing on ios. I tested on a bareflow latest react native project (0.70.6) and I am having the below error, can someone guide me?

    Screenshot 2022-12-13 at 3 01 13 PM

    opened by ehtisham-ali-emumba 5
  • 'BraintreeCore.h' file not found

    'BraintreeCore.h' file not found

    ▸ Compiling react-native-braintree-dummy.m
    ▸ Compiling RNBraintreeApplePay.m
    ▸ Compiling RNBraintree.m
    
    ❌  /Users/boblin/Desktop/WorkSpace/ReactNative/ignite/moon/node_modules/@ekreative/react-native-braintree/ios/RNBraintree.m:2:9: 'BraintreeCore.h' file not found
    
    #import "BraintreeCore.h"
    

    environment

        "react": "18.0.0",
        "react-native": "0.69.6",
        "@ekreative/react-native-braintree": "^1.3.0",
    
    opened by Bob-MYMC 7
Releases(v1.3.0)
Owner
eKreative
We're a software development company, specializing in apps, sites and online systems for a wide range of industries.
eKreative
React Native library that implements PayPal Checkout flow using purely native code (swift).

react-native-paypal-swift React Native library that implements PayPal Checkout flow using purely native code (swift). Installation npm install react-n

Tibb 6 Nov 28, 2022
A property finder application written using React Native

React Native PropertyFinder App This repository accompanies the tutorial I published on Ray Wenderlich's website, which describes the process of build

Colin Eberhardt 276 Aug 14, 2022
React Native utility library around image and video files for getting metadata like MIME type, timestamp, duration, and dimensions. Works on iOS and Android using Java and Obj-C, instead of Node 🚀.

Qeepsake React Native File Utils Extracts information from image and video files including MIME type, duration (video), dimensions, and timestamp. The

Qeepsake 12 Oct 19, 2022
React Native 实现无侵入自定义下拉刷新组件

react-native-ly-refresh-control 下拉刷新 iOS 基于MJRefresh 通过RCTCustomRefreshContolProtocol实现RefreshControl组件封装 JS端可以无侵入自定义下拉刷新只需要替换对应的refreshControl Androi

少言 12 Jul 2, 2022
iOS 15 share play API in react-native

react-native-shareplay iOS 15 share play API in react-native Installation yarn add react-native-shareplay And go to Xcode Capabilities and enable "Gro

Popshop Live 27 Oct 16, 2022
React Native package for interacting with HomeKit devices

React Native package for interacting with HomeKit devices

Ibrahim Berat Kaya 4 Dec 24, 2021
react native esptouch

react-native-esptouch One should know that This is a Unofficial project. The official demo is below: EsptouchForAndroid EsptouchForIOS Getting started

五毛共和国 Wumaoland 0 Oct 25, 2021
React Native Template for Taro

React Native Template for Taro requirement taro: @tarojs/cli@^3.2.0 framework: 'react' quick start install react native library install peerDependenci

null 1 Nov 20, 2021
A suite of IoT tools to use with React Native.

react-native-iot-tools WIP. A suite of IoT tools for React Native applications. Package iOS Android @react-native-iot-tools/bluetooth ✅ ❌ @react-nativ

Sara Pope 3 Oct 31, 2022
A testing MQTT react native library

react-native-awesome-testing abc Installation npm install react-native-awesome-testing Usage import { multiply } from "react-native-awesome-testing";

null 0 Nov 26, 2021
Encryption/Decryption for React Native

@dhairyasharma/react-native-encryption Encryption/decryption for React Native. Benchmark File Details File Link http://bit.do/benchmarkfile File Size

Dhairya Sharma 5 Sep 13, 2022
Encryption/Decryption for React Native

@dhairyasharma/react-native-encryption Encryption/decryption for React Native. Benchmark File Details File Link http://bit.do/benchmarkfile File Size

Dhairya Sharma 5 Sep 13, 2022
iOS's Stocks App clone written in React Native for demo purpose (available both iOS and Android).

FinanceReactNative iOS's Stocks App clone written in React Native for demo purpose (available both iOS and Android). Data is pulled from Yahoo Finance

kf 2k Dec 29, 2022
React Native Photo Editor (RNPE)

React Native Photo Editor (RNPE) ?? Image editor using native modules for iOS an

Suman Kamilya 9 Aug 16, 2022
Discover Movies and TV shows - React Native

movieapp Discover Movies and TV shows Download APK file Download from Google Drive - v2.2.1 What's included Name Description React Native Build Native

June Domingo 1.8k Dec 28, 2022
All my React Native examples

ReactNativeExamples All my React Native examples and experiements can be found here. This repo is divided into two sub folders, Instructions git clone

Joseph Khan 93 Oct 2, 2022
React Native Twitch application

Notes I'm going to rewrite this project ?? . Be ready to new Twitch application. Twitch This project was built for The Rolling Scopes #18 meetup. As o

Ilja Satchok 90 Nov 24, 2022
React Native Todo List example app which uses Redux for managing app state

react-native-redux-todo-list A sample todo list app developed by using React Native and Redux. How to run the app Install react-native If you don't ha

null 43 Oct 11, 2022
A simple To Do application written in React Native

Example To Do List application in react-native Requirements, install as needed: React Native: $ npm i -g react-native-cli watchman: $ brew install wa

Joe Maddalone 177 Sep 24, 2022