← All modules

Magento 2 module

Payment Rules

Shows or hides payment methods in the checkout based on rules with conditions on customer data, address data or login status.

Not every payment method suits every customer. Purchase on account should perhaps only be offered to logged-in customers, or certain methods only to customers from specific regions or customer groups. This module lets you define rules per payment method that decide whether the method is offered in the checkout.

Features

  • Rules per website and payment method, each of type “Restriction” or “Permission” and with an active switch.
  • Each rule has one or more conditions. A condition compares a customer attribute or an address attribute with a value using an operator, or uses the custom condition “Logged In”.
  • All conditions of a rule must match for the rule to apply.
  • Restriction rules hide the payment method when they apply.
  • Permission rules make the method available when they apply. If a method has only permission rules, it is hidden for everyone who does not match one of them.
  • Guest checkouts are checked with the billing address data and the email address entered in the checkout.
  • PayPal Express started from the cart is checked as well; if it is not allowed, the shopper returns to the cart with the message “This payment method is not allowed.”

Configuration

Open Infrangible > Payment Rules > Manage Rules. Create a rule, choose the website, the payment method and the type, and add the conditions. Rules can be switched off with “Active” without deleting them.

Good to know

Payment methods without any rule are not affected by the module.

Installation

Install the module with Composer in your Magento root directory:

composer require infrangible/m2-payment-rules

Then enable it and update the store as described in the installation guide. Composer installs the required modules listed on this page automatically.