Changeset 2499400
- Timestamp:
- 03/19/2021 01:08:22 PM (5 years ago)
- Location:
- e-transactions-wc/trunk
- Files:
-
- 1 added
- 12 edited
-
class/wc-etransactions-abstract-gateway.php (modified) (23 diffs)
-
class/wc-etransactions-config.php (modified) (1 diff)
-
class/wc-etransactions-encrypt.php (modified) (2 diffs)
-
class/wc-etransactions-iso3166-country.php (added)
-
class/wc-etransactions-iso4217currency.php (modified) (1 diff)
-
class/wc-etransactions-standard-gateway.php (modified) (1 diff)
-
class/wc-etransactions-threetime-gateway.php (modified) (1 diff)
-
class/wc-etransactions.php (modified) (3 diffs)
-
images/logo.png (modified) (previous)
-
lang/wc-etransactions-fr_FR.mo (modified) (previous)
-
lang/wc-etransactions-fr_FR.po (modified) (10 diffs)
-
readme.txt (modified) (5 diffs)
-
wc-etransactions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
e-transactions-wc/trunk/class/wc-etransactions-abstract-gateway.php
r2391064 r2499400 1 1 <?php 2 2 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 */ 11 abstract class WC_Etransactions_Abstract_Gateway extends WC_Payment_Gateway 12 { 5 13 protected $_config; 6 14 protected $_etransactions; 7 15 private $logger; 8 16 9 public function __construct() { 17 public function __construct() 18 { 10 19 // Logger for debug if needed 11 20 if (WC()->debug === 'yes') { … … 25 34 // $this->description = $this->_config->getDescription(); 26 35 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 31 40 // Actions 32 41 add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); … … 41 50 * @return void 42 51 */ 43 public function process_admin_options() { 52 public function process_admin_options() 53 { 44 54 $crypto = new ETransactionsEncrypt(); 45 55 if (!isset($_POST['crypted'])) { 46 if (isset($_POST["woocommerce_etransactions_std_hmackey"])) 56 if (isset($_POST["woocommerce_etransactions_std_hmackey"])) { 47 57 $_POST["woocommerce_etransactions_std_hmackey"] = $crypto->encrypt($_POST["woocommerce_etransactions_std_hmackey"]); 48 else58 } else { 49 59 $_POST["woocommerce_etransactions_3x_hmackey"] = $crypto->encrypt($_POST["woocommerce_etransactions_3x_hmackey"]); 60 } 50 61 $_POST['crypted'] = true; 51 62 } 63 52 64 parent::process_admin_options(); 53 65 } 54 66 55 public function admin_options() {56 67 public function admin_options() 68 { 57 69 $crypt = new ETransactionsEncrypt(); 58 70 $this->settings['hmackey'] = $crypt->decrypt($this->settings['hmackey']); … … 64 76 * Initialise Gateway Settings Form Fields 65 77 */ 66 public function init_form_fields() { 78 public function init_form_fields() 79 { 67 80 $defaults = new WC_Etransactions_Config(array(), $this->defaultTitle, $this->defaultDesc); 68 81 $defaults = $defaults->getDefaults(); … … 80 93 'default' => __($defaults['title'], WC_ETRANSACTIONS_PLUGIN), 81 94 ); 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 } 90 102 $this->form_fields['icon'] = array( 91 103 'title' => __('Icon file', WC_ETRANSACTIONS_PLUGIN), 92 104 '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/'), 94 106 'default' => __($defaults['icon'], WC_ETRANSACTIONS_PLUGIN), 95 'options' => $fileList,107 'options' => $fileList, 96 108 ); 97 109 $this->form_fields['description'] = array( … … 124 136 'default' => $defaults['amount'] 125 137 ); 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 );148 138 $this->form_fields['etransactions_account'] = array( 149 139 'title' => __('E-Transactions account', WC_ETRANSACTIONS_PLUGIN), … … 189 179 ); 190 180 $this->form_fields['ips'] = array( 191 'title' => __('Allowed IPs ', WC_ETRANSACTIONS_PLUGIN),181 'title' => __('Allowed IPs', WC_ETRANSACTIONS_PLUGIN), 192 182 'type' => 'text', 193 183 'description' => __('A coma separated list of E-Transactions IPs.', WC_ETRANSACTIONS_PLUGIN), … … 208 198 * @return bool 209 199 */ 210 public function is_available() { 200 public function is_available() 201 { 211 202 if (!parent::is_available()) { 212 203 return false; … … 217 208 } 218 209 $total = WC()->cart->total; 210 219 211 return $total >= $minimal; 220 212 } … … 226 218 * @return array TODO 227 219 */ 228 public function process_payment($orderId) { 220 public function process_payment($orderId) 221 { 229 222 $order = wc_get_order($orderId); 230 223 … … 238 231 } 239 232 240 public function receipt_page($orderId) { 233 public function receipt_page($orderId) 234 { 241 235 $order = wc_get_order($orderId); 242 236 … … 269 263 ?> 270 264 <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) : ?> 272 266 <p> 273 267 <?php echo __('This is a debug view. Click continue to be redirected to E-Transactions payment page.', WC_ETRANSACTIONS_PLUGIN); ?> 274 268 </p> 275 <?php else : ?>269 <?php else : ?> 276 270 <p> 277 271 <?php echo __('You will be redirected to the E-Transactions payment page. If not, please use the button bellow.', WC_ETRANSACTIONS_PLUGIN); ?> … … 286 280 <?php 287 281 $type = $debug ? 'text' : 'hidden'; 288 foreach ($params as $name => $value) :282 foreach ($params as $name => $value) { 289 283 $name = esc_attr($name); 290 284 $value = esc_attr($value); 291 if ($debug) :285 if ($debug) { 292 286 echo '<p><label for="' . $name . '">' . $name . '</label>'; 293 endif;287 } 294 288 echo '<input type="' . $type . '" id="' . $name . '" name="' . $name . '" value="' . $value . '" />'; 295 if ($debug) :289 if ($debug) { 296 290 echo '</p>'; 297 endif;298 endforeach;291 } 292 } 299 293 ?> 300 294 </form> … … 302 296 } 303 297 304 public function api_call() { 298 public function api_call() 299 { 305 300 if (!isset($_GET['status'])) { 306 301 header('Status: 404 Not found', true, 404); … … 331 326 } 332 327 333 public function on_payment_failed() { 328 public function on_payment_failed() 329 { 334 330 try { 335 331 $params = $this->_etransactions->getParams(); … … 342 338 $message = __('Payment refused by E-Transactions', WC_ETRANSACTIONS_PLUGIN); 343 339 $this->_etransactions->addCartErrorMessage($message); 344 $order->update_status('failed', $message);340 $order->update_status('failed', $message); 345 341 } 346 342 } catch (Exception $e) { … … 351 347 } 352 348 353 public function on_payment_canceled() { 349 public function on_payment_canceled() 350 { 354 351 try { 355 352 $params = $this->_etransactions->getParams(); … … 361 358 $message = __('Payment canceled', WC_ETRANSACTIONS_PLUGIN); 362 359 $this->_etransactions->addCartErrorMessage($message); 363 $order->update_status('failed', $message);360 $order->update_status('failed', $message); 364 361 } 365 362 } catch (Exception $e) { … … 370 367 } 371 368 372 public function on_payment_succeed() { 369 public function on_payment_succeed() 370 { 373 371 try { 374 372 $params = $this->_etransactions->getParams(); … … 389 387 } 390 388 391 public function on_ipn() { 389 public function on_ipn() 390 { 392 391 global $wpdb; 393 392 394 393 try { 395 396 394 $params = $this->_etransactions->getParams(); 397 395 … … 403 401 404 402 // 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 */ 415 414 // Check required parameters 416 415 $requiredParams = array('amount', 'transaction', 'error', 'reference', 'sign', 'date', 'time'); … … 439 438 $order->payment_complete($params['transaction']); 440 439 $this->_etransactions->addOrderPayment($order, 'first_payment', $params); 441 } else if (!in_array('second_payment', $done)) {440 } elseif (!in_array('second_payment', $done)) { 442 441 $this->_etransactions->addOrderNote($order, __('Second payment was captured by E-Transactions.', WC_ETRANSACTIONS_PLUGIN)); 443 442 $this->_etransactions->addOrderPayment($order, 'second_payment', $params); 444 } else if (!in_array('third_payment', $done)) {443 } elseif (!in_array('third_payment', $done)) { 445 444 $this->_etransactions->addOrderNote($order, __('Third payment was captured by E-Transactions.', WC_ETRANSACTIONS_PLUGIN)); 446 445 $this->_etransactions->addOrderPayment($order, 'third_payment', $params); … … 458 457 throw new Exception($message); 459 458 } 460 } 461 462 // Payment refused 463 else { 459 } else { 460 // Payment refused 464 461 $message = __('Payment was refused by E-Transactions (%s).', WC_ETRANSACTIONS_PLUGIN); 465 462 $error = $this->_etransactions->toErrorMessage($params['error']); 466 463 $message = sprintf($message, $error); 467 $this->_etransactions->addOrderPayment($order, 'failed_payment', $params);464 $this->_etransactions->addOrderPayment($order, 'failed_payment', $params); 468 465 $this->_etransactions->addOrderNote($order, $message); 469 466 } 470 467 } 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 { 478 476 wp_redirect(WC()->cart->get_cart_url()); 479 477 die(); 480 478 } 481 482 public function checkCrypto(){ 483 $crypt = new ETransactionsEncrypt(); 479 480 public function checkCrypto() 481 { 482 $crypt = new ETransactionsEncrypt(); 484 483 return $crypt->decrypt($this->settings['hmackey']); 485 }486 487 public abstractfunction showDetails($orderId);484 } 485 486 abstract public function showDetails($orderId); 488 487 } -
e-transactions-wc/trunk/class/wc-etransactions-config.php
r2240388 r2499400 1 1 <?php 2 2 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 */ 8 class 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 ); 19 23 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 } 25 30 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 } 35 41 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 } 39 47 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 } 44 52 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 } 49 57 50 public function getAllowedIps() { 51 return explode(',', $this->_getOption('ips')); 52 } 58 public function getDelay() 59 { 60 return (int)$this->_getOption('delay'); 61 } 53 62 54 public function getDefaults() { 55 return $this->_defaults; 56 } 63 public function getDescription() 64 { 65 return $this->_getOption('description'); 66 } 57 67 58 public function getDelay() { 59 return (int)$this->_getOption('delay'); 60 } 68 public function getHmacAlgo() 69 { 70 return 'SHA512'; 71 } 61 72 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 } 65 78 66 public function getHmacAlgo() { 67 return 'SHA512'; 68 } 79 public function getIdentifier() 80 { 81 return $this->_getOption('identifier'); 82 } 69 83 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 } 74 88 75 public function getIdentifier() { 76 return $this->_getOption('identifier'); 77 } 89 public function getSite() 90 { 91 return $this->_getOption('site'); 92 } 78 93 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 } 82 101 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 } 86 108 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 } 93 116 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 } 99 121 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 } 106 126 107 public function getTitle() { 108 return $this->_getOption('title'); 109 } 127 public function isDebug() 128 { 129 return $this->_getOption('debug') === 'yes'; 130 } 110 131 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 } 122 136 } -
e-transactions-wc/trunk/class/wc-etransactions-encrypt.php
r2239652 r2499400 9 9 * Software License (OSL-3.0) that is available through the world-wide-web 10 10 * 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 12 12 * to obtain it through the web, please send a note to 13 13 * support@e-transactions.fr so we can mail you a copy immediately. … … 20 20 * */ 21 21 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); 22 class 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 } 37 40 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 } 97 88 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 } 111 105 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); 112 118 113 // Prepare key114 $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 vector120 $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(); 121 127 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 } 158 130 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 } 161 155 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 } 162 167 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); 174 170 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 } 177 186 } -
e-transactions-wc/trunk/class/wc-etransactions-iso4217currency.php
r2239559 r2499400 1 1 <?php 2 2 3 class WC_Etransactions_Iso4217Currency { 3 /** 4 * E-Transactions - ISO 4217 Currency class. 5 * 6 * @class WC_Etransactions_Iso4217Currency 7 */ 8 class 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 ); 4 189 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 } 191 197 } -
e-transactions-wc/trunk/class/wc-etransactions-standard-gateway.php
r2257349 r2499400 1 1 <?php 2 2 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 */ 9 class WC_EStdGw extends WC_Etransactions_Abstract_Gateway 10 { 11 protected $defaultTitle = 'E-Transactions payment'; 12 protected $defaultDesc = 'xxxx'; 13 protected $type = 'standard'; 7 14 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'); 15 23 16 parent::__construct(); 17 } 18 private function _showDetailRow($label, $value) { 19 return '<strong>'.$label.'</strong> '.__($value, WC_ETRANSACTIONS_PLUGIN); 20 } 24 parent::__construct(); 25 } 21 26 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 } 25 31 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'); 43 36 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 } 48 40 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 } 49 71 } -
e-transactions-wc/trunk/class/wc-etransactions-threetime-gateway.php
r2391064 r2499400 1 1 <?php 2 2 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 */ 11 class WC_E3Gw extends WC_Etransactions_Abstract_Gateway 12 { 13 protected $defaultTitle = 'E-Transactions 3 times payment'; 14 protected $defaultDesc = 'xxxx'; 15 protected $type = 'threetime'; 7 16 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'; 15 25 16 parent::__construct();17 }26 parent::__construct(); 27 } 18 28 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 } 22 33 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 } 41 45 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 } 55 50 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); 68 53 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 } 72 56 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'); 81 61 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 } 90 65 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 } 94 75 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 } 99 125 } 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 */ 135 class 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 } 107 145 } -
e-transactions-wc/trunk/class/wc-etransactions.php
r2239559 r2499400 1 1 <?php 2 2 3 class WC_Etransactions { 4 private $_config; 5 private $_currencyDecimals = array( 3 /** 4 * E-Transactions - Main class. 5 * 6 * @class WC_Etransactions 7 */ 8 class WC_Etransactions 9 { 10 private $_config; 11 private $_currencyDecimals = array( 6 12 '008' => 2, 7 13 '012' => 2, … … 174 180 '997' => 2, 175 181 '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'); 440 566 if (empty($data)) { 441 567 $data = $_SERVER['QUERY_STRING']; 442 568 } 443 569 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 } 553 681 554 682 public function toErrorMessage($code) 555 {683 { 556 684 if (isset($this->_errorCode[$code])) { 557 685 return $this->_errorCode[$code]; … … 561 689 } 562 690 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 } 591 720 } -
e-transactions-wc/trunk/lang/wc-etransactions-fr_FR.po
r2240388 r2499400 2 2 msgstr "" 3 3 "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" 6 6 "Last-Translator: Jérôme Cintas <jerome.cintas@verifonecom>\n" 7 7 "Language-Team: BM Services <wordpress@e-transactions.fr>\n" 8 "Language: fr \n"8 "Language: fr_FR\n" 9 9 "MIME-Version: 1.0\n" 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 2. 2.3\n"12 "X-Generator: Poedit 2.4.1\n" 13 13 "X-Poedit-Basepath: ..\n" 14 14 "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" 15 17 "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" 17 21 "X-Poedit-SearchPath-0: .\n" 18 19 #: class/wc-etransactions-abstract-gateway.php:71 20 #: class/wc-etransactions-abstract-gateway.php: 13122 "X-Poedit-SearchPathExcluded-0: *.min.js\n" 23 24 #: class/wc-etransactions-abstract-gateway.php:84 21 25 msgid "Enable/Disable" 22 26 msgstr "Actif/Inactif" 23 27 24 #: class/wc-etransactions-abstract-gateway.php: 7328 #: class/wc-etransactions-abstract-gateway.php:86 25 29 msgid "Enable E-Transactions Payment" 26 30 msgstr "Activer le paiement par E-Transactions" 27 31 28 #: class/wc-etransactions-abstract-gateway.php: 7732 #: class/wc-etransactions-abstract-gateway.php:90 29 33 msgid "Title" 30 34 msgstr "Titre" 31 35 32 #: class/wc-etransactions-abstract-gateway.php: 7936 #: class/wc-etransactions-abstract-gateway.php:92 33 37 msgid "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: 9138 msgstr "Titre visible par le client lors d'une commande." 39 40 #: class/wc-etransactions-abstract-gateway.php:103 37 41 msgid "Icon file" 38 42 msgstr "Fichier icone" 39 43 40 #: class/wc-etransactions-abstract-gateway.php: 9344 #: class/wc-etransactions-abstract-gateway.php:105 41 45 msgid "Icon file to be displayed to customers. file are located in: " 42 46 msgstr "" 43 47 "Fichier d'icône à afficher au client. les fichiers sont dans le répertoire: " 44 48 45 #: class/wc-etransactions-abstract-gateway.php: 9849 #: class/wc-etransactions-abstract-gateway.php:110 46 50 msgid "Description" 47 51 msgstr "Description" 48 52 49 #: class/wc-etransactions-abstract-gateway.php:1 0053 #: class/wc-etransactions-abstract-gateway.php:112 50 54 msgid "Payment method description that the customer will see on your checkout." 51 55 msgstr "" 52 56 "Description de la méthode de paiement . Visible par le client lors d'une " 53 "commande "54 55 #: class/wc-etransactions-abstract-gateway.php:1 0557 "commande." 58 59 #: class/wc-etransactions-abstract-gateway.php:117 56 60 msgid "Delay" 57 61 msgstr "Délai" 58 62 59 #: class/wc-etransactions-abstract-gateway.php:1 0863 #: class/wc-etransactions-abstract-gateway.php:120 60 64 msgid "Immediate" 61 65 msgstr "Immédiat" 62 66 63 #: class/wc-etransactions-abstract-gateway.php:1 0967 #: class/wc-etransactions-abstract-gateway.php:121 64 68 msgid "1 day" 65 69 msgstr "1 jour" 66 70 67 #: class/wc-etransactions-abstract-gateway.php:1 1071 #: class/wc-etransactions-abstract-gateway.php:122 68 72 msgid "2 days" 69 73 msgstr "2 jours" 70 74 71 #: class/wc-etransactions-abstract-gateway.php:1 1175 #: class/wc-etransactions-abstract-gateway.php:123 72 76 msgid "3 days" 73 77 msgstr "3 jours" 74 78 75 #: class/wc-etransactions-abstract-gateway.php:1 1279 #: class/wc-etransactions-abstract-gateway.php:124 76 80 msgid "4 days" 77 81 msgstr "4 jours" 78 82 79 #: class/wc-etransactions-abstract-gateway.php:1 1383 #: class/wc-etransactions-abstract-gateway.php:125 80 84 msgid "5 days" 81 85 msgstr "5 jours" 82 86 83 #: class/wc-etransactions-abstract-gateway.php:1 1487 #: class/wc-etransactions-abstract-gateway.php:126 84 88 msgid "6 days" 85 89 msgstr "6 jours" 86 90 87 #: class/wc-etransactions-abstract-gateway.php:1 1591 #: class/wc-etransactions-abstract-gateway.php:127 88 92 msgid "7 days" 89 93 msgstr "7 jours" 90 94 91 #: class/wc-etransactions-abstract-gateway.php:121 92 #: class/wc-etransactions-abstract-gateway.php:143 95 #: class/wc-etransactions-abstract-gateway.php:133 93 96 msgid "Minimal amount" 94 97 msgstr "Montant minimal" 95 98 96 #: class/wc-etransactions-abstract-gateway.php:1 2399 #: class/wc-etransactions-abstract-gateway.php:135 97 100 msgid "" 98 101 "Enable this payment method for order with amount greater or equals to this " … … 103 106 "condition)" 104 107 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 109 msgid "Version" 110 msgstr "Version" 111 112 #: class/wc-etransactions-abstract-gateway.php:153 141 113 msgid "E-Transactions account" 142 114 msgstr "Compte E-Transactions" 143 115 144 #: class/wc-etransactions-abstract-gateway.php:15 3116 #: class/wc-etransactions-abstract-gateway.php:157 145 117 msgid "Site number" 146 118 msgstr "Numéro du site" 147 119 148 #: class/wc-etransactions-abstract-gateway.php:15 5120 #: class/wc-etransactions-abstract-gateway.php:159 149 121 msgid "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:1 59122 msgstr "Le numéro du site vous est fourni par E-Transactions." 123 124 #: class/wc-etransactions-abstract-gateway.php:163 153 125 msgid "Rank number" 154 126 msgstr "Rang" 155 127 156 #: class/wc-etransactions-abstract-gateway.php:16 1128 #: class/wc-etransactions-abstract-gateway.php:165 157 129 msgid "Rank number provided by E-Transactions (two last digits)." 158 130 msgstr "Numéro de rang fourni par E-Transactions (deux derniers chiffres)." 159 131 160 #: class/wc-etransactions-abstract-gateway.php:16 5132 #: class/wc-etransactions-abstract-gateway.php:169 161 133 msgid "Login" 162 134 msgstr "Identifiant" 163 135 164 #: class/wc-etransactions-abstract-gateway.php:1 67136 #: class/wc-etransactions-abstract-gateway.php:171 165 137 msgid "Internal login provided by E-Transactions." 166 msgstr "Votre identifiant vous est fourni par E-Transactions "167 168 #: class/wc-etransactions-abstract-gateway.php:17 1138 msgstr "Votre identifiant vous est fourni par E-Transactions." 139 140 #: class/wc-etransactions-abstract-gateway.php:175 169 141 msgid "HMAC" 170 142 msgstr "HMAC" 171 143 172 #: class/wc-etransactions-abstract-gateway.php:17 3144 #: class/wc-etransactions-abstract-gateway.php:177 173 145 msgid "Secrete HMAC key to create using the E-Transactions interface." 174 146 msgstr "" … … 176 148 "Transactions." 177 149 178 #: class/wc-etransactions-abstract-gateway.php:1 77150 #: class/wc-etransactions-abstract-gateway.php:181 179 151 msgid "Environment" 180 152 msgstr "Environnement" 181 153 182 #: class/wc-etransactions-abstract-gateway.php:1 79154 #: class/wc-etransactions-abstract-gateway.php:183 183 155 msgid "In test mode your payments will not be sent to the bank." 184 156 msgstr "En mode test, vos paiements ne seront pas envoyé à la banque." 185 157 186 #: class/wc-etransactions-abstract-gateway.php:18 1158 #: class/wc-etransactions-abstract-gateway.php:185 187 159 msgid "Production" 188 160 msgstr "Production" 189 161 190 #: class/wc-etransactions-abstract-gateway.php:18 2162 #: class/wc-etransactions-abstract-gateway.php:186 191 163 msgid "Test" 192 164 msgstr "Test" 193 165 194 #: class/wc-etransactions-abstract-gateway.php:1 87166 #: class/wc-etransactions-abstract-gateway.php:191 195 167 msgid "Technical settings" 196 168 msgstr "Configuration technique" 197 169 198 #: class/wc-etransactions-abstract-gateway.php:19 1199 msgid "Allowed IPs "170 #: class/wc-etransactions-abstract-gateway.php:195 171 msgid "Allowed IPs" 200 172 msgstr "Adresses IP autorisées" 201 173 202 #: class/wc-etransactions-abstract-gateway.php:19 3174 #: class/wc-etransactions-abstract-gateway.php:197 203 175 msgid "A coma separated list of E-Transactions IPs." 204 176 msgstr "" … … 206 178 "réception des Notifications Instantanées de Paiement." 207 179 208 #: class/wc-etransactions-abstract-gateway.php: 197180 #: class/wc-etransactions-abstract-gateway.php:201 209 181 msgid "Debug" 210 182 msgstr "Debug" 211 183 212 #: class/wc-etransactions-abstract-gateway.php: 199184 #: class/wc-etransactions-abstract-gateway.php:203 213 185 msgid "Enable some debugging information" 214 186 msgstr "Activer les informations de debuggage" 215 187 216 #: class/wc-etransactions-abstract-gateway.php:23 1188 #: class/wc-etransactions-abstract-gateway.php:238 217 189 msgid "Customer is redirected to E-Transactions payment page" 218 190 msgstr "Le client est redirigé vers la pages de paiement etransactions" 219 191 220 #: class/wc-etransactions-abstract-gateway.php:2 65192 #: class/wc-etransactions-abstract-gateway.php:273 221 193 msgid "Back..." 222 194 msgstr "Retour..." 223 195 224 #: class/wc-etransactions-abstract-gateway.php:2 73196 #: class/wc-etransactions-abstract-gateway.php:281 225 197 msgid "" 226 198 "This is a debug view. Click continue to be redirected to E-Transactions " … … 230 202 "la page de paiement E-Transactions." 231 203 232 #: class/wc-etransactions-abstract-gateway.php:2 77204 #: class/wc-etransactions-abstract-gateway.php:285 233 205 msgid "" 234 206 "You will be redirected to the E-Transactions payment page. If not, please " … … 238 210 "pas le cas, merci d'utiliser le bouton ci dessous." 239 211 240 #: class/wc-etransactions-abstract-gateway.php:2 85212 #: class/wc-etransactions-abstract-gateway.php:293 241 213 msgid "Continue..." 242 214 msgstr "Continuer..." 243 215 244 #: class/wc-etransactions-abstract-gateway.php:3 39245 #: class/wc-etransactions-abstract-gateway.php:3 75216 #: class/wc-etransactions-abstract-gateway.php:349 217 #: class/wc-etransactions-abstract-gateway.php:389 246 218 msgid "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:3 40250 #: class/wc-etransactions-abstract-gateway.php:3 42219 msgstr "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 251 223 msgid "Payment refused by E-Transactions" 252 224 msgstr "Le paiement a été refusé par E-Transactions" 253 225 254 #: class/wc-etransactions-abstract-gateway.php:3 58226 #: class/wc-etransactions-abstract-gateway.php:370 255 227 msgid "Payment was canceled by user on E-Transactions payment page." 256 228 msgstr "" … … 258 230 "Transactions." 259 231 260 #: class/wc-etransactions-abstract-gateway.php:3 60232 #: class/wc-etransactions-abstract-gateway.php:372 261 233 msgid "Payment canceled" 262 234 msgstr "Le paiement a été annulé" 263 235 264 #: class/wc-etransactions-abstract-gateway.php:4 17236 #: class/wc-etransactions-abstract-gateway.php:432 265 237 #, php-format 266 238 msgid "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:4 27270 #: class/wc-etransactions-abstract-gateway.php:4 36239 msgstr "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 271 243 msgid "Payment was authorized and captured by E-Transactions." 272 244 msgstr "Paiement autorisé et capturé par E-Transactions." 273 245 274 #: class/wc-etransactions-abstract-gateway.php:4 40246 #: class/wc-etransactions-abstract-gateway.php:455 275 247 msgid "Second payment was captured by E-Transactions." 276 248 msgstr "Deuxième paiement capturé par E-Transactions." 277 249 278 #: class/wc-etransactions-abstract-gateway.php:4 43250 #: class/wc-etransactions-abstract-gateway.php:458 279 251 msgid "Third payment was captured by E-Transactions." 280 252 msgstr "Troisième paiement capturé par E-Transactions." 281 253 282 #: class/wc-etransactions-abstract-gateway.php:4 46254 #: class/wc-etransactions-abstract-gateway.php:461 283 255 msgid "Invalid three-time payment status" 284 256 msgstr "Statut du paiement en trois fois non valide" 285 257 286 #: class/wc-etransactions-abstract-gateway.php:4 53287 #: class/wc-etransactions.php:3 03258 #: class/wc-etransactions-abstract-gateway.php:468 259 #: class/wc-etransactions.php:314 288 260 #, php-format 289 261 msgid "Unexpected type %s" 290 262 msgstr "Type %s inattendu" 291 263 292 #: class/wc-etransactions-abstract-gateway.php:4 62264 #: class/wc-etransactions-abstract-gateway.php:475 293 265 #, php-format 294 266 msgid "Payment was refused by E-Transactions (%s)." 295 267 msgstr "Paiement refusé par E-Transactions (%s)." 296 268 297 #: class/wc-etransactions-encrypt.php:6 0 class/wc-etransactions-encrypt.php:76269 #: class/wc-etransactions-encrypt.php:65 class/wc-etransactions-encrypt.php:81 298 270 msgid "" 299 271 "For some reason, the key has just been generated. please reenter the HMAC " … … 303 275 "clé HMAC pour qu'elle soit cryptée." 304 276 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 306 280 msgid "E-Transactions" 307 281 msgstr "E-Transactions" 308 282 309 #: class/wc-etransactions-standard-gateway.php: 29310 #: class/wc-etransactions-threetime-gateway.php: 57283 #: class/wc-etransactions-standard-gateway.php:43 284 #: class/wc-etransactions-threetime-gateway.php:77 311 285 msgid "Reference:" 312 msgstr "Référence "313 314 #: class/wc-etransactions-standard-gateway.php: 31315 #: class/wc-etransactions-threetime-gateway.php: 59286 msgstr "Référence:" 287 288 #: class/wc-etransactions-standard-gateway.php:45 289 #: class/wc-etransactions-threetime-gateway.php:79 316 290 msgid "Country of IP:" 317 291 msgstr "Pays de l'IP:" 318 292 319 #: class/wc-etransactions-standard-gateway.php: 33320 #: class/wc-etransactions-threetime-gateway.php: 61293 #: class/wc-etransactions-standard-gateway.php:47 294 #: class/wc-etransactions-threetime-gateway.php:81 321 295 msgid "Processing date:" 322 296 msgstr "Date de traitement:" 323 297 324 #: class/wc-etransactions-standard-gateway.php: 35325 #: class/wc-etransactions-threetime-gateway.php: 63298 #: class/wc-etransactions-standard-gateway.php:49 299 #: class/wc-etransactions-threetime-gateway.php:83 326 300 msgid "Card numbers:" 327 301 msgstr "Numéros de la carte:" 328 302 329 #: class/wc-etransactions-standard-gateway.php: 38330 #: class/wc-etransactions-threetime-gateway.php: 66303 #: class/wc-etransactions-standard-gateway.php:52 304 #: class/wc-etransactions-threetime-gateway.php:86 331 305 msgid "Validity date:" 332 306 msgstr "Date de validité:" 333 307 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 310 msgid "3DS version:" 311 msgstr "Version 3DS:" 312 313 #: class/wc-etransactions-standard-gateway.php:64 314 #: class/wc-etransactions-threetime-gateway.php:118 336 315 msgid "Transaction:" 337 316 msgstr "Transaction:" 338 317 339 #: class/wc-etransactions-standard-gateway.php: 41340 #: class/wc-etransactions-threetime-gateway.php: 92318 #: class/wc-etransactions-standard-gateway.php:65 319 #: class/wc-etransactions-threetime-gateway.php:119 341 320 msgid "Call:" 342 321 msgstr "Appel:" 343 322 344 #: class/wc-etransactions-standard-gateway.php: 42345 #: class/wc-etransactions-threetime-gateway.php: 93323 #: class/wc-etransactions-standard-gateway.php:66 324 #: class/wc-etransactions-threetime-gateway.php:120 346 325 msgid "Authorization:" 347 326 msgstr "Autorisation:" 348 327 349 #: class/wc-etransactions-standard-gateway.php: 44350 #: class/wc-etransactions-threetime-gateway.php: 95328 #: class/wc-etransactions-standard-gateway.php:68 329 #: class/wc-etransactions-threetime-gateway.php:122 351 330 msgid "Payment information" 352 331 msgstr "Informations sur le paiement" 353 332 354 #: class/wc-etransactions-threetime-gateway.php: 11333 #: class/wc-etransactions-threetime-gateway.php:21 355 334 msgid "E-Transactions 3 times" 356 335 msgstr "E-Transactions paiement en trois fois" 357 336 358 #: class/wc-etransactions-threetime-gateway.php: 71337 #: class/wc-etransactions-threetime-gateway.php:100 359 338 msgid "First debit:" 360 339 msgstr "Premier paiement:" 361 340 362 #: class/wc-etransactions-threetime-gateway.php: 78363 #: class/wc-etransactions-threetime-gateway.php: 87341 #: class/wc-etransactions-threetime-gateway.php:106 342 #: class/wc-etransactions-threetime-gateway.php:114 364 343 msgid "Not achieved" 365 344 msgstr "Non traité" 366 345 367 #: class/wc-etransactions-threetime-gateway.php: 80346 #: class/wc-etransactions-threetime-gateway.php:108 368 347 msgid "Second debit:" 369 348 msgstr "Seconde échéance:" 370 349 371 #: class/wc-etransactions-threetime-gateway.php: 89350 #: class/wc-etransactions-threetime-gateway.php:116 372 351 msgid "Third debit:" 373 352 msgstr "Troisième échéance:" 374 353 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 381 355 msgid "E-Transactions not available. Please try again later." 382 356 msgstr "E-Transactions n'est pas disponible. Merci d'essayer plus tard." 383 357 384 #: wc-etransactions.php: 43358 #: wc-etransactions.php:39 wc-etransactions.php:40 385 359 msgid "Previous plugin already installed. deactivate the previous one first." 386 360 msgstr "" … … 388 362 "désactivez la version précédente avant d'activer celle-ci." 389 363 390 #: wc-etransactions.php:132 364 #: wc-etransactions.php:53 365 msgid "WooCommerce must be activated" 366 msgstr "WooCommerce doit être activé" 367 368 #: wc-etransactions.php:138 391 369 msgid "HMAC key cannot be decrypted please re-enter or reinitialise it." 392 370 msgstr "" … … 394 372 "réinitialisez la." 395 373 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 375 msgid "Woocommerce is not active !" 376 msgstr "WooCommerce n’est pas activé !" 377 378 #. Description of the plugin/theme 379 msgid "E-Transactions gateway payment plugins for WooCommerce" 380 msgstr "Extension E-Transactions - passerelle de paiement pour WooCommerce" 381 382 #. Author URI of the plugin/theme 383 msgid "http://www.e-transactions.fr" 384 msgstr "" -
e-transactions-wc/trunk/readme.txt
r2391064 r2499400 4 4 Tags: Payment Gateway, Orders, woocommerce, e-commerce, payment, E-Transactions 5 5 Requires at least: 3.0.1 6 Tested up to: 5. 5.16 Tested up to: 5.7 7 7 Stable tag: 0.9.9.9.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 WC requires at least: 2.6 11 WC tested up to: 4.5.211 WC tested up to: 5.1.0 12 12 This plugin is a E-Transactions payment gateway for WooCommerce 2.x 13 13 … … 23 23 it 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. 24 24 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. 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. 26 26 27 27 The plugin checks for availability of the E-Transactions platform, through a call to our servers. … … 51 51 = My orders are not validated, even though the payment went through ? = 52 52 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. 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. 55 55 56 56 = Something is not working for me, how can i get help ? = … … 68 68 69 69 == Changelog == 70 = 0.9.9.9.3 = 71 Force 3DSv2 for all cards 72 73 = 0.9.9.9.2 = 74 Add 3DSv2 support 75 70 76 = 0.9.8.9 = 71 77 various fixes and alignments … … 118 124 119 125 = 0.9.6.7 = 120 Changed: 121 only rely on the $_SERVER data to check for the IP address: 126 Changed: 127 only rely on the $_SERVER data to check for the IP address: 122 128 this solves the non reception of the IPN (error 500) 123 129 124 130 = 0.9.6.6 = 125 Second release: 126 Fixed: 131 Second release: 132 Fixed: 127 133 -Missing table now created ok. 128 -"Syntax error: Unexpected token < " message when checking out, 134 -"Syntax error: Unexpected token < " message when checking out, 129 135 -Use of deprecated functions to get pages url: now we use endpoints. 130 136 -
e-transactions-wc/trunk/wc-etransactions.php
r2391064 r2499400 3 3 * Plugin Name: E-Transactions 4 4 * Description: E-Transactions gateway payment plugins for WooCommerce 5 * Version: 0.9.9.9. 15 * Version: 0.9.9.9.3 6 6 * Author: E-Transactions 7 7 * Author URI: http://www.e-transactions.fr 8 8 * Text Domain: wc-etransactions 9 10 * 9 * 11 10 * @package WordPress 12 11 * @since 0.9.0 13 12 */ 13 14 14 // Ensure not called directly 15 15 if (!defined('ABSPATH')) { 16 exit;16 exit; 17 17 } 18 18 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écédente du plugin E-Transactions est déjà installée. veuillez la dé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')))); 20 if (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')))); 35 23 } 24 if ($previousET) { 25 die("Une version précédente du plugin E-Transactions est déjà installée. veuillez la désactiver avant d'activer celle-ci."); 26 } 27 28 function 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 36 37 // Ensure WooCommerce is active 38 if (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 } 42 defined('WC_ETRANSACTIONS_PLUGIN') or define('WC_ETRANSACTIONS_PLUGIN', 'wc-etransactions'); 43 defined('WC_ETRANSACTIONS_VERSION') or define('WC_ETRANSACTIONS_VERSION', '0.9.9.9.3'); 44 defined('WC_ETRANSACTIONS_KEY_PATH') or define('WC_ETRANSACTIONS_KEY_PATH', ABSPATH . '/kek.php'); 37 45 46 function 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'); 38 51 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))"; 46 65 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 } 65 71 66 require_once(ABSPATH.'wp-admin/includes/upgrade.php'); 72 function wc_etransactions_initialization() 73 { 74 if (!wooCommerceActiveETwp()) { 75 return ("Woocommerce not Active") ; 76 } 77 $class = 'WC_Etransactions_Abstract_Gateway'; 67 78 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 } 69 89 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/'); 79 91 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 } 89 96 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) { 96 98 wc_etransactions_installation(); 97 99 } 98 100 } 99 101 100 function wc_etransactions_register(array $methods) { 101 $methods[] = 'WC_EStdGw'; 102 $methods[] = 'WC_E3Gw'; 103 return $methods; 102 function wc_etransactions_register(array $methods) 103 { 104 $methods[] = 'WC_EStdGw'; 105 $methods[] = 'WC_E3Gw'; 106 return $methods; 104 107 } 105 108 … … 108 111 add_filter('woocommerce_payment_gateways', 'wc_etransactions_register'); 109 112 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 } 113 function 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 } 122 126 } 123 127 124 128 add_action('woocommerce_admin_order_data_after_billing_address', 'wc_etransactions_show_details'); 125 129 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 } 130 function 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 } 143 146 } 144 147 add_action('admin_notices', 'hmac_admin_notice');
Note: See TracChangeset
for help on using the changeset viewer.