PHPackages                             danhunsaker/laravel-braintree - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. danhunsaker/laravel-braintree

ActiveLibrary[Framework](/categories/framework)

danhunsaker/laravel-braintree
=============================

A Braintree bridge for Laravel

6.0.0(5y ago)02.3k1[1 PRs](https://github.com/danhunsaker/Laravel-Braintree/pulls)MITPHPPHP &gt;=7.2

Since Nov 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/danhunsaker/Laravel-Braintree)[ Packagist](https://packagist.org/packages/danhunsaker/laravel-braintree)[ RSS](/packages/danhunsaker-laravel-braintree/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (6)Versions (8)Used By (0)

Laravel Braintree
=================

[](#laravel-braintree)

[![Build Status](https://camo.githubusercontent.com/20927df1bfb6793b9eef2ebfd8dac1928799564ba78813007ef7594d7b2183b8/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f64616e68756e73616b65722f4c61726176656c2d427261696e747265652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/danhunsaker/Laravel-Braintree)![PHP from Packagist](https://camo.githubusercontent.com/9a204aba2103a8a02d3a86e47e5e4a398135ce1f48281649bd8837bd874309fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64616e68756e73616b65722f6c61726176656c2d627261696e747265652e7376673f7374796c653d666c61742d737175617265)[![Latest Version](https://camo.githubusercontent.com/8387dc99e502af37c67642cc1ffb5af3a55a6978cdcde603a8b46b930047b64e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f64616e68756e73616b65722f4c61726176656c2d427261696e747265652e7376673f7374796c653d666c61742d737175617265)](https://github.com/danhunsaker/Laravel-Braintree/releases)[![License](https://camo.githubusercontent.com/602d203514b6fd08e8139937c3a71cff1a0864b0f1d88b972fa9cc638c2159e9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64616e68756e73616b65722f4c61726176656c2d427261696e747265652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danhunsaker/Laravel-Braintree)

> A [Braintree](https://www.braintreepayments.com) bridge for Laravel.

Installation
------------

[](#installation)

Require this package, with [Composer](https://getcomposer.org/), in the root directory of your project.

```
$ composer require danhunsaker/laravel-braintree
```

Configuration
-------------

[](#configuration)

Laravel Braintree requires connection configuration. To get started, you'll need to publish all vendor assets:

```
$ php artisan vendor:publish --provider="Danhunsaker\Braintree\BraintreeServiceProvider"
```

This will create a `config/braintree.php` file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

#### Default Connection Name

[](#default-connection-name)

This option `default` is where you may specify which of the connections below you wish to use as your default connection for all work. Of course, you may use many connections at once using the manager class. The default value for this setting is `main`.

#### Braintree Connections

[](#braintree-connections)

This option `connections` is where each of the connections are setup for your application. Example configuration has been included, but you may add as many connections as you would like.

Usage
-----

[](#usage)

#### BraintreeManager

[](#braintreemanager)

This is the class of most interest. It is bound to the ioc container as `braintree` and can be accessed using the `Danhunsaker\Braintree\Facades\Braintree` facade. This class implements the ManagerInterface by extending AbstractManager. The interface and abstract class are both part of [Graham Campbell's](https://github.com/GrahamCampbell) [Laravel Manager](https://github.com/GrahamCampbell/Laravel-Manager) package, so you may want to go and checkout the docs for how to use the manager class over at that repository. Note that the connection class returned will always be an instance of `Braintree\Braintree`.

#### Facades\\Braintree

[](#facadesbraintree)

This facade will dynamically pass static method calls to the `braintree` object in the ioc container which by default is the `BraintreeManager` class.

#### BraintreeServiceProvider

[](#braintreeserviceprovider)

This class contains no public methods of interest. This class should be added to the providers array in `config/app.php`. This class will setup ioc bindings.

### Examples

[](#examples)

Here you can see an example of just how simple this package is to use. Out of the box, the default adapter is `main`. After you enter your authentication details in the config file, it will just work:

```
// You can alias this in config/app.php.
use Danhunsaker\Braintree\Facades\Braintree;

Braintree::getTransaction()->sale([
    'amount' => '10.00',
    'paymentMethodNonce' => $nonceFromTheClient,
    'options' => ['submitForSettlement' => true]
]);
// We're done here - how easy was that, it just works!
```

The Braintree manager will behave like it is a `Braintree\Braintree`. If you want to call specific connections, you can do that with the connection method:

```
use Danhunsaker\Braintree\Facades\Braintree;

// Writing this…
Braintree::connection('main')->getCharge()->([
    'amount' => '10.00',
    'paymentMethodNonce' => $nonceFromTheClient,
    'options' => ['submitForSettlement' => true]
]);

// …is identical to writing this
Braintree::getCharge()->([
    'amount' => '10.00',
    'paymentMethodNonce' => $nonceFromTheClient,
    'options' => ['submitForSettlement' => true]
]);

// and is also identical to writing this.
Braintree::connection()->getCharge()->([
    'amount' => '10.00',
    'paymentMethodNonce' => $nonceFromTheClient,
    'options' => ['submitForSettlement' => true]
]);

// This is because the main connection is configured to be the default.
Braintree::getDefaultConnection(); // This will return main.

// We can change the default connection.
Braintree::setDefaultConnection('alternative'); // The default is now alternative.
```

If you prefer to use dependency injection over facades like me, then you can inject the manager:

```
use Danhunsaker\Braintree\BraintreeManager;

class Foo
{
    protected $braintree;

    public function __construct(BraintreeManager $braintree)
    {
        $this->braintree = $braintree;
    }

    public function bar($params)
    {
        $this->braintree->getCharge()->([
            'amount' => '10.00',
            'paymentMethodNonce' => $nonceFromTheClient,
            'options' => ['submitForSettlement' => true]
        ]);
    }
}

App::make('Foo')->bar($params);
```

Documentation
-------------

[](#documentation)

There are other classes in this package that are not documented here. This is because the package is a Laravel wrapper of [the official Braintree package](https://github.com/braintree/braintree_php).

Testing
-------

[](#testing)

```
$ phpunit
```

Security
--------

[](#security)

If you discover a security vulnerability within this package, please send an e-mail to . All security vulnerabilities will be promptly addressed.

Credits
-------

[](#credits)

- [Brian Faust](https://github.com/faustbrian)
- [Dan Hunsaker](https://github.com/danhunsaker)
- [All Contributors](../../contributors)

License
-------

[](#license)

[MIT](LICENSE) © [Brian Faust](https://brianfaust.me) and Dan Hunsaker

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~238 days

Recently: every ~339 days

Total

7

Last Release

2041d ago

Major Versions

1.0.0 → 2.0.02016-12-04

2.1.1 → v3.0.02017-11-02

v3.1.0 → 6.0.02020-10-09

PHP version history (4 changes)1.0.0PHP ^5.6 || ^7.0

2.0.0PHP ^7.1

v3.0.0PHP ^7.0

6.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1534396?v=4)[Hennik Hunsaker](/maintainers/danhunsaker)[@danhunsaker](https://github.com/danhunsaker)

---

Top Contributors

[![faustbrian](https://avatars.githubusercontent.com/u/22145591?v=4)](https://github.com/faustbrian "faustbrian (12 commits)")[![danhunsaker](https://avatars.githubusercontent.com/u/1534396?v=4)](https://github.com/danhunsaker "danhunsaker (3 commits)")[![garret-gunter](https://avatars.githubusercontent.com/u/8146238?v=4)](https://github.com/garret-gunter "garret-gunter (1 commits)")

---

Tags

frameworklaravelLaravel-Braintree

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/danhunsaker-laravel-braintree/health.svg)

```
[![Health](https://phpackages.com/badges/danhunsaker-laravel-braintree/health.svg)](https://phpackages.com/packages/danhunsaker-laravel-braintree)
```

###  Alternatives

[rebing/graphql-laravel

Laravel wrapper for PHP GraphQL

2.2k7.1M26](/packages/rebing-graphql-laravel)[graham-campbell/markdown

Markdown Is A CommonMark Wrapper For Laravel

1.3k7.1M64](/packages/graham-campbell-markdown)[graham-campbell/manager

Manager Provides Some Manager Functionality For Laravel

39221.1M134](/packages/graham-campbell-manager)[graham-campbell/github

GitHub Is A GitHub Bridge For Laravel

6411.7M19](/packages/graham-campbell-github)[laravel-lang/publisher

Localization publisher for your Laravel application

2167.7M24](/packages/laravel-lang-publisher)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
