Skip to content

A react native interface for integrating Braintree's native Drop-in Payment UI for Android

License

Notifications You must be signed in to change notification settings

eulo/react-native-braintree-android

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-braintree-android

A react native interface for integrating Braintree's native Drop-in Payment UI for Android using Braintree's v.zero SDK.

Screenshot

Setup

  1. Add Braintree to your React Native project
npm install --save react-native-braintree-android
  1. Add the following to android/settings.gradle
include ':react-native-braintree'
project(':react-native-braintree').projectDir = new File(settingsDir, '../node_modules/react-native-braintree-android')
  1. Add the following to android/app/build.gradle
dependencies {
  // ...
  compile project(':react-native-braintree')
}
  1. Edit android/src/.../MainApplication.java
// ...
import com.surialabs.rn.braintree.BraintreePackage; // <--
import android.content.Intent; // <--

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
					new BraintreePackage()
      );
    }

  };

  @Override
  public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
  }
}

Usage

import Braintree from 'react-native-braintree-android';

class Payment extends Component {
  ...

  componentDidMount() {
    Braintree.setup(CLIENT_TOKEN)
  }

  _paymentInit() {
    Braintree.showPaymentViewController().then((nonce) => {
      // Do something with nonce
    });
  }

  ...
}

About

A react native interface for integrating Braintree's native Drop-in Payment UI for Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 87.5%
  • JavaScript 12.5%