Disable payment via custom module is there anyway, we can disable payment of specific payment option via custom module? I Have done some research that payment in drupal commerce is setup via rules, so is there an option we can create custom module and hit the current payment rules and disable it?

and is there a way via custom module, we can get the list of available or activated payment?

some references would be great.

thank you!
Option 1: Hook Form Alter

Rules are event-based conditional actions. For "showing" or "hiding" payments, that event it almost always going to be simply showing the form on checkout. So, technically, you could just use hook_form_alter() and locate the checkout pane that has the payment details and modify from there.

A video where I walk you through how to do hook_form_alter: https://youtu.be/xYMd6WDqxKY?t=1m3s (admittedly, this is for a different use case, but I do show you how to locate the form_id and customize the form_alter for whatever situation you're in).

Option 2: Custom Rules Condition

Another option would be to create a rule condition that you can add to your payment gateways. I think this would be more in spirit with how Drupal Commerce works.

Over here, I have shown you how to create a custom Rules action and condition:
Different vat rate per commerce shipping service

There is also a clear example here: 
How do I add a new condition in Rules 2?

How to do option 2

As I said above, this is how Drupal Commerce is supposed to work. If you create a custom rule condition (perhaps there's a business server that returns a REST true/false for an A/B comparison) then that condition is exposed in the user interface and keeps the logic in code where it can be maintained separate from being implemented.


Create the custom rule condition in your custom module with your custom logic
Add that condition to your payment method: /admin/commerce/config/payment-methods
Know that every time that payment method might appear (both in checkout and on the order editing payment screen) that rule condition will be run