/rn-braintree-test

for android - react js bridge test

Primary LanguageJavaMIT LicenseMIT

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.

orignal verison from https://github.com/surialabs/react-native-braintree-android

Screenshot

Setup

  1. git clone

  2. Add the following to android/settings.gradle

include ':react-native-braintree'
project(':react-native-braintree').projectDir = new File(settingsDir, 'path/to/clone')
  1. Add the following to android/app/build.gradle
dependencies {
  // ...
  compile project(':react-native-braintree')
}
  1. Edit android/src/main/java/com/.../MainActivity.java
...

+ import com.mezzoky.rn.braintree.BraintreePackage;

public class MainActivity extends ReactActivity {

    ...

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

Usage

import Braintree from '../path/to/clone/index.android';

async function openBraintreeDropin(token: string) {
    let ret;
    try {
        ret = await Braintree.paymentRequest(token)
    } catch (e) {
        ret = null
        console.error(e)
    }
    return ret
}

const token = "eyJ2ZXJzaW9u..."
openBraintreeDropin(token)