There may be circumstances where a retailer wishes to restrict the payment methods that are available to a customer when checking out. Whilst a payment gateway may have restrictions, these may not be sufficient, or the limitations may need to apply to multiple methods.
The payment methods can be refined for a store, by adding a cart validator resolver, for example:
\Aero\Payment\Models\PaymentMethod::setCartValidator(function ($method, $cart) {
if ($method->driver === 'cash' && $cart->total()->inc()->value > 1000) {
return false;
}
return $method->getDriver()->validateForCart($cart);
});
Note that the validator falls back to the driver validation.