Is it possible to restrict payment gateways on a per user group basis?

e.g. Say you want a user group to assign users into from a certain country that cannot use PayPal, so you can offer them a different gateway instead?



This is really more of a Craft general thing than Commerce per se, if you're content to simply 'restrict' them by only showing them the appropriate options depends on their group.

If so, then it's as simple as some twig code to test the user group and show/not show things accordingly.

{% if currentUser.isInGroup('groupHandle') %}
   ... show something
{% else %}
   ... show something else
{% endif %}

(Of course that requires a logged in user and the bigger questions here is whether user groups is the right way to handle this scenario...)

If you want to take things further, you could listen to various Commerce events in a custom module and take action there if they should/shouldn't be allowed to do what they arte doing. You might look at:



...or others - they are listed here:


In reality, as usual, probably some combination of front end logic and back end verification would be the way to go.

Hopefully that is enough to get you started!

  • I think the event listeners are the only sensible way to approach it, anybody can bypass some HTML on a page, only a server-side solution is really reliable. Thanks :)
    – owenmelbz
    Sep 17 '20 at 15:50
  • Well, technically, twig IS server side. But as far as messing with websites go, I just don't see people creating and submitting fake/alternate payment forms to send me money as a big, or realistic, problem! There are much easier ways to mess with websites and shop owners... but more generally, almost everything in e-commerce tends to end up being a bit of both how/what is presented to the client, AND appropriate verification & validation at the server, for sure. Sep 17 '20 at 22:40
  • One of our payment methods is "Paid via phone" :D so thats why we do not want anybody to be able to submit it :) as then it's definitely free!
    – owenmelbz
    Sep 18 '20 at 14:44
  • (...of course your store operators would see the order's unpaid status (assuming you're using the manual gateway) - and then have to explicitly and manually confirm the order by capturing the payment, before this was actually processed, right?! ... otherwise I'd say you have a significant problem in your processing flow!!) Sep 18 '20 at 23:28
  • So if you're using "manual gateway" it always goes in as unpaid?
    – owenmelbz
    Sep 21 '20 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.