Skip to content

Siteation/magento2-braintree-silence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Siteation - Magento 2 Braintree Silence

Supported Magento Versions License

The Magento 2 Braintree Silence module suppresses configuration validation errors from the PayPal Braintree payment module when it's disabled or not configured.

The Problem

When the PayPal Braintree payment module is disabled or not configured, it still attempts to validate its configuration on initialization. This results in error messages like:

merchantId needs to be set

These errors flood your system.log even though the payment method is intentionally disabled, making it harder to identify real issues.

The Solution

This lightweight module uses a plugin (interceptor) to catch and suppress the specific Braintree configuration errors before they reach your logs. It only silences the merchantId needs to be set error, allowing any real Braintree errors to still be reported if you enable the payment method later.

Key Features:

  • Clean Logs: Eliminates unnecessary Braintree configuration errors from system logs
  • Surgical Approach: Only suppresses the specific "merchantId needs to be set" error
  • Safe: Real errors are still reported if Braintree is enabled
  • Version Control Friendly: No need to add dummy data to your database configuration
  • Lightweight: Single plugin class with minimal overhead

Installation

Install the package via Composer:

composer require siteation/magento2-braintree-silence
bin/magento module:enable Siteation_BraintreeSilence

Alternatively, install by copying the module to your app/code directory:

mkdir -p app/code/Siteation
cp -r path/to/BraintreeSilence app/code/Siteation/
bin/magento module:enable Siteation_BraintreeSilence

Note

This Module requires Magento 2.4 or higher! For more requirements see the composer.json.

How it Works

The module registers a plugin on PayPal\Braintree\Model\Adapter\BraintreeAdapter methods (generate and find) that:

  1. Attempts to execute the original method
  2. Catches any exceptions thrown
  3. Checks if the exception message contains "merchantId needs to be set"
  4. If it matches, returns null instead of throwing the error
  5. If it doesn't match, re-throws the exception (preserving real errors)

Technical Details

Module Structure

app/code/Siteation/BraintreeSilence/
├── Plugin/
│   └── SilenceConfigErrors.php  # Plugin interceptor
├── etc/
│   ├── module.xml               # Module declaration
│   └── di.xml                   # Dependency injection configuration
└── registration.php             # Module registration

Configuration

No configuration is required. The module works automatically once enabled.

Compatibility

  • Magento 2.4.x (tested with 2.4.8-p3)
  • PayPal_Braintree module (any version)
  • Compatible with all Magento modes (developer, default, production)

Why Not Just Disable the Module?

Disabling core Adobe/Magento modules can lead to "Missing dependency" errors if other third-party modules (like advanced checkout extensions or "Pay Later" banners) expect those classes to exist.

This module provides a clean alternative that:

  • Keeps the Braintree module enabled but silent
  • Avoids dependency issues with third-party extensions
  • Lives in version control for consistent environments
  • Doesn't require database configuration changes

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This module is licensed under the MIT License. See the LICENSE file for details.

Support

For bugs or feature requests, please create an issue in the repository.

Author

Siteation


Making Magento development cleaner, one module at a time.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages