Drupal Commerce: How to get payment module settings? How to programmatically retrieve configuration of the specific payment module?

I tried 

$settings = rules_config_load('commerce_payment_MODULE_NAME');


It returns very basic info (name, ID etc) and empty "settings" array.

Cant also get it directly from DB .

It is stored in serialized array that can not be fully processed with the unserialize() function.
I'm using this:

$payment = commerce_payment_method_instance_load('foo|commerce_payment_foo');


where foo is the payment method string identifier.

The resulting array contains the 'settings' index, with the data saved in the settings form.



In other words foo|commerce_payment_foo is instance id which consist method_id|rule_name.

The method_id can be found by executing commerce_payment_methods() and rule_name can be found in URL when editing Payment action (at /admin/commerce/config/payment-methods).