braintree_checkout_flutter

A Flutter plugin that enables seamless PayPal, Venmo and Card payments using Braintree, with support for native mobile experiences and device data collection for fraud prevention.

⚠️ Note: This plugin currently supports Vault (tokenize only) transactions. You are responsible for capturing the payment server-side using the nonce returned. Full Checkout (automatic capture) is not supported at this time.

Features

  • Native PayPal payment flow
  • Native Venmo payment flow
  • Native Card payment flow
  • Device data collection
  • Venmo App availability check

Platform Support

Feature Android iOS
PayPal Vault
Venmo Vault
Card Vault
3D Secure
Device Data Collect

Installation

Add the dependency in your pubspec.yaml:

dependencies:
  braintree_checkout_flutter: ^<latest_version>

Then run:

flutter pub get

iOS Setup

  1. Add required URL schemes to your ios/Runner/Info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>venmo</string>
  <string>com.venmo.touch.v2</string>
  <string>paypal</string>
</array>
  1. Enable app switch handling in AppDelegate.swift:
import Braintree

func application(
  _ application: UIApplication,
  open url: URL,
  options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
  return BTAppSwitch.handleOpen(url, options: options)
}

Android Setup

Make sure you have the necessary intent filters and SDK dependencies in your native Android project.

Refer to Braintree's official Android guide for more details.

Usage

Create the plugin instance

import 'package:braintree_checkout_flutter/braintree_checkout_flutter.dart';

final checkout = BraintreeCheckoutFlutter();

PayPal Vault Transaction

final result = await checkout.paypalPayment(
  PayPalRequest(
    token: 'your-client-token-or-tokenization-key',
    amount: '10.00',
    currencyCode: 'USD',
    displayName: 'Your Store',
  ),
);

if (result != null) {
  print('PayPal nonce: ${result.nonce}');
}

Venmo Vault Transaction

final result = await checkout.venmoPayment(
  VenmoRequest(
    token: 'your-client-token-or-tokenization-key',
  ),
);

if (result != null) {
  print('Venmo nonce: ${result.nonce}');
}

Card Vault Transaction

final result = await checkout.tokenizeCard(
  CardRequest(
    token: 'your-client-token-or-tokenization-key',
    cardholderName: 'cardholder-name',
    cardNumber: 'card-number',
    expirationMonth: 'expiration-month',
    exoprationYear: 'expiration-year',
    cvv: 'cvv',
  ),
);

if (result != null) {
  print('Card nonce: ${result.nonce}');
}

3D Secure Transaction

final result = await braintree.threeDSecurePayment(
  ThreeDSecureRequest(
    token: 'your-client-token-or-tokenization-key',
    amount: 'amount',
    nonce: 'card-nonce',
    email: 'optional-user-email',
  ),
);

if (result != null) {
  print('3D Secure nonce: ${result.nonce}');
}

Device Data Collection

final deviceData = await checkout.collectDeviceData('your-client-token-or-tokenization-key');
print('Collected device data: $deviceData');

Check if Venmo App is Installed

final isInstalled = await checkout.isVenmoAppInstalled();
print('Is Venmo installed: $isInstalled');

Exports

The plugin exports these models:

  • PayPalRequest, PayPalAccountNonce
  • VenmoRequest, VenmoAccountNonce
  • CardRequest, CardAccountNonce
  • PostalAddress (for PayPal shipping address)

Contributing

Contributions are welcome! Feel free to open issues or pull requests on the GitHub repository.