PHPackages                             smaex/additional-payment-checks - 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. [Payment Processing](/categories/payments)
4. /
5. smaex/additional-payment-checks

AbandonedArchivedMagento2-module[Payment Processing](/categories/payments)

smaex/additional-payment-checks
===============================

Enables additional checks for payment methods in Magento 2.

1.1.2(7y ago)481231MITPHPPHP ^7.1

Since Nov 1Pushed 7y agoCompare

[ Source](https://github.com/jensscherbl/additional-payment-checks)[ Packagist](https://packagist.org/packages/smaex/additional-payment-checks)[ RSS](/packages/smaex-additional-payment-checks/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (5)Used By (1)

Magento 2: Additional Payment Checks
====================================

[](#magento-2-additional-payment-checks)

Enables additional checks for payment methods in [Magento 2](https://github.com/magento/magento2).

Intro
-----

[](#intro)

Adding additional checks to payment methods – to decide if a certain payment method is applicable to a certain customer or not – is pretty easy and straight forward in Magento 2.

Magento [provides a rather simplistic interface](https://github.com/magento/magento2/blob/2.3/app/code/Magento/Payment/Model/Checks/SpecificationInterface.php) for custom payment method checks, and [uses a composite check](https://github.com/magento/magento2/blob/2.3/app/code/Magento/Payment/Model/Checks/Composite.php) to process these individual checks. Adding a custom check is therefore just a matter of injecting it into Magento’s composite check via dependency injection.

```
/**
 * Combines several checks with logic "AND" operation.
 *
 * Use this class to register own specifications.
 */
class Composite implements SpecificationInterface
{
    /**
     * Check whether payment method is applicable to quote
     */
    public function isApplicable(MethodInterface $paymentMethod, Quote $quote): bool
    {
        foreach ($this->list as $specification) {
            if (!$specification->isApplicable($paymentMethod, $quote)) {
                return false;
            }
        }
        return true;
    }
}
```

Well, at least in an ideal world. But since we’re talking about Magento here, it’s geting a bit more messy complex. Different checks might be necessary in different scenarios, so Magento [uses a factory](https://github.com/magento/magento2/blob/2.3/app/code/Magento/Payment/Model/Checks/SpecificationFactory.php) to instantiate its composite check dynamically with a varying list of checks in different places.

```
/**
 * Creates complex specification.
 *
 * Use this class to register predefined list of specifications
 * that should be added to any complex specification.
 */
class SpecificationFactory
{
    /**
     * Creates new instances of payment method models
     */
    public function create(array $data): Composite
    {
        $specifications = array_intersect_key($this->mapping, array_flip((array)$data));
        return $this->compositeFactory->create(['list' => $specifications]);
    }
}
```

However, and in typical Magento fashion, this mechanism is only half baked. Magento [uses a class called MethodList](https://github.com/magento/magento2/blob/2.3/app/code/Magento/Payment/Model/MethodList.php) to retrieve applicable payment methods, and hardcodes the list of checks that are performed to figure out which payment methods to offer.

```
/**
 * Methods List service class.
 */
class MethodList
{
    /**
     * Check payment method model
     */
    protected function _canUseMethod(MethodInterface $method, CartInterface $quote): bool
    {
        return $this->methodSpecificationFactory->create(
            [
                AbstractMethod::CHECK_USE_CHECKOUT,
                AbstractMethod::CHECK_USE_FOR_COUNTRY,
                AbstractMethod::CHECK_USE_FOR_CURRENCY,
                AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX,
            ]
        )->isApplicable($method, $quote);
    }
}
```

Fortunately, this extension provides a handy workaround.

How to install
--------------

[](#how-to-install)

Simply require the extension via [Composer](https://getcomposer.org).

```
$ composer require smaex/additional-payment-checks ^1.0
```

Finally, enable the module via [Magento’s CLI](https://devdocs.magento.com/guides/v2.3/install-gde/install/cli/install-cli-subcommands-enable.html).

```
$ magento module:enable Smaex_AdditionalPaymentChecks
```

How to use
----------

[](#how-to-use)

The extension plugs into the factory’s `create`-method and extends the list of checks that is passed to Magento’s composite check upon creation. All we have to do now, besides injecting our custom check into the factory as described above, is adding it to the plugin provided by this extension.

```

                    Acme\Payment\Model\Checks\CustomPaymentMethodCheck

                    acme_custom_payment_method_check

```

For a real-life example, check out [smaex/customer-group-payments](https://github.com/smaex/customer-group-payments) as well.

We’re hiring!
-------------

[](#were-hiring)

Wanna work for [one of Germany’s leading Magento partners](https://www.techdivision.com/karriere/offene-stellen/magento-developer-m-w.html)? With agile methods, small teams and big clients? We’re currently looking for experienced masochists **PHP &amp; Magento developers in Munich**. Sounds interesting? Just drop me a line via

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~48 days

Total

4

Last Release

2601d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a6efc76b9774f586b05d3c0429c3458aa3c672cbba47f30069acdc6f5db28b22?d=identicon)[jensscherbl](/maintainers/jensscherbl)

---

Top Contributors

[![jensscherbl](https://avatars.githubusercontent.com/u/1640033?v=4)](https://github.com/jensscherbl "jensscherbl (5 commits)")

---

Tags

magentopaymentphpmagentopayment

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/smaex-additional-payment-checks/health.svg)

```
[![Health](https://phpackages.com/badges/smaex-additional-payment-checks/health.svg)](https://phpackages.com/packages/smaex-additional-payment-checks)
```

PHPackages © 2026

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