3

I'd like to ask a question related to a community extension, but about how to specifically extend that extension. The extension developer's support doesn't extend this far.

It's a payment module in the checkout. In system->config->payment methods there is a field within the credit card section for client ID. I need to set it up so instead of being able to provide one client ID to the payment service as it is just now, I need the plugin to be able to handle multiple client IDs, one for each of our business partners.

So for example, a customer buys a product on the site, which belongs to one of our partners (id of 1), then the client ID sent to the payment service should be for partner 1. A product of partner 2 should send to the payment service the equivalent client id 2.

Looking at the extension code, I found the client_id section within etc/system.xml, allowing us to set the client id in admin.

Also in Model/Observer.php I can see

$clientId = Mage::getStoreConfig('payment/'.$payment->getMethod().'/client_id', $storeId);

This is overly simplistic, but could I somehow

  1. Add extra sections within system.xml for each client ID I required, so these can be entered in admin (e.g. client_id1, client_id2)
  2. When a product goes to checkout, use the observer to get the partner id of the product to set client id (e.g. client_id1, client_id2) to be sent to the payment service?

Or would there be a better/correct way to approach this, perhaps as a separate local extension?

1

I would advise against changing the extension files themselves for the same reason that you should not touch the core. So you should try to make your modifications in a separate local module.

  • You can add additional fields to existing groups in your own system.xml.
  • You can change a configuration value temporarily without saving it (see: https://magento.stackexchange.com/a/55174/243), which enables you to do something like this in your own observer:

    // decide which configuration to use:
    $clientId = Mage::getStoreConfig('payment/'.$payment->getMethod().'/client_1_id');
    // set temp. config:
    Mage::app()->getStore()->setConfig('payment/'.$payment->getMethod().'/client_id', $clientId);
    
1
  • Thanks! I got this working a while back but only by modifying the extension. So I will try your suggestion. The first bit about adding extra fields in system.xml is straightforward but the next bit about changing config values will be a lot harder for me. Also, I found out that it's not just an Observer, but other files that are used in determining client id, like an Abstract, controller and block.
    – Mchl
    Sep 18 '15 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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