Needs review
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Payment
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Aug 2011 at 09:45 UTC
Updated:
23 Jan 2019 at 00:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
artusamakThe attached patch is adding the support for payment method settings declaration in the hook_commerce_payment_method_info().
You just need to declare the settings such as below:
If you are just using a payment method which is previously exposing the settings you can use the hook_commerce_payment_method_info_alter() if you want to override the default values.
Comment #2
hazaTested, works as expected ! Thanks for this patch !
Comment #3
rszrama commentedSo basically this patch just lets you define default settings inside your hook_commerce_payment_method_info() declaration (or via the alter hook)? And this in turn makes it so you can store default configuration for payment methods in code without depending on exported Rules? If so, I like it.
The one thing I see in this patch, though, is that your $action_settings variable seems to put a non-payment method setting for the action in the payment method settings array. I'm not sure how it's working. Is that a bug or was it buggy before?
Compare what you made it:
To the previous array:
Seems yours should just be this, no?
Comment #4
mrfelton commented+1 to this functionality. Patch works as expected.
Comment #5
vadym.kononenko commentedBut why we need to rebuild all settings structure?
I've reached identical result just made such simple patch.
It just get payment method info from modules 'hook_commerce_payment_method_info()' and 'hook_commerce_payment_method_info_alter()' and fill in the rule action form with it.
It also give me ability to modify (add some conditions to set payment method visibility) any payment rule by using 'hook_default_rules_configuration_alter()'
All works like a charm in several projects.
Comment #6
pixelula commentedHi,
Patch #5 works for me. Thanks
Comment #7
bsandor commentedI heaven't understood the idea of patch #5.
Can you explain it please.
Am I right in followings:
If I apply this patch I can 'add' my modules configuration settings (which come in a rule) programmatically by using hook_commerce_payment_method_info_alter(); while without it I can not? Or I can but my settings need to be saved first than I can use this hook without the patch.
I need some clarification please.
Or at least can you add directions how to use patch#5 once i implemented the hook. (how to add settings in the implementation)
How can I fill the rule action form with it?
Thanks
Comment #8
bsandor commentedI've checked the code:
If I'm right this alter function runs only during rule action save.
It means you need to go to edit the rule action than save it for it to be effective. So basically you can do the same thing with hook_form_alter().
Or if you are writing your own module you can set it up in _payment_default_settings ()
I can not try if i'm right as I don't know what to do with this Patch#5. I need information.
Comment #9
chris matthews commentedThe 5 year old patch in #5 to commerce_payment.rules_defaults.inc applied cleanly to the latest commerce 7.x-1.x-dev and already has several reviews, but there are also some outstanding questions so leaving the status as is.