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.

Comments

svendecabooter’s picture

Great 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

svendecabooter’s picture

Status: Needs review » Fixed

And fixed :)

mr.baileys’s picture

If you want I can add you as Git maintainer to this project to add in more improvements.

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

svendecabooter’s picture

Done.
Thx for your help!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

floretan’s picture

Component: Code » Documentation
Status: Closed (fixed) » Needs review
StatusFileSize
new1.52 KB

The commerce_ogone.api.php has the wrong hook name (hook_commerce_ogone_data instead of hook_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.

mr.baileys’s picture

Status: Needs review » Fixed

Thanks! Committed with some minor formatting changes .

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.