| +34 608 61 64 10



Magento, Aitoc and skin Adyen movil

After almost hundred post in Italian, I've decided starting to write in english. That's my first post and I'm sorry for the grammatical errors that you'll find here. But it's an IT blog at least and I'm sure you'll excuse me ;)

In this post I'll talk of Magento, that I've started developing since only two mounth.
Currently the Aitoc plugin, that we are using to connect to the Adyen payment platform, allows to configure only one skin. I'll show how to add to add another to configure the movil skin too. These are the steps:

menu system/config/payment methods, section "Hpp"
Modify the file app/code/community/Madia/Adyen/etc/system.xml adding these code

<skinCodeWap translate="label">
   <label>Skin Code Wap</label>
   <comment>The skin code you want to use (You can find this in the admin are of your Adyen account)</comment>

Note: I assigned the value 4 to the sort_order parameter, in order to show it at the bottom of the another input value Skin, that we'll use for the web environment. If we assign 4, we'll have to change all the ordinal values of the others inputs form.
We don't need anything else, because Magento will save automatically this value into the core_config_data table. The record will be like this


where hwM2tgIZ is the Adyen skin code, that we'll configure in the Adyen platform.
Note: I'm preparing three posts about Adyen and their excellent payment platform. I'll realease as soon as possible.

We need to modify this file app/code/community/Madia/Adyen/Model/Adyen/Hpp.php to allow to choose the WEB or Movil skin, depending which type of device the user is using to browser into our e-commerce application.
a) modify the getFormFields() method in this way

$skinCodeWap = $this->_getConfigData('skinCodeWap', 'adyen_hpp');

if ($this->isMobile()) {
    $adyFields['skinCode'] = $skinCodeWap;
} else {
    $adyFields['skinCode'] = $skinCode;

b) Modify the all code of the getAdyenSharedUrl() method, to choose which type the Adyen file and environment (test/live) called.

public function getAdyenSharedUrl() {
    $brandCode = $this->getInfoInstance()->getCcType();
    $paymentRoutine = $this->_getConfigData('payment_routines', 'adyen_hpp');
    $isConfigDemoMode = $this->getConfigDataDemoMode();
    switch ($isConfigDemoMode) {
        case true:
            if ($this->isMobile()) {
                 $url = "";
            } else {
                 $url = "";

            if ($this->isMobile()) {
                 $url = "";
            } else {
                 $url = "";

c) Finally, adding the method isMobile() to check the movil type.
Note: This code is from an post

function isMobile(){  

    $regex_match = "/(nokia|iphone|android|motorola|"
       . "^mot\-|softbank|"
       . "foma|docomo|kddi|up\.browser|up\.link|"  
       . "htc|dopod|blazer|netfront|helio|hosin|"
       . "huawei|novarra|CoolPad|webos|techfaith|palmsource|"  
       . "blackberry|alcatel|amoi|ktouch|nexian|"
       . "samsung|^sam\-|s[cg]h|^lge|"
       . "ericsson|philips|sagem|wellcom|bunjalloo|maui|"  
       . "symbian|smartphone|mmp|midp|wap|phone|windows ce|"
       . "iemobile|^spice|^bird|^zte\-|longcos|"
       . "pantech|gionee|^sie\-|portalmmm|"  
       . "jig\s browser|hiptop|^ucweb|^benq|haier|^lct|"
       . "opera\s*mobi|opera\*mini|320x320|240x320|176x220"  
       . ")/i";  

    if (preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT']))) {  
         return TRUE;  

    if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or 
        ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {  
         return TRUE;  

    $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));  
    $mobile_agents = array(  
       'w3c ','acs-','alav','alca','amoi','audi',
       'xda ','xda-');  

    if (in_array($mobile_ua,$mobile_agents)) {  
       return TRUE;  

    if (isset($_SERVER['ALL_HTTP']) && 
        strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini') > 0) {  
       return TRUE;  

    return FALSE;