For a customer of ours we use the Commerce Ogone module, but had the following requirements currently not possible without hacking the module:
- Use the site's active language for the Ogone Payment form;
- Use a dynamic template hosted on our end for the Ogone Payment form;
Both properties can be set via hidden values in the form sent to Ogone (and language can currently be configured via the Payment Method settings screen for Ogone, but only to a single language), but unfortunately the key-signing process makes using hook_form_alter on this form relatively hard.
Now, since Ogone supports a gazillion parameters (See Ogone : Parameter Cookbook), it is not feasible to provide configuration options for each of them, which is why I propose to introduce an hook_commerce_ogone_data_alter(&$data, $order, $settings) hook, allowing modules to extend Commerce Ogone or make tweaks to the data for individual sites.
the hook implementation for the above use case would then become:
function myshop_commerce_ogone_data_alter(&$data, $order, $settings) {
global $language;
// Set the dynamic template to be used by Ogone.
$data['TP'] = url('checkout/ogone', array('absolute' => TRUE));
// For multilingual sites, attempt to use the site's active language rather
// than the language configured through the payment method settings form.
$language_mapping = array(
'nl' => 'nl_BE',
'fr' => 'fr_FR',
'en' => 'en_US',
);
$data['LANGUAGE'] = isset($language_mapping[$language->language]) ? $language_mapping[$language->language] : $settings['language'];
}
Attached is a patch that introduces the hook, along with a api documentation file.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | commerce_ogone-dynamic_templates_docs-1239096-6.patch | 1.52 KB | floretan |
| commerce_ogone_data_alter_hook.patch | 1.96 KB | mr.baileys |
Comments
Comment #1
svendecabooterGreat idea Ivo.
I've committed the code now.
If you want I can add you as Git maintainer to this project to add in more improvements.
I'll roll a new release once I tackled the remaining active issues
Comment #2
svendecabooterAnd fixed :)
Comment #3
mr.baileysThat would be lovely, thanks! Currently working on adding Direct server-to-server support (#1229244: Changing the Status after payment with a "Direct HTTP server-to-server request"), will get you a patch for review soon.
Comment #4
svendecabooterDone.
Thx for your help!
Comment #6
floretan commentedThe commerce_ogone.api.php has the wrong hook name (
hook_commerce_ogone_datainstead ofhook_commerce_ogone_data_alter). A minor fix that will save time to anyone wanting to use dynamic templates.The attached patch fixes the function name and adds some documentation about using dynamic templates in README.txt.
Comment #7
mr.baileysThanks! Committed with some minor formatting changes .