npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

capacitor-braintree

v1.0.0

Published

A Capacitor plugin for the Braintree mobile payment processing SDK with 3D secure and Data Collecting.

Downloads

7

Readme

Capacitor Braintree Plugin

A Capacitor plugin for the Braintree mobile payment processing SDK with 3D secure and Data Collecting.

Features

  • Google Pay Integration (Android)
  • Apple Pay Integration (iOS)
  • 3D Secure Verification (iOS)
  • Device Data Collection
  • Payment Method Tokenization

Installation

npm install capacitor-braintree
npx cap sync

Android Setup

1. Add Google Pay Configuration

Add the following to your android/app/src/main/AndroidManifest.xml:

<activity android:name=".MainActivity">
    <!-- ... existing activity configuration ... -->
    <intent-filter>
        <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" />
    </intent-filter>
</activity>

2. Configure Google Pay

Make sure you have:

  • Google Pay API enabled in your Google Cloud Console
  • A valid merchant ID configured
  • Google Play Services installed on test devices

iOS Setup

1. Add Apple Pay Capability

In Xcode:

  1. Select your target
  2. Go to "Signing & Capabilities"
  3. Add "Apple Pay" capability
  4. Configure your merchant ID

2. Configure URL Schemes

Add the following to your Info.plist:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string></string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>$(PRODUCT_BUNDLE_IDENTIFIER).braintree</string>
        </array>
    </dict>
</array>

Usage

Initialize the Plugin

import { Braintree } from 'capacitor-braintree';

// Initialize with your client token
await Braintree.initialize('your-client-token');

Check Payment Availability

// Check if Google Pay is available (Android)
const canMakePayments = await Braintree.canMakePayments({ requireExistingPaymentMethods: false });
console.log('Can make payments:', canMakePayments.value);

Setup Apple Pay (iOS)

await Braintree.setupApplePay({
  merchantId: 'merchant.com.yourcompany',
  currency: 'USD',
  country: 'US',
  cardTypes: ['visa', 'mastercard', 'amex']
});

Launch Google Pay (Android)

const result = await Braintree.launchGooglePay({
  amount: '10.00',
  currency: 'USD',
  environment: 'TEST', // or 'PRODUCTION'
  requiredShippingContactFields: ['emailAddress', 'phoneNumber'],
  cardTypes: ['VISA', 'MASTERCARD']
});

if (!result.userCancelled) {
  console.log('Payment successful:', result.nonce);
  console.log('Device data:', result.deviceData);
}

Launch Apple Pay (iOS)

const result = await Braintree.launchApplePay({
  amount: '10.00',
  primaryDescription: 'Your Order',
  requiredShippingContactFields: ['emailAddress', 'phoneNumber']
});

if (!result.userCancelled) {
  console.log('Payment successful:', result.nonce);
  console.log('Device data:', result.deviceData);
}

Verify Card with 3D Secure (iOS only)

const result = await Braintree.verifyCard({
  amount: '10.00',
  nonce: 'existing-payment-method-nonce',
  email: '[email protected]',
  billingAddress: {
    givenName: 'John',
    surname: 'Doe',
    phoneNumber: '+1234567890',
    countryCodeAlpha2: 'US'
  }
});

console.log('Verification result:', result.nonce);
console.log('Device data:', result.deviceData);

API Reference

Methods

initialize(options: InitializeOptions)

Initialize the Braintree client with a client token.

canMakePayments(options: CanMakePaymentsOptions)

Check if the device can make payments.

setupApplePay(options: SetupApplePayOptions)

Configure Apple Pay settings (iOS only).

launchApplePay(options: LaunchApplePayOptions)

Launch Apple Pay payment sheet (iOS only).

launchGooglePay(options: LaunchGooglePayOptions)

Launch Google Pay payment flow (Android only).

verifyCard(options: VerifyCardOptions)

Verify a payment method with 3D Secure (iOS only).

Interfaces

interface InitializeOptions {
  token: string;
}

interface CanMakePaymentsOptions {
  requireExistingPaymentMethods: boolean;
}

interface CanMakePaymentsResult {
  value: boolean;
}

interface SetupApplePayOptions {
  merchantId: string;
  currency: string;
  country: string;
  cardTypes: string[];
}

interface LaunchApplePayOptions {
  amount: string;
  primaryDescription?: string;
  requiredShippingContactFields?: string[];
}

interface LaunchGooglePayOptions {
  amount: string;
  currency: string;
  environment: string;
  requiredShippingContactFields?: string[];
  cardTypes: string[];
}

interface VerifyCardOptions {
  amount: string;
  nonce: string;
  email: string;
  billingAddress: {
    givenName: string;
    surname: string;
    phoneNumber: string;
    countryCodeAlpha2: string;
  };
}

interface PaymentResult {
  userCancelled: boolean;
  nonce?: string;
  deviceData?: string;
  emailAddress?: string;
  name?: string;
  phoneNumber?: string;
  card?: {
    lastTwo: string;
    network: string;
  };
  applePayCard?: any;
  type?: string;
}

interface VerifyCardResult {
  nonce: string;
  deviceData: string;
  error?: string;
}

Platform Support

| Platform | Google Pay | Apple Pay | 3D Secure | |----------|------------|-----------|-----------| | iOS | ❌ | ✅ | ✅ | | Android | ✅ | ❌ | ❌ | | Web | ❌ | ❌ | ❌ |

Implementation Notes

  • Android: Google Pay is fully implemented. 3D Secure verification returns "not implemented" error.
  • iOS: Apple Pay and 3D Secure verification are fully implemented.
  • Web: Not currently supported.

Example Usage

See the example app for complete implementation examples including:

  • Platform detection
  • Payment flow management
  • Error handling
  • Contact information collection

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.