How do you change rules settings on the fly? I want to be able to modify a rule based on a setting choice made by a user, but I don't want to expose the form for setting the rule that you see at 

admin/commerce/config/payment-methods/manage/&lt;payment_method&gt;/edit/&lt;action_id&gt;


because it contains some sensitive information such as our company's secret key for connecting to the payment gateway.  

I have figured out that this UI is governed by a rule, and this particular setting is stored in the rules_config entity in its data field.  I want to be able to directly manipulate this field, but I am unfamiliar with the format and do not want to mess up the entire rule.

Is there a way to do a entity_import and change the rule with the new settings on the fly?  It seems like all of the hooks are only for when the module loads/installs.
There are likely several ways of peeling the proverbial potato, depending on what you're actually trying to do:


See if the rule's callback function has some sort of hooks to allow you to change the data there. This is the easiest way to do anything and the least invasive.
Implement hook_rules_config_execute(). This hook gets called during the invocation of the rule and it appears to give you a chance to modify the rule before everything gets executed.


Not generally recommended but also possible:


Alter the rule's callback to call a new custom callback which wraps or replaces the original function and sets the configuration that you want.