Giter Club home page Giter Club logo

react-native-braintree-xplat's Introduction

react-native-braintree-xplat

npm version

An effort to merge react-native-braintree and react-native-braintree-android

iOS Installation

You can use the React Native CLI to add native dependencies automatically:

$ react-native link

or do it manually as described below:

  1. Run npm install react-native-braintree-xplat --save
  2. Open your project in XCode, right click on Libraries and click Add Files to "Your Project Name" Look under node_modules/react-native-braintree-xplat and add RCTBraintree.xcodeproj.
  3. Add libRCTBraintree.a to Build Phases -> Link Binary With Libraries
  4. Done!

Android Installation

Run npm install react-native-braintree-xplat --save

RN 0.29 and over

In android/settings.gradle

...

include ':react-native-braintree-xplat'
project(':react-native-braintree-xplat').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-braintree-xplat/android')

In android/app/build.gradle

...

dependencies {
    ...

    compile project(':react-native-braintree-xplat')
}

Register module (in MainApplication.java)

import com.pw.droplet.braintree.BraintreePackage; // <--- Import Package
import android.content.Intent; // <--- Import 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() // <--- Initialize the package
      );
    }
  };

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

RN 0.28 and under

In android/settings.gradle

...

include ':react-native-braintree-xplat'
project(':react-native-braintree-xplat').projectDir = file('../node_modules/react-native-braintree-xplat/android')

In android/app/build.gradle

...

dependencies {
    ...

    compile project(':react-native-braintree-xplat')
}

Register module (in MainActivity.java)

import com.pw.droplet.braintree.BraintreePackage; // <--- Import Package
import android.content.Intent; // <--- Import Intent

public class MainActivity extends ReactActivity {
    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "example";
    }

    /**
     * Returns whether dev mode should be enabled.
     * This enables e.g. the dev menu.
     */
    @Override
    protected boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
    }

    /**
     * A list of packages used by the app. If the app uses additional views
     * or modules besides the default ones, add more packages here.
     */
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new BraintreePackage() // <---  Initialize the Package
        );
    }
}

Usage

Setup

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

You can find a demo client token here.

Show Payment Screen (Android & iOS)

v.zero

BTClient.showPaymentViewController(options).then(function(nonce) {
  //payment succeeded, pass nonce to server
})
.catch(function(err) {
  //error handling
});

Options

  • [iOS] bgColor - Background color for the view.
  • [iOS] tintColor - Tint color for the view.
  • [iOS] barBgColor - Background color for the navbar.
  • [iOS] barTintColor - Tint color for the navbar.
  • [iOS] callToActionText - Text for call to action button. (Works for both Android and iOS)
  • threeDSecure - If you want to enable 3DSecure, pass an object with an amount key that takes a number value

Example:

const options = {
  bgColor: '#FFF',
  tintColor: 'orange',
  callToActionText: 'Save',
  threeDSecure: {
    amount: 1.0
  }
}

PayPal only

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

Custom Integration

If you only want to tokenize credit card information, you can use the following:

const card = {
  number: "4111111111111111",
  expirationDate: "10/20", // or "10/2020" or any valid date
  cvv: "400",
}

BTClient.getCardNonce(card).then(function(nonce) {
  //payment succeeded, pass nonce to server
})
.catch(function(err) {
  //error handling
});

// Full list of card parameters:
type Card = {
  number: string,
  cvv: string,
  expirationDate: string,
  cardholderName: string,
  firstName: string,
  lastName: string,
  company: string,
  countryName: string,
  countryCodeAlpha2: string,
  countryCodeAlpha3: string,
  countryCodeNumeric: string,
  locality: string,
  postalCode: string,
  region: string,
  streetAddress: string,
  extendedAddress: string,
}

One Touch on iOS

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) More info here TL;DR

Add CFBundleURLTypes to Info.Plist

	<key>CFBundleURLTypes</key>
	<array>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLName</key>
		<string>your.bundle.id</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>your.bundle.id.payments</string>
		</array>
	</dict>
	</array>

WhiteList

If your app is built using iOS 9 as its Base SDK, then you must add URLs to a whitelist in your app's info.plist

   <key>LSApplicationQueriesSchemes</key>
   <array>
     <string>com.paypal.ppclient.touch.v1</string>
     <string>com.paypal.ppclient.touch.v2</string>
     <string>com.venmo.touch.v2</string>
   </array>
  1. For iOS: Use setupWithURLScheme instead, passing the url scheme you have registered in previous step
var BTClient = require('react-native-braintree');
BTClient.setupWithURLScheme(token, 'your.bundle.id.payments');

For xplat, you can do something like this:

 if (Platform.OS === 'ios') {
      BTClient.setupWithURLScheme(token, 'your.bundle.id.payments');
  } else {
      BTClient.setup(token);
  }
  1. Add this delegate method (callback) to your AppDelegate.m
#import "RCTBraintree.h"

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[RCTBraintree sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}

Credits

Big thanks to @alanhhwong and @surialabs for the original ios & android modules.

react-native-braintree-xplat's People

Contributors

adrianchinghc avatar andreyco avatar aroth avatar blakewilliams avatar damathryx avatar darron-haworth avatar edvinasbartkus avatar faceyspacey avatar ferdinandvhagen avatar gameboyvito avatar iancanderson avatar kraffslol avatar kylejones avatar minishlink avatar stevepotter avatar the-simian avatar tsmmark avatar tsubery avatar umars-menlo avatar vansonleung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-braintree-xplat's Issues

The operation could not be completed. Application does not support one touch call back URL scheme.

I have successfully setup the credit card payment using this library.

However, when click on the blue PayPal Check Out button in drop in UI screen iOS, I am getting this dialog "The operation could not be completed. Application does not support one touch call back URL scheme." I suppose it's referring to the one touch callback URL.
I rechecked and performed all steps in https://github.com/kraffslol/react-native-braintree-xplat#one-touch-on-ios but still getting the same error.

Android has no problem and I have go through the sandbox paypal payment too.

Anyone has any idea?

BTPayPalDriver failed because BTAPIClient is nil.

      BTClient.showPayPalViewController().then(nonce => {
            console.log(nonce);
           this.payment(nonce);
      })

It is giving error "BTPayPalDriver failed because BTAPIClient is nil." in iPhone.
In android it works fine.

Please guide me.

Implementation using Venmo

How can I implement using Venmo.
I have configured this package and working fine.
screen shot 2018-01-16 at 1 56 26 pm

My code:
`const token = "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiI5YzRiYWQxMmEzNzc1ZmRjNDJjMmJiMzkwMWQ4ODhlODQwZTkzZDYxYzgyOTgyYjU1MDBlZDNhYzUzZWRkMjM5fGNyZWF0ZWRfYXQ9MjAxNi0wNi0xOFQxNDoyMjo1MS43Mzc1OTcwMjcrMDAwMFx1MDAyNm1lcmNoYW50X2lkPWNjOWY2OHZ3Y2NrdDYzdGpcdTAwMjZwdWJsaWNfa2V5PW0ycGJ4a3F4Yzl5ZHQyYzIiLCJjb25maWdVcmwiOiJodHRwczovL2FwaS5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tOjQ0My9tZXJjaGFudHMvY2M5ZjY4dndjY2t0NjN0ai9jbGllbnRfYXBpL3YxL2NvbmZpZ3VyYXRpb24iLCJjaGFsbGVuZ2VzIjpbXSwiZW52aXJvbm1lbnQiOiJzYW5kYm94IiwiY2xpZW50QXBpVXJsIjoiaHR0cHM6Ly9hcGkuc2FuZGJveC5icmFpbnRyZWVnYXRld2F5LmNvbTo0NDMvbWVyY2hhbnRzL2NjOWY2OHZ3Y2NrdDYzdGovY2xpZW50X2FwaSIsImFzc2V0c1VybCI6Imh0dHBzOi8vYXNzZXRzLmJyYWludHJlZWdhdGV3YXkuY29tIiwiYXV0aFVybCI6Imh0dHBzOi8vYXV0aC52ZW5tby5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tIiwiYW5hbHl0aWNzIjp7InVybCI6Imh0dHBzOi8vY2xpZW50LWFuYWx5dGljcy5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tL2NjOWY2OHZ3Y2NrdDYzdGoifSwidGhyZWVEU2VjdXJlRW5hYmxlZCI6dHJ1ZSwicGF5cGFsRW5hYmxlZCI6dHJ1ZSwicGF5cGFsIjp7ImRpc3BsYXlOYW1lIjoiV2h5d2FpdCB0ZXN0IiwiY2xpZW50SWQiOm51bGwsInByaXZhY3lVcmwiOiJodHRwOi8vZXhhbXBsZS5jb20vcHAiLCJ1c2VyQWdyZWVtZW50VXJsIjoiaHR0cDovL2V4YW1wbGUuY29tL3RvcyIsImJhc2VVcmwiOiJodHRwczovL2Fzc2V0cy5icmFpbnRyZWVnYXRld2F5LmNvbSIsImFzc2V0c1VybCI6Imh0dHBzOi8vY2hlY2tvdXQucGF5cGFsLmNvbSIsImRpcmVjdEJhc2VVcmwiOm51bGwsImFsbG93SHR0cCI6dHJ1ZSwiZW52aXJvbm1lbnROb05ldHdvcmsiOnRydWUsImVudmlyb25tZW50Ijoib2ZmbGluZSIsInVudmV0dGVkTWVyY2hhbnQiOmZhbHNlLCJicmFpbnRyZWVDbGllbnRJZCI6Im1hc3RlcmNsaWVudDMiLCJiaWxsaW5nQWdyZWVtZW50c0VuYWJsZWQiOnRydWUsIm1lcmNoYW50QWNjb3VudElkIjoiV2h5d2FpdF9zdmVuc2tfdGVzdDIiLCJjdXJyZW5jeUlzb0NvZGUiOiJTRUsifSwiY29pbmJhc2VFbmFibGVkIjpmYWxzZSwibWVyY2hhbnRJZCI6ImNjOWY2OHZ3Y2NrdDYzdGoiLCJ2ZW5tbyI6Im9mZiJ9";
BTClient.setup(token);

if (Platform.OS === 'ios') {
  BTClient.setupWithURLScheme(token, 'com.xyz.app.payments');
} else {
  BTClient.setup(token);
}

BTClient.showPaymentViewController({
  bgColor: '#FFF',
  tintColor: 'red',
  barBgColor: '#1A1F19',
  barTintColor: 'white',
}).then(function(nonce) {
  console.log('nonce ******** ',nonce)
  //API
})
.catch(function(err) {
  //error handling
});`

Error compiling on Android

I get the error: Execution failed for task ':react-native-braintree-xplat:compileReleaseJavaWithJavac' when I attempt to compile my app on Android.

"react-native": "^0.30.0",
"react-native-braintree-xplat": "^3.0.0",

getCardNonce is not handling errors

using react-native 0.30

BTClient.getCardNonce("4111111111111111", "10", "20", "400").then(function(nonce) { console.log(nonce) }) .catch(function(err) { console.log(err) });

Im getting a nonce back if I call it with a valid card but if i call it with a invalid card (for example a 15 digit card) I dont get an error back

[Android] Compile Error

I'm getting a Compile Error with latest react-native-braintree-xplat (2.1.0) and React Native (0.34.1).

I created a Push Request to solve this issue but it will most probably break older code bases. What do you suggest?

Error Output:

:react-native-braintree-xplat:compileReleaseJavaWithJavac
/Users/jyotipuri/humble/gostudent/mobile-app/node_modules/react-native-braintree-xplat/android/src/main/java/com/pw/droplet/braintree/Braintree.java:22: error: Braintree is not abstract and does not override abstract method onActivityResult(Activity,int,int,Intent) in ActivityEventListener
public class Braintree extends ReactContextBaseJavaModule implements ActivityEventListener {
       ^
/Users/jyotipuri/humble/gostudent/mobile-app/node_modules/react-native-braintree-xplat/android/src/main/java/com/pw/droplet/braintree/Braintree.java:108: error: method does not override or implement a method from a supertype
  @Override
  ^
2 errors
:react-native-braintree-xplat:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-braintree-xplat:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 33.236 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

Won't compile on Android

Hello, i'm able to run this on iOS but am having issues with Android. I ran rnpm link and that changed some files on Android but i'm not sure what these errors are getting at. Would you have any insight on what I should try next?

Versions

  • react-native 0.30.0
  • react 15.2

Expected:
Android to compile with react-native run-android

Actual:
Error message:

:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
/Users/adam/Projects/acme/myapp-mobile/android/app/src/main/java/com/myapp/MainActivity.java:38: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/adam/Projects/acme/myapp-mobile/android/app/src/main/java/com/myapp/MainActivity.java:43: error: constructor BraintreePackage in class BraintreePackage cannot be applied to given types;
            new BraintreePackage(),
            ^
  required: Context
  found: no arguments
  reason: actual and formal argument lists differ in length
/Users/adam/Projects/acme/myapp-mobile/android/app/src/main/java/com/myapp/MainActivity.java:45: error: constructor BraintreePackage in class BraintreePackage cannot be applied to given types;
            new BraintreePackage()
            ^
  required: Context
  found: no arguments
  reason: actual and formal argument lists differ in length
3 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

My MainActivity.java file looks like:

package com.myapp;

import com.facebook.react.ReactActivity;
import com.oblador.vectoricons.VectorIconsPackage;
import com.pw.droplet.braintree.BraintreePackage;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;

import java.util.Arrays;
import java.util.List;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "MyApp";
    }

    /**
     * Returns whether dev mode should be enabled.
     * This enables e.g. the dev menu.
     */
    @Override
    protected boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
    }

    /**
     * A list of packages used by the app. If the app uses additional views
     * or modules besides the default ones, add more packages here.
     */
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new VectorIconsPackage(),
            new BraintreePackage()
        );
    }
}

I've also tried to go back to React Native 0.26 to see if that would help and it gives me less errors with:

:app:generateDebugSources
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
/Users/adam/Projects/acme/myapp-mobile/android/app/src/main/java/com/myapp/MainActivity.java:41: error: constructor BraintreePackage in class BraintreePackage cannot be applied to given types;
            new BraintreePackage()
            ^
  required: Context
  found: no arguments
  reason: actual and formal argument lists differ in length
1 error
:app:compileDebugJavaWithJavac FAILED

Any help would be appreciated!!

address support for AVS verification

I see that CVV support was just merged. It seems the last remaining aspect of card verification is being able to optionally collect address info. I'd do it, but i dont have much experience beyond js.

BT not validating card

Hello,

I've been trying to use this package, but when I am using getCardNonce() function, no matter what data I pass to it (it can be even nulls) it's always returning me a new card nonce. Is it expected behaviour? Shouldn't it return me any error that the card is invalid or something? It's happening on both android and ios. I am using sanbox testing token.

setup of undefined

I'm getting this error using BTClient.setup('ezC..') but when I log BTClient its there.
screen shot 2016-12-17 at 2 11 25 pm

Platform is iOS.
Ver. 2.4.0

i used react-native link for setup. checked the steps manually good but I have noticed this in my build phases under Link Binary
screen shot 2016-12-17 at 2 14 05 pm
Is this the problem?

Latest Brain tree version

Hi @kraffslol and Team

Can you please update the brain tree version to 4.9.4 so that we will have a latest version of brain tree in the repo, i found many features in the latest version.

Or else please guide me to how to do that in the repo.

Thanks,
Phani.

showPayPalViewController never showing UI on Android

The code below used to work, but recently broke (we didn't have good tests on this so I don't know when). Everything still works fine for iOS.

async _loadPayPal(token) {
	if (Platform.OS === 'ios') {
		BTClient.setupWithURLScheme(token, 'com.company.mobileapp');
	} else {
		await BTClient.setup(token);
	}

	let self = this;
	BTClient.showPayPalViewController().then(function(nonce) {
		CheckoutService.addNonce(nonce);
		self._exit();
	})
	.catch(function(err) {
		console.log('Whats going on here!', err);
		self._exit();
	})
}

Neither the then or catch blocks are ever called and nothing at all appears to happen after calling showPayPalViewController. I saw a couple of threads about setting a timeout before calling showPayPalViewController, but that didn't fix anything. Any help would be appreciated!

Paypal checkout crashes the app

I use version "3.2.0" of "react-native-braintree-xplat" and react native 0.42

I have managed to build a custom "pay by card" checkout using getCardNonce method and everything works fine.I would also like to add paypal checkout. I have added showPayPalViewController method and setup everything in Xcode. It opens safari, fetches the account that sandbox environment belongs to and I get the accept button. Everything's perfect so far. When I hit the agree button, it crashes the app...

If I do paypal checkout through Drop-in UI (using showPaymentViewController) works like a charm.

P.S: I can provide the Xcode errors I get

Any help would be highly appreciated!!!

iOS - showPayPalViewController - Safari view cancel throws NSInvalidArgumentException

Been trying to debug this for an hour or so.
The view works totally fine when using showPaymentViewController, and selecting PayPal, clicking cancel, or "Done" in the top left of the safari browser will send you back to the CreditCard view.
But doing so without having first been on it, ie: using the showPayPalViewController will throw an exception.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]'
***
First throw call stack:
(
    0   CoreFoundation                      0x000000010550a34b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010441a21e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010541a3b3 -[__NSPlaceholderArray initWithObjects:count:] + 275
    3   CoreFoundation                      0x00000001054215c4 +[NSArray arrayWithObjects:count:] + 52
    4   myapp                              0x000000010326cf55 __41-[RCTBraintree showPayPalViewController:]_block_invoke_2 + 293
    5   myapp                              0x00000001033383b0 __57-[BTPayPalDriver setAppSwitchReturnBlock:forPaymentType:]_block_invoke_2 + 656
    6   myapp                              0x000000010337ec99 +[PPOTResult parseURL:completionBlock:] + 3193
    7   myapp                              0x000000010337d617 +[PPOTCore parseResponseURL:completionBlock:] + 391
    8   myapp                              0x00000001033380b8 __57-[BTPayPalDriver setAppSwitchReturnBlock:forPaymentType:]_block_invoke + 552
    9   myapp                              0x000000010333cc79 +[BTPayPalDriver handleAppSwitchReturnURL:] + 73
    10  myapp                              0x0000000103344697 -[BTAppSwitch handleOpenURL:sourceApplication:] + 455
    11  myapp                              0x0000000103344488 +[BTAppSwitch handleOpenURL:sourceApplication:] + 136
    12  myapp                              0x000000010326d8d2 -[RCTBraintree application:openURL:sourceApplication:annotation:] + 242
    13  myapp                              0x0000000103053245 -[AppDelegate application:openURL:sourceApplication:annotation:] + 485
    14  UIKit                               0x0000000107de1ae3 __45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 940
    15  UIKit                               0x0000000107de1472 -[UIApplication _applicationOpenURL:payload:] + 757
    16  SafariServices                      0x0000000103c84060 -[SFSafariViewController remoteViewController:hostApplicationOpenURL:] + 155
    17  SafariServices                      0x0000000103c7bdb7 -[SFBrowserRemoteViewController willOpenURLInHostApplication:] + 68
    18  CoreFoundation                      0x000000010549105c __invoking___ + 140
    19  CoreFoundation                      0x0000000105490ee1 -[NSInvocation invoke] + 289
    20  FrontBoardServices                  0x000000010e72876b __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    21  FrontBoardServices                  0x000000010e7285e4 -[FBSSerialQueue _performNext] + 189
    22  FrontBoardServices                  0x000000010e72896d -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    23  CoreFoundation                      0x00000001054af311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    24  CoreFoundation                      0x000000010549459c __CFRunLoopDoSources0 + 556
    25  CoreFoundation                      0x0000000105493a86 __CFRunLoopRun + 918
    26  CoreFoundation                      0x0000000105493494 CFRunLoopRunSpecific + 420
    27  GraphicsServices                    0x000000010d46aa6f GSEventRunModal + 161
    28  UIKit                               0x0000000107dd6f34 UIApplicationMain + 159
    29  myapp                              0x00000001030538af main + 111
    30  libdyld.dylib                       0x00000001097ab68d start + 1
    31  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

I've added the openURL handle to AppDelegate.m correctly I think, and added the URL type. Following the directions from the odd repo

  if ([url.scheme localizedCaseInsensitiveCompare:@"com.myapp.payments"] == NSOrderedSame) {
    return [[RCTBraintree sharedInstance] application:application
                                              openURL:url
                                    sourceApplication:sourceApplication
                                           annotation:annotation  ];
  }

If you can think of something I'm overlooking debugging the issue let me know.

Difference between paypal method authorizeAccountWithCompletion vs requestOneTimePayment from the docs?

If you look at the Braintree paypal docs they use requestOneTimePayment for making payments along with a precise amount:

https://developers.braintreepayments.com/guides/paypal/checkout-with-paypal/ios/v4

xplat on the other hand just gets the nonce without the amount (like we typically do with a card) and then obviously we provide the amount in Transaction.sale on the server. My feeling is that--since their docs have you provide the amount--that it's likely to be successful more often.

What are everyone's thought on this one?

Remove PayPal Check out bar

Using this:

BTClient.showPaymentViewController(options).then(function(nonce) {
//payment succeeded, pass nonce to server
})
.catch(function(err) {
//error handling
});

shows both PayPal and card entry options. I would like to hide the PayPal option. Is there a way to do this?

Error when starting Android app

I've got this error when I want to start the Android app. In iOS it works fine.

/Users/williamschrauwen/ReactNative/BraintreeSample/node_modules/react-native-braintree-xplat/android/src/main/java/com/pw/droplet/braintree/Braintree.java:22: error: Braintree is not abstract and does not override abstract method onActivityResult(Activity,int,int,Intent) in ActivityEventListener
public class Braintree extends ReactContextBaseJavaModule implements ActivityEventListener {
^
/Users/williamschrauwen/ReactNative/BraintreeSample/node_modules/react-native-braintree-xplat/android/src/main/java/com/pw/droplet/braintree/Braintree.java:108: error: method does not override or implement a method from a supertype
@OverRide
^
2 errors
:react-native-braintree-xplat:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-braintree-xplat:compileReleaseJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 10.834 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

Build Failed: CompileC BTAnalyticsMetadata.m

RN: 0.45.1
braintree-xplat: ^3.0.0

Any help would be appreciated!

** BUILD FAILED **

The following build commands failed:
        CompileC /Users/peter/Sites/tallydrinks/Tally/ios/build/Build/Intermediates/Braintree.build/Debug-iphonesimulator/Braintree.build/Objects-normal/x86_64/BTAnalyticsMetadata.o BraintreeCore/BTAnalyticsMetadata.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Accessing BTVenmoDriver from react

Is it possible currently to access functions (for example BTVenmoDriver.initWithAPIClient) from React as of now? If so, do you have any simple code example of this/documentation?

Proceed with Sandbox purchase button does not work.

After calling BTClient.showPayPalViewController().then(function(nonce) { }) the Proceed with sandbox purchase button does not redirect me anywhere. I am also not getting any errors. Any help will be appreciated.

thoughts on including cvv?

I notice the cvv isn't passed along to Braintree, but is accepted by the base Braintree methods in native code. Would a pull request making this change be welcome? I think the ideal case would be that it's optional, correct?

The goal being Braintree can better detect fraudulent activity when the verifyCard: true option is past.

tapping DONE in Paypal modal crashes app

It's occurring at this line:

https://github.com/kraffslol/react-native-braintree-xplat/blob/master/ios/RCTBraintree/RCTBraintree.m#L99

Here's the error I'm getting delivered to fabric:

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x187e801c0 __exceptionPreprocess
1  libobjc.A.dylib                0x1868b855c objc_exception_throw
2  CoreFoundation                 0x187d5f600 -[__NSPlaceholderArray initWithObjects:count:]
3  CoreFoundation                 0x187d6b38c +[NSArray arrayWithObjects:count:]
4  CelebvidyDev                   0x10017df10 __41-[RCTBraintree showPayPalViewController:]_block_invoke_2 (RCTBraintree.m:92)
5  CelebvidyDev                   0x10022e348 __57-[BTPayPalDriver setAppSwitchReturnBlock:forPaymentType:]_block_invoke (BTPayPalDriver.m:338)
6  CelebvidyDev                   0x100232e98 +[BTPayPalDriver handleAppSwitchReturnURL:] (BTPayPalDriver.m:773)
7  CelebvidyDev                   0x100231a98 -[BTPayPalDriver safariViewControllerDidFinish:] (BTPayPalDriver.m:638)
8  SafariServices                 0x196108e18 -[SFSafariViewController remoteViewControllerWillDismiss:]
9  SafariServices                 0x196101318 -[SFBrowserRemoteViewController willDismissServiceViewController]
10 CoreFoundation                 0x187e86160 __invoking___
11 CoreFoundation                 0x187d79c3c -[NSInvocation invoke]
12 FrontBoardServices             0x189a21904 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
13 FrontBoardServices             0x189a21770 -[FBSSerialQueue _performNext]
14 FrontBoardServices             0x189a21b18 -[FBSSerialQueue _performNextFromRunLoopSource]
15 CoreFoundation                 0x187e2e278 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
16 CoreFoundation                 0x187e2dbc0 __CFRunLoopDoSources0
17 CoreFoundation                 0x187e2b7c0 __CFRunLoopRun
18 CoreFoundation                 0x187d5a048 CFRunLoopRunSpecific
19 GraphicsServices               0x1897dd198 GSEventRunModal
20 UIKit                          0x18dd33818 -[UIApplication _run]
21 UIKit                          0x18dd2e550 UIApplicationMain
22 CelebvidyDev                   0x10006f5c4 main (main.m:16)
23 libdispatch.dylib              0x186d3c5b8 (Missing)

Drop in UI spins forever on Android

import React, { Component } from 'react';
import {
  AppRegistry,
  Text,
  TouchableOpacity,
  Platform,
  View
} from 'react-native';
import BTClient from 'react-native-braintree-xplat';


export default class bt extends Component {
  onPress() {
    const token = "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiIzZWRiNjBlZjZlMjFlYzQwYzRlZjgyMWJjYjViNzI4YjllYmE3NWM1ZDE4YzEzZjdjNTIxMTM0YWU1YTAyOGRifGNyZWF0ZWRfYXQ9MjAxNi0xMC0yMFQwMDoxNzoxMy44MjI0MTI2MzArMDAwMFx1MDAyNm1lcmNoYW50X2lkPTM0OHBrOWNnZjNiZ3l3MmJcdTAwMjZwdWJsaWNfa2V5PTJuMjQ3ZHY4OWJxOXZtcHIiLCJjb25maWdVcmwiOiJodHRwczovL2FwaS5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tOjQ0My9tZXJjaGFudHMvMzQ4cGs5Y2dmM2JneXcyYi9jbGllbnRfYXBpL3YxL2NvbmZpZ3VyYXRpb24iLCJjaGFsbGVuZ2VzIjpbXSwiZW52aXJvbm1lbnQiOiJzYW5kYm94IiwiY2xpZW50QXBpVXJsIjoiaHR0cHM6Ly9hcGkuc2FuZGJveC5icmFpbnRyZWVnYXRld2F5LmNvbTo0NDMvbWVyY2hhbnRzLzM0OHBrOWNnZjNiZ3l3MmIvY2xpZW50X2FwaSIsImFzc2V0c1VybCI6Imh0dHBzOi8vYXNzZXRzLmJyYWludHJlZWdhdGV3YXkuY29tIiwiYXV0aFVybCI6Imh0dHBzOi8vYXV0aC52ZW5tby5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tIiwiYW5hbHl0aWNzIjp7InVybCI6Imh0dHBzOi8vY2xpZW50LWFuYWx5dGljcy5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tLzM0OHBrOWNnZjNiZ3l3MmIifSwidGhyZWVEU2VjdXJlRW5hYmxlZCI6dHJ1ZSwicGF5cGFsRW5hYmxlZCI6dHJ1ZSwicGF5cGFsIjp7ImRpc3BsYXlOYW1lIjoiQWNtZSBXaWRnZXRzLCBMdGQuIChTYW5kYm94KSIsImNsaWVudElkIjpudWxsLCJwcml2YWN5VXJsIjoiaHR0cDovL2V4YW1wbGUuY29tL3BwIiwidXNlckFncmVlbWVudFVybCI6Imh0dHA6Ly9leGFtcGxlLmNvbS90b3MiLCJiYXNlVXJsIjoiaHR0cHM6Ly9hc3NldHMuYnJhaW50cmVlZ2F0ZXdheS5jb20iLCJhc3NldHNVcmwiOiJodHRwczovL2NoZWNrb3V0LnBheXBhbC5jb20iLCJkaXJlY3RCYXNlVXJsIjpudWxsLCJhbGxvd0h0dHAiOnRydWUsImVudmlyb25tZW50Tm9OZXR3b3JrIjp0cnVlLCJlbnZpcm9ubWVudCI6Im9mZmxpbmUiLCJ1bnZldHRlZE1lcmNoYW50IjpmYWxzZSwiYnJhaW50cmVlQ2xpZW50SWQiOiJtYXN0ZXJjbGllbnQzIiwiYmlsbGluZ0FncmVlbWVudHNFbmFibGVkIjp0cnVlLCJtZXJjaGFudEFjY291bnRJZCI6ImFjbWV3aWRnZXRzbHRkc2FuZGJveCIsImN1cnJlbmN5SXNvQ29kZSI6IlVTRCJ9LCJjb2luYmFzZUVuYWJsZWQiOmZhbHNlLCJtZXJjaGFudElkIjoiMzQ4cGs5Y2dmM2JneXcyYiIsInZlbm1vIjoib2ZmIn0=";
    BTClient.setup(token);
    BTClient.showPaymentViewController()
      .then(nonce => {
        console.log(`Complete: ${nonce}`);
      }).catch(err => {
        console.log('err', err);
      });
  }

  render() {
    return (
      <View >
        <TouchableOpacity onPress={this.onPress.bind(this)}>
          <Text>
            Welcome to React Native!
          </Text>
        </TouchableOpacity>
      </View>
    );
  }
}

AppRegistry.registerComponent('bt', () => bt);

image

I'm using the sample token on the braintree developers site. If I start a brand new app with the above code as my index.android.js and click the button, the spinner will come up and never go away. If I click android back and then click the button again the drop in ui will appear.

Rejecting re-init on previously-failed class java.lang.

I/art: Rejecting re-init on previously-failed class java.lang.Class<com.braintreepayments.api.BraintreeFragment$13>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;
I/art:     at java.lang.Class dalvik.system.DexFile.defineClassNative(java.lang.String, java.lang.ClassLoader, java.lang.Object, dalvik.system.DexFile) (DexFile.java:-2)
I/art:     at java.lang.Class dalvik.system.DexFile.defineClass(java.lang.String, java.lang.ClassLoader, java.lang.Object, dalvik.system.DexFile, java.util.List) (DexFile.java:299)
I/art:     at java.lang.Class dalvik.system.DexFile.loadClassBinaryName(java.lang.String, java.lang.ClassLoader, java.util.List) (DexFile.java:292)
I/art:     at java.lang.Class dalvik.system.DexPathList.findClass(java.lang.String, java.util.List) (DexPathList.java:418)
I/art:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:54)
I/art:     at java.lang.Class com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(java.lang.String) (IncrementalClassLoader.java:90)
I/art:     at java.lang.Class com.android.tools.fd.runtime.IncrementalClassLoader.findClass(java.lang.String) (IncrementalClassLoader.java:62)
I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:367)
I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:367)
I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
I/art:     at void com.pw.droplet.braintree.Braintree.setup(java.lang.String, com.facebook.react.bridge.Callback, com.facebook.react.bridge.Callback) (Braintree.java:54)
I/art:     at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/art:     at void com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(com.facebook.react.bridge.CatalystInstance, com.facebook.react.bridge.ExecutorToken, com.facebook.react.bridge.ReadableNativeArray) (BaseJavaModule.java:318)
I/art:     at void com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(com.facebook.react.bridge.ExecutorToken, int, com.facebook.react.bridge.ReadableNativeArray) (JavaModuleWrapper.java:158)
I/art:     at void com.facebook.react.bridge.queue.NativeRunnable.run() (NativeRunnable.java:-2)
I/art:     at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:751)
I/art:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:95)
I/art:     at void com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(android.os.Message) (MessageQueueThreadHandler.java:31)
I/art:     at void android.os.Looper.loop() (Looper.java:154)
I/art:     at void com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run() (MessageQueueThreadImpl.java:196)
I/art:     at void java.lang.Thread.run() (Thread.java:761)
I/art: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.api.GoogleApiClient$ConnectionCallbacks" on path: DexPathList[[dex file "/data/data/com.demoxplat/files/instant-run/dex/slice-support-annotations-23.2.1_4a58147eb7883b42f08db6248032a6b941f70c96-classes.dex", dex file "/data/data/com.demoxplat/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.demoxplat/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.demoxplat/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.demoxplat/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.demoxplat/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.demoxplat/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.demoxplat/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.demoxplat/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.demoxplat/files/
I/art:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
I/art:     at java.lang.Class com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(java.lang.String) (IncrementalClassLoader.java:90)
I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
I/art:     at java.lang.Class dalvik.system.DexFile.defineClassNative(java.lang.String, java.lang.ClassLoader, java.lang.Object, dalvik.system.DexFile) (DexFile.java:-2)
I/art:     at java.lang.Class dalvik.system.DexFile.defineClass(java.lang.String, java.lang.ClassLoader, java.lang.Object, dalvik.system.DexFile, java.util.List) (DexFile.java:299)
I/art:     at java.lang.Class dalvik.system.DexFile.loadClassBinaryName(java.lang.String, java.lang.ClassLoader, java.util.List) (DexFile.java:292)
I/art:     at java.lang.Class dalvik.system.DexPathList.findClass(java.lang.String, java.util.List) (DexPathList.java:418)
I/art:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:54)
I/art:     at java.lang.Class com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(java.lang.String) (IncrementalClassLoader.java:90)
I/art:     at java.lang.Class com.android.tools.fd.runtime.IncrementalClassLoader.findClass(java.lang.String) (IncrementalClassLoader.java:62)
I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:367)
I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:367)
I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
I/art:     at void com.pw.droplet.braintree.Braintree.setup(java.lang.String, com.facebook.react.bridge.Callback, com.facebook.react.bridge.Callback) (Braintree.java:54)
I/art:     at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/art:     at void com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(com.facebook.react.bridge.CatalystInstance, com.facebook.react.bridge.ExecutorToken, com.facebook.react.bridge.ReadableNativeArray) (BaseJavaModule.java:318)
I/art:     at void com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(com.facebook.react.bridge.ExecutorToken, int, com.facebook.react.bridge.ReadableNativeArray) (JavaModuleWrapper.java:158)
I/art:     at void com.facebook.react.bridge.queue.NativeRunnable.run() (NativeRunnable.java:-2)
I/art:     at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:751)
I/art:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:95)
I/art:     at void com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(android.os.Message) (MessageQueueThreadHandler.java:31)
I/art:     at void android.os.Looper.loop() (Looper.java:154)
I/art:     at void com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run() (MessageQueueThreadImpl.java:196)
I/art:     at void java.lang.Thread.run() (Thread.java:761)
W/art: Suspending all threads took: 10.006ms
I/art: Background sticky concurrent mark sweep GC freed 7631(4MB) AllocSpace objects, 57(1252KB) LOS objects, 32% free, 6MB/10MB, paused 11.428ms total 36.430ms
E/EGL_emulation: tid 2593: eglSurfaceAttrib(1146): error 0x3009 (EGL_BAD_MATCH)
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xeac4f9c0, error=EGL_BAD_MATCH

Upgrade to current braintree version

The current braintree version version used here, still have the bug, that the BTAnalyticsMetadata.m trys to import BTAnalyticsMetaData.h. But there is a typo that is fixed in the current braintree release. This typo throws an issue in the newest XCode version 8.3 so that you cannot build to test.

Have you cloned the braintree ios sdk and commited it statically within this repo? Or is there a podfile sneaking around that I am missing out?

How can we get device data info

This is my calling:

BTClient.setup(client_token)
  .then((data) => {
     if (data) {
         BTClient.getDeviceData({
            kount: {
               environment: 'production'
            }
         })
           .then(deviceData => {
               console.log('deviceData: ', deviceData)
           })
           .catch(err => {
                console.log('err: ', err)
           })
    }
})

But the deviceData is always null. The data selector options that I'm using is correct or not?

kount: {
    environment: 'production'
}

Android + PayPal

Hi

Thanks for the library

Would this work on android if i wanted to offer paypal payment? or not yet
and is there a reason if it doesn't work

thank you

Add instructions on how to fix iOS error: missing returnURLScheme

Thanks for doing creating this module.

I was going to open an issue to ask how to fix this issue but I managed myself.
Maybe would be good to add the step in the README? or link to this issue?

BTClient.setup(client_token);

BTClient.showPayPalViewController()...

I get this error in the iOS simulator:

Error Domain=com.braintreepayments.BTPayPalDriverErrorDomain Code=2

"PayPal app switch is missing a returnURLScheme"

UserInfo={
  NSLocalizedDescription=PayPal app switch is missing a returnURLScheme,
  NSLocalizedRecoverySuggestion=PayPal requires a return URL scheme to be configured via [BTAppSwitch setReturnURLScheme:].
  This custom URL scheme must also be registered with your app.
}

This is my Info.plist file:

$ cat ios/myRN/Info.plist | grep -A 20 CFBundleURLTypes
	<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLName</key>
			<string>com.my.app</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>com.my.app.payments</string>
			</array>
		</dict>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>com.googleusercontent.apps.123-abc</string>
			</array>
		</dict>
	</array>
$ cat ios/myRN/Info.plist | grep -A 5 LSApplicationQueriesSchemes
	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>com.paypal.ppclient.touch.v1</string>
		<string>com.paypal.ppclient.touch.v2</string>
		<string>com.venmo.touch.v2</string>
	</array>

Fix

What was missing was this line in the AppDelegate.m file.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ...
    [BTAppSwitch setReturnURLScheme:@"com.your-company.Your-App.payments"];
    return YES;
}

As explained in the Braintree docs:
https://developers.braintreepayments.com/guides/paypal/client-side/ios/v4#update-your-application-delegate

use more unique request code

In Braintree.java you define
private static final int PAYMENT_REQUEST = 1;
This will cause issues with other rn-modules that listen to or emitting the same request code, most likely the app will crash.

iPhone Error

On Android works well but in iOS im receiving this error.

RN V : 0.47.3
Plugin V : Last One

Libtool /Users/dantecervantes/Library/Developer/Xcode/DerivedData/Guest-gnllumsbialpfwfqyqqcfganqyvz/Build/Intermediates.noindex/ArchiveIntermediates/Guest/IntermediateBuildFilesPath/RCTBraintree.build/Release-iphoneos/RCTBraintree.build/Objects-normal/armv7/libRCTBraintree.a normal armv7
    cd /Users/dantecervantes/Documents/react-native/EM/CHM/Guest/node_modules/react-native-braintree-xplat/ios
    export IPHONEOS_DEPLOYMENT_TARGET=7.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only armv7 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk -L/Users/dantecervantes/Library/Developer/Xcode/DerivedData/Guest-gnllumsbialpfwfqyqqcfganqyvz/Build/Intermediates.noindex/ArchiveIntermediates/Guest/BuildProductsPath/Release-iphoneos -filelist /Users/dantecervantes/Library/Developer/Xcode/DerivedData/Guest-gnllumsbialpfwfqyqqcfganqyvz/Build/Intermediates.noindex/ArchiveIntermediates/Guest/IntermediateBuildFilesPath/RCTBraintree.build/Release-iphoneos/RCTBraintree.build/Objects-normal/armv7/RCTBraintree.LinkFileList /Users/dantecervantes/Library/Developer/Xcode/DerivedData/Guest-gnllumsbialpfwfqyqqcfganqyvz/Build/Intermediates.noindex/ArchiveIntermediates/Guest/BuildProductsPath/Release-iphoneos/libBraintree.a -o /Users/dantecervantes/Library/Developer/Xcode/DerivedData/Guest-gnllumsbialpfwfqyqqcfganqyvz/Build/Intermediates.noindex/ArchiveIntermediates/Guest/IntermediateBuildFilesPath/RCTBraintree.build/Release-iphoneos/RCTBraintree.build/Objects-normal/armv7/libRCTBraintree.a

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't open file: /Users/dantecervantes/Library/Developer/Xcode/DerivedData/Guest-gnllumsbialpfwfqyqqcfganqyvz/Build/Intermediates.noindex/ArchiveIntermediates/Guest/BuildProductsPath/Release-iphoneos/libBraintree.a (No such file or directory)

Tapping "Paypal check out" crashes the app on android

FATAL EXCEPTION: main
	Process: com.test, PID: 1861
	java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1706816330, result=3, data=Intent { (has extras) }} to activity {com.test/com.test.MainActivity}: java.lang.RuntimeException: Cannot convert argument of type class com.braintreepayments.api.exceptions.UnexpectedException
		at android.app.ActivityThread.deliverResults(ActivityThread.java:4925)
		at android.app.ActivityThread.handleSendResult(ActivityThread.java:4968)
		at android.app.ActivityThread.access$1600(ActivityThread.java:222)
		at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1849)
		at android.os.Handler.dispatchMessage(Handler.java:102)
		at android.os.Looper.loop(Looper.java:158)
		at android.app.ActivityThread.main(ActivityThread.java:7229)
		at java.lang.reflect.Method.invoke(Native Method)
		at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
		at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
	 Caused by: java.lang.RuntimeException: Cannot convert argument of type class com.braintreepayments.api.exceptions.UnexpectedException
		at com.facebook.react.bridge.Arguments.fromJavaArgs(Arguments.java:57)
		at com.facebook.react.bridge.CallbackImpl.invoke(CallbackImpl.java:36)
		at com.pw.droplet.braintree.Braintree.onActivityResult(Braintree.java:131)
		at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:265)
		at com.facebook.react.ReactInstanceManager.onActivityResult(ReactInstanceManager.java:675)
		at com.facebook.react.ReactActivityDelegate.onActivityResult(ReactActivityDelegate.java:149)
		at com.facebook.react.ReactActivity.onActivityResult(ReactActivity.java:77)
		at android.app.Activity.dispatchActivityResult(Activity.java:7137)
		at android.app.ActivityThread.deliverResults(ActivityThread.java:4921)
		at android.app.ActivityThread.handleSendResult(ActivityThread.java:4968) 
		at android.app.ActivityThread.access$1600(ActivityThread.java:222) 
		at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1849) 
		at android.os.Handler.dispatchMessage(Handler.java:102) 
		at android.os.Looper.loop(Looper.java:158) 
		at android.app.ActivityThread.main(ActivityThread.java:7229) 
		at java.lang.reflect.Method.invoke(Native Method) 
		at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
		at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Conflicting requestCode

It seems that react-native-braintree-xplat and react-native-image-picker are using the same requestCode in android, this causes the error below:

09-21 20:40:59.763 1906 1906 E AndroidRuntime: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { }} to activity {com.gostudentmobile/com.gostudentmobile.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.braintreepayments.api.models.PaymentMethodNonce.getNonce()' on a null object reference

Would be nice if either of you used more unique numbers, so they wouldn't conflict. Is it possible to change it?

Conflicting lines:

https://github.com/marcshilling/react-native-image-picker/blob/master/android/src/main/java/com/imagepicker/ImagePickerModule.java#L61

https://github.com/kraffslol/react-native-braintree-xplat/blob/master/android/src/main/java/com/pw/droplet/braintree/Braintree.java#L23

Thanks!

Cross issue: react-native-image-picker/react-native-image-picker#327

Android setup() + showPaymentViewController() flow hangs

On iOS, the flow works perfect. But the same code breaks on Android:

// snippet from an action:
async (token) => {
  try {
    const brainTreeOptions = {
        tintColor: config.color.brand,
        barBgColor: 'white',
        barTintColor: config.color.brand,
        bgColor: config.color.gradient[0],
        callToActionText: 'Save Card'
      }

      await BTClient.setup(token)
      const nonce = await BTClient.showPaymentViewController(brainTreeOptions)
  } catch (error) {
    // does not happen
  }
}

I suspect this is to do with the setup() promise being resolved too early.

Typo in BTAnalyticsMetadata.m

Building on iOS throws the following error. The #import statement refers to "BTAnalyticsMetaData.h" when the file is actually "BTAnalyticsMetadata.h". I guess the error message is saying it's not portable across operating systems that are fussy about cases.

Regardless, correcting that reference to a lowercase "d" in the #import statement corrects the issue.

/node_modules/react-native-braintree-xplat/ios/RCTBraintree/Braintree/BraintreeCore/BTAnalyticsMetadata.m:1:9: 
error: non-portable path to file '"BTAnalyticsMetadata.h"'; specified path differs in case from file name on disk [-Werror,-Wnonportable-include-path]
#import "BTAnalyticsMetaData.h"
        ^~~~~~~~~~~~~~~~~~~~~~~
        "BTAnalyticsMetadata.h"
1 error generated.

New to contributing - I know it's only one line, but I tried to create a PR for this and failed. Do I need to be added to the project or something?

PayPal Error on Example

I'm trying to get the PayPal button to work but my own app and the example app are returning the error: Paypal app switch is missing a returnURLScheme. However, the CC portion works great.

Digging into what a URL scheme is it seems like that is required for one-touch support and that is enabled by default in the Braintree library. (and I cant seem to disable it, i'd rather not have it for now)

I also tried to follow the instructions on the original repo to add one-touch support but when adding the openURL method to AppDelegate I get the error: RNBraintree.h not found. I've tried tinkering with link binaries and can't get it to work.

any advice on this would be very much appreciated... i'm kind of dead in the water without PayPal support and am spinning my wheels.

There is a similar unanswered issue here:
alanhhwong/react-native-braintree#20

Error React/RCTBridgeModule.h file not found in RCTBraintree.h

I followed step by step to link react-native-braintree-xplat to my project (ios) but I got an error when building (error from file RCTBraintree.h) - 'React/RCTBridgeModule.h' file not found
#import <React/RCTBridgeModule.h>
.
Could you guys point me what's happen with me?

Note: My version React Native is 0.39.

Android not doing Payment Controller callback

I'm using your v1.1.1 because our project is on RN 0.25.1 and I lost 6 hours trying to upgrade it to 0.40+ and then to 0.39, to no avail. it's just too big a challenge to undertake right now. I've got your older xplat working perfectly with iOS, but in Android, it never does the callback to return the nonce. I've tried in Android Nougat and O, to no avail. It just closes the drop-in ui.

Do you have any idea why this might be happening?

My code is thus:

`
setupBraintree() {

let that = this;

let nav = this.props.navigator;

fetch(Config().apiUrl + '/api/v2/payments/get_token', {method: "GET", headers: {'Authorization': that.props.authentication_token} })
.then((response) => response.json())
.then((responseData) => {
  var clientToken = responseData.client_token;
  BTClient.setup(clientToken).then(() => {
    BTClient.showPaymentViewController().then((nonce) => {
      fetch(Config().apiUrl + '/api/v2/payments',
       {
         method: 'POST',
         headers: {
           'Accept': 'application/json',
           'Content-Type': 'application/json',
           'Authorization': that.props.authentication_token
         },
         body: JSON.stringify({
           payment_method_nonce: nonce,
           vehicle_id: that.props.vehicleId
         })
       })
       .then((response) => response.json())
       .then((responseData) => {
          if(responseData.success == true)
           {
             that.setState({
                visible: false
               });
             nav.push({ indent:'PaymentThanks' });
           } else {
             Alert.alert(
                 'Error',
                 responseData.message,
                 [
                   {text: "OK", onPress: () => nav.pop()},
                 ]
               );
           }
        }).catch(function(err) {
         Alert.alert(
             'Error',
             "An error occurred, please try again.",
           )
       }).finally(() => that.setState({visible: false}))
    }).catch(function(err) {
      if(err.message) {
         Alert.alert(
           'Error',
           "Payment failed due to: " + err.message,
         )
      }
    }).done();
  });
})

}
`

showPaymentViewController not showing payment method selection options

I have manage to show the drop in payment form using showPaymentViewController and successfully made payment in sandbox.

However, I am not sure why the "Select Payment Method" dialog is not shown. This library is using drop in UI as in https://developers.braintreepayments.com/start/hello-client/ios/v4 right? I integrated it natively in Android and able to see the "Select Payment Method" dialog correctly. However in react native using this library, the payment UI looks different and there's no "Select Payment Method" dialog.

Am I missing something here? showPaymentViewController is implemented using drop in UI, BTDropInViewController right? I tried to check in Android version, but cant find how showPaymentViewController is implemented. There is only a "paymentRequest" method there. I can't understand how react native call and show drop in UI here.

Thanks

Android Paypal payment automatically cancelled

Every time I clicked paypal checkout, it will throw "USER_CANCELLATION" error. No Paypal Interface will show up. Please help.

Platform: Android
"react": "16.0.0-alpha.12",
"react-native": "^0.48.0",
"react-native-braintree-xplat": "^4.0.0",

compileSdkVersion 26
buildToolsVersion "26.0.2"

defaultConfig {
    applicationId "com.react_native_navigation_bootstrap"
    minSdkVersion 17
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.