---
title: "Integrating Braintree for Flutter"  
description: "With an increase in online transactions, App and Web users are more prone to cyber-attacks. Several big companies are investing in building a secure"  
author: "Apeksha Khanna"  
published: 2019-12-06  
updated: 2019-12-06  
canonical: https://www.mindstick.com/blog/276180/integrating-braintree-for-flutter  
category: "mobile development"  
tags: ["open source development", "mobile app development"]  
reading_time: 3 minutes  

---

# Integrating Braintree for Flutter

With an increase in [online transactions](https://answers.mindstick.com/qa/105281/how-is-ai-used-in-fraud-prevention-in-online-transactions), App and Web users are more prone to cyber-attacks. Several big companies are investing in building a [secure data](https://www.mindstick.com/forum/160203/how-to-apply-encryption-authentication-and-authorization-mechanisms-to-secure-data-in-sql-server) transmitting system. Studies showed that Companies with weak [data storage](https://www.mindstick.com/interview/2601/what-are-different-data-storage-options-are-available-in-android) protocols are at high risk of losing a large portion of [your audience](https://answers.mindstick.com/qa/96461/what-s-another-way-to-show-you-pins-to-your-audience-without-always-linking-to-pinterest). This is where Braintree comes in limelight. Braintree coupled with Paypal is one such secure gateway provider that offers fraud control tools, processes debit/ credit cards, and is available in multiple languages. Plus, Braintree supports Flutter which makes it even easier for developers to build an exquisite app for both iOS and Android with a single code base.

A [mobile application](https://www.mindstick.com/forum/201/namespace-for-mobile-application-in-dot-net) build with Flutter looks native on both Android and iOS, saves [App development](https://www.mindstick.com/services/mobile-app-development) time and money.

Follow the below-given steps to enable [payment gateway](https://www.mindstick.com/articles/323674/how-payment-gateways-work) support.

## Steps to Enable Braintree for Flutter-build App

Step 1: Signup for a free Sandbox account to test the Braintree code. \

You'll need your:

- Sandbox merchant ID
- Public key
- Private key

to test the values of a secure protocol. We will come to that later.

Step 2: Create your Flutter Project and do the followings for:\

## Android

Add support for Paypal Payment by adding below lines inside the [AndroidManifest.xml](https://www.mindstick.com/interview/2588/explain-androidmanifest-xml-file-in-detail) file.

<activity android:name="com.braintreepayments.api.BraintreeBrowserSwitchActivity"

android:launchMode="singleTask">

<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>

## IOS:

To add support for Paypal Payment on IOS.

Basic insturctions from braintree:

1. Register URL Type

2. Update application delegate to setReturnUrlScheme

3. Update application delegate to pass the payment authorization URL to Braintree for finalization

For Detailed instuction follow steps here :- https://developers.braintreepayments.com/guides/paypal/client-side/ios/v4

## Google Pay

To add support for Google Pay add below lines inside AndroidManifest.xml.

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

Step3: Open Pubspec.yaml file and add the dependencies.

Step 4: Import the plugin:

import 'package:braintree_payment/braintree_payment.dart';

Step 5: Create an object of Braintree Payment and pass the client nonce.

String clientNonce = " GET YOUR CLIENT NONCE FROM YOUR SERVER";

BraintreePayment braintreePayment = new BraintreePayment();

var data = await braintreePayment.showDropIn(

nonce: clientNonce, amount: "2.0", enableGooglePay: true);

Step6: Variable data will have the payment nonce. Send the payment nonce to the server for further processing of the payment:

var data = await braintreePayment.showDropIn(

nonce: clientNonce, amount: "2.0", enableGooglePay: true);

print("Response of the payment $data");

// In case of success

//{"status":"success","message":"Payment successful. Send the payment nonce to the server for the further processing.":"paymentNonce":"jdsfhedbyq772_34dfsf"}

// In case of Failure

//{"status":"fail","message":"User canceled the payment"}

Step 7: Test the values on Sandbox and you are ready to launch the secure payments app.

Check the [GitHub project](https://github.com/DeligenceTechnologies/Braintree-Payment-Gateway-for-Flutter) to run the examples.

**Disclosure**: Braintree Flutter integration is an open-[source code](https://www.mindstick.com/forum/33476/pls-send-me-source-code-for-changing-passward-in-asp-dot-net-i-tried-so-much-from-google-but-its-not-workining) available at Github developed by Deligence Technologies. Developers can use it by following the license.

---

Original Source: https://www.mindstick.com/blog/276180/integrating-braintree-for-flutter

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
