Braintree paypal



Hello, how are you all?

Recently I am developing a Braintree plugin with paypal but apparently I do not get references of my created objecters, help please.

import { Common } from './paypal-checkout.common';
import * as app from "tns-core-modules/application";

declare const com: any;

export class PaypalCheckout extends Common {

    private braintree: any; // com.braintreepayments.api.BraintreeFragment

    paypalRequest(options: PaypalOptions): Promise<any> {
        return new Promise(function (resolve, reject) {

            try {
                let activity = ||;
                this.braintree = com.braintreepayments.api.BraintreeFragment.newInstance(activity, options.token);
            } catch(error) {
               reject("Braintree created error: " + error);

            let request = new com.braintreepayments.api.models.PayPalRequest(options.amount).currencyCode(options.currencyCode);
            com.braintreepayments.api.PayPal.requestOneTimePayment(this.braintree, request);

            this.braintree.addListener(new com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener({
                    onPaymentMethodNonceCreated: function(paymentMethodNonce) {

            this.braintree.addListener(new com.braintreepayments.api.interfaces.BraintreeErrorListener({
                    onError: function(error) {

export interface PaypalOptions {
    token: string;
    amount: string;
    currencyCode: string;

Error: TypeError: Cannot read property 'newInstance' of undefined


Here error, please help


Did you make sure your dependencies are installed properly? Tried a clean build?


Yes, file include.gradle is:

android {


allprojects {
    repositories {
        maven {
            url ''

dependencies {
    // Describe plugin native Android dependencies like
	  compile "com.braintreepayments.api:braintree:2.+"

and AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="">

  <!--Describe the permissions, features or other configurations required by your plugin for Android. To read more about android permissions go to -->
  <!--EXAMPLE: uses-permission android:name="android.permission.INTERNET"/> -->
    <activity android:name="com.braintreepayments.api.BraintreeBrowserSwitchActivity" android:launchMode="singleTask">
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="${applicationId}.braintree"/>



Thanks, recreate a new project and it worked