8

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.

1 Answer 1

16

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).

2
  • this is really helpful for me, are there a way to validate settings form?
    – svetlio
    Commented Aug 2, 2012 at 5:47
  • Where can I get the payment method string identifier 'foo' and 'commerce_payment_foo'?
    – Randell
    Commented Sep 1, 2014 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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