Download the PHP package smaex/additional-payment-checks without Composer
On this page you can find all versions of the php package smaex/additional-payment-checks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package additional-payment-checks
Magento 2: Additional Payment Checks
Enables additional checks for payment methods in Magento 2.
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 for custom payment method checks, and uses a composite check 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.
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 to instantiate its composite check dynamically with a varying list of checks in different places.
However, and in typical Magento fashion, this mechanism is only half baked. Magento uses a class called MethodList to retrieve applicable payment methods, and hardcodes the list of checks that are performed to figure out which payment methods to offer.
Fortunately, this extension provides a handy workaround.
How to install
Simply require the extension via Composer.
Finally, enable the module via Magento’s CLI.
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.
For a real-life example, check out smaex/customer-group-payments as well.
We’re hiring!
Wanna work for one of Germany’s leading Magento partners? With agile methods, small teams and big clients? We’re currently looking for experienced masochists PHP & Magento developers in Munich. Sounds interesting? Just drop me a line via [email protected]