flutter_braintree 0.5.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 90

Braintree for Flutter #

A Flutter plugin that wraps the native Braintree SDKs. Unlike other plugins, this plugin not only lets you start Braintree's native Drop-in UI, but also allows you to create your own custom Flutter UI with Braintree functionality.

Custom UI is still early in development and does not yet work on iOS!

Installation #

Add flutter_braintree to your pubspec.yaml file:

  flutter_braintree: ^0.5.3

Android #

You must migrate to AndroidX.
In /app/build.gradle, set your minSdkVersion to at least 21.

PayPal / Venmo / 3D Secure #

In order for this plugin to support PayPal, Venmo or 3D Secure payments, you must allow for the browser switch by adding an intent filter to your AndroidManifest.xml (inside the <application> body):

<activity android:name="com.braintreepayments.api.BraintreeBrowserSwitchActivity"
        <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" />

Important: Your app's URL scheme must begin with your app's package ID and end with .braintree. For example, if the Package ID is com.your-company.your-app, then your URL scheme should be com.your-company.your-app.braintree. ${applicationId} is automatically applied with your app's package when using Gradle. Note: The scheme you define must use all lowercase letters. If your package contains underscores, the underscores should be removed when specifying the scheme in your Android Manifest.

Google Pay #

Add the wallet enabled meta-data tag to your AndroidManifest.xml (inside the <application> body):

<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true"/>

iOS #

Warning: Device data collection is not yet supported for iOS.

PayPal / Venmo / 3D Secure #

In your App Delegate or your Runner project, you need to specify the URL scheme for redirecting payments as following:


Moreover, you need to specify the same URL scheme in your Info.plist:


See the official Braintree documentation for a more detailed explanation.

Usage #

First, import the plugin:

import 'package:flutter_braintree/flutter_braintree.dart';

Flutter UI #

Warning: This feature is only implemented for Android.

Credit cards #

Create a credit card request object:

final request = BraintreeCreditCardRequest(
  cardNumber: '4111111111111111',
  expirationMonth: '12',
  expirationYear: '2021',

Then ask Braintree to tokenize it:

BraintreePaymentMethodNonce result = await Braintree.tokenizeCreditCard(
   '<Insert your tokenization key or client token here>',

PayPal #

Create a PayPal request object:

final request = BraintreePayPalRequest(amount: '13.37');

Or, for the Vault flow:

final request = BraintreePayPalRequest(
  billingAgreementDescription: 'I hearby agree that flutter_braintree is great.',

Then launch the PayPal request:

BraintreePaymentMethodNonce result = await Braintree.requestPaypalNonce(
   '<Insert your tokenization key or client token here>',
if (result != null) {
  print('Nonce: ${result.nonce}');
} else {
  print('PayPal flow was canceled.');

Braintree's native drop-in #

Create a drop-in request object:

final request = BraintreeDropInRequest(
  clientToken: '<Insert your client token here>',
  collectDeviceData: true,
  googlePaymentRequest: BraintreeGooglePaymentRequest(
    totalPrice: '4.20',
    currencyCode: 'USD',
    billingAddressRequired: false,
  paypalRequest: BraintreePayPalRequest(
    amount: '4.20',
    displayName: 'Example company',

Then launch the drop-in:

BraintreeDropInResult result = await BraintreeDropIn.start(request);

Access the payment nonce:

if (result != null) {
  print('Nonce: ${result.paymentMethodNonce.nonce}');
} else {
  print('Selection was canceled.');

See BraintreeDropInRequest and BraintreeDropInResult for more documentation.

0.5.3 #

  • Fix incompatibility with Flutter's new v2 embedding
  • Update example project to use v2 embedding
  • Use new platforms key in pubspec.yaml (requires Flutter 1.10 or newer!)

0.5.2 #

  • Fix credit card expiration not being included correctly

0.5.1 #

  • Improve README.md

0.5.0 #

  • Add basic support for the direct PayPal Checkout and Vault flow Android

0.4.0 #

  • Add basic support for direct credit card tokenization on Android

0.3.0 #

  • Add iOS support (thank you to Johannes Erschbamer!)
  • Improve documentation

0.2.0 #

  • Refactor source code
  • Set minimum Dart version to 2.2.2

0.1.2 #

  • Fix typo in README.md

0.1.1 #

  • Throw proper exception when the Drop-in is launched twice
  • Improve README.md

0.1.0 #

  • Initial release after discontinuing the old plugin


flutter_braintree_example #

Demonstrates how to use the flutter_braintree plugin.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_braintree: ^0.5.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_braintree/flutter_braintree.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
flutter 0.0.0
meta >=1.0.0 <2.0.0 1.1.8
Transitive dependencies
collection 1.14.11 1.14.12
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8