Plugin Directory

Changeset 2499400


Ignore:
Timestamp:
03/19/2021 01:08:22 PM (5 years ago)
Author:
paybox
Message:

v0.9.9.9.3
3DSv2

Location:
e-transactions-wc/trunk
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • e-transactions-wc/trunk/class/wc-etransactions-abstract-gateway.php

    r2391064 r2499400  
    11<?php
    22
    3 abstract class WC_Etransactions_Abstract_Gateway extends WC_Payment_Gateway {
    4 
     3/**
     4 * E-Transactions - Payment Gateway class.
     5 *
     6 * Extended by individual payment gateways to handle payments.
     7 *
     8 * @class   WC_Etransactions_Abstract_Gateway
     9 * @extends WC_Payment_Gateway
     10 */
     11abstract class WC_Etransactions_Abstract_Gateway extends WC_Payment_Gateway
     12{
    513    protected $_config;
    614    protected $_etransactions;
    715    private $logger;
    816
    9     public function __construct() {
     17    public function __construct()
     18    {
    1019        // Logger for debug if needed
    1120        if (WC()->debug === 'yes') {
     
    2534        // $this->description = $this->_config->getDescription();
    2635
    27         $this->title = apply_filters('title',$this->_config->getTitle());
    28         $this->description = apply_filters('description',$this->_config->getDescription());
    29         $this->icon = apply_filters( WC_ETRANSACTIONS_PLUGIN, plugin_dir_url(__DIR__).'images/')
    30                 .apply_filters('icon',$this->_config->getIcon());
     36        $this->title = apply_filters('title', $this->_config->getTitle());
     37        $this->description = apply_filters('description', $this->_config->getDescription());
     38        $this->icon = apply_filters(WC_ETRANSACTIONS_PLUGIN, plugin_dir_url(__DIR__) . 'images/') . apply_filters('icon', $this->_config->getIcon());
     39
    3140        // Actions
    3241        add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
     
    4150     * @return void
    4251     */
    43     public function process_admin_options() {
     52    public function process_admin_options()
     53    {
    4454        $crypto = new ETransactionsEncrypt();
    4555        if (!isset($_POST['crypted'])) {
    46             if (isset($_POST["woocommerce_etransactions_std_hmackey"]))
     56            if (isset($_POST["woocommerce_etransactions_std_hmackey"])) {
    4757                $_POST["woocommerce_etransactions_std_hmackey"] = $crypto->encrypt($_POST["woocommerce_etransactions_std_hmackey"]);
    48             else
     58            } else {
    4959                $_POST["woocommerce_etransactions_3x_hmackey"] = $crypto->encrypt($_POST["woocommerce_etransactions_3x_hmackey"]);
     60            }
    5061            $_POST['crypted'] = true;
    5162        }
     63
    5264        parent::process_admin_options();
    5365    }
    5466
    55     public function admin_options() {
    56 
     67    public function admin_options()
     68    {
    5769        $crypt = new ETransactionsEncrypt();
    5870        $this->settings['hmackey'] = $crypt->decrypt($this->settings['hmackey']);
     
    6476     * Initialise Gateway Settings Form Fields
    6577     */
    66     public function init_form_fields() {
     78    public function init_form_fields()
     79    {
    6780        $defaults = new WC_Etransactions_Config(array(), $this->defaultTitle, $this->defaultDesc);
    6881        $defaults = $defaults->getDefaults();
     
    8093            'default' => __($defaults['title'], WC_ETRANSACTIONS_PLUGIN),
    8194        );
    82         $allFiles = scandir( plugin_dir_path( __DIR__ ) .'images/');   
    83         $fileList = array();
    84         foreach($allFiles as $id=>$file){
    85             if (in_array( explode(".",$file)[1], array('png','jpg','gif','svg'))){
    86                
    87                 $fileList[$file]=$file;
    88             }
    89         }
     95        $allFiles = scandir(plugin_dir_path(__DIR__) . 'images/');
     96        $fileList = array();
     97        foreach ($allFiles as $id => $file) {
     98            if (in_array(explode(".", $file)[1], array('png','jpg','gif','svg'))) {
     99                $fileList[$file]=$file;
     100            }
     101        }
    90102        $this->form_fields['icon'] = array(
    91103            'title' => __('Icon file', WC_ETRANSACTIONS_PLUGIN),
    92104            'type' => 'select',
    93             'description' => __('Icon file to be displayed to customers. file are located in: ', WC_ETRANSACTIONS_PLUGIN).apply_filters( WC_ETRANSACTIONS_PLUGIN, ''.plugin_dir_url(__DIR__).'images/'),
     105            'description' => __('Icon file to be displayed to customers. file are located in: ', WC_ETRANSACTIONS_PLUGIN) . apply_filters(WC_ETRANSACTIONS_PLUGIN, '' . plugin_dir_url(__DIR__) . 'images/'),
    94106            'default' => __($defaults['icon'], WC_ETRANSACTIONS_PLUGIN),
    95             'options' => $fileList,
     107            'options' => $fileList,
    96108        );
    97109        $this->form_fields['description'] = array(
     
    124136            'default' => $defaults['amount']
    125137        );
    126         $this->form_fields['3ds'] = array(
    127             'title' => __('3D Secure', WC_ETRANSACTIONS_PLUGIN),
    128             'type' => 'title',
    129         );
    130         $this->form_fields['3ds_enabled'] = array(
    131             'title' => __('Enable/Disable', WC_ETRANSACTIONS_PLUGIN),
    132             'type' => 'select',
    133             'label' => __('Enable 3D Secure', WC_ETRANSACTIONS_PLUGIN),
    134             'description' => __('You can enable 3D Secure for all orders or depending on following conditions', WC_ETRANSACTIONS_PLUGIN),
    135             'default' => $defaults['3ds_enabled'],
    136             'options' => array(
    137                 'never' => __('Disabled', WC_ETRANSACTIONS_PLUGIN),
    138                 'always' => __('Enabled', WC_ETRANSACTIONS_PLUGIN),
    139                 'conditional' => __('Conditional', WC_ETRANSACTIONS_PLUGIN),
    140             ),
    141         );
    142         $this->form_fields['3ds_amount'] = array(
    143             'title' => __('Minimal amount', WC_ETRANSACTIONS_PLUGIN),
    144             'type' => 'text',
    145             'description' => __('Enable 3D Secure for order with amount greater or equals to this amount (empty to ignore this condition)', WC_ETRANSACTIONS_PLUGIN),
    146             'default' => $defaults['3ds_amount']
    147         );
    148138        $this->form_fields['etransactions_account'] = array(
    149139            'title' => __('E-Transactions account', WC_ETRANSACTIONS_PLUGIN),
     
    189179        );
    190180        $this->form_fields['ips'] = array(
    191             'title' => __('Allowed IPs ', WC_ETRANSACTIONS_PLUGIN),
     181            'title' => __('Allowed IPs', WC_ETRANSACTIONS_PLUGIN),
    192182            'type' => 'text',
    193183            'description' => __('A coma separated list of E-Transactions IPs.', WC_ETRANSACTIONS_PLUGIN),
     
    208198     * @return bool
    209199     */
    210     public function is_available() {
     200    public function is_available()
     201    {
    211202        if (!parent::is_available()) {
    212203            return false;
     
    217208        }
    218209        $total = WC()->cart->total;
     210
    219211        return $total >= $minimal;
    220212    }
     
    226218     * @return array TODO
    227219     */
    228     public function process_payment($orderId) {
     220    public function process_payment($orderId)
     221    {
    229222        $order = wc_get_order($orderId);
    230223
     
    238231    }
    239232
    240     public function receipt_page($orderId) {
     233    public function receipt_page($orderId)
     234    {
    241235        $order = wc_get_order($orderId);
    242236
     
    269263        ?>
    270264        <form id="pbxep_form" method="post" action="<?php echo esc_url($url); ?>" enctype="application/x-www-form-urlencoded">
    271             <?php if ($debug): ?>
     265            <?php if ($debug) : ?>
    272266                <p>
    273267                    <?php echo __('This is a debug view. Click continue to be redirected to E-Transactions payment page.', WC_ETRANSACTIONS_PLUGIN); ?>
    274268                </p>
    275             <?php else: ?>
     269            <?php else : ?>
    276270                <p>
    277271                    <?php echo __('You will be redirected to the E-Transactions payment page. If not, please use the button bellow.', WC_ETRANSACTIONS_PLUGIN); ?>
     
    286280            <?php
    287281            $type = $debug ? 'text' : 'hidden';
    288             foreach ($params as $name => $value):
     282            foreach ($params as $name => $value) {
    289283                $name = esc_attr($name);
    290284                $value = esc_attr($value);
    291                 if ($debug):
     285                if ($debug) {
    292286                    echo '<p><label for="' . $name . '">' . $name . '</label>';
    293                 endif;
     287                }
    294288                echo '<input type="' . $type . '" id="' . $name . '" name="' . $name . '" value="' . $value . '" />';
    295                 if ($debug):
     289                if ($debug) {
    296290                    echo '</p>';
    297                 endif;
    298             endforeach;
     291                }
     292            }
    299293            ?>
    300294        </form>
     
    302296    }
    303297
    304     public function api_call() {
     298    public function api_call()
     299    {
    305300        if (!isset($_GET['status'])) {
    306301            header('Status: 404 Not found', true, 404);
     
    331326    }
    332327
    333     public function on_payment_failed() {
     328    public function on_payment_failed()
     329    {
    334330        try {
    335331            $params = $this->_etransactions->getParams();
     
    342338                $message = __('Payment refused by E-Transactions', WC_ETRANSACTIONS_PLUGIN);
    343339                $this->_etransactions->addCartErrorMessage($message);
    344                 $order->update_status('failed', $message);
     340                $order->update_status('failed', $message);
    345341            }
    346342        } catch (Exception $e) {
     
    351347    }
    352348
    353     public function on_payment_canceled() {
     349    public function on_payment_canceled()
     350    {
    354351        try {
    355352            $params = $this->_etransactions->getParams();
     
    361358                $message = __('Payment canceled', WC_ETRANSACTIONS_PLUGIN);
    362359                $this->_etransactions->addCartErrorMessage($message);
    363                 $order->update_status('failed', $message);
     360                $order->update_status('failed', $message);
    364361            }
    365362        } catch (Exception $e) {
     
    370367    }
    371368
    372     public function on_payment_succeed() {
     369    public function on_payment_succeed()
     370    {
    373371        try {
    374372            $params = $this->_etransactions->getParams();
     
    389387    }
    390388
    391     public function on_ipn() {
     389    public function on_ipn()
     390    {
    392391        global $wpdb;
    393392
    394393        try {
    395 
    396394            $params = $this->_etransactions->getParams();
    397395
     
    403401
    404402            // IP not allowed
    405             /*              $allowedIps = $this->_config->getAllowedIps();
    406               $currentIp = $this->_etransactions->getClientIp();
    407               if (!in_array($currentIp, $allowedIps)) {
    408               $message = __('IPN call from %s not allowed.', WC_ETRANSACTIONS_PLUGIN);
    409               $message = sprintf($message, $currentIp);
    410               $this->_etransactions->addOrderNote($order, $message);
    411               throw new Exception($message);
    412               }
    413               //removed by JC: no need for IP checking anymore.
    414              */
     403            /*
     404            $allowedIps = $this->_config->getAllowedIps();
     405            $currentIp = $this->_etransactions->getClientIp();
     406            if (!in_array($currentIp, $allowedIps)) {
     407                $message = __('IPN call from %s not allowed.', WC_ETRANSACTIONS_PLUGIN);
     408                $message = sprintf($message, $currentIp);
     409                $this->_etransactions->addOrderNote($order, $message);
     410                throw new Exception($message);
     411            }
     412            // removed by JC: no need for IP checking anymore.
     413            */
    415414            // Check required parameters
    416415            $requiredParams = array('amount', 'transaction', 'error', 'reference', 'sign', 'date', 'time');
     
    439438                            $order->payment_complete($params['transaction']);
    440439                            $this->_etransactions->addOrderPayment($order, 'first_payment', $params);
    441                         } else if (!in_array('second_payment', $done)) {
     440                        } elseif (!in_array('second_payment', $done)) {
    442441                            $this->_etransactions->addOrderNote($order, __('Second payment was captured by E-Transactions.', WC_ETRANSACTIONS_PLUGIN));
    443442                            $this->_etransactions->addOrderPayment($order, 'second_payment', $params);
    444                         } else if (!in_array('third_payment', $done)) {
     443                        } elseif (!in_array('third_payment', $done)) {
    445444                            $this->_etransactions->addOrderNote($order, __('Third payment was captured by E-Transactions.', WC_ETRANSACTIONS_PLUGIN));
    446445                            $this->_etransactions->addOrderPayment($order, 'third_payment', $params);
     
    458457                        throw new Exception($message);
    459458                }
    460             }
    461 
    462             // Payment refused
    463             else {
     459            } else {
     460                // Payment refused
    464461                $message = __('Payment was refused by E-Transactions (%s).', WC_ETRANSACTIONS_PLUGIN);
    465462                $error = $this->_etransactions->toErrorMessage($params['error']);
    466463                $message = sprintf($message, $error);
    467                 $this->_etransactions->addOrderPayment($order, 'failed_payment', $params);
     464                $this->_etransactions->addOrderPayment($order, 'failed_payment', $params);
    468465                $this->_etransactions->addOrderNote($order, $message);
    469466            }
    470467        } catch (Exception $e) {
    471             if (WC()->debug === 'yes') {
    472                 $this->logger->add("etransactions", $e->getMessage());
    473             }
    474         }
    475     }
    476 
    477     public function redirectToCheckout() {
     468            if (WC()->debug === 'yes') {
     469                $this->logger->add("etransactions", $e->getMessage());
     470            }
     471        }
     472    }
     473
     474    public function redirectToCheckout()
     475    {
    478476        wp_redirect(WC()->cart->get_cart_url());
    479477        die();
    480478    }
    481    
    482     public function checkCrypto(){
    483         $crypt = new ETransactionsEncrypt();
     479
     480    public function checkCrypto()
     481    {
     482        $crypt = new ETransactionsEncrypt();
    484483        return $crypt->decrypt($this->settings['hmackey']);
    485     }
    486 
    487     public abstract function showDetails($orderId);
     484    }
     485
     486    abstract public function showDetails($orderId);
    488487}
  • e-transactions-wc/trunk/class/wc-etransactions-config.php

    r2240388 r2499400  
    11<?php
    22
    3 class WC_Etransactions_Config {
    4     private $_values;
    5     private $_defaults = array(
    6         '3ds_enabled' => 'always',
    7         'icon' => 'cbvisamcecb.png',
    8         '3ds_amount' => '',
    9         'amount' => '',
    10         'debug' => 'no',
    11         'delay' => 0,
    12         'environment' => 'TEST',
    13         'hmackey' => '4642EDBBDFF9790734E673A9974FC9DD4EF40AA2929925C40B3A95170FF5A578E7D2579D6074E28A78BD07D633C0E72A378AD83D4428B0F3741102B69AD1DBB0',
    14         'identifier' => 3262411,
    15         'ips' => '194.2.122.158,195.25.7.166,195.101.99.76',
    16         'rank' => 95,
    17         'site' => 9999999,
    18     );
     3/**
     4 * E-Transactions - Configuration class.
     5 *
     6 * @class   WC_Etransactions_Config
     7 */
     8class WC_Etransactions_Config
     9{
     10    private $_values;
     11    private $_defaults = array(
     12        'icon' => 'cbvisamcecb.png',
     13        'amount' => '',
     14        'debug' => 'no',
     15        'delay' => 0,
     16        'environment' => 'TEST',
     17        'hmackey' => '4642EDBBDFF9790734E673A9974FC9DD4EF40AA2929925C40B3A95170FF5A578E7D2579D6074E28A78BD07D633C0E72A378AD83D4428B0F3741102B69AD1DBB0',
     18        'identifier' => 3262411,
     19        'ips' => '194.2.122.158,195.25.7.166,195.101.99.76',
     20        'rank' => 95,
     21        'site' => 9999999,
     22    );
    1923
    20     public function __construct(array $values, $defaultTitle, $defaultDesc) {
    21         $this->_values = $values;
    22         $this->_defaults['title'] = $defaultTitle;
    23         $this->_defaults['description'] = $defaultDesc;
    24     }
     24    public function __construct(array $values, $defaultTitle, $defaultDesc)
     25    {
     26        $this->_values = $values;
     27        $this->_defaults['title'] = $defaultTitle;
     28        $this->_defaults['description'] = $defaultDesc;
     29    }
    2530
    26     protected function _getOption($name) {
    27         if (isset($this->_values[$name])) {
    28             return $this->_values[$name];
    29         }
    30         if (isset($this->_defaults[$name])) {
    31             return $this->_defaults[$name];
    32         }
    33         return null;
    34     }
     31    protected function _getOption($name)
     32    {
     33        if (isset($this->_values[$name])) {
     34            return $this->_values[$name];
     35        }
     36        if (isset($this->_defaults[$name])) {
     37            return $this->_defaults[$name];
     38        }
     39        return null;
     40    }
    3541
    36     public function get3DSEnabled() {
    37         return $this->_getOption('3ds_enabled');
    38     }
     42    public function getAmount()
     43    {
     44        $value = $this->_getOption('amount');
     45        return empty($value) ? null : floatval($value);
     46    }
    3947
    40     public function get3DSAmount() {
    41         $value = $this->_getOption('3ds_amount');
    42         return empty($value) ? null : floatval($value);
    43     }
     48    public function getAllowedIps()
     49    {
     50        return explode(',', $this->_getOption('ips'));
     51    }
    4452
    45     public function getAmount() {
    46         $value = $this->_getOption('amount');
    47         return empty($value) ? null : floatval($value);
    48     }
     53    public function getDefaults()
     54    {
     55        return $this->_defaults;
     56    }
    4957
    50     public function getAllowedIps() {
    51         return explode(',', $this->_getOption('ips'));
    52     }
     58    public function getDelay()
     59    {
     60        return (int)$this->_getOption('delay');
     61    }
    5362
    54     public function getDefaults() {
    55         return $this->_defaults;
    56     }
     63    public function getDescription()
     64    {
     65            return $this->_getOption('description');
     66    }
    5767
    58     public function getDelay() {
    59         return (int)$this->_getOption('delay');
    60     }
     68    public function getHmacAlgo()
     69    {
     70        return 'SHA512';
     71    }
    6172
    62     public function getDescription() {
    63             return $this->_getOption('description');
    64     }
     73    public function getHmacKey()
     74    {
     75        $crypto = new ETransactionsEncrypt();
     76        return $crypto->decrypt($this->_values['hmackey']);
     77    }
    6578
    66     public function getHmacAlgo() {
    67         return 'SHA512';
    68     }
     79    public function getIdentifier()
     80    {
     81        return $this->_getOption('identifier');
     82    }
    6983
    70     public function getHmacKey() {
    71         $crypto = new ETransactionsEncrypt();
    72         return $crypto->decrypt($this->_values['hmackey']);
    73     }
     84    public function getRank()
     85    {
     86        return $this->_getOption('rank');
     87    }
    7488
    75     public function getIdentifier() {
    76         return $this->_getOption('identifier');
    77     }
     89    public function getSite()
     90    {
     91        return $this->_getOption('site');
     92    }
    7893
    79     public function getRank() {
    80         return $this->_getOption('rank');
    81     }
     94    public function getSystemProductionUrls()
     95    {
     96        return array(
     97            'https://tpeweb.e-transactions.fr/cgi/MYchoix_pagepaiement.cgi',
     98            'https://tpeweb1.e-transactions.fr/cgi/MYchoix_pagepaiement.cgi',
     99        );
     100    }
    82101
    83     public function getSite() {
    84         return $this->_getOption('site');
    85     }
     102    public function getSystemTestUrls()
     103    {
     104        return array(
     105            'https://preprod-tpeweb.e-transactions.fr/cgi/MYchoix_pagepaiement.cgi'
     106        );
     107    }
    86108
    87     public function getSystemProductionUrls() {
    88         return array(
    89             'https://tpeweb.e-transactions.fr/cgi/MYchoix_pagepaiement.cgi',
    90             'https://tpeweb1.e-transactions.fr/cgi/MYchoix_pagepaiement.cgi',
    91         );
    92     }
     109    public function getSystemUrls()
     110    {
     111        if ($this->isProduction()) {
     112            return $this->getSystemProductionUrls();
     113        }
     114        return $this->getSystemTestUrls();
     115    }
    93116
    94     public function getSystemTestUrls() {
    95         return array(
    96             'https://preprod-tpeweb.e-transactions.fr/cgi/MYchoix_pagepaiement.cgi'
    97         );
    98     }
     117    public function getTitle()
     118    {
     119        return $this->_getOption('title');
     120    }
    99121
    100     public function getSystemUrls() {
    101         if ($this->isProduction()) {
    102             return $this->getSystemProductionUrls();
    103         }
    104         return $this->getSystemTestUrls();
    105     }
     122    public function getIcon()
     123    {
     124        return $this->_getOption('icon');
     125    }
    106126
    107     public function getTitle() {
    108         return $this->_getOption('title');
    109     }
     127    public function isDebug()
     128    {
     129        return $this->_getOption('debug') === 'yes';
     130    }
    110131
    111     public function getIcon() {
    112         return $this->_getOption('icon');
    113     }
    114 
    115     public function isDebug() {
    116         return $this->_getOption('debug') === 'yes';
    117     }
    118 
    119     public function isProduction() {
    120         return $this->_getOption('environment') === 'PRODUCTION';
    121     }
     132    public function isProduction()
     133    {
     134        return $this->_getOption('environment') === 'PRODUCTION';
     135    }
    122136}
  • e-transactions-wc/trunk/class/wc-etransactions-encrypt.php

    r2239652 r2499400  
    99 * Software License (OSL-3.0) that is available through the world-wide-web
    1010 * at the following URI: http://opensource.org/licenses/OSL-3.0. If
    11  * you did not receive a copy of the OSL-3.0 license and are unable 
     11 * you did not receive a copy of the OSL-3.0 license and are unable
    1212 * to obtain it through the web, please send a note to
    1313 * support@e-transactions.fr so we can mail you a copy immediately.
     
    2020 * */
    2121
    22 class ETransactionsEncrypt {
    23     /*IV generation */
    24     private function _MakeIv($key){
    25         if(function_exists('openssl_cipher_iv_length')){
    26             //openssl
    27             $len =  openssl_cipher_iv_length ( 'AES-128-CBC' );
    28             $strong_crypto = true;
    29             $iv = openssl_random_pseudo_bytes($len, $strong_crypto);
    30         }else{
    31             //mcrypt
    32             $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
    33             $size = mcrypt_enc_get_iv_size($td);
    34             $iv = mcrypt_create_iv($size, MCRYPT_RAND);
    35         }
    36         return bin2hex($iv);
     22class ETransactionsEncrypt
     23{
     24    /*IV generation */
     25    private function _MakeIv($key)
     26    {
     27        if (function_exists('openssl_cipher_iv_length')) {
     28            //openssl
     29            $len = openssl_cipher_iv_length('AES-128-CBC');
     30            $strong_crypto = true;
     31            $iv = openssl_random_pseudo_bytes($len, $strong_crypto);
     32        } else {
     33            //mcrypt
     34            $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
     35            $size = mcrypt_enc_get_iv_size($td);
     36            $iv = mcrypt_create_iv($size, MCRYPT_RAND);
     37        }
     38        return bin2hex($iv);
     39    }
    3740
    38     }
    39     /*
    40      * You can change this method
    41      if you want to change the way the key is generated.
    42      */
    43     public function generateKey(){
    44         // generate key, write to KEY_FILE_PATH
    45         $key = openssl_random_pseudo_bytes(16);
    46         if(file_exists(WC_ETRANSACTIONS_KEY_PATH))unlink(WC_ETRANSACTIONS_KEY_PATH);
    47         $key = bin2hex($key);
    48         $iv = $this->_MakeIv($key);
    49         return file_put_contents(WC_ETRANSACTIONS_KEY_PATH,"<?php" . $key.$iv);
    50     }
    51     /**
    52      * @return string Key used for encryption
    53      */
    54      private function _getKey()
    55     {
    56         //check whether key on KEY_FILE_PATH exists, if not generate it.
    57         $ok = true;
    58         if(!file_exists(WC_ETRANSACTIONS_KEY_PATH)){
    59             $ok = $this->generateKey();
    60             $_POST['KEY_ERROR'] = __("For some reason, the key has just been generated. please reenter the HMAC key to crypt it.");
    61         }
    62         if($ok!==false){
    63             $key = file_get_contents(WC_ETRANSACTIONS_KEY_PATH);
    64             $key = substr($key,5,32);
    65             return $key;
    66         }
    67     }
    68     /**
    69      * @return string Key used for encryption
    70      */
    71      private function _getIv()
    72     {
    73         //check whether key on KEY_FILE_PATH exists, if not generate it.
    74         if(!file_exists(WC_ETRANSACTIONS_KEY_PATH)){
    75             $this->generateKey();
    76             $_POST['KEY_ERROR'] = __("For some reason, the key has just been generated. please reenter the HMAC key to crypt it.");
    77         }else{
    78             $iv = file_get_contents(WC_ETRANSACTIONS_KEY_PATH);
    79             $iv = substr($iv,37,16);
    80             return $iv;
    81         }
    82     }
    83     private function _crypt($key,$iv,$data){
    84             if(function_exists('openssl_encrypt')){
    85                 //openssl
    86                 $result = openssl_encrypt($data, 'aes-128-cbc', $key, OPENSSL_RAW_DATA , $iv);
    87             }else{
    88                 // Prepare mcrypt
    89                 $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
    90                 mcrypt_generic_init($td, $key, $iv);
    91                 // Encrypt
    92                 $result =  mcrypt_generic($td, $data);
    93             }
    94             // Encode (to avoid data loose when saved to database or
    95             // any storage that does not support null chars)
    96             return base64_encode($result);
     41    /*
     42     * You can change this method
     43     if you want to change the way the key is generated.
     44     */
     45    public function generateKey()
     46    {
     47        // generate key, write to KEY_FILE_PATH
     48        $key = openssl_random_pseudo_bytes(16);
     49        if (file_exists(WC_ETRANSACTIONS_KEY_PATH)) {
     50            unlink(WC_ETRANSACTIONS_KEY_PATH);
     51        }
     52        $key = bin2hex($key);
     53        $iv = $this->_MakeIv($key);
     54        return file_put_contents(WC_ETRANSACTIONS_KEY_PATH, "<?php" . $key . $iv);
     55    }
     56    /**
     57     * @return string Key used for encryption
     58     */
     59    private function _getKey()
     60    {
     61        //check whether key on KEY_FILE_PATH exists, if not generate it.
     62        $ok = true;
     63        if (!file_exists(WC_ETRANSACTIONS_KEY_PATH)) {
     64            $ok = $this->generateKey();
     65            $_POST['KEY_ERROR'] = __("For some reason, the key has just been generated. please reenter the HMAC key to crypt it.");
     66        }
     67        if ($ok!==false) {
     68            $key = file_get_contents(WC_ETRANSACTIONS_KEY_PATH);
     69            $key = substr($key, 5, 32);
     70            return $key;
     71        }
     72    }
     73    /**
     74     * @return string Key used for encryption
     75     */
     76    private function _getIv()
     77    {
     78        //check whether key on KEY_FILE_PATH exists, if not generate it.
     79        if (!file_exists(WC_ETRANSACTIONS_KEY_PATH)) {
     80            $this->generateKey();
     81            $_POST['KEY_ERROR'] = __("For some reason, the key has just been generated. please reenter the HMAC key to crypt it.");
     82        } else {
     83            $iv = file_get_contents(WC_ETRANSACTIONS_KEY_PATH);
     84            $iv = substr($iv, 37, 16);
     85            return $iv;
     86        }
     87    }
    9788
    98     }
    99     /**
    100      * Encrypt $data using AES
    101      * @param string $data The data to encrypt
    102      * @return string The result of encryption
    103      */
    104     public function encrypt($data)
    105     {
    106         if (empty($data)) {
    107             return '';
    108         }
    109         // First encode data to base64 (see end of descrypt)
    110         $data = base64_encode($data);
     89    private function _crypt($key, $iv, $data)
     90    {
     91        if (function_exists('openssl_encrypt')) {
     92            //openssl
     93            $result = openssl_encrypt($data, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv);
     94        } else {
     95            // Prepare mcrypt
     96            $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
     97            mcrypt_generic_init($td, $key, $iv);
     98            // Encrypt
     99            $result =  mcrypt_generic($td, $data);
     100        }
     101        // Encode (to avoid data loose when saved to database or
     102        // any storage that does not support null chars)
     103        return base64_encode($result);
     104    }
    111105
     106    /**
     107     * Encrypt $data using AES
     108     * @param string $data The data to encrypt
     109     * @return string The result of encryption
     110     */
     111    public function encrypt($data)
     112    {
     113        if (empty($data)) {
     114            return '';
     115        }
     116        // First encode data to base64 (see end of descrypt)
     117        $data = base64_encode($data);
    112118
    113         // Prepare key
    114         $key = $this->_getKey();
    115         $key = substr($key, 0, 24);
    116         while (strlen($key) < 24) {
    117             $key .= substr($key, 0, 24 - strlen($key));
    118         }
    119         // Init vector
    120         $iv = $this->_getIv();
     119        // Prepare key
     120        $key = $this->_getKey();
     121        $key = substr($key, 0, 24);
     122        while (strlen($key) < 24) {
     123            $key .= substr($key, 0, 24 - strlen($key));
     124        }
     125        // Init vector
     126        $iv = $this->_getIv();
    121127
    122         return $this->_crypt($key,$iv,$data);
    123        
    124     }
    125     private function _decrypt($key,$iv,$data){
    126         if(function_exists('openssl_decrypt')){
    127             //openssl
    128             $result = openssl_decrypt($data, 'aes-128-cbc', $key, OPENSSL_RAW_DATA , $iv);
    129             if(!$result && function_exists('mcrypt_module_open')){
    130                 $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
    131                 mcrypt_generic_init($td, $key, $iv);
    132                 // Decrypt
    133                 $result = mdecrypt_generic($td, $data);
    134             }
    135             if(!$result) show_message(new WP_Error("","","ATTENTION:le module ne peut plus afficher la clef HMAC, veuillez l'initiailiser de nouveau."));
    136         }else{
    137             // Prepare mcrypt
    138             $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
    139             mcrypt_generic_init($td, $key, $iv);
    140             // Decrypt
    141             $result = mdecrypt_generic($td, $data);
    142         }
    143         // Decode data
    144         return base64_decode($result);
    145        
    146     }
    147     /**
    148      * Decrypt $data using 3DES
    149      * @param string $data The data to decrypt
    150      * @return string The result of decryption
    151      * @see PAYBOX_Epayment_Helper_Encrypt::_getKey()
    152      */
    153     public function decrypt($data)
    154     {
    155         if (empty($data)) {
    156             return '';
    157         }
     128        return $this->_crypt($key, $iv, $data);
     129    }
    158130
    159         // First decode encrypted message (see end of encrypt)
    160         $data = base64_decode($data);
     131    private function _decrypt($key, $iv, $data)
     132    {
     133        if (function_exists('openssl_decrypt')) {
     134            //openssl
     135            $result = openssl_decrypt($data, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv);
     136            if (!$result && function_exists('mcrypt_module_open')) {
     137                $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
     138                mcrypt_generic_init($td, $key, $iv);
     139                // Decrypt
     140                $result = mdecrypt_generic($td, $data);
     141            }
     142            if (!$result) {
     143                show_message(new WP_Error("", "", "ATTENTION:le module ne peut plus afficher la clef HMAC, veuillez l'initiailiser de nouveau."));
     144            }
     145        } else {
     146            // Prepare mcrypt
     147            $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
     148            mcrypt_generic_init($td, $key, $iv);
     149            // Decrypt
     150            $result = mdecrypt_generic($td, $data);
     151        }
     152        // Decode data
     153        return base64_decode($result);
     154    }
    161155
     156    /**
     157     * Decrypt $data using 3DES
     158     * @param string $data The data to decrypt
     159     * @return string The result of decryption
     160     * @see PAYBOX_Epayment_Helper_Encrypt::_getKey()
     161     */
     162    public function decrypt($data)
     163    {
     164        if (empty($data)) {
     165            return '';
     166        }
    162167
    163         // Prepare key
    164         $key = $this->_getKey();
    165         $key = substr($key, 0, 24);
    166         while (strlen($key) < 24) {
    167             $key .= substr($key, 0, 24 - strlen($key));
    168         }
    169         // Init vector
    170         $iv = $this->_getIv();
    171         $result = $this->_decrypt($key,$iv,$data);
    172         // Remove any null char (data is base64 encoded so no data loose)
    173         $result = rtrim($result, "\0");
     168        // First decode encrypted message (see end of encrypt)
     169        $data = base64_decode($data);
    174170
    175         return $result;
    176     }
     171        // Prepare key
     172        $key = $this->_getKey();
     173        $key = substr($key, 0, 24);
     174        while (strlen($key) < 24) {
     175            $key .= substr($key, 0, 24 - strlen($key));
     176        }
     177
     178        // Init vector
     179        $iv = $this->_getIv();
     180        $result = $this->_decrypt($key, $iv, $data);
     181        // Remove any null char (data is base64 encoded so no data loose)
     182        $result = rtrim($result, "\0");
     183
     184        return $result;
     185    }
    177186}
  • e-transactions-wc/trunk/class/wc-etransactions-iso4217currency.php

    r2239559 r2499400  
    11<?php
    22
    3 class WC_Etransactions_Iso4217Currency {
     3/**
     4 * E-Transactions - ISO 4217 Currency class.
     5 *
     6 * @class   WC_Etransactions_Iso4217Currency
     7 */
     8class WC_Etransactions_Iso4217Currency
     9{
     10    private static $_mapping = array(
     11        'AED' => '784',
     12        'AFN' => '971',
     13        'ALL' => '008',
     14        'AMD' => '051',
     15        'ANG' => '532',
     16        'AOA' => '973',
     17        'ARS' => '032',
     18        'AUD' => '036',
     19        'AWG' => '533',
     20        'AZN' => '944',
     21        'BAM' => '977',
     22        'BBD' => '052',
     23        'BDT' => '050',
     24        'BGN' => '975',
     25        'BHD' => '048',
     26        'BIF' => '108',
     27        'BMD' => '060',
     28        'BND' => '096',
     29        'BOB' => '068',
     30        'BOV' => '984',
     31        'BRL' => '986',
     32        'BSD' => '044',
     33        'BTN' => '064',
     34        'BWP' => '072',
     35        'BYR' => '974',
     36        'BZD' => '084',
     37        'CAD' => '124',
     38        'CDF' => '976',
     39        'CHE' => '947',
     40        'CHF' => '756',
     41        'CHW' => '948',
     42        'CLF' => '990',
     43        'CLP' => '152',
     44        'CNY' => '156',
     45        'COP' => '170',
     46        'COU' => '970',
     47        'CRC' => '188',
     48        'CUC' => '931',
     49        'CUP' => '192',
     50        'CVE' => '132',
     51        'CZK' => '203',
     52        'DJF' => '262',
     53        'DKK' => '208',
     54        'DOP' => '214',
     55        'DZD' => '012',
     56        'EEK' => '233',
     57        'EGP' => '818',
     58        'ERN' => '232',
     59        'ETB' => '230',
     60        'EUR' => '978',
     61        'FJD' => '242',
     62        'FKP' => '238',
     63        'GBP' => '826',
     64        'GEL' => '981',
     65        'GHS' => '936',
     66        'GIP' => '292',
     67        'GMD' => '270',
     68        'GNF' => '324',
     69        'GTQ' => '320',
     70        'GYD' => '328',
     71        'HKD' => '344',
     72        'HNL' => '340',
     73        'HRK' => '191',
     74        'HTG' => '332',
     75        'HUF' => '348',
     76        'IDR' => '360',
     77        'ILS' => '376',
     78        'INR' => '356',
     79        'IQD' => '368',
     80        'IRR' => '364',
     81        'ISK' => '352',
     82        'JMD' => '388',
     83        'JOD' => '400',
     84        'JPY' => '392',
     85        'KES' => '404',
     86        'KGS' => '417',
     87        'KHR' => '116',
     88        'KMF' => '174',
     89        'KPW' => '408',
     90        'KRW' => '410',
     91        'KWD' => '414',
     92        'KYD' => '136',
     93        'KZT' => '398',
     94        'LAK' => '418',
     95        'LBP' => '422',
     96        'LKR' => '144',
     97        'LRD' => '430',
     98        'LSL' => '426',
     99        'LTL' => '440',
     100        'LVL' => '428',
     101        'LYD' => '434',
     102        'MAD' => '504',
     103        'MDL' => '498',
     104        'MGA' => '969',
     105        'MKD' => '807',
     106        'MMK' => '104',
     107        'MNT' => '496',
     108        'MOP' => '446',
     109        'MRO' => '478',
     110        'MUR' => '480',
     111        'MVR' => '462',
     112        'MWK' => '454',
     113        'MXN' => '484',
     114        'MXV' => '979',
     115        'MYR' => '458',
     116        'MZN' => '943',
     117        'NAD' => '516',
     118        'NGN' => '566',
     119        'NIO' => '558',
     120        'NOK' => '578',
     121        'NPR' => '524',
     122        'NZD' => '554',
     123        'OMR' => '512',
     124        'PAB' => '590',
     125        'PEN' => '604',
     126        'PGK' => '598',
     127        'PHP' => '608',
     128        'PKR' => '586',
     129        'PLN' => '985',
     130        'PYG' => '600',
     131        'QAR' => '634',
     132        'RON' => '946',
     133        'RSD' => '941',
     134        'RUB' => '643',
     135        'RWF' => '646',
     136        'SAR' => '682',
     137        'SBD' => '090',
     138        'SCR' => '690',
     139        'SDG' => '938',
     140        'SEK' => '752',
     141        'SGD' => '702',
     142        'SHP' => '654',
     143        'SLL' => '694',
     144        'SOS' => '706',
     145        'SRD' => '968',
     146        'STD' => '678',
     147        'SYP' => '760',
     148        'SZL' => '748',
     149        'THB' => '764',
     150        'TJS' => '972',
     151        'TMT' => '934',
     152        'TND' => '788',
     153        'TOP' => '776',
     154        'TRY' => '949',
     155        'TTD' => '780',
     156        'TWD' => '901',
     157        'TZS' => '834',
     158        'UAH' => '980',
     159        'UGX' => '800',
     160        'USD' => '840',
     161        'USN' => '997',
     162        'USS' => '998',
     163        'UYU' => '858',
     164        'UZS' => '860',
     165        'VEF' => '937',
     166        'VND' => '704',
     167        'VUV' => '548',
     168        'WST' => '882',
     169        'XAF' => '950',
     170        'XAG' => '961',
     171        'XAU' => '959',
     172        'XBA' => '955',
     173        'XBB' => '956',
     174        'XBC' => '957',
     175        'XBD' => '958',
     176        'XCD' => '951',
     177        'XDR' => '960',
     178        'XOF' => '952',
     179        'XPD' => '964',
     180        'XPF' => '953',
     181        'XPT' => '962',
     182        'XTS' => '963',
     183        'XXX' => '999',
     184        'YER' => '886',
     185        'ZAR' => '710',
     186        'ZMK' => '894',
     187        'ZWL' => '932',
     188    );
    4189
    5     private static $_mapping = array(
    6         'AED' => '784',
    7         'AFN' => '971',
    8         'ALL' => '008',
    9         'AMD' => '051',
    10         'ANG' => '532',
    11         'AOA' => '973',
    12         'ARS' => '032',
    13         'AUD' => '036',
    14         'AWG' => '533',
    15         'AZN' => '944',
    16         'BAM' => '977',
    17         'BBD' => '052',
    18         'BDT' => '050',
    19         'BGN' => '975',
    20         'BHD' => '048',
    21         'BIF' => '108',
    22         'BMD' => '060',
    23         'BND' => '096',
    24         'BOB' => '068',
    25         'BOV' => '984',
    26         'BRL' => '986',
    27         'BSD' => '044',
    28         'BTN' => '064',
    29         'BWP' => '072',
    30         'BYR' => '974',
    31         'BZD' => '084',
    32         'CAD' => '124',
    33         'CDF' => '976',
    34         'CHE' => '947',
    35         'CHF' => '756',
    36         'CHW' => '948',
    37         'CLF' => '990',
    38         'CLP' => '152',
    39         'CNY' => '156',
    40         'COP' => '170',
    41         'COU' => '970',
    42         'CRC' => '188',
    43         'CUC' => '931',
    44         'CUP' => '192',
    45         'CVE' => '132',
    46         'CZK' => '203',
    47         'DJF' => '262',
    48         'DKK' => '208',
    49         'DOP' => '214',
    50         'DZD' => '012',
    51         'EEK' => '233',
    52         'EGP' => '818',
    53         'ERN' => '232',
    54         'ETB' => '230',
    55         'EUR' => '978',
    56         'FJD' => '242',
    57         'FKP' => '238',
    58         'GBP' => '826',
    59         'GEL' => '981',
    60         'GHS' => '936',
    61         'GIP' => '292',
    62         'GMD' => '270',
    63         'GNF' => '324',
    64         'GTQ' => '320',
    65         'GYD' => '328',
    66         'HKD' => '344',
    67         'HNL' => '340',
    68         'HRK' => '191',
    69         'HTG' => '332',
    70         'HUF' => '348',
    71         'IDR' => '360',
    72         'ILS' => '376',
    73         'INR' => '356',
    74         'IQD' => '368',
    75         'IRR' => '364',
    76         'ISK' => '352',
    77         'JMD' => '388',
    78         'JOD' => '400',
    79         'JPY' => '392',
    80         'KES' => '404',
    81         'KGS' => '417',
    82         'KHR' => '116',
    83         'KMF' => '174',
    84         'KPW' => '408',
    85         'KRW' => '410',
    86         'KWD' => '414',
    87         'KYD' => '136',
    88         'KZT' => '398',
    89         'LAK' => '418',
    90         'LBP' => '422',
    91         'LKR' => '144',
    92         'LRD' => '430',
    93         'LSL' => '426',
    94         'LTL' => '440',
    95         'LVL' => '428',
    96         'LYD' => '434',
    97         'MAD' => '504',
    98         'MDL' => '498',
    99         'MGA' => '969',
    100         'MKD' => '807',
    101         'MMK' => '104',
    102         'MNT' => '496',
    103         'MOP' => '446',
    104         'MRO' => '478',
    105         'MUR' => '480',
    106         'MVR' => '462',
    107         'MWK' => '454',
    108         'MXN' => '484',
    109         'MXV' => '979',
    110         'MYR' => '458',
    111         'MZN' => '943',
    112         'NAD' => '516',
    113         'NGN' => '566',
    114         'NIO' => '558',
    115         'NOK' => '578',
    116         'NPR' => '524',
    117         'NZD' => '554',
    118         'OMR' => '512',
    119         'PAB' => '590',
    120         'PEN' => '604',
    121         'PGK' => '598',
    122         'PHP' => '608',
    123         'PKR' => '586',
    124         'PLN' => '985',
    125         'PYG' => '600',
    126         'QAR' => '634',
    127         'RON' => '946',
    128         'RSD' => '941',
    129         'RUB' => '643',
    130         'RWF' => '646',
    131         'SAR' => '682',
    132         'SBD' => '090',
    133         'SCR' => '690',
    134         'SDG' => '938',
    135         'SEK' => '752',
    136         'SGD' => '702',
    137         'SHP' => '654',
    138         'SLL' => '694',
    139         'SOS' => '706',
    140         'SRD' => '968',
    141         'STD' => '678',
    142         'SYP' => '760',
    143         'SZL' => '748',
    144         'THB' => '764',
    145         'TJS' => '972',
    146         'TMT' => '934',
    147         'TND' => '788',
    148         'TOP' => '776',
    149         'TRY' => '949',
    150         'TTD' => '780',
    151         'TWD' => '901',
    152         'TZS' => '834',
    153         'UAH' => '980',
    154         'UGX' => '800',
    155         'USD' => '840',
    156         'USN' => '997',
    157         'USS' => '998',
    158         'UYU' => '858',
    159         'UZS' => '860',
    160         'VEF' => '937',
    161         'VND' => '704',
    162         'VUV' => '548',
    163         'WST' => '882',
    164         'XAF' => '950',
    165         'XAG' => '961',
    166         'XAU' => '959',
    167         'XBA' => '955',
    168         'XBB' => '956',
    169         'XBC' => '957',
    170         'XBD' => '958',
    171         'XCD' => '951',
    172         'XDR' => '960',
    173         'XOF' => '952',
    174         'XPD' => '964',
    175         'XPF' => '953',
    176         'XPT' => '962',
    177         'XTS' => '963',
    178         'XXX' => '999',
    179         'YER' => '886',
    180         'ZAR' => '710',
    181         'ZMK' => '894',
    182         'ZWL' => '932',
    183     );
    184 
    185     public static function getIsoCode($code, $default = null) {
    186         if (isset(WC_Etransactions_Iso4217Currency::$_mapping[$code])) {
    187             return WC_Etransactions_Iso4217Currency::$_mapping[$code];
    188         }
    189         return $default;
    190     }
     190    public static function getIsoCode($code, $default = null)
     191    {
     192        if (isset(WC_Etransactions_Iso4217Currency::$_mapping[$code])) {
     193            return WC_Etransactions_Iso4217Currency::$_mapping[$code];
     194        }
     195        return $default;
     196    }
    191197}
  • e-transactions-wc/trunk/class/wc-etransactions-standard-gateway.php

    r2257349 r2499400  
    11<?php
    22
    3 class WC_EStdGw extends WC_Etransactions_Abstract_Gateway {
    4     protected $defaultTitle = 'E-Transactions payment';
    5     protected $defaultDesc = 'xxxx';
    6     protected $type = 'standard';
     3/**
     4 * E-Transactions - Individual Payment Gateway class.
     5 *
     6 * @class   WC_EStdGw
     7 * @extends WC_Etransactions_Abstract_Gateway
     8 */
     9class WC_EStdGw extends WC_Etransactions_Abstract_Gateway
     10{
     11    protected $defaultTitle = 'E-Transactions payment';
     12    protected $defaultDesc = 'xxxx';
     13    protected $type = 'standard';
    714
    8     public function __construct() {
    9         // Some properties
    10         $this->id = 'etransactions_std';
    11         $this->method_title = __('E-Transactions', WC_ETRANSACTIONS_PLUGIN);
    12         $this->has_fields = false;
    13         $this->icon = 'cbvisamcecb.png';
    14         //$this->icon              = apply_filters( 'woocommerce_paypal_icon', WC()->plugin_url() . '/assets/images/icons/paypal.png' );
     15    public function __construct()
     16    {
     17        // Some properties
     18        $this->id = 'etransactions_std';
     19        $this->method_title = __('E-Transactions', WC_ETRANSACTIONS_PLUGIN);
     20        $this->has_fields = false;
     21        $this->icon = 'cbvisamcecb.png';
     22        // $this->icon = apply_filters('woocommerce_paypal_icon', WC()->plugin_url() . '/assets/images/icons/paypal.png');
    1523
    16         parent::__construct();
    17     }
    18     private function _showDetailRow($label, $value) {
    19         return '<strong>'.$label.'</strong> '.__($value, WC_ETRANSACTIONS_PLUGIN);
    20     }
     24        parent::__construct();
     25    }
    2126
    22     public function showDetails($order) {
    23         $orderId = $order->get_id();
    24         $payment = $this->_etransactions->getOrderPayments($orderId, 'capture');
     27    private function _showDetailRow($label, $value)
     28    {
     29        return '<strong>'.$label.'</strong> '.__($value, WC_ETRANSACTIONS_PLUGIN);
     30    }
    2531
    26         if (!empty($payment)) {
    27             $data = unserialize($payment->data);
    28             $rows = array();
    29             $rows[] = $this->_showDetailRow(__('Reference:', WC_ETRANSACTIONS_PLUGIN), $data['reference']);
    30             if (isset($data['ip'])) {
    31                 $rows[] = $this->_showDetailRow(__('Country of IP:', WC_ETRANSACTIONS_PLUGIN), $data['ip']);
    32             }
    33             $rows[] = $this->_showDetailRow(__('Processing date:', WC_ETRANSACTIONS_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date'])." - ".$data['time']);
    34             if (isset($data['firstNumbers']) && isset($data['lastNumbers'])) {
    35                 $rows[] = $this->_showDetailRow(__('Card numbers:', WC_ETRANSACTIONS_PLUGIN), $data['firstNumbers'].'...'.$data['lastNumbers']);
    36             }
    37             if (isset($data['validity'])) {
    38                 $rows[] = $this->_showDetailRow(__('Validity date:', WC_ETRANSACTIONS_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})$/', '$2/$1', $data['validity']));
    39             }
    40             $rows[] = $this->_showDetailRow(__('Transaction:', WC_ETRANSACTIONS_PLUGIN), $data['transaction']);
    41             $rows[] = $this->_showDetailRow(__('Call:', WC_ETRANSACTIONS_PLUGIN), $data['call']);
    42             $rows[] = $this->_showDetailRow(__('Authorization:', WC_ETRANSACTIONS_PLUGIN), $data['authorization']);
     32    public function showDetails($order)
     33    {
     34        $orderId = $order->get_id();
     35        $payment = $this->_etransactions->getOrderPayments($orderId, 'capture');
    4336
    44             echo '<h4>'.__('Payment information', WC_ETRANSACTIONS_PLUGIN).'</h4>';
    45             echo '<p>'.implode('<br/>', $rows).'</p>';
    46         }
    47     }
     37        if (empty($payment)) {
     38            return;
     39        }
    4840
     41        $data = unserialize($payment->data);
     42        $rows = array();
     43        $rows[] = $this->_showDetailRow(__('Reference:', WC_ETRANSACTIONS_PLUGIN), $data['reference']);
     44        if (isset($data['ip'])) {
     45            $rows[] = $this->_showDetailRow(__('Country of IP:', WC_ETRANSACTIONS_PLUGIN), $data['ip']);
     46        }
     47        $rows[] = $this->_showDetailRow(__('Processing date:', WC_ETRANSACTIONS_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date'])." - ".$data['time']);
     48        if (isset($data['firstNumbers']) && isset($data['lastNumbers'])) {
     49            $rows[] = $this->_showDetailRow(__('Card numbers:', WC_ETRANSACTIONS_PLUGIN), $data['firstNumbers'].'...'.$data['lastNumbers']);
     50        }
     51        if (isset($data['validity'])) {
     52            $rows[] = $this->_showDetailRow(__('Validity date:', WC_ETRANSACTIONS_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})$/', '$2/$1', $data['validity']));
     53        }
     54
     55        // 3DS Version
     56        if (!empty($data['3ds']) && $data['3ds'] == 'Y') {
     57            $cc_3dsVersion = '1.0.0';
     58            if (!empty($data['3dsVersion'])) {
     59                $cc_3dsVersion = str_replace('3DSv', '', trim($data['3dsVersion']));
     60            }
     61            $rows[] = $this->_showDetailRow(__('3DS version:', WC_ETRANSACTIONS_PLUGIN), $cc_3dsVersion);
     62        }
     63
     64        $rows[] = $this->_showDetailRow(__('Transaction:', WC_ETRANSACTIONS_PLUGIN), $data['transaction']);
     65        $rows[] = $this->_showDetailRow(__('Call:', WC_ETRANSACTIONS_PLUGIN), $data['call']);
     66        $rows[] = $this->_showDetailRow(__('Authorization:', WC_ETRANSACTIONS_PLUGIN), $data['authorization']);
     67
     68        echo '<h4>'.__('Payment information', WC_ETRANSACTIONS_PLUGIN).'</h4>';
     69        echo '<p>'.implode('<br/>', $rows).'</p>';
     70    }
    4971}
  • e-transactions-wc/trunk/class/wc-etransactions-threetime-gateway.php

    r2391064 r2499400  
    11<?php
    22
    3 class WC_E3Gw extends WC_Etransactions_Abstract_Gateway {
    4     protected $defaultTitle = 'E-Transactions 3 times payment';
    5     protected $defaultDesc = 'xxxx';
    6     protected $type = 'threetime';
     3/**
     4 * E-Transactions 3 times - Payment Gateway class.
     5 *
     6 * Extended by individual payment gateways to handle payments.
     7 *
     8 * @class   WC_E3Gw
     9 * @extends WC_Etransactions_Abstract_Gateway
     10 */
     11class WC_E3Gw extends WC_Etransactions_Abstract_Gateway
     12{
     13    protected $defaultTitle = 'E-Transactions 3 times payment';
     14    protected $defaultDesc = 'xxxx';
     15    protected $type = 'threetime';
    716
    8     public function __construct() {
    9         // Some properties
    10         $this->id = 'etransactions_3x';
    11         $this->method_title = __('E-Transactions 3 times', WC_ETRANSACTIONS_PLUGIN);
    12         $this->has_fields = false;
    13         $this->icon = '3xcbvisamcecb.png';
    14         //$this->icon = TODO;
     17    public function __construct()
     18    {
     19        // Some properties
     20        $this->id = 'etransactions_3x';
     21        $this->method_title = __('E-Transactions 3 times', WC_ETRANSACTIONS_PLUGIN);
     22        $this->has_fields = false;
     23        $this->icon = '3xcbvisamcecb.png';
     24        //$this->icon = 'TODO';
    1525
    16         parent::__construct();
    17     }
     26        parent::__construct();
     27    }
    1828
    19     private function _showDetailRow($label, $value) {
    20         return '<strong>'.$label.'</strong> '.$value;
    21     }
     29    private function _showDetailRow($label, $value)
     30    {
     31        return '<strong>'.$label.'</strong> '.$value;
     32    }
    2233
    23     /**
    24      * Check If The Gateway Is Available For Use
    25      *
    26      * @access public
    27      * @return bool
    28      */
    29     public function is_available() {
    30         if (!parent::is_available()) {
    31             return false;
    32         }
    33         $minimal = $this->_config->getAmount();
    34         if (empty($minimal)) {
    35             return true;
    36         }
    37         $total = WC()->cart->total;
    38         $minimal = floatval($minimal);
    39         return $total >= $minimal;
    40     }
     34    /**
     35     * Check If The Gateway Is Available For Use
     36     *
     37     * @access public
     38     * @return bool
     39     */
     40    public function is_available()
     41    {
     42        if (!parent::is_available()) {
     43            return false;
     44        }
    4145
    42     public function showDetails($order) {
    43         $orderId = $order->get_id();
    44         $payment = $this->_etransactions->getOrderPayments($orderId, 'first_payment');
    45         if (!empty($payment)) {
    46             $data = unserialize($payment->data);
    47             $payment = $this->_etransactions->getOrderPayments($orderId, 'second_payment');
    48             if (!empty($payment)) {
    49                 $second = unserialize($payment->data);
    50             }
    51             $payment = $this->_etransactions->getOrderPayments($orderId, 'third_payment');
    52             if (!empty($payment)) {
    53                 $third = unserialize($payment->data);
    54             }
     46        $minimal = $this->_config->getAmount();
     47        if (empty($minimal)) {
     48            return true;
     49        }
    5550
    56             $rows = array();
    57             $rows[] = $this->_showDetailRow(__('Reference:', WC_ETRANSACTIONS_PLUGIN), $data['reference']);
    58             if (isset($data['ip'])) {
    59                 $rows[] = $this->_showDetailRow(__('Country of IP:', WC_ETRANSACTIONS_PLUGIN), $data['ip']);
    60             }
    61             $rows[] = $this->_showDetailRow(__('Processing date:', WC_ETRANSACTIONS_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date'])." - ".$data['time']);
    62             if (isset($data['firstNumbers']) && isset($data['lastNumbers'])) {
    63                 $rows[] = $this->_showDetailRow(__('Card numbers:', WC_ETRANSACTIONS_PLUGIN), $data['firstNumbers'].'...'.$data['lastNumbers']);
    64             }
    65             if (isset($data['validity'])) {
    66                 $rows[] = $this->_showDetailRow(__('Validity date:', WC_ETRANSACTIONS_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})$/', '$2/$1', $data['validity']));
    67             }
     51        $total = WC()->cart->total;
     52        $minimal = floatval($minimal);
    6853
    69             $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date']);
    70             $value = sprintf('%s (%s)', $data['amount'] / 100.0, $date);
    71             $rows[] = $this->_showDetailRow(__('First debit:'), $value);
     54        return $total >= $minimal;
     55    }
    7256
    73             if (isset($second)) {
    74                 $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $second['date']);
    75                 $value = sprintf('%s (%s)', $second['amount'] / 100.0, $date);
    76             }
    77             else {
    78                 $value = __('Not achieved', WC_ETRANSACTIONS_PLUGIN);
    79             }
    80             $rows[] = $this->_showDetailRow(__('Second debit:'), $value);
     57    public function showDetails($order)
     58    {
     59        $orderId = $order->get_id();
     60        $payment = $this->_etransactions->getOrderPayments($orderId, 'first_payment');
    8161
    82             if (isset($third)) {
    83                 $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $third['date']);
    84                 $value = sprintf('%s (%s)', $third['amount'] / 100.0, $date);
    85             }
    86             else {
    87                 $value = __('Not achieved', WC_ETRANSACTIONS_PLUGIN);
    88             }
    89             $rows[] = $this->_showDetailRow(__('Third debit:'), $value);
     62        if (empty($payment)) {
     63            return;
     64        }
    9065
    91             $rows[] = $this->_showDetailRow(__('Transaction:', WC_ETRANSACTIONS_PLUGIN), $data['transaction']);
    92             $rows[] = $this->_showDetailRow(__('Call:', WC_ETRANSACTIONS_PLUGIN), $data['call']);
    93             $rows[] = $this->_showDetailRow(__('Authorization:', WC_ETRANSACTIONS_PLUGIN), $data['authorization']);
     66        $data = unserialize($payment->data);
     67        $payment = $this->_etransactions->getOrderPayments($orderId, 'second_payment');
     68        if (!empty($payment)) {
     69            $second = unserialize($payment->data);
     70        }
     71        $payment = $this->_etransactions->getOrderPayments($orderId, 'third_payment');
     72        if (!empty($payment)) {
     73            $third = unserialize($payment->data);
     74        }
    9475
    95             echo '<h4>'.__('Payment information', WC_ETRANSACTIONS_PLUGIN).'</h4>';
    96             echo '<p>'.implode('<br/>', $rows).'</p>';
    97         }
    98     }
     76        $rows = array();
     77        $rows[] = $this->_showDetailRow(__('Reference:', WC_ETRANSACTIONS_PLUGIN), $data['reference']);
     78        if (isset($data['ip'])) {
     79            $rows[] = $this->_showDetailRow(__('Country of IP:', WC_ETRANSACTIONS_PLUGIN), $data['ip']);
     80        }
     81        $rows[] = $this->_showDetailRow(__('Processing date:', WC_ETRANSACTIONS_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date'])." - ".$data['time']);
     82        if (isset($data['firstNumbers']) && isset($data['lastNumbers'])) {
     83            $rows[] = $this->_showDetailRow(__('Card numbers:', WC_ETRANSACTIONS_PLUGIN), $data['firstNumbers'].'...'.$data['lastNumbers']);
     84        }
     85        if (isset($data['validity'])) {
     86            $rows[] = $this->_showDetailRow(__('Validity date:', WC_ETRANSACTIONS_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})$/', '$2/$1', $data['validity']));
     87        }
     88
     89        // 3DS Version
     90        if (!empty($data['3ds']) && $data['3ds'] == 'Y') {
     91            $cc_3dsVersion = '1.0.0';
     92            if (!empty($data['3dsVersion'])) {
     93                $cc_3dsVersion = str_replace('3DSv', '', trim($data['3dsVersion']));
     94            }
     95            $rows[] = $this->_showDetailRow(__('3DS version:', WC_ETRANSACTIONS_PLUGIN), $cc_3dsVersion);
     96        }
     97
     98        $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date']);
     99        $value = sprintf('%s (%s)', $data['amount'] / 100.0, $date);
     100        $rows[] = $this->_showDetailRow(__('First debit:'), $value);
     101
     102        if (isset($second)) {
     103            $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $second['date']);
     104            $value = sprintf('%s (%s)', $second['amount'] / 100.0, $date);
     105        } else {
     106            $value = __('Not achieved', WC_ETRANSACTIONS_PLUGIN);
     107        }
     108        $rows[] = $this->_showDetailRow(__('Second debit:'), $value);
     109
     110        if (isset($third)) {
     111            $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $third['date']);
     112            $value = sprintf('%s (%s)', $third['amount'] / 100.0, $date);
     113        } else {
     114            $value = __('Not achieved', WC_ETRANSACTIONS_PLUGIN);
     115        }
     116        $rows[] = $this->_showDetailRow(__('Third debit:'), $value);
     117
     118        $rows[] = $this->_showDetailRow(__('Transaction:', WC_ETRANSACTIONS_PLUGIN), $data['transaction']);
     119        $rows[] = $this->_showDetailRow(__('Call:', WC_ETRANSACTIONS_PLUGIN), $data['call']);
     120        $rows[] = $this->_showDetailRow(__('Authorization:', WC_ETRANSACTIONS_PLUGIN), $data['authorization']);
     121
     122        echo '<h4>'.__('Payment information', WC_ETRANSACTIONS_PLUGIN).'</h4>';
     123        echo '<p>'.implode('<br/>', $rows).'</p>';
     124    }
    99125}
    100 class WC_Etransactions_Threetime_GateWay extends WC_E3Gw{
    101     public function is_available() {
    102             return false;
    103     }
    104     public function receipt_page($orderId){
    105         return;
    106     }   
     126
     127/**
     128 * E-Transactions 3 times - Payment Gateway class.
     129 *
     130 * Extended by individual payment gateways to handle payments.
     131 *
     132 * @class   WC_Etransactions_Threetime_GateWay
     133 * @extends WC_E3Gw
     134 */
     135class WC_Etransactions_Threetime_GateWay extends WC_E3Gw
     136{
     137    public function is_available()
     138    {
     139        return false;
     140    }
     141    public function receipt_page($orderId)
     142    {
     143        return;
     144    }
    107145}
  • e-transactions-wc/trunk/class/wc-etransactions.php

    r2239559 r2499400  
    11<?php
    22
    3 class WC_Etransactions {
    4     private $_config;
    5     private $_currencyDecimals = array(
     3/**
     4 * E-Transactions - Main class.
     5 *
     6 * @class   WC_Etransactions
     7 */
     8class WC_Etransactions
     9{
     10    private $_config;
     11    private $_currencyDecimals = array(
    612        '008' => 2,
    713        '012' => 2,
     
    174180        '997' => 2,
    175181        '998' => 2,
    176     );
    177 
    178     private $_errorCode = array(
    179         '00000' => 'Successful operation',
    180         '00001' => 'Payment system not available',
    181         '00003' => 'Paybor error',
    182         '00004' => 'Card number or invalid cryptogram',
    183         '00006' => 'Access denied or invalid identification',
    184         '00008' => 'Invalid validity date',
    185         '00009' => 'Subscription creation failed',
    186         '00010' => 'Unknown currency',
    187         '00011' => 'Invalid amount',
    188         '00015' => 'Payment already done',
    189         '00016' => 'Existing subscriber',
    190         '00021' => 'Unauthorized card',
    191         '00029' => 'Invalid card',
    192         '00030' => 'Timeout',
    193         '00033' => 'Unauthorized IP country',
    194         '00040' => 'No 3D Secure',
    195     );
    196 
    197     private $_resultMapping = array(
    198         'M' => 'amount',
    199         'R' => 'reference',
    200         'T' => 'call',
    201         'A' => 'authorization',
    202         'B' => 'subscription',
    203         'C' => 'cardType',
    204         'D' => 'validity',
    205         'E' => 'error',
    206         'F' => '3ds',
    207         'G' => '3dsWarranty',
    208         'H' => 'imprint',
    209         'I' => 'ip',
    210         'J' => 'lastNumbers',
    211         'K' => 'sign',
    212         'N' => 'firstNumbers',
    213         'O' => '3dsInlistment',
    214         'o' => 'celetemType',
    215         'P' => 'paymentType',
    216         'Q' => 'time',
    217         'S' => 'transaction',
    218         'U' => 'subscriptionData',
    219         'W' => 'date',
    220         'Y' => 'country',
    221         'Z' => 'paymentIndex',
    222     );
    223 
    224     public function __construct(WC_Etransactions_Config $config) {
    225         $this->_config = $config;
    226     }
    227 
    228     public function addCartErrorMessage($message) {
    229         wc_add_notice($message, 'error');
    230     }
    231 
    232     public function addOrderNote(WC_Order $order, $message) {
    233         $order->add_order_note($message);
    234     }
    235 
    236     public function addOrderPayment(WC_Order $order, $type, array $data) {
    237         global $wpdb;
    238         $wpdb->insert($wpdb->prefix.'wc_etransactions_payment', array(
    239             'order_id' => $order->get_id(),
    240             'type' => $type,
    241             'data' => serialize($data),
    242         ));
    243     }
    244    
    245 
    246     /**
    247      * @params WC_Order $order Order
    248      * @params string $type Type of payment (standard or threetime)
    249      * @params array $additionalParams Additional parameters
    250      */
    251     public function buildSystemParams(WC_Order $order, $type, array $additionalParams = array()) {
    252         global $wpdb;
    253 
    254         // Parameters
    255         $values = array();
    256 
    257         // Merchant information
    258         $values['PBX_SITE'] = $this->_config->getSite();
    259         $values['PBX_RANG'] = $this->_config->getRank();
    260         $values['PBX_IDENTIFIANT'] = $this->_config->getIdentifier();
    261 
    262         // Order information
    263         $values['PBX_PORTEUR'] = $this->getBillingEmail($order);
    264         $values['PBX_DEVISE'] = $this->getCurrency();
    265         $values['PBX_CMD'] = $order->get_id().' - '.$this->getBillingName($order);
    266 
    267         // Amount
    268         $orderAmount = floatval($order->get_total());
    269         $amountScale = $this->_currencyDecimals[$values['PBX_DEVISE']];
    270         $amountScale = pow(10, $amountScale);
    271         switch ($type) {
    272             case 'standard':
    273                 $delay = $this->_config->getDelay();
    274                 if ($delay > 0) {
    275                     if ($delay > 7) {
    276                         $delay = 7;
    277                     }
    278                     $values['PBX_DIFF'] = sprintf('%02d', $delay);
    279                 }
    280                 $values['PBX_TOTAL'] = sprintf('%03d', round($orderAmount * $amountScale));
    281                 break;
    282 
    283             case 'threetime':
    284                 // Compute each payment amount
    285                 $step = round($orderAmount * $amountScale / 3);
    286                 $firstStep = ($orderAmount * $amountScale) - 2 * $step;
    287                 $values['PBX_TOTAL'] = sprintf('%03d', $firstStep);
    288                 $values['PBX_2MONT1'] = sprintf('%03d', $step);
    289                 $values['PBX_2MONT2'] = sprintf('%03d', $step);
    290 
    291                 // Payment dates
    292                 $now = new DateTime();
    293                 $now->modify('1 month');
    294                 $values['PBX_DATE1'] = $now->format('d/m/Y');
    295                 $now->modify('1 month');
    296                 $values['PBX_DATE2'] = $now->format('d/m/Y');
    297 
    298                 // Force validity date of card
    299                 $values['PBX_DATEVALMAX'] = $now->format('ym');
    300                 break;
    301 
    302             default:
    303                 $message  = __('Unexpected type %s', WC_ETRANSACTIONS_PLUGIN);
    304                 $message = sprintf($message, $type);
    305                 throw new Exception($message);
    306         }
    307 
    308         // 3D Secure
    309         switch ($this->_config->get3DSEnabled()) {
    310             case 'never':
    311                 $enable3ds = false;
    312                 break;
    313             case null:
    314             case 'always':
    315                 $enable3ds = true;
    316                 break;
    317             case 'conditional':
    318                 $tdsAmount = $this->_config->get3DSAmount();
    319                 $enable3ds = empty($tdsAmount) || ($orderAmount >= $tdsAmount);
    320                 break;
    321             default:
    322                 $message  = __('Unexpected 3-D Secure status %s', WC_ETRANSACTIONS_PLUGIN);
    323                 $message = sprintf($message, $this->_config->get3DSEnabled());
    324                 throw new Exception($message);
    325         }
    326         // Enable is the default behaviour
    327         if (!$enable3ds) {
    328             $values['PBX_3DS'] = 'N';
    329         }
    330 
    331         // E-Transactions => Magento
    332         $values['PBX_RETOUR'] = 'M:M;R:R;T:T;A:A;B:B;C:C;D:D;E:E;F:F;G:G;I:I;J:J;N:N;O:O;P:P;Q:Q;S:S;W:W;Y:Y;K:K';
    333         $values['PBX_RUF1'] = 'POST';
    334 
    335         // Choose correct language
    336         $lang = get_locale();
    337         if (!empty($lang)) {
    338             $lang = preg_replace('#_.*$#', '', $lang);
    339         }
    340         $languages = $this->getLanguages();
    341         if (!array_key_exists($lang, $languages)) {
    342             $lang = 'default';
    343         }
    344         $values['PBX_LANGUE'] = $languages[$lang];
    345 
    346         // Choose page format depending on browser/devise
    347         if ($this->isMobile()) {
    348             $values['PBX_SOURCE'] = 'XHTML';
    349         }
    350 
    351         // Misc.
    352         $values['PBX_TIME'] = date('c');
    353         $values['PBX_HASH'] = strtoupper($this->_config->getHmacAlgo());
    354 
    355         // Adding additionnal informations
    356         $values = array_merge($values, $additionalParams);
    357 
    358         // Sort parameters for simpler debug
    359         ksort($values);
    360 
    361         // Sign values
    362         $sign = $this->signValues($values);
    363 
    364         // Hash HMAC
    365         $values['PBX_HMAC'] = $sign;
    366 
    367         return $values;
    368     }
    369 
    370     public function convertParams(array $params) {
    371         $result = array();
    372         foreach ($this->_resultMapping as $param => $key) {
    373             if (isset($params[$param]))
    374                 $result[$key] = utf8_encode($params[$param]);
    375         }
    376 
    377         return $result;
    378     }
    379 
    380     public function getBillingEmail(WC_Order $order) {
    381         return $order->get_billing_email();
    382     }
    383 
    384     public function getBillingName(WC_Order $order) {
    385         $name = $order->get_billing_first_name().' '.$order->get_billing_last_name();
    386         $name = remove_accents($name);
    387         $name = trim(preg_replace('/[^-. a-zA-Z0-9]/', '', $name));
    388         return $name;
    389     }
    390    
    391    
    392    
    393     public function getClientIp() {
    394         $ipaddress = '';
    395         if ($_SERVER['HTTP_CLIENT_IP'])
    396             $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
    397         else if($_SERVER['HTTP_X_FORWARDED_FOR'])
    398             $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
    399         else if($_SERVER['HTTP_X_FORWARDED'])
    400             $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
    401         else if($_SERVER['HTTP_FORWARDED_FOR'])
    402             $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
    403         else if($_SERVER['HTTP_FORWARDED'])
    404             $ipaddress = $_SERVER['HTTP_FORWARDED'];
    405         else if($_SERVER['REMOTE_ADDR'])
    406             $ipaddress = $_SERVER['REMOTE_ADDR'];
    407         else
    408             $ipaddress = 'UNKNOWN';
    409        
    410         return $ipaddress;
    411     }
    412 
    413     public function getCurrency() {
    414         return WC_Etransactions_Iso4217Currency::getIsoCode(get_woocommerce_currency());
    415     }
    416 
    417     public function getLanguages() {
    418         return array(
    419             'fr' => 'FRA',
    420             'es' => 'ESP',
    421             'it' => 'ITA',
    422             'de' => 'DEU',
    423             'nl' => 'NLD',
    424             'sv' => 'SWE',
    425             'pt' => 'PRT',
    426             'default' => 'GBR',
    427         );
    428     }
    429 
    430     public function getOrderPayments($orderId, $type) {
    431         global $wpdb;
    432         $sql = 'select * from '.$wpdb->prefix.'wc_etransactions_payment where order_id = %d and type = %s';
    433         $sql = $wpdb->prepare($sql, $orderId, $type);
    434         return $wpdb->get_row($sql);
    435     }
    436 
    437     public function getParams() {
    438         // Retrieves data
    439         $data = file_get_contents('php://input');
     182    );
     183
     184    private $_errorCode = array(
     185        '00000' => 'Successful operation',
     186        '00001' => 'Payment system not available',
     187        '00003' => 'Paybor error',
     188        '00004' => 'Card number or invalid cryptogram',
     189        '00006' => 'Access denied or invalid identification',
     190        '00008' => 'Invalid validity date',
     191        '00009' => 'Subscription creation failed',
     192        '00010' => 'Unknown currency',
     193        '00011' => 'Invalid amount',
     194        '00015' => 'Payment already done',
     195        '00016' => 'Existing subscriber',
     196        '00021' => 'Unauthorized card',
     197        '00029' => 'Invalid card',
     198        '00030' => 'Timeout',
     199        '00033' => 'Unauthorized IP country',
     200        '00040' => 'No 3D Secure',
     201    );
     202
     203    private $_resultMapping = array(
     204        'M' => 'amount',
     205        'R' => 'reference',
     206        'T' => 'call',
     207        'A' => 'authorization',
     208        'B' => 'subscription',
     209        'C' => 'cardType',
     210        'D' => 'validity',
     211        'E' => 'error',
     212        'F' => '3ds',
     213        'G' => '3dsWarranty',
     214        'H' => 'imprint',
     215        'I' => 'ip',
     216        'J' => 'lastNumbers',
     217        'K' => 'sign',
     218        'N' => 'firstNumbers',
     219        'O' => '3dsInlistment',
     220        'o' => 'celetemType',
     221        'P' => 'paymentType',
     222        'Q' => 'time',
     223        'S' => 'transaction',
     224        'U' => 'subscriptionData',
     225        'W' => 'date',
     226        'Y' => 'country',
     227        'Z' => 'paymentIndex',
     228        'v' => '3dsVersion',
     229    );
     230
     231    public function __construct(WC_Etransactions_Config $config)
     232    {
     233        $this->_config = $config;
     234    }
     235
     236    public function addCartErrorMessage($message)
     237    {
     238        wc_add_notice($message, 'error');
     239    }
     240
     241    public function addOrderNote(WC_Order $order, $message)
     242    {
     243        $order->add_order_note($message);
     244    }
     245
     246    public function addOrderPayment(WC_Order $order, $type, array $data)
     247    {
     248        global $wpdb;
     249        $wpdb->insert($wpdb->prefix.'wc_etransactions_payment', array(
     250            'order_id' => $order->get_id(),
     251            'type' => $type,
     252            'data' => serialize($data),
     253        ));
     254    }
     255
     256    /**
     257     * @params WC_Order $order Order
     258     * @params string $type Type of payment (standard or threetime)
     259     * @params array $additionalParams Additional parameters
     260     */
     261    public function buildSystemParams(WC_Order $order, $type, array $additionalParams = array())
     262    {
     263        global $wpdb;
     264
     265        // Parameters
     266        $values = array();
     267
     268        // Merchant information
     269        $values['PBX_SITE'] = $this->_config->getSite();
     270        $values['PBX_RANG'] = $this->_config->getRank();
     271        $values['PBX_IDENTIFIANT'] = $this->_config->getIdentifier();
     272        $values['PBX_VERSION'] = WC_ETRANSACTIONS_PLUGIN . "-" . WC_ETRANSACTIONS_VERSION . "_WP" . get_bloginfo('version') . "_WC" . WC()->version;
     273
     274        // Order information
     275        $values['PBX_PORTEUR'] = $this->getBillingEmail($order);
     276        $values['PBX_DEVISE'] = $this->getCurrency();
     277        $values['PBX_CMD'] = $order->get_id().' - '.$this->getBillingName($order);
     278
     279        // Amount
     280        $orderAmount = floatval($order->get_total());
     281        $amountScale = $this->_currencyDecimals[$values['PBX_DEVISE']];
     282        $amountScale = pow(10, $amountScale);
     283        switch ($type) {
     284            case 'standard':
     285                $delay = $this->_config->getDelay();
     286                if ($delay > 0) {
     287                    if ($delay > 7) {
     288                        $delay = 7;
     289                    }
     290                    $values['PBX_DIFF'] = sprintf('%02d', $delay);
     291                }
     292                $values['PBX_TOTAL'] = sprintf('%03d', round($orderAmount * $amountScale));
     293                break;
     294
     295            case 'threetime':
     296                // Compute each payment amount
     297                $step = round($orderAmount * $amountScale / 3);
     298                $firstStep = ($orderAmount * $amountScale) - 2 * $step;
     299                $values['PBX_TOTAL'] = sprintf('%03d', $firstStep);
     300                $values['PBX_2MONT1'] = sprintf('%03d', $step);
     301                $values['PBX_2MONT2'] = sprintf('%03d', $step);
     302
     303                // Payment dates
     304                $now = new DateTime();
     305                $now->modify('1 month');
     306                $values['PBX_DATE1'] = $now->format('d/m/Y');
     307                $now->modify('1 month');
     308                $values['PBX_DATE2'] = $now->format('d/m/Y');
     309
     310                // Force validity date of card
     311                $values['PBX_DATEVALMAX'] = $now->format('ym');
     312                break;
     313
     314            default:
     315                $message  = __('Unexpected type %s', WC_ETRANSACTIONS_PLUGIN);
     316                $message = sprintf($message, $type);
     317                throw new Exception($message);
     318        }
     319
     320        // E-Transactions => Magento
     321        $values['PBX_RETOUR'] = 'M:M;R:R;T:T;A:A;B:B;C:C;D:D;E:E;F:F;G:G;I:I;J:J;N:N;O:O;P:P;Q:Q;S:S;W:W;Y:Y;v:v;K:K';
     322        $values['PBX_RUF1'] = 'POST';
     323
     324        // 3DSv2 parameters
     325        $values['PBX_SHOPPINGCART'] = $this->getXmlShoppingCartInformation($order);
     326        $values['PBX_BILLING'] = $this->getXmlBillingInformation($order);
     327
     328        // Choose correct language
     329        $lang = get_locale();
     330        if (!empty($lang)) {
     331            $lang = preg_replace('#_.*$#', '', $lang);
     332        }
     333        $languages = $this->getLanguages();
     334        if (!array_key_exists($lang, $languages)) {
     335            $lang = 'default';
     336        }
     337        $values['PBX_LANGUE'] = $languages[$lang];
     338
     339        // Choose page format depending on browser/devise
     340        if ($this->isMobile()) {
     341            $values['PBX_SOURCE'] = 'XHTML';
     342        }
     343
     344        // Misc.
     345        $values['PBX_TIME'] = date('c');
     346        $values['PBX_HASH'] = strtoupper($this->_config->getHmacAlgo());
     347
     348        // Adding additionnal informations
     349        $values = array_merge($values, $additionalParams);
     350
     351        // Sort parameters for simpler debug
     352        ksort($values);
     353
     354        // Sign values
     355        $sign = $this->signValues($values);
     356
     357        // Hash HMAC
     358        $values['PBX_HMAC'] = $sign;
     359
     360        return $values;
     361    }
     362
     363    public function convertParams(array $params)
     364    {
     365        $result = array();
     366        foreach ($this->_resultMapping as $param => $key) {
     367            if (isset($params[$param])) {
     368                $result[$key] = utf8_encode($params[$param]);
     369            }
     370        }
     371
     372        return $result;
     373    }
     374
     375    public function getBillingEmail(WC_Order $order)
     376    {
     377        return $order->get_billing_email();
     378    }
     379
     380    public function getBillingName(WC_Order $order)
     381    {
     382        $name = $order->get_billing_first_name().' '.$order->get_billing_last_name();
     383        $name = remove_accents($name);
     384        $name = trim(preg_replace('/[^-. a-zA-Z0-9]/', '', $name));
     385        return $name;
     386    }
     387
     388    /**
     389     * Format a value to respect specific rules
     390     *
     391     * @param string $value
     392     * @param string $type
     393     * @param int $maxLength
     394     * @return string
     395     */
     396    protected function formatTextValue($value, $type, $maxLength = null)
     397    {
     398        /*
     399        AN : Alphanumerical without special characters
     400        ANP : Alphanumerical with spaces and special characters
     401        ANS : Alphanumerical with special characters
     402        N : Numerical only
     403        A : Alphabetic only
     404        */
     405
     406        switch ($type) {
     407            default:
     408            case 'AN':
     409                $value = remove_accents($value);
     410                break;
     411            case 'ANP':
     412                $value = remove_accents($value);
     413                $value = preg_replace('/[^-. a-zA-Z0-9]/', '', $value);
     414                break;
     415            case 'ANS':
     416                break;
     417            case 'N':
     418                $value = preg_replace('/[^0-9.]/', '', $value);
     419                break;
     420            case 'A':
     421                $value = remove_accents($value);
     422                $value = preg_replace('/[^A-Za-z]/', '', $value);
     423                break;
     424        }
     425        // Remove carriage return characters
     426        $value = trim(preg_replace("/\r|\n/", '', $value));
     427
     428        // Cut the string when needed
     429        if (!empty($maxLength) && is_numeric($maxLength) && $maxLength > 0) {
     430            if (function_exists('mb_strlen')) {
     431                if (mb_strlen($value) > $maxLength) {
     432                    $value = mb_substr($value, 0, $maxLength);
     433                }
     434            } elseif (strlen($value) > $maxLength) {
     435                $value = substr($value, 0, $maxLength);
     436            }
     437        }
     438
     439        return $value;
     440    }
     441
     442    /**
     443     * Import XML content as string and use DOMDocument / SimpleXML to validate, if available
     444     *
     445     * @param string $xml
     446     * @return string
     447     */
     448    protected function exportToXml($xml)
     449    {
     450        if (class_exists('DOMDocument')) {
     451            $doc = new DOMDocument();
     452            $doc->loadXML($xml);
     453            $xml = $doc->saveXML();
     454        } elseif (function_exists('simplexml_load_string')) {
     455            $xml = simplexml_load_string($xml)->asXml();
     456        }
     457
     458        $xml = trim(preg_replace('/(\s*)(' . preg_quote('<?xml version="1.0" encoding="utf-8"?>') . ')(\s*)/', '$2', $xml));
     459        $xml = trim(preg_replace("/\r|\n/", '', $xml));
     460
     461        return $xml;
     462    }
     463
     464    /**
     465     * Generate XML value for PBX_BILLING parameter
     466     *
     467     * @param WC_Order $order
     468     * @return string
     469     */
     470    public function getXmlBillingInformation(WC_Order $order)
     471    {
     472        $firstName = $this->formatTextValue($order->get_billing_first_name(), 'ANP', 30);
     473        $lastName = $this->formatTextValue($order->get_billing_last_name(), 'ANP', 30);
     474        $addressLine1 = $this->formatTextValue($order->get_billing_address_1(), 'ANS', 50);
     475        $addressLine2 = $this->formatTextValue($order->get_billing_address_2(), 'ANS', 50);
     476        $zipCode = $this->formatTextValue($order->get_billing_postcode(), 'ANS', 16);
     477        $city = $this->formatTextValue($order->get_billing_city(), 'ANS', 50);
     478        $countryCode = (int)WC_Etransactions_Iso3166_Country::getNumericCode($order->get_billing_country());
     479
     480        $xml = sprintf(
     481            '<?xml version="1.0" encoding="utf-8"?><Billing><Address><FirstName>%s</FirstName><LastName>%s</LastName><Address1>%s</Address1><Address2>%s</Address2><ZipCode>%s</ZipCode><City>%s</City><CountryCode>%d</CountryCode></Address></Billing>',
     482            $firstName,
     483            $lastName,
     484            $addressLine1,
     485            $addressLine2,
     486            $zipCode,
     487            $city,
     488            $countryCode
     489        );
     490
     491        return $this->exportToXml($xml);
     492    }
     493
     494    /**
     495     * Generate XML value for PBX_SHOPPINGCART parameter
     496     *
     497     * @param WC_Order $order
     498     * @return string
     499     */
     500    public function getXmlShoppingCartInformation(WC_Order $order)
     501    {
     502        $totalQuantity = 0;
     503        foreach ($order->get_items() as $item) {
     504            $totalQuantity += (int)$item->get_quantity();
     505        }
     506        // totalQuantity must be less or equal than 99
     507        $totalQuantity = min($totalQuantity, 99);
     508
     509        return sprintf('<?xml version="1.0" encoding="utf-8"?><shoppingcart><total><totalQuantity>%d</totalQuantity></total></shoppingcart>', $totalQuantity);
     510    }
     511
     512
     513    public function getClientIp()
     514    {
     515        $ipaddress = '';
     516        if ($_SERVER['HTTP_CLIENT_IP']) {
     517            $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
     518        } elseif ($_SERVER['HTTP_X_FORWARDED_FOR']) {
     519            $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
     520        } elseif ($_SERVER['HTTP_X_FORWARDED']) {
     521            $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
     522        } elseif ($_SERVER['HTTP_FORWARDED_FOR']) {
     523            $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
     524        } elseif ($_SERVER['HTTP_FORWARDED']) {
     525            $ipaddress = $_SERVER['HTTP_FORWARDED'];
     526        } elseif ($_SERVER['REMOTE_ADDR']) {
     527            $ipaddress = $_SERVER['REMOTE_ADDR'];
     528        } else {
     529            $ipaddress = 'UNKNOWN';
     530        }
     531
     532        return $ipaddress;
     533    }
     534
     535    public function getCurrency()
     536    {
     537        return WC_Etransactions_Iso4217Currency::getIsoCode(get_woocommerce_currency());
     538    }
     539
     540    public function getLanguages()
     541    {
     542        return array(
     543            'fr' => 'FRA',
     544            'es' => 'ESP',
     545            'it' => 'ITA',
     546            'de' => 'DEU',
     547            'nl' => 'NLD',
     548            'sv' => 'SWE',
     549            'pt' => 'PRT',
     550            'default' => 'GBR',
     551        );
     552    }
     553
     554    public function getOrderPayments($orderId, $type)
     555    {
     556        global $wpdb;
     557        $sql = 'select * from '.$wpdb->prefix.'wc_etransactions_payment where order_id = %d and type = %s';
     558        $sql = $wpdb->prepare($sql, $orderId, $type);
     559        return $wpdb->get_row($sql);
     560    }
     561
     562    public function getParams()
     563    {
     564        // Retrieves data
     565        $data = file_get_contents('php://input');
    440566        if (empty($data)) {
    441567            $data = $_SERVER['QUERY_STRING'];
    442568        }
    443569        if (empty($data)) {
    444             $message = 'An unexpected error in E-Transactions call has occured: no parameters.';
    445             throw new Exception(__($message, WC_ETRANSACTIONS_PLUGIN));
    446         }
    447 
    448         // Extract signature
    449         $matches = array();
    450         if (!preg_match('#^(.*)&K=(.*)$#', $data, $matches)) {
    451             $message = 'An unexpected error in E-Transactions call has occured: missing signature.';
    452             throw new Exception(__($message, WC_ETRANSACTIONS_PLUGIN));
    453         }
    454 
    455         // Check signature
    456         $signature = base64_decode(urldecode($matches[2]));
    457         $pubkey = file_get_contents(dirname(__FILE__).'/pubkey.pem');
    458         $res = (boolean) openssl_verify($matches[1], $signature, $pubkey);
    459 
    460         if (!$res) {
    461             if (preg_match('#^s=i&(.*)&K=(.*)$#', $data, $matches)) {
    462                 $signature = base64_decode(urldecode($matches[2]));
    463                 $res = (boolean) openssl_verify($matches[1], $signature, $pubkey);
    464             }
    465 
    466             if (!$res) {
    467                 $message = 'An unexpected error in E-Transactions call has occured: invalid signature.';
    468                 throw new Exception(__($message, WC_ETRANSACTIONS_PLUGIN));
    469             }
    470         }
    471 
    472         $rawParams = array();
    473         parse_str($data, $rawParams);
    474 
    475         // Decrypt params
    476         $params = $this->convertParams($rawParams);
    477         if (empty($params)) {
    478             $message = 'An unexpected error in E-Transactions call has occured: no parameters.';
    479             throw new Exception(__($message, WC_ETRANSACTIONS_PLUGIN));
    480         }
    481 
    482         return $params;
    483     }
    484 
    485     public function getSystemUrl() {
    486         $urls = $this->_config->getSystemUrls();
    487         if (empty($urls)) {
    488             $message = 'Missing URL for E-Transactions system in configuration';
    489             throw new Exception(__($message, WC_ETRANSACTIONS_PLUGIN));
    490         }
    491 
    492         // look for valid peer
    493         $error = null;
    494         foreach ($urls as $url) {
    495             $testUrl = preg_replace('#^([a-zA-Z0-9]+://[^/]+)(/.*)?$#', '\1/load.html', $url);
    496 
    497             $connectParams = array(
    498                 'timeout' => 5,
    499                 'redirection' => 0,
    500                 'user-agent' => 'Woocommerce E-Transactions module',
    501                 'httpversion' => '2',
    502             );
    503             try {
    504                 $response = wp_remote_get($testUrl, $connectParams);
    505                 if (is_array($response) && ($response['response']['code'] == 200)) {
    506                     if (preg_match('#<div id="server_status" style="text-align:center;">OK</div>#', $response['body']) == 1) {
    507                         return $url;
    508                     }
    509                 }
    510             }
    511             catch (Exception $e) {
    512                 $error = $e;
    513             }
    514         }
    515 
    516         // Here, there's a problem
    517         throw new Exception(__('E-Transactions not available. Please try again later.'));
    518     }
    519 
    520     public function isMobile() {
    521         // From http://detectmobilebrowsers.com/, regexp of 09/09/2013
    522         global $_SERVER;
    523         $userAgent = $_SERVER['HTTP_USER_AGENT'];
    524         if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$userAgent)) {
    525             return true;
    526         }
    527         if (preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr($userAgent, 0, 4))) {
    528             return true;
    529         }
    530         return false;
    531     }
    532 
    533     public function signValues(array $values) {
    534         // Serialize values
    535         $params = array();
    536         foreach ($values as $name => $value) {
    537             $params[] = $name.'='.$value;
    538         }
    539         $query = implode('&', $params);
    540 
    541         // Prepare key
    542         $key = pack('H*', $this->_config->getHmacKey());
    543 
    544         // Sign values
    545         $sign = hash_hmac($this->_config->getHmacAlgo(), $query, $key);
    546         if ($sign === false) {
    547             $errorMsg = 'Unable to create hmac signature. Maybe a wrong configuration.';
    548             throw new Exception(__($errorMsg, WC_ETRANSACTIONS_PLUGIN));
    549         }
    550 
    551         return strtoupper($sign);
    552     }
     570            $message = 'An unexpected error in E-Transactions call has occured: no parameters.';
     571            throw new Exception(__($message, WC_ETRANSACTIONS_PLUGIN));
     572        }
     573
     574        // Extract signature
     575        $matches = array();
     576        if (!preg_match('#^(.*)&K=(.*)$#', $data, $matches)) {
     577            $message = 'An unexpected error in E-Transactions call has occured: missing signature.';
     578            throw new Exception(__($message, WC_ETRANSACTIONS_PLUGIN));
     579        }
     580
     581        // Check signature
     582        $signature = base64_decode(urldecode($matches[2]));
     583        $pubkey = file_get_contents(dirname(__FILE__).'/pubkey.pem');
     584        $res = (boolean) openssl_verify($matches[1], $signature, $pubkey);
     585
     586        if (!$res) {
     587            if (preg_match('#^s=i&(.*)&K=(.*)$#', $data, $matches)) {
     588                $signature = base64_decode(urldecode($matches[2]));
     589                $res = (boolean) openssl_verify($matches[1], $signature, $pubkey);
     590            }
     591
     592            if (!$res) {
     593                $message = 'An unexpected error in E-Transactions call has occured: invalid signature.';
     594                throw new Exception(__($message, WC_ETRANSACTIONS_PLUGIN));
     595            }
     596        }
     597
     598        $rawParams = array();
     599        parse_str($data, $rawParams);
     600
     601        // Decrypt params
     602        $params = $this->convertParams($rawParams);
     603        if (empty($params)) {
     604            $message = 'An unexpected error in E-Transactions call has occured: no parameters.';
     605            throw new Exception(__($message, WC_ETRANSACTIONS_PLUGIN));
     606        }
     607
     608        return $params;
     609    }
     610
     611    public function getSystemUrl()
     612    {
     613        $urls = $this->_config->getSystemUrls();
     614        if (empty($urls)) {
     615            $message = 'Missing URL for E-Transactions system in configuration';
     616            throw new Exception(__($message, WC_ETRANSACTIONS_PLUGIN));
     617        }
     618
     619        // look for valid peer
     620        $error = null;
     621        foreach ($urls as $url) {
     622            $testUrl = preg_replace('#^([a-zA-Z0-9]+://[^/]+)(/.*)?$#', '\1/load.html', $url);
     623
     624            $connectParams = array(
     625                'timeout' => 5,
     626                'redirection' => 0,
     627                'user-agent' => 'Woocommerce E-Transactions module',
     628                'httpversion' => '2',
     629            );
     630            try {
     631                $response = wp_remote_get($testUrl, $connectParams);
     632                if (is_array($response) && ($response['response']['code'] == 200)) {
     633                    if (preg_match('#<div id="server_status" style="text-align:center;">OK</div>#', $response['body']) == 1) {
     634                        return $url;
     635                    }
     636                }
     637            } catch (Exception $e) {
     638                $error = $e;
     639            }
     640        }
     641
     642        // Here, there's a problem
     643        throw new Exception(__('E-Transactions not available. Please try again later.'));
     644    }
     645
     646    public function isMobile()
     647    {
     648        // From http://detectmobilebrowsers.com/, regexp of 09/09/2013
     649        global $_SERVER;
     650        $userAgent = $_SERVER['HTTP_USER_AGENT'];
     651        if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $userAgent)) {
     652            return true;
     653        }
     654        if (preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr($userAgent, 0, 4))) {
     655            return true;
     656        }
     657        return false;
     658    }
     659
     660    public function signValues(array $values)
     661    {
     662        // Serialize values
     663        $params = array();
     664        foreach ($values as $name => $value) {
     665            $params[] = $name.'='.$value;
     666        }
     667        $query = implode('&', $params);
     668
     669        // Prepare key
     670        $key = pack('H*', $this->_config->getHmacKey());
     671
     672        // Sign values
     673        $sign = hash_hmac($this->_config->getHmacAlgo(), $query, $key);
     674        if ($sign === false) {
     675            $errorMsg = 'Unable to create hmac signature. Maybe a wrong configuration.';
     676            throw new Exception(__($errorMsg, WC_ETRANSACTIONS_PLUGIN));
     677        }
     678
     679        return strtoupper($sign);
     680    }
    553681
    554682    public function toErrorMessage($code)
    555     {
     683    {
    556684        if (isset($this->_errorCode[$code])) {
    557685            return $this->_errorCode[$code];
     
    561689    }
    562690
    563     /**
    564      * Load order from the $token
    565      * @param string $token Token (@see tokenizeOrder)
    566      * @return Mage_Sales_Model_Order
    567      */
    568     public function untokenizeOrder($token) {
    569         $parts = explode(' - ', $token, 2);
    570         if (count($parts) < 2) {
    571             $message = 'Invalid decrypted token "%s"';
    572             throw new Exception(sprintf(__($message, WC_ETRANSACTIONS_PLUGIN), $token));
    573         }
    574 
    575         // Retrieves order
    576         $order = new WC_Order($parts[0]);
    577         $temp_id=$order->get_id();
    578         if (empty($temp_id)) {
    579             $message = 'Not existing order id from decrypted token "%s"';
    580             throw new Exception(sprintf(__($message, WC_ETRANSACTIONS_PLUGIN), $token));
    581         }
    582 
    583         $name = $this->getBillingName($order);
    584         if (($name != utf8_decode($parts[1])) && ($name != $parts[1])) {
    585             $message = 'Consistency error on descrypted token "%s"';
    586             throw new Exception(sprintf(__($message, WC_ETRANSACTIONS_PLUGIN), $token));
    587         }
    588 
    589         return $order;
    590     }
     691    /**
     692     * Load order from the $token
     693     * @param string $token Token (@see tokenizeOrder)
     694     * @return Mage_Sales_Model_Order
     695     */
     696    public function untokenizeOrder($token)
     697    {
     698        $parts = explode(' - ', $token, 2);
     699        if (count($parts) < 2) {
     700            $message = 'Invalid decrypted token "%s"';
     701            throw new Exception(sprintf(__($message, WC_ETRANSACTIONS_PLUGIN), $token));
     702        }
     703
     704        // Retrieves order
     705        $order = new WC_Order($parts[0]);
     706        $temp_id=$order->get_id();
     707        if (empty($temp_id)) {
     708            $message = 'Not existing order id from decrypted token "%s"';
     709            throw new Exception(sprintf(__($message, WC_ETRANSACTIONS_PLUGIN), $token));
     710        }
     711
     712        $name = $this->getBillingName($order);
     713        if (($name != utf8_decode($parts[1])) && ($name != $parts[1])) {
     714            $message = 'Consistency error on descrypted token "%s"';
     715            throw new Exception(sprintf(__($message, WC_ETRANSACTIONS_PLUGIN), $token));
     716        }
     717
     718        return $order;
     719    }
    591720}
  • e-transactions-wc/trunk/lang/wc-etransactions-fr_FR.po

    r2240388 r2499400  
    22msgstr ""
    33"Project-Id-Version: Woocommerce E-Transactions plugin\n"
    4 "POT-Creation-Date: 2020-02-07 11:16+0100\n"
    5 "PO-Revision-Date: 2020-02-07 11:18+0100\n"
     4"POT-Creation-Date: 2020-10-07 18:56+0200\n"
     5"PO-Revision-Date: 2020-10-08 16:07+0200\n"
    66"Last-Translator: Jérôme Cintas <jerome.cintas@verifonecom>\n"
    77"Language-Team: BM Services <wordpress@e-transactions.fr>\n"
    8 "Language: fr\n"
     8"Language: fr_FR\n"
    99"MIME-Version: 1.0\n"
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 2.2.3\n"
     12"X-Generator: Poedit 2.4.1\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=2; plural=(n > 1);\n"
     15"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
     16"X-Poedit-WPHeader: wc-etransactions.php\n"
    1517"X-Poedit-SourceCharset: UTF-8\n"
    16 "X-Poedit-KeywordsList: __;__e\n"
     18"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
     19"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
     20"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
    1721"X-Poedit-SearchPath-0: .\n"
    18 
    19 #: class/wc-etransactions-abstract-gateway.php:71
    20 #: class/wc-etransactions-abstract-gateway.php:131
     22"X-Poedit-SearchPathExcluded-0: *.min.js\n"
     23
     24#: class/wc-etransactions-abstract-gateway.php:84
    2125msgid "Enable/Disable"
    2226msgstr "Actif/Inactif"
    2327
    24 #: class/wc-etransactions-abstract-gateway.php:73
     28#: class/wc-etransactions-abstract-gateway.php:86
    2529msgid "Enable E-Transactions Payment"
    2630msgstr "Activer le paiement par E-Transactions"
    2731
    28 #: class/wc-etransactions-abstract-gateway.php:77
     32#: class/wc-etransactions-abstract-gateway.php:90
    2933msgid "Title"
    3034msgstr "Titre"
    3135
    32 #: class/wc-etransactions-abstract-gateway.php:79
     36#: class/wc-etransactions-abstract-gateway.php:92
    3337msgid "This controls the title which the user sees during checkout."
    34 msgstr "Titre visible par le client lors d'une commande"
    35 
    36 #: class/wc-etransactions-abstract-gateway.php:91
     38msgstr "Titre visible par le client lors d'une commande."
     39
     40#: class/wc-etransactions-abstract-gateway.php:103
    3741msgid "Icon file"
    3842msgstr "Fichier icone"
    3943
    40 #: class/wc-etransactions-abstract-gateway.php:93
     44#: class/wc-etransactions-abstract-gateway.php:105
    4145msgid "Icon file to be displayed to customers. file are located in: "
    4246msgstr ""
    4347"Fichier d'icône à afficher au client. les fichiers sont dans le répertoire: "
    4448
    45 #: class/wc-etransactions-abstract-gateway.php:98
     49#: class/wc-etransactions-abstract-gateway.php:110
    4650msgid "Description"
    4751msgstr "Description"
    4852
    49 #: class/wc-etransactions-abstract-gateway.php:100
     53#: class/wc-etransactions-abstract-gateway.php:112
    5054msgid "Payment method description that the customer will see on your checkout."
    5155msgstr ""
    5256"Description de la méthode de paiement . Visible par le client lors d'une "
    53 "commande"
    54 
    55 #: class/wc-etransactions-abstract-gateway.php:105
     57"commande."
     58
     59#: class/wc-etransactions-abstract-gateway.php:117
    5660msgid "Delay"
    5761msgstr "Délai"
    5862
    59 #: class/wc-etransactions-abstract-gateway.php:108
     63#: class/wc-etransactions-abstract-gateway.php:120
    6064msgid "Immediate"
    6165msgstr "Immédiat"
    6266
    63 #: class/wc-etransactions-abstract-gateway.php:109
     67#: class/wc-etransactions-abstract-gateway.php:121
    6468msgid "1 day"
    6569msgstr "1 jour"
    6670
    67 #: class/wc-etransactions-abstract-gateway.php:110
     71#: class/wc-etransactions-abstract-gateway.php:122
    6872msgid "2 days"
    6973msgstr "2 jours"
    7074
    71 #: class/wc-etransactions-abstract-gateway.php:111
     75#: class/wc-etransactions-abstract-gateway.php:123
    7276msgid "3 days"
    7377msgstr "3 jours"
    7478
    75 #: class/wc-etransactions-abstract-gateway.php:112
     79#: class/wc-etransactions-abstract-gateway.php:124
    7680msgid "4 days"
    7781msgstr "4 jours"
    7882
    79 #: class/wc-etransactions-abstract-gateway.php:113
     83#: class/wc-etransactions-abstract-gateway.php:125
    8084msgid "5 days"
    8185msgstr "5 jours"
    8286
    83 #: class/wc-etransactions-abstract-gateway.php:114
     87#: class/wc-etransactions-abstract-gateway.php:126
    8488msgid "6 days"
    8589msgstr "6 jours"
    8690
    87 #: class/wc-etransactions-abstract-gateway.php:115
     91#: class/wc-etransactions-abstract-gateway.php:127
    8892msgid "7 days"
    8993msgstr "7 jours"
    9094
    91 #: class/wc-etransactions-abstract-gateway.php:121
    92 #: class/wc-etransactions-abstract-gateway.php:143
     95#: class/wc-etransactions-abstract-gateway.php:133
    9396msgid "Minimal amount"
    9497msgstr "Montant minimal"
    9598
    96 #: class/wc-etransactions-abstract-gateway.php:123
     99#: class/wc-etransactions-abstract-gateway.php:135
    97100msgid ""
    98101"Enable this payment method for order with amount greater or equals to this "
     
    103106"condition)"
    104107
    105 #: class/wc-etransactions-abstract-gateway.php:127
    106 msgid "3D Secure"
    107 msgstr "3D Secure"
    108 
    109 #: class/wc-etransactions-abstract-gateway.php:133
    110 msgid "Enable 3D Secure"
    111 msgstr "Activer 3D Secure"
    112 
    113 #: class/wc-etransactions-abstract-gateway.php:134
    114 msgid ""
    115 "You can enable 3D Secure for all orders or depending on following conditions"
    116 msgstr ""
    117 "Vous pouvez activer  3D Secure pour toutes les commandes ou en fonction des "
    118 "conditions suivantes."
    119 
    120 #: class/wc-etransactions-abstract-gateway.php:137
    121 msgid "Disabled"
    122 msgstr "Inactif"
    123 
    124 #: class/wc-etransactions-abstract-gateway.php:138
    125 msgid "Enabled"
    126 msgstr "Actif"
    127 
    128 #: class/wc-etransactions-abstract-gateway.php:139
    129 msgid "Conditional"
    130 msgstr "Sélectif"
    131 
    132 #: class/wc-etransactions-abstract-gateway.php:145
    133 msgid ""
    134 "Enable 3D Secure for order with amount greater or equals to this amount "
    135 "(empty to ignore this condition)"
    136 msgstr ""
    137 "Activer 3D Secure pour les commandes dont le montant est supérieur ou égal "
    138 "au montant suivant "
    139 
    140 #: class/wc-etransactions-abstract-gateway.php:149
     108#: class/wc-etransactions-abstract-gateway.php:143
     109msgid "Version"
     110msgstr "Version"
     111
     112#: class/wc-etransactions-abstract-gateway.php:153
    141113msgid "E-Transactions account"
    142114msgstr "Compte E-Transactions"
    143115
    144 #: class/wc-etransactions-abstract-gateway.php:153
     116#: class/wc-etransactions-abstract-gateway.php:157
    145117msgid "Site number"
    146118msgstr "Numéro du site"
    147119
    148 #: class/wc-etransactions-abstract-gateway.php:155
     120#: class/wc-etransactions-abstract-gateway.php:159
    149121msgid "Site number provided by E-Transactions."
    150 msgstr "Le numéro du site vous est fourni par E-Transactions"
    151 
    152 #: class/wc-etransactions-abstract-gateway.php:159
     122msgstr "Le numéro du site vous est fourni par E-Transactions."
     123
     124#: class/wc-etransactions-abstract-gateway.php:163
    153125msgid "Rank number"
    154126msgstr "Rang"
    155127
    156 #: class/wc-etransactions-abstract-gateway.php:161
     128#: class/wc-etransactions-abstract-gateway.php:165
    157129msgid "Rank number provided by E-Transactions (two last digits)."
    158130msgstr "Numéro de rang fourni par E-Transactions (deux derniers chiffres)."
    159131
    160 #: class/wc-etransactions-abstract-gateway.php:165
     132#: class/wc-etransactions-abstract-gateway.php:169
    161133msgid "Login"
    162134msgstr "Identifiant"
    163135
    164 #: class/wc-etransactions-abstract-gateway.php:167
     136#: class/wc-etransactions-abstract-gateway.php:171
    165137msgid "Internal login provided by E-Transactions."
    166 msgstr "Votre identifiant vous est fourni par E-Transactions"
    167 
    168 #: class/wc-etransactions-abstract-gateway.php:171
     138msgstr "Votre identifiant vous est fourni par E-Transactions."
     139
     140#: class/wc-etransactions-abstract-gateway.php:175
    169141msgid "HMAC"
    170142msgstr "HMAC"
    171143
    172 #: class/wc-etransactions-abstract-gateway.php:173
     144#: class/wc-etransactions-abstract-gateway.php:177
    173145msgid "Secrete HMAC key to create using the E-Transactions interface."
    174146msgstr ""
     
    176148"Transactions."
    177149
    178 #: class/wc-etransactions-abstract-gateway.php:177
     150#: class/wc-etransactions-abstract-gateway.php:181
    179151msgid "Environment"
    180152msgstr "Environnement"
    181153
    182 #: class/wc-etransactions-abstract-gateway.php:179
     154#: class/wc-etransactions-abstract-gateway.php:183
    183155msgid "In test mode your payments will not be sent to the bank."
    184156msgstr "En mode test, vos paiements ne seront pas envoyé à la banque."
    185157
    186 #: class/wc-etransactions-abstract-gateway.php:181
     158#: class/wc-etransactions-abstract-gateway.php:185
    187159msgid "Production"
    188160msgstr "Production"
    189161
    190 #: class/wc-etransactions-abstract-gateway.php:182
     162#: class/wc-etransactions-abstract-gateway.php:186
    191163msgid "Test"
    192164msgstr "Test"
    193165
    194 #: class/wc-etransactions-abstract-gateway.php:187
     166#: class/wc-etransactions-abstract-gateway.php:191
    195167msgid "Technical settings"
    196168msgstr "Configuration technique"
    197169
    198 #: class/wc-etransactions-abstract-gateway.php:191
    199 msgid "Allowed IPs "
     170#: class/wc-etransactions-abstract-gateway.php:195
     171msgid "Allowed IPs"
    200172msgstr "Adresses IP autorisées"
    201173
    202 #: class/wc-etransactions-abstract-gateway.php:193
     174#: class/wc-etransactions-abstract-gateway.php:197
    203175msgid "A coma separated list of E-Transactions IPs."
    204176msgstr ""
     
    206178"réception des Notifications Instantanées de Paiement."
    207179
    208 #: class/wc-etransactions-abstract-gateway.php:197
     180#: class/wc-etransactions-abstract-gateway.php:201
    209181msgid "Debug"
    210182msgstr "Debug"
    211183
    212 #: class/wc-etransactions-abstract-gateway.php:199
     184#: class/wc-etransactions-abstract-gateway.php:203
    213185msgid "Enable some debugging information"
    214186msgstr "Activer les informations de debuggage"
    215187
    216 #: class/wc-etransactions-abstract-gateway.php:231
     188#: class/wc-etransactions-abstract-gateway.php:238
    217189msgid "Customer is redirected to E-Transactions payment page"
    218190msgstr "Le client est redirigé vers la pages de paiement etransactions"
    219191
    220 #: class/wc-etransactions-abstract-gateway.php:265
     192#: class/wc-etransactions-abstract-gateway.php:273
    221193msgid "Back..."
    222194msgstr "Retour..."
    223195
    224 #: class/wc-etransactions-abstract-gateway.php:273
     196#: class/wc-etransactions-abstract-gateway.php:281
    225197msgid ""
    226198"This is a debug view. Click continue to be redirected to E-Transactions "
     
    230202"la page de paiement E-Transactions."
    231203
    232 #: class/wc-etransactions-abstract-gateway.php:277
     204#: class/wc-etransactions-abstract-gateway.php:285
    233205msgid ""
    234206"You will be redirected to the E-Transactions payment page. If not, please "
     
    238210"pas le cas, merci d'utiliser le bouton ci dessous."
    239211
    240 #: class/wc-etransactions-abstract-gateway.php:285
     212#: class/wc-etransactions-abstract-gateway.php:293
    241213msgid "Continue..."
    242214msgstr "Continuer..."
    243215
    244 #: class/wc-etransactions-abstract-gateway.php:339
    245 #: class/wc-etransactions-abstract-gateway.php:375
     216#: class/wc-etransactions-abstract-gateway.php:349
     217#: class/wc-etransactions-abstract-gateway.php:389
    246218msgid "Customer is back from E-Transactions payment page."
    247 msgstr "Le client revient de la page de paiement E-Transactions"
    248 
    249 #: class/wc-etransactions-abstract-gateway.php:340
    250 #: class/wc-etransactions-abstract-gateway.php:342
     219msgstr "Le client revient de la page de paiement E-Transactions."
     220
     221#: class/wc-etransactions-abstract-gateway.php:350
     222#: class/wc-etransactions-abstract-gateway.php:352
    251223msgid "Payment refused by E-Transactions"
    252224msgstr "Le paiement a été refusé par E-Transactions"
    253225
    254 #: class/wc-etransactions-abstract-gateway.php:358
     226#: class/wc-etransactions-abstract-gateway.php:370
    255227msgid "Payment was canceled by user on E-Transactions payment page."
    256228msgstr ""
     
    258230"Transactions."
    259231
    260 #: class/wc-etransactions-abstract-gateway.php:360
     232#: class/wc-etransactions-abstract-gateway.php:372
    261233msgid "Payment canceled"
    262234msgstr "Le paiement a été annulé"
    263235
    264 #: class/wc-etransactions-abstract-gateway.php:417
     236#: class/wc-etransactions-abstract-gateway.php:432
    265237#, php-format
    266238msgid "Missing %s parameter in E-Transactions call"
    267 msgstr "Le paramêtre %s manque dans l'appel E-Transactions"
    268 
    269 #: class/wc-etransactions-abstract-gateway.php:427
    270 #: class/wc-etransactions-abstract-gateway.php:436
     239msgstr "Le paramètre %s manque dans l'appel E-Transactions"
     240
     241#: class/wc-etransactions-abstract-gateway.php:442
     242#: class/wc-etransactions-abstract-gateway.php:451
    271243msgid "Payment was authorized and captured by E-Transactions."
    272244msgstr "Paiement autorisé et capturé par E-Transactions."
    273245
    274 #: class/wc-etransactions-abstract-gateway.php:440
     246#: class/wc-etransactions-abstract-gateway.php:455
    275247msgid "Second payment was captured by E-Transactions."
    276248msgstr "Deuxième paiement capturé par E-Transactions."
    277249
    278 #: class/wc-etransactions-abstract-gateway.php:443
     250#: class/wc-etransactions-abstract-gateway.php:458
    279251msgid "Third payment was captured by E-Transactions."
    280252msgstr "Troisième paiement capturé par E-Transactions."
    281253
    282 #: class/wc-etransactions-abstract-gateway.php:446
     254#: class/wc-etransactions-abstract-gateway.php:461
    283255msgid "Invalid three-time payment status"
    284256msgstr "Statut du paiement en trois fois non valide"
    285257
    286 #: class/wc-etransactions-abstract-gateway.php:453
    287 #: class/wc-etransactions.php:303
     258#: class/wc-etransactions-abstract-gateway.php:468
     259#: class/wc-etransactions.php:314
    288260#, php-format
    289261msgid "Unexpected type %s"
    290262msgstr "Type %s inattendu"
    291263
    292 #: class/wc-etransactions-abstract-gateway.php:462
     264#: class/wc-etransactions-abstract-gateway.php:475
    293265#, php-format
    294266msgid "Payment was refused by E-Transactions (%s)."
    295267msgstr "Paiement refusé par E-Transactions (%s)."
    296268
    297 #: class/wc-etransactions-encrypt.php:60 class/wc-etransactions-encrypt.php:76
     269#: class/wc-etransactions-encrypt.php:65 class/wc-etransactions-encrypt.php:81
    298270msgid ""
    299271"For some reason, the key has just been generated. please reenter the HMAC "
     
    303275"clé HMAC pour qu'elle soit cryptée."
    304276
    305 #: class/wc-etransactions-standard-gateway.php:11
     277#. Plugin Name of the plugin/theme
     278#. Author of the plugin/theme
     279#: class/wc-etransactions-standard-gateway.php:19
    306280msgid "E-Transactions"
    307281msgstr "E-Transactions"
    308282
    309 #: class/wc-etransactions-standard-gateway.php:29
    310 #: class/wc-etransactions-threetime-gateway.php:57
     283#: class/wc-etransactions-standard-gateway.php:43
     284#: class/wc-etransactions-threetime-gateway.php:77
    311285msgid "Reference:"
    312 msgstr "Référence"
    313 
    314 #: class/wc-etransactions-standard-gateway.php:31
    315 #: class/wc-etransactions-threetime-gateway.php:59
     286msgstr "Référence:"
     287
     288#: class/wc-etransactions-standard-gateway.php:45
     289#: class/wc-etransactions-threetime-gateway.php:79
    316290msgid "Country of IP:"
    317291msgstr "Pays de l'IP:"
    318292
    319 #: class/wc-etransactions-standard-gateway.php:33
    320 #: class/wc-etransactions-threetime-gateway.php:61
     293#: class/wc-etransactions-standard-gateway.php:47
     294#: class/wc-etransactions-threetime-gateway.php:81
    321295msgid "Processing date:"
    322296msgstr "Date de traitement:"
    323297
    324 #: class/wc-etransactions-standard-gateway.php:35
    325 #: class/wc-etransactions-threetime-gateway.php:63
     298#: class/wc-etransactions-standard-gateway.php:49
     299#: class/wc-etransactions-threetime-gateway.php:83
    326300msgid "Card numbers:"
    327301msgstr "Numéros de la carte:"
    328302
    329 #: class/wc-etransactions-standard-gateway.php:38
    330 #: class/wc-etransactions-threetime-gateway.php:66
     303#: class/wc-etransactions-standard-gateway.php:52
     304#: class/wc-etransactions-threetime-gateway.php:86
    331305msgid "Validity date:"
    332306msgstr "Date de validité:"
    333307
    334 #: class/wc-etransactions-standard-gateway.php:40
    335 #: class/wc-etransactions-threetime-gateway.php:91
     308#: class/wc-etransactions-standard-gateway.php:61
     309#: class/wc-etransactions-threetime-gateway.php:95
     310msgid "3DS version:"
     311msgstr "Version 3DS:"
     312
     313#: class/wc-etransactions-standard-gateway.php:64
     314#: class/wc-etransactions-threetime-gateway.php:118
    336315msgid "Transaction:"
    337316msgstr "Transaction:"
    338317
    339 #: class/wc-etransactions-standard-gateway.php:41
    340 #: class/wc-etransactions-threetime-gateway.php:92
     318#: class/wc-etransactions-standard-gateway.php:65
     319#: class/wc-etransactions-threetime-gateway.php:119
    341320msgid "Call:"
    342321msgstr "Appel:"
    343322
    344 #: class/wc-etransactions-standard-gateway.php:42
    345 #: class/wc-etransactions-threetime-gateway.php:93
     323#: class/wc-etransactions-standard-gateway.php:66
     324#: class/wc-etransactions-threetime-gateway.php:120
    346325msgid "Authorization:"
    347326msgstr "Autorisation:"
    348327
    349 #: class/wc-etransactions-standard-gateway.php:44
    350 #: class/wc-etransactions-threetime-gateway.php:95
     328#: class/wc-etransactions-standard-gateway.php:68
     329#: class/wc-etransactions-threetime-gateway.php:122
    351330msgid "Payment information"
    352331msgstr "Informations sur le paiement"
    353332
    354 #: class/wc-etransactions-threetime-gateway.php:11
     333#: class/wc-etransactions-threetime-gateway.php:21
    355334msgid "E-Transactions 3 times"
    356335msgstr "E-Transactions paiement en trois fois"
    357336
    358 #: class/wc-etransactions-threetime-gateway.php:71
     337#: class/wc-etransactions-threetime-gateway.php:100
    359338msgid "First debit:"
    360339msgstr "Premier paiement:"
    361340
    362 #: class/wc-etransactions-threetime-gateway.php:78
    363 #: class/wc-etransactions-threetime-gateway.php:87
     341#: class/wc-etransactions-threetime-gateway.php:106
     342#: class/wc-etransactions-threetime-gateway.php:114
    364343msgid "Not achieved"
    365344msgstr "Non traité"
    366345
    367 #: class/wc-etransactions-threetime-gateway.php:80
     346#: class/wc-etransactions-threetime-gateway.php:108
    368347msgid "Second debit:"
    369348msgstr "Seconde échéance:"
    370349
    371 #: class/wc-etransactions-threetime-gateway.php:89
     350#: class/wc-etransactions-threetime-gateway.php:116
    372351msgid "Third debit:"
    373352msgstr "Troisième échéance:"
    374353
    375 #: class/wc-etransactions.php:322
    376 #, php-format
    377 msgid "Unexpected 3-D Secure status %s"
    378 msgstr "Statut 3-D Secure inattendu: %s"
    379 
    380 #: class/wc-etransactions.php:517
     354#: class/wc-etransactions.php:644
    381355msgid "E-Transactions not available. Please try again later."
    382356msgstr "E-Transactions n'est pas disponible. Merci d'essayer plus tard."
    383357
    384 #: wc-etransactions.php:43
     358#: wc-etransactions.php:39 wc-etransactions.php:40
    385359msgid "Previous plugin already installed. deactivate the previous one first."
    386360msgstr ""
     
    388362"désactivez la version précédente avant d'activer celle-ci."
    389363
    390 #: wc-etransactions.php:132
     364#: wc-etransactions.php:53
     365msgid "WooCommerce must be activated"
     366msgstr "WooCommerce doit être activé"
     367
     368#: wc-etransactions.php:138
    391369msgid "HMAC key cannot be decrypted please re-enter or reinitialise it."
    392370msgstr ""
     
    394372"réinitialisez la."
    395373
    396 #~ msgid "IPN call from %s not allowed."
    397 #~ msgstr "Appel IPN depuis %s non autorisé."
    398 
    399 #~ msgid "Rank number provided by E-Transactions."
    400 #~ msgstr "Le rang de votre site vous est fourni par E-Transactions"
    401 
    402 #~ msgid "Unexpected 3D Secure status %s"
    403 #~ msgstr "Satut 3D Secure %s inattendu"
    404 
    405 #~ msgid "Depending on following conditions (and)"
    406 #~ msgstr "Suivant les conditions ci-dessous (et)"
    407 
    408 #~ msgid "Depending on following conditions (or)"
    409 #~ msgstr "Suivant les conditions ci-dessous (ou)"
    410 
    411 #~ msgid "Maximal order count"
    412 #~ msgstr "Nombre maximal de commande"
    413 
    414 #~ msgid ""
    415 #~ "Enable 3D Secure for customer with less than this number of orders (empty "
    416 #~ "to ignore this condition)"
    417 #~ msgstr ""
    418 #~ "Activer 3D Secure pour les clients ayant passé moins de  for customer "
    419 #~ "with less than this number of orders (laisser vide pour ignorer cette "
    420 #~ "condition)"
    421 
    422 #~ msgid "TODO"
    423 #~ msgstr "TODO"
     374#: wc-etransactions.php:143
     375msgid "Woocommerce is not active !"
     376msgstr "WooCommerce n’est pas activé !"
     377
     378#. Description of the plugin/theme
     379msgid "E-Transactions gateway payment plugins for WooCommerce"
     380msgstr "Extension E-Transactions - passerelle de paiement pour WooCommerce"
     381
     382#. Author URI of the plugin/theme
     383msgid "http://www.e-transactions.fr"
     384msgstr ""
  • e-transactions-wc/trunk/readme.txt

    r2391064 r2499400  
    44Tags: Payment Gateway, Orders, woocommerce, e-commerce, payment, E-Transactions
    55Requires at least: 3.0.1
    6 Tested up to: 5.5.1
     6Tested up to: 5.7
    77Stable tag: 0.9.9.9.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010WC requires at least: 2.6
    11 WC tested up to: 4.5.2
     11WC tested up to: 5.1.0
    1212This plugin is a E-Transactions payment gateway for WooCommerce 2.x
    1313
     
    2323it adds payment information to the orders details and changes the status of orders (upon reception of an IPN, see below.) and adds payment means on the checkout page.
    2424
    25 This plugin takes information from the order and creates a form containing the details of the payment to be made, including parameters configured in the admin panel of the module that identify the mechant. 
     25This plugin takes information from the order and creates a form containing the details of the payment to be made, including parameters configured in the admin panel of the module that identify the mechant.
    2626
    2727The plugin checks for availability of the E-Transactions platform, through a call to our servers.
     
    5151= My orders are not validated, even though the payment went through ? =
    5252
    53 The oder paid with E-Transactions is only validated upon rectpion of a positive Instant Payment Notification (IPN) this IPN is authenticated with the filter on the IP address, if the IP is somewhow changed, the plugin will give a 500 HTTP error. 
    54 Avoid Maintenance mode, or allow E-Transactions IP to go through (194.2.122.158,195.25.7.166,195.101.99.76). If the WordPress Installation is in maintenance mode, the E-Transactions server will not be able to contact it. 
     53The oder paid with E-Transactions is only validated upon rectpion of a positive Instant Payment Notification (IPN) this IPN is authenticated with the filter on the IP address, if the IP is somewhow changed, the plugin will give a 500 HTTP error.
     54Avoid Maintenance mode, or allow E-Transactions IP to go through (194.2.122.158,195.25.7.166,195.101.99.76). If the WordPress Installation is in maintenance mode, the E-Transactions server will not be able to contact it.
    5555
    5656= Something is not working for me, how can i get help ? =
     
    6868
    6969== Changelog ==
     70= 0.9.9.9.3 =
     71Force 3DSv2 for all cards
     72
     73= 0.9.9.9.2 =
     74Add 3DSv2 support
     75
    7076= 0.9.8.9 =
    7177various fixes and alignments
     
    118124
    119125= 0.9.6.7 =
    120 Changed: 
    121 only rely on the $_SERVER data to check for the IP address: 
     126Changed:
     127only rely on the $_SERVER data to check for the IP address:
    122128this solves the non reception of the IPN  (error 500)
    123129
    124130= 0.9.6.6 =
    125 Second release: 
    126 Fixed: 
     131Second release:
     132Fixed:
    127133-Missing table now created ok.
    128 -"Syntax error: Unexpected token < " message when checking out, 
     134-"Syntax error: Unexpected token < " message when checking out,
    129135-Use of deprecated functions to get pages url: now we use endpoints.
    130136
  • e-transactions-wc/trunk/wc-etransactions.php

    r2391064 r2499400  
    33 * Plugin Name: E-Transactions
    44 * Description: E-Transactions gateway payment plugins for WooCommerce
    5  * Version: 0.9.9.9.1
     5 * Version: 0.9.9.9.3
    66 * Author: E-Transactions
    77 * Author URI: http://www.e-transactions.fr
    88 * Text Domain: wc-etransactions
    9 
    10  *
     9 *
    1110 * @package WordPress
    1211 * @since 0.9.0
    1312 */
     13
    1414// Ensure not called directly
    1515if (!defined('ABSPATH')) {
    16     exit;
     16    exit;
    1717}
    1818
    19     $previousET = (in_array('woocommerce-etransactions/woocommerce-etransactions.php',apply_filters('active_plugins', get_option('active_plugins'))));
    20     if(is_multisite()){
    21         // //Si multisite
    22         $previousET = (array_key_exists('woocommerce-etransactions/woocommerce-etransactions.php',
    23                                                         apply_filters('active_plugins', get_site_option('active_sitewide_plugins'))));
    24     }
    25     if ($previousET) {
    26         die("Une version pr&eacute;c&eacute;dente du plugin E-Transactions est d&eacute;j&agrave; install&eacute;e. veuillez la d&eacute;sactiver avant d'activer celle-ci.");     
    27     }
    28    
    29 function wooCommerceActiveETwp(){
    30         // Makes sure the plugin is defined before trying to use it
    31         if ( !class_exists( 'WC_Payment_Gateway' ) ) {
    32             return false;
    33         }
    34         return true;
     19$previousET = (in_array('woocommerce-etransactions/woocommerce-etransactions.php', apply_filters('active_plugins', get_option('active_plugins'))));
     20if (is_multisite()) {
     21    // Si multisite
     22    $previousET = (array_key_exists('woocommerce-etransactions/woocommerce-etransactions.php', apply_filters('active_plugins', get_site_option('active_sitewide_plugins'))));
    3523}
     24if ($previousET) {
     25    die("Une version pr&eacute;c&eacute;dente du plugin E-Transactions est d&eacute;j&agrave; install&eacute;e. veuillez la d&eacute;sactiver avant d'activer celle-ci.");
     26}
     27
     28function wooCommerceActiveETwp()
     29{
     30    // Makes sure the plugin is defined before trying to use it
     31    if (!class_exists('WC_Payment_Gateway')) {
     32        return false;
     33    }
     34    return true;
     35}
     36
    3637// Ensure WooCommerce is active
     38if (defined('WC_ETRANSACTIONS_PLUGIN')) {
     39    _e('Previous plugin already installed. deactivate the previous one first.', WC_ETRANSACTIONS_PLUGIN);
     40    die(__('Previous plugin already installed. deactivate the previous one first.', WC_ETRANSACTIONS_PLUGIN));
     41}
     42defined('WC_ETRANSACTIONS_PLUGIN') or define('WC_ETRANSACTIONS_PLUGIN', 'wc-etransactions');
     43defined('WC_ETRANSACTIONS_VERSION') or define('WC_ETRANSACTIONS_VERSION', '0.9.9.9.3');
     44defined('WC_ETRANSACTIONS_KEY_PATH') or define('WC_ETRANSACTIONS_KEY_PATH', ABSPATH . '/kek.php');
    3745
     46function wc_etransactions_installation()
     47{
     48    global $wpdb;
     49    $installed_ver = get_option("WC_ETRANSACTIONS_PLUGIN.'_version'");
     50    include_once(ABSPATH . 'wp-admin/includes/plugin.php');
    3851
    39 if(defined('WC_ETRANSACTIONS_PLUGIN')){
    40         _e('Previous plugin already installed. deactivate the previous one first.', WC_ETRANSACTIONS_PLUGIN);
    41         die(__('Previous plugin already installed. deactivate the previous one first.', WC_ETRANSACTIONS_PLUGIN));         
    42 }
    43     defined('WC_ETRANSACTIONS_PLUGIN') or define('WC_ETRANSACTIONS_PLUGIN', 'wc-etransactions');
    44     defined('WC_ETRANSACTIONS_VERSION') or define('WC_ETRANSACTIONS_VERSION', '0.9.9.9.1');
    45     defined('WC_ETRANSACTIONS_KEY_PATH') or define('WC_ETRANSACTIONS_KEY_PATH', ABSPATH . '/kek.php');
     52    if (!wooCommerceActiveETwp()) {
     53        _e('WooCommerce must be activated', WC_ETRANSACTIONS_PLUGIN);
     54        die();
     55    }
     56    if ($installed_ver != WC_ETRANSACTIONS_VERSION) {
     57        $tableName = $wpdb->prefix.'wc_etransactions_payment';
     58        $sql = "CREATE TABLE $tableName (
     59             id int not null auto_increment,
     60             order_id bigint not null,
     61             type enum('capture', 'first_payment', 'second_payment', 'third_payment') not null,
     62             data varchar(2048) not null,
     63             KEY order_id (order_id),
     64             PRIMARY KEY  (id))";
    4665
    47 function wc_etransactions_installation() {
    48     global $wpdb;
    49     $installed_ver = get_option( "WC_ETRANSACTIONS_PLUGIN.'_version'" );
    50    
    51     include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    52     if(!wooCommerceActiveETwp()) {
    53         _e('WooCommerce must be activated', WC_ETRANSACTIONS_PLUGIN);
    54         die();
    55     }
    56     if ( $installed_ver != WC_ETRANSACTIONS_VERSION ) {
    57         $tableName = $wpdb->prefix.'wc_etransactions_payment';
    58         $sql = "CREATE TABLE $tableName (
    59              id int not null auto_increment,
    60              order_id bigint not null,
    61              type enum('capture', 'first_payment', 'second_payment', 'third_payment') not null,
    62              data varchar(2048) not null,
    63              KEY order_id (order_id),
    64              PRIMARY KEY  (id))";
     66        require_once(ABSPATH.'wp-admin/includes/upgrade.php');
     67        dbDelta($sql);
     68        update_option(WC_ETRANSACTIONS_PLUGIN.'_version', WC_ETRANSACTIONS_VERSION);
     69    }
     70}
    6571
    66         require_once(ABSPATH.'wp-admin/includes/upgrade.php');
     72function wc_etransactions_initialization()
     73{
     74    if (!wooCommerceActiveETwp()) {
     75        return ("Woocommerce not Active") ;
     76    }
     77    $class = 'WC_Etransactions_Abstract_Gateway';
    6778
    68         dbDelta( $sql );
     79    if (!class_exists($class)) {
     80        require_once(dirname(__FILE__).'/class/wc-etransactions-config.php');
     81        require_once(dirname(__FILE__).'/class/wc-etransactions-iso4217currency.php');
     82        require_once(dirname(__FILE__).'/class/wc-etransactions-iso3166-country.php');
     83        require_once(dirname(__FILE__).'/class/wc-etransactions.php');
     84        require_once(dirname(__FILE__).'/class/wc-etransactions-abstract-gateway.php');
     85        require_once(dirname(__FILE__).'/class/wc-etransactions-standard-gateway.php');
     86        require_once(dirname(__FILE__).'/class/wc-etransactions-threetime-gateway.php');
     87        require_once(dirname(__FILE__).'/class/wc-etransactions-encrypt.php');
     88    }
    6989
    70         update_option(WC_ETRANSACTIONS_PLUGIN.'_version', WC_ETRANSACTIONS_VERSION);
    71     }
    72    
    73 }
    74 function wc_etransactions_initialization() {
    75     if(!wooCommerceActiveETwp()){
    76         return ("Woocommerce not Active") ;
    77     }
    78     $class = 'WC_Etransactions_Abstract_Gateway';
     90    load_plugin_textdomain(WC_ETRANSACTIONS_PLUGIN, false, dirname(plugin_basename(__FILE__)).'/lang/');
    7991
    80     if (!class_exists($class)) {
    81         require_once(dirname(__FILE__).'/class/wc-etransactions-config.php');
    82         require_once(dirname(__FILE__).'/class/wc-etransactions-iso4217currency.php');
    83         require_once(dirname(__FILE__).'/class/wc-etransactions.php');
    84         require_once(dirname(__FILE__).'/class/wc-etransactions-abstract-gateway.php');
    85         require_once(dirname(__FILE__).'/class/wc-etransactions-standard-gateway.php');
    86         require_once(dirname(__FILE__).'/class/wc-etransactions-threetime-gateway.php');
    87         require_once(dirname(__FILE__).'/class/wc-etransactions-encrypt.php');
    88     }
     92    $crypto = new ETransactionsEncrypt();
     93    if (!file_exists(WC_ETRANSACTIONS_KEY_PATH)) {
     94        $crypto->generateKey();
     95    }
    8996
    90     load_plugin_textdomain(WC_ETRANSACTIONS_PLUGIN, false, dirname(plugin_basename(__FILE__)).'/lang/');
    91 
    92     $crypto = new ETransactionsEncrypt();
    93     if(!file_exists(WC_ETRANSACTIONS_KEY_PATH))$crypto->generateKey();
    94    
    95     if ( get_site_option( WC_ETRANSACTIONS_PLUGIN.'_version' ) != WC_ETRANSACTIONS_VERSION ) {
     97    if (get_site_option(WC_ETRANSACTIONS_PLUGIN.'_version') != WC_ETRANSACTIONS_VERSION) {
    9698        wc_etransactions_installation();
    9799    }
    98100}
    99101
    100 function wc_etransactions_register(array $methods) {
    101     $methods[] = 'WC_EStdGw';
    102     $methods[] = 'WC_E3Gw';
    103     return $methods;
     102function wc_etransactions_register(array $methods)
     103{
     104    $methods[] = 'WC_EStdGw';
     105    $methods[] = 'WC_E3Gw';
     106    return $methods;
    104107}
    105108
     
    108111add_filter('woocommerce_payment_gateways', 'wc_etransactions_register');
    109112
    110 function wc_etransactions_show_details(WC_Order $order) {
    111     $method = get_post_meta($order->get_id(), '_payment_method', true);
    112     switch ($method) {
    113         case 'etransactions_std':
    114             $method = new WC_EStdGw();
    115             $method->showDetails($order);
    116             break;
    117         case 'etransactions_3x':
    118             $method = new WC_E3Gw();
    119             $method->showDetails($order);
    120             break;
    121     }
     113function wc_etransactions_show_details(WC_Order $order)
     114{
     115    $method = get_post_meta($order->get_id(), '_payment_method', true);
     116    switch ($method) {
     117        case 'etransactions_std':
     118            $method = new WC_EStdGw();
     119            $method->showDetails($order);
     120            break;
     121        case 'etransactions_3x':
     122            $method = new WC_E3Gw();
     123            $method->showDetails($order);
     124            break;
     125    }
    122126}
    123127
    124128add_action('woocommerce_admin_order_data_after_billing_address', 'wc_etransactions_show_details');
    125129
    126 function hmac_admin_notice(){
    127    
    128     if(wooCommerceActiveETwp()){
    129         $temp = new WC_EStdGw();
    130         $plugin_data = get_plugin_data( __FILE__ );
    131         $plugin_name = $plugin_data['Name'];
    132         if ( !$temp->checkCrypto() ) {
    133         echo "<div class='notice notice-error  is-dismissible'>
    134               <p><strong>/!\ Attention ! plugin ".$plugin_name." : </strong>".__('HMAC key cannot be decrypted please re-enter or reinitialise it.', WC_ETRANSACTIONS_PLUGIN)."</p>
    135              </div>";
    136         }
    137     }else{
    138         echo "<div class='notice notice-error  is-dismissible'>
    139               <p><strong>/!\ Attention ! plugin E-Transactions : </strong>".__('Woocommerce is not active !.', 'wc-etransactions')."</p>
    140              </div>";
    141        
    142     }
     130function hmac_admin_notice()
     131{
     132    if (wooCommerceActiveETwp()) {
     133        $temp = new WC_EStdGw();
     134        $plugin_data = get_plugin_data(__FILE__);
     135        $plugin_name = $plugin_data['Name'];
     136        if (!$temp->checkCrypto()) {
     137            echo "<div class='notice notice-error  is-dismissible'>
     138                <p><strong>/!\ Attention ! plugin ".$plugin_name." : </strong>".__('HMAC key cannot be decrypted please re-enter or reinitialise it.', WC_ETRANSACTIONS_PLUGIN)."</p>
     139                </div>";
     140        }
     141    } else {
     142        echo "<div class='notice notice-error  is-dismissible'>
     143              <p><strong>/!\ Attention ! plugin E-Transactions : </strong>".__('Woocommerce is not active !', 'wc-etransactions')."</p>
     144             </div>";
     145    }
    143146}
    144147add_action('admin_notices', 'hmac_admin_notice');
Note: See TracChangeset for help on using the changeset viewer.