# vaimo/module-braintree-magento2

> Fork from the Magento Braintree 2.2.0 module by Gene Commerce for PayPal.

`composer require vaimo/module-braintree-magento2`

Canonical URL: https://packagento.com/vaimo/module-braintree-magento2

## At a glance

- **Vendor**: Vaimo (https://packagento.com/vaimo.md)
- **Latest version**: 4.0.8 — released 2021-09-14
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/vaimo/module-braintree-magento2 and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require vaimo/module-braintree-magento2:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Fork from the Magento Braintree 2.2.0 module by Gene Commerce for PayPal.

## README

Module Magento\Braintree implements integration with the Braintree payment system.

### Overview

This module overwrites the original Magento Braintree module, to provide additional features and bug fixes.

### Available Payment Methods
* Credit Card
    * Visa
    * Mastercard
    * Amex
    * Discover
    * JCB
    * Diners
    * Maestro
    * Restrictions apply.
* PayPal
* PayPal Credit
    * US and UK only. Restrictions apply.
* Google Pay
* Apple Pay
* Venmo (US only)
* ACH Direct Debit (US only)

### Additional Features

#### M1 to M2 Stored Card migration tool
If you are looking to migrate to M2 and want to offer the best experience for existing customers by migrating their stored
credit cards, this is now possible with the new console command.

To use the new command, ensure that
- Your M1 database is online and accessible
- Your M2 store is in Braintree Production mode
- You have already migrated the customers from M1 to M2

Run the following command on your M2 server

`bin/magento braintree:migrate --host=<HOSTNAME_OR_IP> --dbname=<DB_NAME>`

You will be prompted for the DB Username and Password and after that, the tool will query your M1 DB, find any stored cards
and locate them in your Braintree account (this is why you must run it with Braintree in Production mode).
Any matching records that are found are then queried in your M2 database, and the card details* are stored for that customer.

<small>
* Credit Card information is stored by way of a token that matches a Vault record in Braintree.
No sensitive card data is ever exposed.
</small>

#### Kount ENS Webhook
If your Kount and Braintree accounts have been linked, you can now configure Braintree with your Kount Merchant ID to
enable the ENS webhook. Add the ENS URL to your Kount portal (more info in the configuration options) and any orders
that get flagged as "Review" or "Escalate" can be accepted or declined through Kount. The ENS webhook in Magento will
pick up this status change and handle the Magento Order accordingly.
More information available [here](https://articles.braintreepayments.com/guides/fraud-tools/advanced/kount-custom).

#### Custom Fields
If you would like to add [Custom Fields](https://articles.braintreepayments.com/control-panel/custom-fields) to your
Braintree transactions, we provide an example module [here](https://github.com/genecommerce/module-braintree-customfields-example)
that can be used to create a custom module for your store to add these fields.

## Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### [4.0.3] - 2020-02-20
#### Fixed
- Feedback to end-user when using vaulted payment methods

### [4.0.2] - 2019-12-09
#### Fixed
- Replaced `getPrice` with `getBasePrice` in Level 2/3 data builder in order to correctly get a float
- Issue when trying to use a UK Maestro card to checkout

### [4.0.1] - 2019-11-27
#### Fixed
- LPM allowed payment methods config value saved incorrectly as `null`

### [4.0.0] - 2019-11-20
#### Added
- Local Payment Methods
  - Merchants can now offer up to 8 new payment methods for EU based customers
  - Bancontact, EPS, girpoay, iDEAL, Klarna Pay Now/SOFORT, MyBank, P24 and SEPA/ELV Direct Debit are now supported
- Minimum requirements have been updated to Magento 2.3, and PHP 7.2

### [3.4.1] - 2019-11-20
#### Fixed
- Hotfix for bug that stopped stored cards being used when CVV Re-verification is disabled

### [3.4.0] - 2019-11-15
#### Added
- M1 to M2 Stored Card migration tool
  - New `bin/magento braintree:migrate` console command to connect to your remote M1 database and potentially copy across customers
    stored cards. This should be run whilst Braintree is in Production mode.
- Kount ENS webhook
  - Allow "suspected fraud" orders in Magento to be accepted or decline by changing status in your Kount portal
- CVV Re-verification for Stored Cards
  - This option can be enabled so that registered Customers need to provide the CVV in order to use a Stored Card
- Information about Apple Pay on-boarding
- Information about Custom Fields

#### Fixed
- Level 2/3 Processing data now only used for Credit/Debit card transactions and now includes shipping tax
- Correct state now set on the PayPal Onclick review page
- Bug where PayPal was not using updated shipping address if the customer changed it during checkout
- Bug that stopped Admins creating orders in the backend when Braintree was the only payment method
- API validation check now uses correct Store IDs when a multi-store is being used

#### Removed
- Removed old PayPal `payee email` configuration option as it has been deprecated by Braintree

### [3.3.3]
#### Fixed
- Updated PayPal Credit APR percentages

### [3.3.2] - 2019-09-26
#### Fixed
- Level 2 / 3 Processing data should now only send shipping data if a shipping address is present.

### [3.3.1] - 2019-09-25
#### Fixed
- Level 2 / 3 Processing data should now return strings for the float values as per the documentation

### [3.3.0] - 2019-09-18
#### Added
- New payment methods; Venmo and ACH Direct Debit
- Both new payment methods are for merchants based in the US and will require you to speak with your Braintree Account 
Manager to enable the services on your account
- Level 2 /3 Processing information. For more details, see [here](https://developers.braintreepayments.com/reference/general/level-2-and-3-processing/overview)
- Braintree PHP SDK (3.40.0) is now included as part of the module in order to maintain BC with Magento 2.2

#### Fixed
- PayPal not working with virtual products
- CVV validation bug (https://github.com/nicholasscottfish)
- Google Pay library now correctly excluded from JS minification

#### Removed
- Unused Guzzle PSR7 library

### [3.2.1] - 2019-07-31
#### Fixed
- Bug in backend create order

### [3.2.0] - 2019-07-31
#### Added
- 3DS 2 now supported
- Basic validation to Dynamic Descriptor configuration options to alleviate errors in checkout

_(Changelog truncated for .md surface. Full history on https://packagento.com/vaimo/module-braintree-magento2.)_

## Recent Versions

| Version | Released |
|---|---|
| 4.0.8 | 2021-09-14 |
| 4.0.7 | 2021-04-29 |
| 4.0.6 | 2021-01-29 |
| 4.0.5 | 2020-11-10 |
| 3.5.0 | 2020-11-09 |
| 3.4.4 | 2020-09-02 |
| 3.4.3 | 2020-05-19 |
| 4.0.4 | 2020-05-19 |
| 4.0.3 | 2020-02-20 |
| 4.0.2 | 2019-12-13 |

Showing 10 of 36 versions. Full release history on https://packagento.com/vaimo/module-braintree-magento2.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| ext-json | * |
| ext-simplexml | * |
| league/iso3166 | ^2.1 |
| magento/module-backend | 100.2.*\|\|101.0.* |
| magento/module-catalog | 102.0.*\|\|103.0.* |
| magento/module-checkout | 100.2.*\|\|100.3.* |
| magento/module-config | 101.0.*\|\|101.1.* |
| magento/module-customer | 101.0.*\|\|102.0.* |
| magento/module-directory | 100.2.*\|\|100.3.* |
| magento/module-multishipping | 100.2.*\|\|100.3.* |
| magento/module-payment | 100.2.*\|\|100.3.* |
| magento/module-paypal | 100.2.*\|\|100.3.* |
| magento/module-quote | 101.0.*\|\|101.1.* |
| magento/module-sales | 101.0.*\|\|102.0.* |
| magento/module-theme | 100.2.*\|\|101.0.* |
| magento/module-ui | 101.0.*\|\|101.1.* |
| magento/module-vault | 101.0.*\|\|101.1.* |
| msp/recaptcha | ^2.2.3 |
| php | >=7.2.0 |

### Replace

| Package | Constraint |
|---|---|
| braintree/braintree_php | 3.* |
| magento/module-braintree | 100.*.* |

## Quality

Latest release (4.0.8) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 1 | 1 | – | – |
| 2.4.8 | – | 1 | 1 | – |
| 2.4.9 | – | – | not tested | not tested |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 3516 | 8 errors, 3508 warnings (ruleset: Magento2) — 1677 auto-fixable with phpcbf |
| PHPMD | Warning | 157 | 157 rule violations (MissingImport:25, UndefinedVariable:23, TooManyPublicMethods:18, UnusedPrivateMethod:14, UnusedPrivateField:14) |
| Cpd | Warning | 12 | 12 duplicated chunks spanning 655 total lines (min-lines=5, min-tokens=70) |
| Composer validate | Info | 1 | valid; 1 advisory note (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Error | Error | – | – |
| 2.4.8 | – | Error | Error | – |
| 2.4.9 | – | – | Error | Error |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | N/A | 0 | no resolvable dependency tree to audit — Your requirements could not be resolved to an installable set of packages. Problem 1 |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["vaimo/module-braintree-magento2"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

Vaimo is a Magento 2 vendor on Packagento. See https://packagento.com/vaimo.md for their full catalogue.

