Skip to content

A react native interface for integrating payments using Braintree's v.zero SDK

License

Notifications You must be signed in to change notification settings

APSL/react-native-braintree

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-braintree

A react native interface for integrating payments using Braintree's v.zero SDK. Accepts Credit/Debit Cards

Usage

Setup

var BTClient = require('react-native-braintree');
BTClient.setup(<token>);

You can find a demo client token here.

To take advantage of One Touch, there are additional setup required:

  1. Register a URL scheme in Xcode (should always start with your Bundle ID) Register URL Scheme

  2. Use setupWithURLScheme instead, passing the url scheme you have registered in previous step

var BTClient = require('react-native-braintree');
BTClient.setupWithURLScheme(<token>, <url scheme>);
  1. Add this delegate method (callback) to your AppDelegate.m
  #import <RNBraintree.h>

  - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [[RNBraintree sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
  }
  1. Optionally, install the fake PayPal wallet app in your simulator to simulate and test responses

Show Payment Screen

v.zero

BTClient.showPaymentViewController(function(err, nonce) {
  //payment succeeded, pass nonce to server
});

PayPal only

BTClient.showPayPalViewController(function(err, nonce) {
  //payment succeeded, pass nonce to server
});

Installation

  1. react-native init BTRNSample (skip for existing projects)
  2. Run npm install react-native-braintree --save to add the package
  3. Inside the ios directory, create a Podfile:
source 'https://github.com/CocoaPods/Specs.git'
pod 'React', :subspecs => ['Core', 'RCTImage', 'RCTNetwork', 'RCTText', 'RCTWebSocket'], :path => '../node_modules/react-native'
pod 'react-native-braintree', :path => '../node_modules/react-native-braintree'
  1. Run pod install. This installs the Braintree iOS SDK and a new workspace is created.

  2. Open BTRNSample.xcworkspace

  3. Under your app target -> build settings, look for Other Linker Flags and add $(inherited)

Accepts Credit/Debit Cards

  1. Build and run project! If it fails the first time, clean and rebuild.

Requirements

Tested with:

  • Node 4.1.0
  • npm 2.14.3
  • react-native 0.8.0

License

react-native-braintree is available under the MIT license. See the LICENSE file for more info.

About

A react native interface for integrating payments using Braintree's v.zero SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 77.5%
  • Ruby 14.1%
  • JavaScript 8.4%