Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

A react native interface for integrating Braintree's native Drop-in Payment UI for Android
https://github.com/surialabs/react-native-braintree-android

Last synced: about 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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](https://developers.braintreepayments.com/start/overview).

Screenshot

## Setup

1. Add Braintree to your React Native project

```
npm install --save react-native-braintree-android
```

2. Add the following to android/settings.gradle

```java
include ':react-native-braintree'
project(':react-native-braintree').projectDir = new File(settingsDir, '../node_modules/react-native-braintree-android')
```

3. Add the following to android/app/build.gradle

```java
dependencies {
// ...
compile project(':react-native-braintree')
}
```

4. Edit android/src/.../MainApplication.java

```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 getPackages() {
return Arrays.asList(
new MainReactPackage(),
new BraintreePackage()
);
}

};

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

## Usage

```js

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
});
}

...
}

```