Changeset 2501160
- Timestamp:
- 03/22/2021 04:07:00 PM (5 years ago)
- Location:
- paybox-woocommerce-gateway/trunk
- Files:
-
- 1 added
- 14 edited
-
class/wc-paybox-abstract-gateway.php (modified) (29 diffs)
-
class/wc-paybox-config.php (modified) (1 diff)
-
class/wc-paybox-encrypt.php (modified) (2 diffs)
-
class/wc-paybox-iso3166-country.php (added)
-
class/wc-paybox-iso4217currency.php (modified) (1 diff)
-
class/wc-paybox-standard-gateway.php (modified) (1 diff)
-
class/wc-paybox-threetime-gateway.php (modified) (1 diff)
-
class/wc-paybox.php (modified) (3 diffs)
-
images/3xcbvisamcecb.png (modified) (previous)
-
images/cbvisamcecb.png (modified) (previous)
-
images/logo.png (modified) (previous)
-
lang/woocommerce-paybox-fr_FR.mo (modified) (previous)
-
lang/woocommerce-paybox-fr_FR.po (modified) (7 diffs)
-
readme.txt (modified) (6 diffs)
-
woocommerce-paybox.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
paybox-woocommerce-gateway/trunk/class/wc-paybox-abstract-gateway.php
r2294678 r2501160 1 1 <?php 2 2 3 abstract class WC_Paybox_Abstract_Gateway extends WC_Payment_Gateway { 4 3 /** 4 * Paybox - Payment Gateway class. 5 * 6 * Extended by individual payment gateways to handle payments. 7 * 8 * @class WC_Paybox_Abstract_Gateway 9 * @extends WC_Payment_Gateway 10 */ 11 abstract class WC_Paybox_Abstract_Gateway extends WC_Payment_Gateway 12 { 5 13 protected $_config; 6 14 protected $_paybox; 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') { … … 13 22 } 14 23 15 16 24 $this->method_description = '<center><img src="' . plugins_url('images/logo.png', plugin_basename(dirname(__FILE__))) . '"/></center>'; 17 25 … … 23 31 $this->_paybox = new WC_Paybox($this->_config); 24 32 25 // $this->title = $this->_config->getTitle(); 26 // $this->description = $this->_config->getDescription(); 27 28 $this->title = apply_filters('title',$this->_config->getTitle()); 29 $this->description = apply_filters('description',$this->_config->getDescription()); 30 $this->icon = apply_filters( WC_PAYBOX_PLUGIN, plugin_dir_url(__DIR__).'images/') 31 .apply_filters('icon',$this->_config->getIcon()); 33 // $this->title = $this->_config->getTitle(); 34 // $this->description = $this->_config->getDescription(); 35 36 $this->title = apply_filters('title', $this->_config->getTitle()); 37 $this->description = apply_filters('description', $this->_config->getDescription()); 38 $this->icon = apply_filters(WC_PAYBOX_PLUGIN, plugin_dir_url(__DIR__) . 'images/') . apply_filters('icon', $this->_config->getIcon()); 32 39 33 40 // Actions … … 43 50 * @return void 44 51 */ 45 public function process_admin_options() { 52 public function process_admin_options() 53 { 46 54 $crypto = new PayboxEncrypt(); 47 55 if (!isset($_POST['crypted'])) { 48 if (isset($_POST["woocommerce_paybox_std_hmackey"])) 56 if (isset($_POST["woocommerce_paybox_std_hmackey"])) { 49 57 $_POST["woocommerce_paybox_std_hmackey"] = $crypto->encrypt($_POST["woocommerce_paybox_std_hmackey"]); 50 else58 } else { 51 59 $_POST["woocommerce_paybox_3x_hmackey"] = $crypto->encrypt($_POST["woocommerce_paybox_3x_hmackey"]); 60 } 52 61 $_POST['crypted'] = true; 53 62 } … … 55 64 } 56 65 57 public function admin_options() {58 66 public function admin_options() 67 { 59 68 $crypt = new PayboxEncrypt(); 60 69 $this->settings['hmackey'] = $crypt->decrypt($this->settings['hmackey']); … … 66 75 * Initialise Gateway Settings Form Fields 67 76 */ 68 public function init_form_fields() { 77 public function init_form_fields() 78 { 69 79 $defaults = new WC_Paybox_Config(array(), $this->defaultTitle, $this->defaultDesc); 70 80 $defaults = $defaults->getDefaults(); … … 82 92 'default' => __($defaults['title'], WC_PAYBOX_PLUGIN), 83 93 ); 84 $allFiles = scandir( plugin_dir_path( __DIR__ ) .'images/'); 85 $fileList = array(); 86 foreach($allFiles as $id=>$file){ 87 if (in_array( explode(".",$file)[1], array('png','jpg','gif','svg'))){ 88 89 $fileList[$file]=$file; 90 } 91 } 94 $allFiles = scandir(plugin_dir_path(__DIR__) . 'images/'); 95 $fileList = array(); 96 foreach ($allFiles as $id => $file) { 97 if (in_array(explode(".", $file)[1], array('png', 'jpg', 'gif', 'svg'))) { 98 $fileList[$file]=$file; 99 } 100 } 92 101 $this->form_fields['icon'] = array( 93 102 'title' => __('Icon file', WC_PAYBOX_PLUGIN), 94 103 'type' => 'select', 95 'description' => __('Icon file to be displayed to customers. file are located in: ', WC_PAYBOX_PLUGIN) .apply_filters( WC_PAYBOX_PLUGIN, ''.plugin_dir_url(__DIR__).'images/'),104 'description' => __('Icon file to be displayed to customers. file are located in: ', WC_PAYBOX_PLUGIN) . apply_filters(WC_PAYBOX_PLUGIN, '' . plugin_dir_url(__DIR__) . 'images/'), 96 105 'default' => __($defaults['icon'], WC_PAYBOX_PLUGIN), 97 'options' => $fileList,106 'options' => $fileList, 98 107 ); 99 108 $this->form_fields['description'] = array( … … 126 135 'default' => $defaults['amount'] 127 136 ); 128 $this->form_fields['3ds'] = array(129 'title' => __('3D Secure', WC_PAYBOX_PLUGIN),130 'type' => 'title',131 );132 $this->form_fields['3ds_enabled'] = array(133 'title' => __('Enable/Disable', WC_PAYBOX_PLUGIN),134 'type' => 'select',135 'label' => __('Enable 3D Secure', WC_PAYBOX_PLUGIN),136 'description' => __('You can enable 3D Secure for all orders or depending on following conditions', WC_PAYBOX_PLUGIN),137 'default' => $defaults['3ds_enabled'],138 'options' => array(139 'never' => __('Disabled', WC_PAYBOX_PLUGIN),140 'always' => __('Enabled', WC_PAYBOX_PLUGIN),141 'conditional' => __('Conditional', WC_PAYBOX_PLUGIN),142 ),143 );144 $this->form_fields['3ds_amount'] = array(145 'title' => __('Minimal amount', WC_PAYBOX_PLUGIN),146 'type' => 'text',147 'description' => __('Enable 3D Secure for order with amount greater or equals to this amount (empty to ignore this condition)', WC_PAYBOX_PLUGIN),148 'default' => $defaults['3ds_amount']149 );150 137 $this->form_fields['paybox_account'] = array( 151 138 'title' => __('Paybox account', WC_PAYBOX_PLUGIN), … … 191 178 ); 192 179 $this->form_fields['ips'] = array( 193 'title' => __('Allowed IPs ', WC_PAYBOX_PLUGIN),180 'title' => __('Allowed IPs', WC_PAYBOX_PLUGIN), 194 181 'type' => 'text', 195 182 'description' => __('A coma separated list of Paybox IPs.', WC_PAYBOX_PLUGIN), … … 210 197 * @return bool 211 198 */ 212 public function is_available() { 199 public function is_available() 200 { 213 201 if (!parent::is_available()) { 214 202 return false; … … 219 207 } 220 208 $total = WC()->cart->total; 209 221 210 return $total >= $minimal; 222 211 } … … 228 217 * @return array TODO 229 218 */ 230 public function process_payment($orderId) { 219 public function process_payment($orderId) 220 { 231 221 $order = new WC_Order($orderId); 232 222 … … 240 230 } 241 231 242 public function receipt_page($orderId) { 232 public function receipt_page($orderId) 233 { 243 234 $order = new WC_Order($orderId); 244 235 … … 265 256 } catch (Exception $e) { 266 257 echo "<p>" . $e->getMessage() . "</p>"; 267 echo "<form><center><button onClick='history.go(-1);return true;'>" . __('Back...', WC_ ETRANSACTIONS_PLUGIN) . "</center></button></form>";258 echo "<form><center><button onClick='history.go(-1);return true;'>" . __('Back...', WC_PAYBOX_PLUGIN) . "</center></button></form>"; 268 259 exit; 269 260 } … … 271 262 ?> 272 263 <form id="pbxep_form" method="post" action="<?php echo esc_url($url); ?>" enctype="application/x-www-form-urlencoded"> 273 <?php if ($debug) : ?>264 <?php if ($debug) : ?> 274 265 <p> 275 266 <?php echo __('This is a debug view. Click continue to be redirected to Paybox payment page.', WC_PAYBOX_PLUGIN); ?> 276 267 </p> 277 <?php else : ?>268 <?php else : ?> 278 269 <p> 279 270 <?php echo __('You will be redirected to the Paybox payment page. If not, please use the button bellow.', WC_PAYBOX_PLUGIN); ?> … … 288 279 <?php 289 280 $type = $debug ? 'text' : 'hidden'; 290 foreach ($params as $name => $value) :281 foreach ($params as $name => $value) { 291 282 $name = esc_attr($name); 292 283 $value = esc_attr($value); 293 if ($debug) :284 if ($debug) { 294 285 echo '<p><label for="' . $name . '">' . $name . '</label>'; 295 endif;286 } 296 287 echo '<input type="' . $type . '" id="' . $name . '" name="' . $name . '" value="' . $value . '" />'; 297 if ($debug) :288 if ($debug) { 298 289 echo '</p>'; 299 endif;300 endforeach;290 } 291 } 301 292 ?> 302 293 </form> … … 304 295 } 305 296 306 public function api_call() { 297 public function api_call() 298 { 307 299 if (!isset($_GET['status'])) { 308 300 header('Status: 404 Not found', true, 404); … … 333 325 } 334 326 335 public function on_payment_failed() { 327 public function on_payment_failed() 328 { 336 329 try { 337 330 $params = $this->_paybox->getParams(); … … 344 337 $message = __('Payment refused by Paybox', WC_PAYBOX_PLUGIN); 345 338 $this->_paybox->addCartErrorMessage($message); 346 $order->update_status('failed', $message); 339 $order->update_status('failed', $message); 347 340 } 348 341 } catch (Exception $e) { … … 353 346 } 354 347 355 public function on_payment_canceled() { 348 public function on_payment_canceled() 349 { 356 350 try { 357 351 $params = $this->_paybox->getParams(); … … 363 357 $message = __('Payment canceled', WC_PAYBOX_PLUGIN); 364 358 $this->_paybox->addCartErrorMessage($message); 365 $order->update_status('failed', $message); 359 $order->update_status('failed', $message); 366 360 } 367 361 } catch (Exception $e) { … … 372 366 } 373 367 374 public function on_payment_succeed() { 368 public function on_payment_succeed() 369 { 375 370 try { 376 371 $params = $this->_paybox->getParams(); … … 391 386 } 392 387 393 public function on_ipn() { 394 global $wpdb; 388 public function on_ipn() 389 { 390 global $wpdb; 395 391 396 392 try { 397 398 393 $params = $this->_paybox->getParams(); 399 394 400 395 if ($params === false) { 401 return;396 return; 402 397 } 403 398 … … 405 400 406 401 // IP not allowed 407 /* $allowedIps = $this->_config->getAllowedIps(); 408 $currentIp = $this->_paybox->getClientIp(); 409 if (!in_array($currentIp, $allowedIps)) { 410 $message = __('IPN call from %s not allowed.', WC_PAYBOX_PLUGIN); 411 $message = sprintf($message, $currentIp); 412 $this->_paybox->addOrderNote($order, $message); 413 throw new Exception($message); 414 } 415 //removed by JC: no need for IP checking anymore. 416 */ 402 /* 403 $allowedIps = $this->_config->getAllowedIps(); 404 $currentIp = $this->_paybox->getClientIp(); 405 if (!in_array($currentIp, $allowedIps)) { 406 $message = __('IPN call from %s not allowed.', WC_PAYBOX_PLUGIN); 407 $message = sprintf($message, $currentIp); 408 $this->_paybox->addOrderNote($order, $message); 409 throw new Exception($message); 410 } 411 // removed by JC: no need for IP checking anymore. 412 */ 417 413 // Check required parameters 418 414 $requiredParams = array('amount', 'transaction', 'error', 'reference', 'sign', 'date', 'time'); … … 421 417 $message = sprintf(__('Missing %s parameter in Paybox call', WC_PAYBOX_PLUGIN), $requiredParam); 422 418 $this->_paybox->addOrderNote($order, $message); 423 throw new Exception($message);419 throw new Exception($message); 424 420 } 425 421 } … … 427 423 // Payment success 428 424 if ($params['error'] == '00000') { 429 430 425 switch ($this->type) { 431 426 case 'standard': … … 437 432 case 'threetime': 438 433 $sql = 'select distinct type from ' . $wpdb->prefix . 'wc_paybox_payment where order_id = ' . $order->get_id(); 439 $done = $wpdb->get_col($sql);434 $done = $wpdb->get_col($sql); 440 435 if (!in_array('first_payment', $done)) { 441 436 $this->_paybox->addOrderNote($order, __('Payment was authorized and captured by Paybox.', WC_PAYBOX_PLUGIN)); 442 437 $order->payment_complete($params['transaction']); 443 438 $this->_paybox->addOrderPayment($order, 'first_payment', $params); 444 } else if (!in_array('second_payment', $done)) {439 } elseif (!in_array('second_payment', $done)) { 445 440 $this->_paybox->addOrderNote($order, __('Second payment was captured by Paybox.', WC_PAYBOX_PLUGIN)); 446 441 $this->_paybox->addOrderPayment($order, 'second_payment', $params); 447 } else if (!in_array('third_payment', $done)) {442 } elseif (!in_array('third_payment', $done)) { 448 443 $this->_paybox->addOrderNote($order, __('Third payment was captured by Paybox.', WC_PAYBOX_PLUGIN)); 449 444 $this->_paybox->addOrderPayment($order, 'third_payment', $params); … … 454 449 } 455 450 break; 456 457 451 default: 458 452 $message = __('Unexpected type %s', WC_PAYBOX_PLUGIN); … … 461 455 throw new Exception($message); 462 456 } 463 } 464 465 // Payment refused 466 else { 457 } else { 458 // Payment refused 467 459 $message = __('Payment was refused by Paybox (%s).', WC_PAYBOX_PLUGIN); 468 460 $error = $this->_paybox->toErrorMessage($params['error']); 469 461 $message = sprintf($message, $error); 470 $this->_paybox->addOrderPayment($order, 'failed_payment', $params);462 $this->_paybox->addOrderPayment($order, 'failed_payment', $params); 471 463 $this->_paybox->addOrderNote($order, $message); 472 464 } 473 465 } catch (Exception $e) { 474 if (WC()->debug === 'yes') { 475 $this->logger->add("paybox", $e->getMessage()); 476 } 477 } 478 } 479 480 public function redirectToCheckout() { 466 if (WC()->debug === 'yes') { 467 $this->logger->add("paybox", $e->getMessage()); 468 } 469 } 470 } 471 472 public function redirectToCheckout() 473 { 481 474 wp_redirect(WC()->cart->get_cart_url()); 482 475 die(); 483 476 } 484 485 public function checkCrypto(){ 486 $crypt = new PayboxEncrypt(); 477 478 public function checkCrypto() 479 { 480 $crypt = new PayboxEncrypt(); 487 481 return $crypt->decrypt($this->settings['hmackey']); 488 } 489 490 public abstract function showDetails($orderId); 491 492 482 } 483 484 abstract public function showDetails($orderId); 493 485 } -
paybox-woocommerce-gateway/trunk/class/wc-paybox-config.php
r2240593 r2501160 1 1 <?php 2 2 3 class WC_Paybox_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' => '0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF', 14 'identifier' => 3262411, 15 'ips' => '194.2.122.158,195.25.7.166,195.101.99.76', 16 'rank' => 77, 17 'site' => 1999888, 18 ); 3 /** 4 * Paybox - Configuration class. 5 * 6 * @class WC_Paybox_Config 7 */ 8 class WC_Paybox_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' => '0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF', 18 'identifier' => 3262411, 19 'ips' => '194.2.122.158,195.25.7.166,195.101.99.76', 20 'rank' => 77, 21 'site' => 1999888, 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 PayboxEncrypt(); 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 PayboxEncrypt(); 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.paybox.com/php/', 98 'https://tpeweb1.paybox.com/php/', 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.paybox.com/php/' 106 ); 107 } 86 108 87 public function getSystemProductionUrls() { 88 return array( 89 'https://tpeweb.paybox.com/php/', 90 'https://tpeweb1.paybox.com/php/', 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.paybox.com/php/' 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 } -
paybox-woocommerce-gateway/trunk/class/wc-paybox-encrypt.php
r2294678 r2501160 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 * [email protected] so we can mail you a copy immediately. … … 20 20 * */ 21 21 22 class PayboxEncrypt { 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 PayboxEncrypt 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 } 37 38 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_PAYBOX_KEY_PATH))unlink(WC_PAYBOX_KEY_PATH); 47 $key = bin2hex($key); 48 $iv = $this->_MakeIv($key); 49 return file_put_contents(WC_PAYBOX_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_PAYBOX_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_PAYBOX_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_PAYBOX_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_PAYBOX_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); 97 } 98 /** 99 * Encrypt $data using AES 100 * @param string $data The data to encrypt 101 * @return string The result of encryption 102 */ 103 public function encrypt($data) 104 { 105 if (empty($data)) { 106 return ''; 107 } 108 // First encode data to base64 (see end of descrypt) 109 $data = base64_encode($data); 39 return bin2hex($iv); 40 } 110 41 42 /* 43 * You can change this method 44 if you want to change the way the key is generated. 45 */ 46 public function generateKey() 47 { 48 // generate key, write to KEY_FILE_PATH 49 $key = openssl_random_pseudo_bytes(16); 50 if (file_exists(WC_PAYBOX_KEY_PATH)) { 51 unlink(WC_PAYBOX_KEY_PATH); 52 } 53 $key = bin2hex($key); 54 $iv = $this->_MakeIv($key); 111 55 112 // Prepare key 113 $key = $this->_getKey(); 114 $key = substr($key, 0, 24); 115 while (strlen($key) < 24) { 116 $key .= substr($key, 0, 24 - strlen($key)); 117 } 118 // Init vector 119 $iv = $this->_getIv(); 56 return file_put_contents(WC_PAYBOX_KEY_PATH, "<?php" . $key . $iv); 57 } 58 /** 59 * @return string Key used for encryption 60 */ 61 private function _getKey() 62 { 63 //check whether key on KEY_FILE_PATH exists, if not generate it. 64 $ok = true; 65 if (!file_exists(WC_PAYBOX_KEY_PATH)) { 66 $ok = $this->generateKey(); 67 $_POST['KEY_ERROR'] = __("For some reason, the key has just been generated. please reenter the HMAC key to crypt it."); 68 } 69 if ($ok!==false) { 70 $key = file_get_contents(WC_PAYBOX_KEY_PATH); 71 $key = substr($key, 5, 32); 72 return $key; 73 } 74 } 75 /** 76 * @return string Key used for encryption 77 */ 78 private function _getIv() 79 { 80 //check whether key on KEY_FILE_PATH exists, if not generate it. 81 if (!file_exists(WC_PAYBOX_KEY_PATH)) { 82 $this->generateKey(); 83 $_POST['KEY_ERROR'] = __("For some reason, the key has just been generated. please reenter the HMAC key to crypt it."); 84 } else { 85 $iv = file_get_contents(WC_PAYBOX_KEY_PATH); 86 $iv = substr($iv, 37, 16); 87 return $iv; 88 } 89 } 120 90 121 return $this->_crypt($key,$iv,$data); 122 123 } 124 private function _decrypt($key,$iv,$data){ 125 if(function_exists('openssl_decrypt')){ 126 //openssl 127 $result = openssl_decrypt($data, 'aes-128-cbc', $key, OPENSSL_RAW_DATA , $iv); 128 if(!$result && function_exists('mcrypt_module_open')){ 129 $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); 130 mcrypt_generic_init($td, $key, $iv); 131 // Decrypt 132 $result = mdecrypt_generic($td, $data); 133 } 134 if(!$result) show_message(new WP_Error("","","ATTENTION:le module ne peut plus afficher la clef HMAC, veuillez l'initiailiser de nouveau.")); 135 }else{ 136 // Prepare mcrypt 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 // Decode data 143 return base64_decode($result); 144 } 145 /** 146 * Decrypt $data using 3DES 147 * @param string $data The data to decrypt 148 * @return string The result of decryption 149 * @see PAYBOX_Epayment_Helper_Encrypt::_getKey() 150 */ 151 public function decrypt($data) 152 { 153 if (empty($data)) { 154 return ''; 155 } 91 private function _crypt($key, $iv, $data) 92 { 93 if (function_exists('openssl_encrypt')) { 94 //openssl 95 $result = openssl_encrypt($data, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv); 96 } else { 97 // Prepare mcrypt 98 $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); 99 mcrypt_generic_init($td, $key, $iv); 100 // Encrypt 101 $result = mcrypt_generic($td, $data); 102 } 156 103 157 // First decode encrypted message (see end of encrypt) 158 $data = base64_decode($data); 104 // Encode (to avoid data loose when saved to database or 105 // any storage that does not support null chars) 106 return base64_encode($result); 107 } 159 108 109 /** 110 * Encrypt $data using AES 111 * @param string $data The data to encrypt 112 * @return string The result of encryption 113 */ 114 public function encrypt($data) 115 { 116 if (empty($data)) { 117 return ''; 118 } 119 // First encode data to base64 (see end of descrypt) 120 $data = base64_encode($data); 160 121 161 // Prepare key 162 $key = $this->_getKey(); 163 $key = substr($key, 0, 24); 164 while (strlen($key) < 24) { 165 $key .= substr($key, 0, 24 - strlen($key)); 166 } 167 // Init vector 168 $iv = $this->_getIv(); 169 $result = $this->_decrypt($key,$iv,$data); 170 // Remove any null char (data is base64 encoded so no data loose) 171 $result = rtrim($result, "\0"); 122 // Prepare key 123 $key = $this->_getKey(); 124 $key = substr($key, 0, 24); 125 while (strlen($key) < 24) { 126 $key .= substr($key, 0, 24 - strlen($key)); 127 } 128 // Init vector 129 $iv = $this->_getIv(); 172 130 131 return $this->_crypt($key, $iv, $data); 132 } 173 133 174 return $result; 175 } 134 private function _decrypt($key, $iv, $data) 135 { 136 if (function_exists('openssl_decrypt')) { 137 //openssl 138 $result = openssl_decrypt($data, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv); 139 if (!$result && function_exists('mcrypt_module_open')) { 140 $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); 141 mcrypt_generic_init($td, $key, $iv); 142 // Decrypt 143 $result = mdecrypt_generic($td, $data); 144 } 145 if (!$result) { 146 show_message(new WP_Error("", "", "ATTENTION:le module ne peut plus afficher la clef HMAC, veuillez l'initiailiser de nouveau.")); 147 } 148 } else { 149 // Prepare mcrypt 150 $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); 151 mcrypt_generic_init($td, $key, $iv); 152 // Decrypt 153 $result = mdecrypt_generic($td, $data); 154 } 155 156 // Decode data 157 return base64_decode($result); 158 } 159 160 /** 161 * Decrypt $data using 3DES 162 * @param string $data The data to decrypt 163 * @return string The result of decryption 164 * @see PAYBOX_Epayment_Helper_Encrypt::_getKey() 165 */ 166 public function decrypt($data) 167 { 168 if (empty($data)) { 169 return ''; 170 } 171 172 // First decode encrypted message (see end of encrypt) 173 $data = base64_decode($data); 174 175 // Prepare key 176 $key = $this->_getKey(); 177 $key = substr($key, 0, 24); 178 while (strlen($key) < 24) { 179 $key .= substr($key, 0, 24 - strlen($key)); 180 } 181 // Init vector 182 $iv = $this->_getIv(); 183 $result = $this->_decrypt($key, $iv, $data); 184 // Remove any null char (data is base64 encoded so no data loose) 185 $result = rtrim($result, "\0"); 186 187 return $result; 188 } 176 189 } -
paybox-woocommerce-gateway/trunk/class/wc-paybox-iso4217currency.php
r1256571 r2501160 1 1 <?php 2 2 3 class WC_Paybox_Iso4217Currency { 3 /** 4 * Paybox - ISO 4217 Currency class. 5 * 6 * @class WC_Paybox_Iso4217Currency 7 */ 8 class WC_Paybox_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_Paybox_Iso4217Currency::$_mapping[$code])) { 187 return WC_Paybox_Iso4217Currency::$_mapping[$code]; 188 } 189 return $default; 190 } 190 public static function getIsoCode($code, $default = null) 191 { 192 if (isset(WC_Paybox_Iso4217Currency::$_mapping[$code])) { 193 return WC_Paybox_Iso4217Currency::$_mapping[$code]; 194 } 195 return $default; 196 } 191 197 } -
paybox-woocommerce-gateway/trunk/class/wc-paybox-standard-gateway.php
r2294678 r2501160 1 1 <?php 2 2 3 class WC_PbxStdGw extends WC_Paybox_Abstract_Gateway { 4 protected $defaultTitle = 'Paybox payment'; 5 protected $defaultDesc = 'xxxx'; 6 protected $type = 'standard'; 3 /** 4 * Paybox - Individual Payment Gateway class. 5 * 6 * @class WC_PbxStdGw 7 * @extends WC_Paybox_Abstract_Gateway 8 */ 9 class WC_PbxStdGw extends WC_Paybox_Abstract_Gateway 10 { 11 protected $defaultTitle = 'Paybox payment'; 12 protected $defaultDesc = 'xxxx'; 13 protected $type = 'standard'; 7 14 8 public function __construct() { 9 // Some properties 10 $this->id = 'paybox_std'; 11 $this->method_title = __('Paybox', WC_PAYBOX_PLUGIN); 12 $this->has_fields = false; 13 $this->icon = 'cbvisamcecb.png'; 15 public function __construct() 16 { 17 // Some properties 18 $this->id = 'paybox_std'; 19 $this->method_title = __('Paybox', WC_PAYBOX_PLUGIN); 20 $this->has_fields = false; 21 $this->icon = 'cbvisamcecb.png'; 14 22 15 parent::__construct(); 16 } 17 private function _showDetailRow($label, $value) { 18 return '<strong>'.$label.'</strong> '.__($value, WC_PAYBOX_PLUGIN); 19 } 23 parent::__construct(); 24 } 20 25 21 public function showDetails($order) { 22 $orderId = $order->get_id(); 23 $payment = $this->_paybox->getOrderPayments($orderId, 'capture'); 26 private function _showDetailRow($label, $value) 27 { 28 return '<strong>'.$label.'</strong> '.__($value, WC_PAYBOX_PLUGIN); 29 } 24 30 25 if (!empty($payment)) { 26 $data = unserialize($payment->data); 27 $rows = array(); 28 $rows[] = $this->_showDetailRow(__('Reference:', WC_PAYBOX_PLUGIN), $data['reference']); 29 if (isset($data['ip'])) { 30 $rows[] = $this->_showDetailRow(__('Country of IP:', WC_PAYBOX_PLUGIN), $data['ip']); 31 } 32 $rows[] = $this->_showDetailRow(__('Processing date:', WC_PAYBOX_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date'])." - ".$data['time']); 33 if (isset($data['firstNumbers']) && isset($data['lastNumbers'])) { 34 $rows[] = $this->_showDetailRow(__('Card numbers:', WC_PAYBOX_PLUGIN), $data['firstNumbers'].'...'.$data['lastNumbers']); 35 } 36 if (isset($data['validity'])) { 37 $rows[] = $this->_showDetailRow(__('Validity date:', WC_PAYBOX_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})$/', '$2/$1', $data['validity'])); 38 } 39 $rows[] = $this->_showDetailRow(__('Transaction:', WC_PAYBOX_PLUGIN), $data['transaction']); 40 $rows[] = $this->_showDetailRow(__('Call:', WC_PAYBOX_PLUGIN), $data['call']); 41 $rows[] = $this->_showDetailRow(__('Authorization:', WC_PAYBOX_PLUGIN), $data['authorization']); 31 public function showDetails($order) 32 { 33 $orderId = $order->get_id(); 34 $payment = $this->_paybox->getOrderPayments($orderId, 'capture'); 42 35 43 echo '<h4>'.__('Payment information', WC_PAYBOX_PLUGIN).'</h4>'; 44 echo '<p>'.implode('<br/>', $rows).'</p>'; 45 } 46 } 36 if (empty($payment)) { 37 return; 38 } 47 39 40 $data = unserialize($payment->data); 41 $rows = array(); 42 $rows[] = $this->_showDetailRow(__('Reference:', WC_PAYBOX_PLUGIN), $data['reference']); 43 if (isset($data['ip'])) { 44 $rows[] = $this->_showDetailRow(__('Country of IP:', WC_PAYBOX_PLUGIN), $data['ip']); 45 } 46 $rows[] = $this->_showDetailRow(__('Processing date:', WC_PAYBOX_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date'])." - ".$data['time']); 47 if (isset($data['firstNumbers']) && isset($data['lastNumbers'])) { 48 $rows[] = $this->_showDetailRow(__('Card numbers:', WC_PAYBOX_PLUGIN), $data['firstNumbers'].'...'.$data['lastNumbers']); 49 } 50 if (isset($data['validity'])) { 51 $rows[] = $this->_showDetailRow(__('Validity date:', WC_PAYBOX_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})$/', '$2/$1', $data['validity'])); 52 } 53 54 // 3DS Version 55 if (!empty($data['3ds']) && $data['3ds'] == 'Y') { 56 $cc_3dsVersion = '1.0.0'; 57 if (!empty($data['3dsVersion'])) { 58 $cc_3dsVersion = str_replace('3DSv', '', trim($data['3dsVersion'])); 59 } 60 $rows[] = $this->_showDetailRow(__('3DS version:', WC_PAYBOX_PLUGIN), $cc_3dsVersion); 61 } 62 63 $rows[] = $this->_showDetailRow(__('Transaction:', WC_PAYBOX_PLUGIN), $data['transaction']); 64 $rows[] = $this->_showDetailRow(__('Call:', WC_PAYBOX_PLUGIN), $data['call']); 65 $rows[] = $this->_showDetailRow(__('Authorization:', WC_PAYBOX_PLUGIN), $data['authorization']); 66 67 echo '<h4>'.__('Payment information', WC_PAYBOX_PLUGIN).'</h4>'; 68 echo '<p>'.implode('<br/>', $rows).'</p>'; 69 } 48 70 } -
paybox-woocommerce-gateway/trunk/class/wc-paybox-threetime-gateway.php
r2298639 r2501160 1 1 <?php 2 2 3 class WC_Pbx3xGw extends WC_Paybox_Abstract_Gateway { 4 protected $defaultTitle = 'Paybox 3 times payment'; 5 protected $defaultDesc = 'xxxx'; 6 protected $type = 'threetime'; 3 /** 4 * Paybox 3 times - Payment Gateway class. 5 * 6 * Extended by individual payment gateways to handle payments. 7 * 8 * @class WC_Pbx3xGw 9 * @extends WC_Paybox_Abstract_Gateway 10 */ 11 class WC_Pbx3xGw extends WC_Paybox_Abstract_Gateway 12 { 13 protected $defaultTitle = 'Paybox 3 times payment'; 14 protected $defaultDesc = 'xxxx'; 15 protected $type = 'threetime'; 7 16 8 public function __construct() { 9 // Some properties 10 $this->id = 'paybox_3x'; 11 $this->method_title = __('Paybox 3 times', WC_PAYBOX_PLUGIN); 12 $this->has_fields = false; 13 $this->icon = '3xcbvisamcecb.png'; 17 public function __construct() 18 { 19 // Some properties 20 $this->id = 'paybox_3x'; 21 $this->method_title = __('Paybox 3 times', WC_PAYBOX_PLUGIN); 22 $this->has_fields = false; 23 $this->icon = '3xcbvisamcecb.png'; 14 24 15 parent::__construct();16 }25 parent::__construct(); 26 } 17 27 18 private function _showDetailRow($label, $value) { 19 return '<strong>'.$label.'</strong> '.$value; 20 } 28 private function _showDetailRow($label, $value) 29 { 30 return '<strong>'.$label.'</strong> '.$value; 31 } 21 32 22 /** 23 * Check If The Gateway Is Available For Use 24 * 25 * @access public 26 * @return bool 27 */ 33 /** 34 * Check If The Gateway Is Available For Use 35 * 36 * @access public 37 * @return bool 38 */ 39 public function showDetails($order) 40 { 41 $orderId = $order->get_id(); 42 $payment = $this->_paybox->getOrderPayments($orderId, 'first_payment'); 28 43 29 public function showDetails($order) { 30 $orderId = $order->get_id(); 31 $payment = $this->_paybox->getOrderPayments($orderId, 'first_payment'); 32 if (!empty($payment)) { 33 $data = unserialize($payment->data); 34 $payment = $this->_paybox->getOrderPayments($orderId, 'second_payment'); 35 if (!empty($payment)) { 36 $second = unserialize($payment->data); 37 } 38 $payment = $this->_paybox->getOrderPayments($orderId, 'third_payment'); 39 if (!empty($payment)) { 40 $third = unserialize($payment->data); 41 } 44 if (empty($payment)) { 45 return; 46 } 42 47 43 $rows = array(); 44 $rows[] = $this->_showDetailRow(__('Reference:', WC_PAYBOX_PLUGIN), $data['reference']); 45 if (isset($data['ip'])) { 46 $rows[] = $this->_showDetailRow(__('Country of IP:', WC_PAYBOX_PLUGIN), $data['ip']); 47 } 48 $rows[] = $this->_showDetailRow(__('Processing date:', WC_PAYBOX_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date'])." - ".$data['time']); 49 if (isset($data['firstNumbers']) && isset($data['lastNumbers'])) { 50 $rows[] = $this->_showDetailRow(__('Card numbers:', WC_PAYBOX_PLUGIN), $data['firstNumbers'].'...'.$data['lastNumbers']); 51 } 52 if (isset($data['validity'])) { 53 $rows[] = $this->_showDetailRow(__('Validity date:', WC_PAYBOX_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})$/', '$2/$1', $data['validity'])); 54 } 48 $data = unserialize($payment->data); 49 $payment = $this->_paybox->getOrderPayments($orderId, 'second_payment'); 50 if (!empty($payment)) { 51 $second = unserialize($payment->data); 52 } 53 $payment = $this->_paybox->getOrderPayments($orderId, 'third_payment'); 54 if (!empty($payment)) { 55 $third = unserialize($payment->data); 56 } 55 57 56 $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date']); 57 $value = sprintf('%s (%s)', $data['amount'] / 100.0, $date); 58 $rows[] = $this->_showDetailRow(__('First debit:'), $value); 58 $rows = array(); 59 $rows[] = $this->_showDetailRow(__('Reference:', WC_PAYBOX_PLUGIN), $data['reference']); 60 if (isset($data['ip'])) { 61 $rows[] = $this->_showDetailRow(__('Country of IP:', WC_PAYBOX_PLUGIN), $data['ip']); 62 } 63 $rows[] = $this->_showDetailRow(__('Processing date:', WC_PAYBOX_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date'])." - ".$data['time']); 64 if (isset($data['firstNumbers']) && isset($data['lastNumbers'])) { 65 $rows[] = $this->_showDetailRow(__('Card numbers:', WC_PAYBOX_PLUGIN), $data['firstNumbers'].'...'.$data['lastNumbers']); 66 } 67 if (isset($data['validity'])) { 68 $rows[] = $this->_showDetailRow(__('Validity date:', WC_PAYBOX_PLUGIN), preg_replace('/^([0-9]{2})([0-9]{2})$/', '$2/$1', $data['validity'])); 69 } 59 70 60 if (isset($second)) { 61 $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $second['date']); 62 $value = sprintf('%s (%s)', $second['amount'] / 100.0, $date);63 } 64 else { 65 $value = __('Not achieved', WC_PAYBOX_PLUGIN); 66 } 67 $rows[] = $this->_showDetailRow(__('Second debit:'), $value); 71 // 3DS Version 72 if (!empty($data['3ds']) && $data['3ds'] == 'Y') { 73 $cc_3dsVersion = '1.0.0'; 74 if (!empty($data['3dsVersion'])) { 75 $cc_3dsVersion = str_replace('3DSv', '', trim($data['3dsVersion'])); 76 } 77 $rows[] = $this->_showDetailRow(__('3DS version:', WC_PAYBOX_PLUGIN), $cc_3dsVersion); 78 } 68 79 69 if (isset($third)) { 70 $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $third['date']); 71 $value = sprintf('%s (%s)', $third['amount'] / 100.0, $date); 72 } 73 else { 74 $value = __('Not achieved', WC_PAYBOX_PLUGIN); 75 } 76 $rows[] = $this->_showDetailRow(__('Third debit:'), $value); 80 $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $data['date']); 81 $value = sprintf('%s (%s)', $data['amount'] / 100.0, $date); 82 $rows[] = $this->_showDetailRow(__('First debit:'), $value); 77 83 78 $rows[] = $this->_showDetailRow(__('Transaction:', WC_PAYBOX_PLUGIN), $data['transaction']); 79 $rows[] = $this->_showDetailRow(__('Call:', WC_PAYBOX_PLUGIN), $data['call']); 80 $rows[] = $this->_showDetailRow(__('Authorization:', WC_PAYBOX_PLUGIN), $data['authorization']); 84 if (isset($second)) { 85 $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $second['date']); 86 $value = sprintf('%s (%s)', $second['amount'] / 100.0, $date); 87 } else { 88 $value = __('Not achieved', WC_PAYBOX_PLUGIN); 89 } 90 $rows[] = $this->_showDetailRow(__('Second debit:'), $value); 81 91 82 echo '<h4>'.__('Payment information', WC_PAYBOX_PLUGIN).'</h4>'; 83 echo '<p>'.implode('<br/>', $rows).'</p>'; 84 } 85 } 92 if (isset($third)) { 93 $date = preg_replace('/^([0-9]{2})([0-9]{2})([0-9]{4})$/', '$1/$2/$3', $third['date']); 94 $value = sprintf('%s (%s)', $third['amount'] / 100.0, $date); 95 } else { 96 $value = __('Not achieved', WC_PAYBOX_PLUGIN); 97 } 98 $rows[] = $this->_showDetailRow(__('Third debit:'), $value); 99 100 $rows[] = $this->_showDetailRow(__('Transaction:', WC_PAYBOX_PLUGIN), $data['transaction']); 101 $rows[] = $this->_showDetailRow(__('Call:', WC_PAYBOX_PLUGIN), $data['call']); 102 $rows[] = $this->_showDetailRow(__('Authorization:', WC_PAYBOX_PLUGIN), $data['authorization']); 103 104 echo '<h4>'.__('Payment information', WC_PAYBOX_PLUGIN).'</h4>'; 105 echo '<p>'.implode('<br/>', $rows).'</p>'; 106 } 86 107 } 87 class WC_Paybox_Threetime_GateWay extends WC_Pbx3xGw{ 88 public function receipt_page($orderId){ 89 return; 90 } 108 109 class WC_Paybox_Threetime_GateWay extends WC_Pbx3xGw 110 { 111 public function receipt_page($orderId) 112 { 113 return; 114 } 91 115 } -
paybox-woocommerce-gateway/trunk/class/wc-paybox.php
r2294684 r2501160 1 1 <?php 2 2 3 class WC_Paybox { 4 private $_config; 5 private $_currencyDecimals = array( 3 /** 4 * Paybox - Main class. 5 * 6 * @class WC_Paybox 7 */ 8 class WC_Paybox 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_Paybox_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_paybox_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_PAYBOX_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_PAYBOX_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 // Paybox => Magento 331 $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'; 332 $values['PBX_RUF1'] = 'POST'; 333 334 // Choose correct language 335 $lang = get_locale(); 336 if (!empty($lang)) { 337 $lang = preg_replace('#_.*$#', '', $lang); 338 } 339 $languages = $this->getLanguages(); 340 if (!array_key_exists($lang, $languages)) { 341 $lang = 'default'; 342 } 343 $values['PBX_LANGUE'] = $languages[$lang]; 344 345 // Choose page format depending on browser/devise 346 if ($this->isMobile()) { 347 $values['PBX_SOURCE'] = 'XHTMl'; 348 } 349 350 // Misc. 351 $values['PBX_TIME'] = date('c'); 352 $values['PBX_HASH'] = strtoupper($this->_config->getHmacAlgo()); 353 354 // Adding additionnal informations 355 $values = array_merge($values, $additionalParams); 356 357 // Sort parameters for simpler debug 358 ksort($values); 359 360 // Sign values 361 $sign = $this->signValues($values); 362 363 // Hash HMAC 364 $values['PBX_HMAC'] = $sign; 365 366 return $values; 367 } 368 369 public function convertParams(array $params) { 370 $result = array(); 371 foreach ($this->_resultMapping as $param => $key) { 372 if (isset($params[$param])) 373 $result[$key] = utf8_encode($params[$param]); 374 } 375 376 return $result; 377 } 378 379 public function getBillingEmail(WC_Order $order) { 380 return $order->get_billing_email(); 381 } 382 383 public function getBillingName(WC_Order $order) { 384 $name = $order->get_billing_first_name().' '.$order->get_billing_last_name(); 385 $name = remove_accents($name); 386 $name = trim(preg_replace('/[^-. a-zA-Z0-9]/', '', $name)); 387 return $name; 388 } 389 390 391 392 public function getClientIp() { 393 $ipaddress = ''; 394 if ($_SERVER['HTTP_CLIENT_IP']) 395 $ipaddress = $_SERVER['HTTP_CLIENT_IP']; 396 else if($_SERVER['HTTP_X_FORWARDED_FOR']) 397 $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; 398 else if($_SERVER['HTTP_X_FORWARDED']) 399 $ipaddress = $_SERVER['HTTP_X_FORWARDED']; 400 else if($_SERVER['HTTP_FORWARDED_FOR']) 401 $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; 402 else if($_SERVER['HTTP_FORWARDED']) 403 $ipaddress = $_SERVER['HTTP_FORWARDED']; 404 else if($_SERVER['REMOTE_ADDR']) 405 $ipaddress = $_SERVER['REMOTE_ADDR']; 406 else 407 $ipaddress = 'UNKNOWN'; 408 409 return $ipaddress; 410 } 411 412 public function getCurrency() { 413 return WC_Paybox_Iso4217Currency::getIsoCode(get_woocommerce_currency()); 414 } 415 416 public function getLanguages() { 417 return array( 418 'fr' => 'FRA', 419 'es' => 'ESP', 420 'it' => 'ITA', 421 'de' => 'DEU', 422 'nl' => 'NLD', 423 'sv' => 'SWE', 424 'pt' => 'PRT', 425 'default' => 'GBR', 426 ); 427 } 428 429 public function getOrderPayments($orderId, $type) { 430 global $wpdb; 431 $sql = 'select * from '.$wpdb->prefix.'wc_paybox_payment where order_id = %d and type = %s'; 432 $sql = $wpdb->prepare($sql, $orderId, $type); 433 return $wpdb->get_row($sql); 434 } 435 436 public function getParams() { 437 // Retrieves data 438 $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_Paybox_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_paybox_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_PAYBOX_PLUGIN . "-" . WC_PAYBOX_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_PAYBOX_PLUGIN); 316 $message = sprintf($message, $type); 317 throw new Exception($message); 318 } 319 320 // Paybox => 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_Paybox_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 public function getClientIp() 513 { 514 $ipaddress = ''; 515 if ($_SERVER['HTTP_CLIENT_IP']) { 516 $ipaddress = $_SERVER['HTTP_CLIENT_IP']; 517 } elseif ($_SERVER['HTTP_X_FORWARDED_FOR']) { 518 $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; 519 } elseif ($_SERVER['HTTP_X_FORWARDED']) { 520 $ipaddress = $_SERVER['HTTP_X_FORWARDED']; 521 } elseif ($_SERVER['HTTP_FORWARDED_FOR']) { 522 $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; 523 } elseif ($_SERVER['HTTP_FORWARDED']) { 524 $ipaddress = $_SERVER['HTTP_FORWARDED']; 525 } elseif ($_SERVER['REMOTE_ADDR']) { 526 $ipaddress = $_SERVER['REMOTE_ADDR']; 527 } else { 528 $ipaddress = 'UNKNOWN'; 529 } 530 531 return $ipaddress; 532 } 533 534 public function getCurrency() 535 { 536 return WC_Paybox_Iso4217Currency::getIsoCode(get_woocommerce_currency()); 537 } 538 539 public function getLanguages() 540 { 541 return array( 542 'fr' => 'FRA', 543 'es' => 'ESP', 544 'it' => 'ITA', 545 'de' => 'DEU', 546 'nl' => 'NLD', 547 'sv' => 'SWE', 548 'pt' => 'PRT', 549 'default' => 'GBR', 550 ); 551 } 552 553 public function getOrderPayments($orderId, $type) 554 { 555 global $wpdb; 556 $sql = 'select * from '.$wpdb->prefix.'wc_paybox_payment where order_id = %d and type = %s'; 557 $sql = $wpdb->prepare($sql, $orderId, $type); 558 559 return $wpdb->get_row($sql); 560 } 561 562 public function getParams() 563 { 564 // Retrieves data 565 $data = file_get_contents('php://input'); 439 566 if (empty($data)) { 440 567 $data = $_SERVER['QUERY_STRING']; 441 568 } 442 569 if (empty($data)) { 443 $message = 'An unexpected error in Paybox call has occured: no parameters.'; 444 throw new Exception(__($message, WC_PAYBOX_PLUGIN)); 445 } 446 447 // Extract signature 448 $matches = array(); 449 if (!preg_match('#^(.*)&K=(.*)$#', $data, $matches)) { 450 $message = 'An unexpected error in Paybox call has occured: missing signature.'; 451 throw new Exception(__($message, WC_PAYBOX_PLUGIN)); 452 } 453 454 // /*Check signature*/ 455 $signature = base64_decode(urldecode($matches[2])); 456 $pubkey = file_get_contents(dirname(__FILE__).'/pubkey.pem'); 457 $res = (boolean) openssl_verify($matches[1], $signature, $pubkey); 458 459 if (!$res) { 460 if (preg_match('#^s=i&(.*)&K=(.*)$#', $data, $matches)) { 461 $signature = base64_decode(urldecode($matches[2])); 462 $res = (boolean) openssl_verify($matches[1], $signature, $pubkey); 463 } 464 465 if (!$res) { 466 $message = 'An unexpected error in Paybox call has occured: invalid signature.'; 467 throw new Exception(__($message, WC_PAYBOX_PLUGIN)); 468 } 469 } 470 471 $rawParams = array(); 472 parse_str($data, $rawParams); 473 474 // Decrypt params 475 $params = $this->convertParams($rawParams); 476 if (empty($params)) { 477 $message = 'An unexpected error in Paybox call has occured: no parameters.'; 478 throw new Exception(__($message, WC_PAYBOX_PLUGIN)); 479 } 480 return $params; 481 } 482 483 public function getSystemUrl() { 484 $urls = $this->_config->getSystemUrls(); 485 if (empty($urls)) { 486 $message = 'Missing URL for Paybox system in configuration'; 487 throw new Exception(__($message, WC_PAYBOX_PLUGIN)); 488 } 489 490 // look for valid peer 491 $error = null; 492 foreach ($urls as $url) { 493 $testUrl = preg_replace('#^([a-zA-Z0-9]+://[^/]+)(/.*)?$#', '\1/load.html', $url); 494 495 $connectParams = array( 496 'timeout' => 5, 497 'redirection' => 0, 498 'user-agent' => 'Woocommerce Paybox module', 499 'httpversion' => '2', 500 ); 501 try { 502 $response = wp_remote_get($testUrl, $connectParams); 503 if (is_array($response) && ($response['response']['code'] == 200)) { 504 if (preg_match('#<div id="server_status" style="text-align:center;">OK</div>#', $response['body']) == 1) { 505 return $url; 506 } 507 } 508 } 509 catch (Exception $e) { 510 $error = $e; 511 } 512 } 513 514 // Here, there's a problem 515 throw new Exception(__('Paybox not available. Please try again later.')); 516 } 517 518 public function isMobile() { 519 // From http://detectmobilebrowsers.com/, regexp of 09/09/2013 520 global $_SERVER; 521 $userAgent = $_SERVER['HTTP_USER_AGENT']; 522 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)) { 523 return true; 524 } 525 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))) { 526 return true; 527 } 528 return false; 529 } 530 531 public function signValues(array $values) { 532 // Serialize values 533 $params = array(); 534 foreach ($values as $name => $value) { 535 $params[] = $name.'='.$value; 536 } 537 $query = implode('&', $params); 538 539 // Prepare key 540 $key = pack('H*', $this->_config->getHmacKey()); 541 542 // Sign values 543 $sign = hash_hmac($this->_config->getHmacAlgo(), $query, $key); 544 if ($sign === false) { 545 $errorMsg = 'Unable to create hmac signature. Maybe a wrong configuration.'; 546 throw new Exception(__($errorMsg, WC_PAYBOX_PLUGIN)); 547 } 548 549 return strtoupper($sign); 550 } 570 $message = 'An unexpected error in Paybox call has occured: no parameters.'; 571 throw new Exception(__($message, WC_PAYBOX_PLUGIN)); 572 } 573 574 // Extract signature 575 $matches = array(); 576 if (!preg_match('#^(.*)&K=(.*)$#', $data, $matches)) { 577 $message = 'An unexpected error in Paybox call has occured: missing signature.'; 578 throw new Exception(__($message, WC_PAYBOX_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 Paybox call has occured: invalid signature.'; 594 throw new Exception(__($message, WC_PAYBOX_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 Paybox call has occured: no parameters.'; 605 throw new Exception(__($message, WC_PAYBOX_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 Paybox system in configuration'; 616 throw new Exception(__($message, WC_PAYBOX_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 Paybox 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(__('Paybox 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 651 $userAgent = $_SERVER['HTTP_USER_AGENT']; 652 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)) { 653 return true; 654 } 655 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))) { 656 return true; 657 } 658 659 return false; 660 } 661 662 public function signValues(array $values) 663 { 664 // Serialize values 665 $params = array(); 666 foreach ($values as $name => $value) { 667 $params[] = $name.'='.$value; 668 } 669 $query = implode('&', $params); 670 671 // Prepare key 672 $key = pack('H*', $this->_config->getHmacKey()); 673 674 // Sign values 675 $sign = hash_hmac($this->_config->getHmacAlgo(), $query, $key); 676 if ($sign === false) { 677 $errorMsg = 'Unable to create hmac signature. Maybe a wrong configuration.'; 678 throw new Exception(__($errorMsg, WC_PAYBOX_PLUGIN)); 679 } 680 681 return strtoupper($sign); 682 } 551 683 552 684 public function toErrorMessage($code) 553 {685 { 554 686 if (isset($this->_errorCode[$code])) { 555 687 return $this->_errorCode[$code]; … … 559 691 } 560 692 561 /** 562 * Load order from the $token 563 * @param string $token Token (@see tokenizeOrder) 564 * @return Mage_Sales_Model_Order 565 */ 566 public function untokenizeOrder($token) { 567 $parts = explode(' - ', $token, 2); 568 if (count($parts) < 2) { 569 $message = 'Invalid decrypted token "%s"'; 570 throw new Exception(sprintf(__($message, WC_PAYBOX_PLUGIN), $token)); 571 } 572 573 // Retrieves order 574 $order = new WC_Order($parts[0]); 575 $temp_id=$order->get_id(); 576 if (empty($temp_id)) { 577 $message = 'Not existing order id from decrypted token "%s"'; 578 throw new Exception(sprintf(__($message, WC_PAYBOX_PLUGIN), $token)); 579 } 580 581 $name = $this->getBillingName($order); 582 if (($name != utf8_decode($parts[1])) && ($name != $parts[1])) { 583 $message = 'Consistency error on descrypted token "%s"'; 584 throw new Exception(sprintf(__($message, WC_PAYBOX_PLUGIN), $token)); 585 } 586 587 return $order; 588 } 693 /** 694 * Load order from the $token 695 * @param string $token Token (@see tokenizeOrder) 696 * @return Mage_Sales_Model_Order 697 */ 698 public function untokenizeOrder($token) 699 { 700 $parts = explode(' - ', $token, 2); 701 if (count($parts) < 2) { 702 $message = 'Invalid decrypted token "%s"'; 703 throw new Exception(sprintf(__($message, WC_PAYBOX_PLUGIN), $token)); 704 } 705 706 // Retrieves order 707 $order = new WC_Order($parts[0]); 708 $temp_id=$order->get_id(); 709 if (empty($temp_id)) { 710 $message = 'Not existing order id from decrypted token "%s"'; 711 throw new Exception(sprintf(__($message, WC_PAYBOX_PLUGIN), $token)); 712 } 713 714 $name = $this->getBillingName($order); 715 if (($name != utf8_decode($parts[1])) && ($name != $parts[1])) { 716 $message = 'Consistency error on descrypted token "%s"'; 717 throw new Exception(sprintf(__($message, WC_PAYBOX_PLUGIN), $token)); 718 } 719 720 return $order; 721 } 589 722 } -
paybox-woocommerce-gateway/trunk/lang/woocommerce-paybox-fr_FR.po
r2240593 r2501160 1 1 msgid "" 2 2 msgstr "" 3 "Project-Id-Version: Woo commerce Payboxplugin\n"4 "POT-Creation-Date: 2020- 02-06 14:16+0100\n"5 "PO-Revision-Date: 2020- 02-07 17:19+0100\n"3 "Project-Id-Version: WooCommerce Paybox Payment plugin\n" 4 "POT-Creation-Date: 2020-10-09 17:28+0200\n" 5 "PO-Revision-Date: 2020-10-09 17:34+0200\n" 6 6 "Last-Translator: Jérôme Cintas <jerome.cintas@verifonecom>\n" 7 7 "Language-Team: BM Services <[email protected]>\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. 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: woocommerce-paybox.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-paybox-abstract-gateway.php:68 20 #: class/wc-paybox-abstract-gateway.php: 11322 "X-Poedit-SearchPathExcluded-0: *.min.js\n" 23 24 #: class/wc-paybox-abstract-gateway.php:83 21 25 msgid "Enable/Disable" 22 26 msgstr "Actif/Inactif" 23 27 24 #: class/wc-paybox-abstract-gateway.php: 7028 #: class/wc-paybox-abstract-gateway.php:85 25 29 msgid "Enable Paybox Payment" 26 30 msgstr "Activer le paiement par Paybox" 27 31 28 #: class/wc-paybox-abstract-gateway.php: 7432 #: class/wc-paybox-abstract-gateway.php:89 29 33 msgid "Title" 30 34 msgstr "Titre" 31 35 32 #: class/wc-paybox-abstract-gateway.php: 7636 #: class/wc-paybox-abstract-gateway.php:91 33 37 msgid "This controls the title which the user sees during checkout." 34 38 msgstr "Titre visible par le client lors d'une commande." 35 39 36 #: class/wc-paybox-abstract-gateway.php:80 40 #: class/wc-paybox-abstract-gateway.php:102 41 msgid "Icon file" 42 msgstr "Fichier icône" 43 44 #: class/wc-paybox-abstract-gateway.php:104 45 msgid "Icon file to be displayed to customers. file are located in: " 46 msgstr "" 47 "Fichier d’icône à afficher au client. les fichiers sont dans le répertoire: " 48 49 #: class/wc-paybox-abstract-gateway.php:109 37 50 msgid "Description" 38 51 msgstr "Description" 39 52 40 #: class/wc-paybox-abstract-gateway.php: 8253 #: class/wc-paybox-abstract-gateway.php:111 41 54 msgid "Payment method description that the customer will see on your checkout." 42 55 msgstr "" … … 44 57 "commande." 45 58 46 #: class/wc-paybox-abstract-gateway.php: 8759 #: class/wc-paybox-abstract-gateway.php:116 47 60 msgid "Delay" 48 61 msgstr "Délai" 49 62 50 #: class/wc-paybox-abstract-gateway.php: 9063 #: class/wc-paybox-abstract-gateway.php:119 51 64 msgid "Immediate" 52 65 msgstr "Immédiat" 53 66 54 #: class/wc-paybox-abstract-gateway.php: 9167 #: class/wc-paybox-abstract-gateway.php:120 55 68 msgid "1 day" 56 69 msgstr "1 jour" 57 70 58 #: class/wc-paybox-abstract-gateway.php: 9271 #: class/wc-paybox-abstract-gateway.php:121 59 72 msgid "2 days" 60 73 msgstr "2 jours" 61 74 62 #: class/wc-paybox-abstract-gateway.php: 9375 #: class/wc-paybox-abstract-gateway.php:122 63 76 msgid "3 days" 64 77 msgstr "3 jours" 65 78 66 #: class/wc-paybox-abstract-gateway.php: 9479 #: class/wc-paybox-abstract-gateway.php:123 67 80 msgid "4 days" 68 81 msgstr "4 jours" 69 82 70 #: class/wc-paybox-abstract-gateway.php: 9583 #: class/wc-paybox-abstract-gateway.php:124 71 84 msgid "5 days" 72 85 msgstr "5 jours" 73 86 74 #: class/wc-paybox-abstract-gateway.php: 9687 #: class/wc-paybox-abstract-gateway.php:125 75 88 msgid "6 days" 76 89 msgstr "6 jours" 77 90 78 #: class/wc-paybox-abstract-gateway.php: 9791 #: class/wc-paybox-abstract-gateway.php:126 79 92 msgid "7 days" 80 93 msgstr "7 jours" 81 94 82 #: class/wc-paybox-abstract-gateway.php:103 83 #: class/wc-paybox-abstract-gateway.php:125 95 #: class/wc-paybox-abstract-gateway.php:132 84 96 msgid "Minimal amount" 85 97 msgstr "Montant minimal" 86 98 87 #: class/wc-paybox-abstract-gateway.php:1 0599 #: class/wc-paybox-abstract-gateway.php:134 88 100 msgid "" 89 101 "Enable this payment method for order with amount greater or equals to this " 90 102 "amount (empty to ignore this condition)" 91 103 msgstr "" 92 "Activer 3D Secure pour les commandes dont le montant est supérieur ou égal " 93 "au montant suivant (laissez vide pour ne pas activer cette condition)" 94 95 #: class/wc-paybox-abstract-gateway.php:109 104 "Activer ce moyen de paiement pour les commandes dont le montant est " 105 "supérieur ou égal au montant suivant (laissez vide pour ne pas activer cette " 106 "condition)" 107 108 #: class/wc-paybox-abstract-gateway.php:138 96 109 msgid "3D Secure" 97 110 msgstr "3D Secure" 98 111 99 #: class/wc-paybox-abstract-gateway.php:115 100 msgid "Enable 3D Secure" 101 msgstr "Activer 3D Secure" 102 103 #: class/wc-paybox-abstract-gateway.php:116 104 msgid "" 105 "You can enable 3D Secure for all orders or depending on following conditions" 106 msgstr "" 107 "Vous pouvez activer 3D Secure pour toutes les commandes ou en fonction des " 108 "conditions suivantes" 109 110 #: class/wc-paybox-abstract-gateway.php:119 111 msgid "Disabled" 112 msgstr "Inactif" 113 114 #: class/wc-paybox-abstract-gateway.php:120 115 msgid "Enabled" 116 msgstr "Actif" 117 118 #: class/wc-paybox-abstract-gateway.php:121 119 msgid "Conditional" 120 msgstr "Sélectif" 121 122 #: class/wc-paybox-abstract-gateway.php:127 123 msgid "" 124 "Enable 3D Secure for order with amount greater or equals to this amount " 125 "(empty to ignore this condition)" 126 msgstr "" 127 "Activer 3D Secure pour les commandes dont le montant est supérieur ou égal " 128 "au montant suivant" 129 130 #: class/wc-paybox-abstract-gateway.php:131 112 #: class/wc-paybox-abstract-gateway.php:142 113 msgid "Version" 114 msgstr "Version" 115 116 #: class/wc-paybox-abstract-gateway.php:152 131 117 msgid "Paybox account" 132 118 msgstr "Compte Paybox" 133 119 134 #: class/wc-paybox-abstract-gateway.php:1 35120 #: class/wc-paybox-abstract-gateway.php:156 135 121 msgid "Site number" 136 122 msgstr "Numéro du site" 137 123 138 #: class/wc-paybox-abstract-gateway.php:1 37124 #: class/wc-paybox-abstract-gateway.php:158 139 125 msgid "Site number provided by Paybox." 140 126 msgstr "Le numéro du site vous est fourni par Paybox." 141 127 142 #: class/wc-paybox-abstract-gateway.php:1 41128 #: class/wc-paybox-abstract-gateway.php:162 143 129 msgid "Rank number" 144 130 msgstr "Rang" 145 131 146 #: class/wc-paybox-abstract-gateway.php:1 43132 #: class/wc-paybox-abstract-gateway.php:164 147 133 msgid "Rank number provided by Paybox (two last digits)." 148 134 msgstr "Numéro de rang fourni par Paybox (deux derniers chiffres)." 149 135 150 #: class/wc-paybox-abstract-gateway.php:1 47136 #: class/wc-paybox-abstract-gateway.php:168 151 137 msgid "Login" 152 138 msgstr "Identifiant" 153 139 154 #: class/wc-paybox-abstract-gateway.php:1 49140 #: class/wc-paybox-abstract-gateway.php:170 155 141 msgid "Internal login provided by Paybox." 156 142 msgstr "Votre identifiant vous est fourni par Paybox." 157 143 158 #: class/wc-paybox-abstract-gateway.php:1 53144 #: class/wc-paybox-abstract-gateway.php:174 159 145 msgid "HMAC" 160 146 msgstr "HMAC" 161 147 162 #: class/wc-paybox-abstract-gateway.php:1 55148 #: class/wc-paybox-abstract-gateway.php:176 163 149 msgid "Secrete HMAC key to create using the Paybox interface." 164 150 msgstr "Clé secrète HMAC à générer puis activer dans votre Back-Office Paybox." 165 151 166 #: class/wc-paybox-abstract-gateway.php:1 59152 #: class/wc-paybox-abstract-gateway.php:180 167 153 msgid "Environment" 168 154 msgstr "Environnement" 169 155 170 #: class/wc-paybox-abstract-gateway.php:1 61156 #: class/wc-paybox-abstract-gateway.php:182 171 157 msgid "In test mode your payments will not be sent to the bank." 172 158 msgstr "En mode test, vos paiements ne seront pas envoyé à la banque." 173 159 174 #: class/wc-paybox-abstract-gateway.php:1 63160 #: class/wc-paybox-abstract-gateway.php:184 175 161 msgid "Production" 176 162 msgstr "Production" 177 163 178 #: class/wc-paybox-abstract-gateway.php:1 64164 #: class/wc-paybox-abstract-gateway.php:185 179 165 msgid "Test" 180 166 msgstr "Test" 181 167 182 #: class/wc-paybox-abstract-gateway.php:1 69168 #: class/wc-paybox-abstract-gateway.php:190 183 169 msgid "Technical settings" 184 170 msgstr "Configuration technique" 185 171 186 #: class/wc-paybox-abstract-gateway.php:1 73187 msgid "Allowed IPs "188 msgstr "Adresses IP autorisées "189 190 #: class/wc-paybox-abstract-gateway.php:1 75172 #: class/wc-paybox-abstract-gateway.php:194 173 msgid "Allowed IPs" 174 msgstr "Adresses IP autorisées" 175 176 #: class/wc-paybox-abstract-gateway.php:196 191 177 msgid "A coma separated list of Paybox IPs." 192 178 msgstr "" … … 194 180 "réception des Notifications Instantanées de Paiement." 195 181 196 #: class/wc-paybox-abstract-gateway.php: 179182 #: class/wc-paybox-abstract-gateway.php:200 197 183 msgid "Debug" 198 184 msgstr "Debug" 199 185 200 #: class/wc-paybox-abstract-gateway.php: 181186 #: class/wc-paybox-abstract-gateway.php:202 201 187 msgid "Enable some debugging information" 202 188 msgstr "Activer les informations de debuggage" 203 189 204 #: class/wc-paybox-abstract-gateway.php:2 13190 #: class/wc-paybox-abstract-gateway.php:237 205 191 msgid "Customer is redirected to Paybox payment page" 206 192 msgstr "Le client est redirigé vers la pages de paiement paybox" 207 193 208 #: class/wc-paybox-abstract-gateway.php:2 47194 #: class/wc-paybox-abstract-gateway.php:272 209 195 msgid "Back..." 210 196 msgstr "Retour..." 211 197 212 #: class/wc-paybox-abstract-gateway.php:2 55198 #: class/wc-paybox-abstract-gateway.php:280 213 199 msgid "" 214 200 "This is a debug view. Click continue to be redirected to Paybox payment page." … … 217 203 "la page de paiement Paybox." 218 204 219 #: class/wc-paybox-abstract-gateway.php:2 59205 #: class/wc-paybox-abstract-gateway.php:284 220 206 msgid "" 221 207 "You will be redirected to the Paybox payment page. If not, please use the " … … 225 211 "cas, merci d'utiliser le bouton ci dessous." 226 212 227 #: class/wc-paybox-abstract-gateway.php:2 67213 #: class/wc-paybox-abstract-gateway.php:292 228 214 msgid "Continue..." 229 215 msgstr "Continuer..." 230 216 231 #: class/wc-paybox-abstract-gateway.php:3 21232 #: class/wc-paybox-abstract-gateway.php:3 57217 #: class/wc-paybox-abstract-gateway.php:348 218 #: class/wc-paybox-abstract-gateway.php:388 233 219 msgid "Customer is back from Paybox payment page." 234 220 msgstr "Le client revient de la page de paiement Paybox." 235 221 236 #: class/wc-paybox-abstract-gateway.php:3 22237 #: class/wc-paybox-abstract-gateway.php:3 24222 #: class/wc-paybox-abstract-gateway.php:349 223 #: class/wc-paybox-abstract-gateway.php:351 238 224 msgid "Payment refused by Paybox" 239 225 msgstr "Le paiement a été refusé par Paybox" 240 226 241 #: class/wc-paybox-abstract-gateway.php:3 40227 #: class/wc-paybox-abstract-gateway.php:369 242 228 msgid "Payment was canceled by user on Paybox payment page." 243 229 msgstr "Le paiement a été annulé par le client sur la page de paiement Paybox." 244 230 245 #: class/wc-paybox-abstract-gateway.php:3 42231 #: class/wc-paybox-abstract-gateway.php:371 246 232 msgid "Payment canceled" 247 233 msgstr "Le paiement a été annulé" 248 234 249 #: class/wc-paybox-abstract-gateway.php: 399235 #: class/wc-paybox-abstract-gateway.php:431 250 236 #, php-format 251 237 msgid "Missing %s parameter in Paybox call" 252 msgstr "Le param être %s manque dans l'appel Paybox"253 254 #: class/wc-paybox-abstract-gateway.php:4 10255 #: class/wc-paybox-abstract-gateway.php:4 19238 msgstr "Le paramètre %s manque dans l'appel Paybox" 239 240 #: class/wc-paybox-abstract-gateway.php:441 241 #: class/wc-paybox-abstract-gateway.php:450 256 242 msgid "Payment was authorized and captured by Paybox." 257 243 msgstr "Paiement autorisé et capturé par Paybox." 258 244 259 #: class/wc-paybox-abstract-gateway.php:4 23245 #: class/wc-paybox-abstract-gateway.php:454 260 246 msgid "Second payment was captured by Paybox." 261 247 msgstr "Deuxième paiement capturé par Paybox." 262 248 263 #: class/wc-paybox-abstract-gateway.php:4 26249 #: class/wc-paybox-abstract-gateway.php:457 264 250 msgid "Third payment was captured by Paybox." 265 251 msgstr "Troisième paiement capturé par Paybox." 266 252 267 #: class/wc-paybox-abstract-gateway.php:4 29253 #: class/wc-paybox-abstract-gateway.php:460 268 254 msgid "Invalid three-time payment status" 269 255 msgstr "Statut du paiement en trois fois non valide" 270 256 271 #: class/wc-paybox-abstract-gateway.php:4 36 class/wc-paybox.php:303257 #: class/wc-paybox-abstract-gateway.php:466 class/wc-paybox.php:314 272 258 #, php-format 273 259 msgid "Unexpected type %s" 274 260 msgstr "Type %s inattendu" 275 261 276 #: class/wc-paybox-abstract-gateway.php:4 45262 #: class/wc-paybox-abstract-gateway.php:473 277 263 #, php-format 278 264 msgid "Payment was refused by Paybox (%s)." 279 265 msgstr "Paiement refusé par Paybox (%s)." 280 266 281 #: class/wc-paybox-encrypt.php:6 1 class/wc-paybox-encrypt.php:76267 #: class/wc-paybox-encrypt.php:67 class/wc-paybox-encrypt.php:83 282 268 msgid "" 283 269 "For some reason, the key has just been generated. please reenter the HMAC " … … 287 273 "clé HMAC pour qu'elle soit cryptée." 288 274 289 #: class/wc-paybox-standard-gateway.php:1 1275 #: class/wc-paybox-standard-gateway.php:19 290 276 msgid "Paybox" 291 277 msgstr "Paybox" 292 278 293 #: class/wc-paybox-standard-gateway.php: 29294 #: class/wc-paybox-threetime-gateway.php:5 5279 #: class/wc-paybox-standard-gateway.php:42 280 #: class/wc-paybox-threetime-gateway.php:59 295 281 msgid "Reference:" 296 msgstr "Référence /"297 298 #: class/wc-paybox-standard-gateway.php: 31299 #: class/wc-paybox-threetime-gateway.php: 57282 msgstr "Référence:" 283 284 #: class/wc-paybox-standard-gateway.php:44 285 #: class/wc-paybox-threetime-gateway.php:61 300 286 msgid "Country of IP:" 301 287 msgstr "Pays de l'IP:" 302 288 303 #: class/wc-paybox-standard-gateway.php: 33304 #: class/wc-paybox-threetime-gateway.php: 59289 #: class/wc-paybox-standard-gateway.php:46 290 #: class/wc-paybox-threetime-gateway.php:63 305 291 msgid "Processing date:" 306 292 msgstr "Date de traitement:" 307 293 308 #: class/wc-paybox-standard-gateway.php: 35309 #: class/wc-paybox-threetime-gateway.php:6 1294 #: class/wc-paybox-standard-gateway.php:48 295 #: class/wc-paybox-threetime-gateway.php:65 310 296 msgid "Card numbers:" 311 297 msgstr "Numéros de la carte:" 312 298 313 #: class/wc-paybox-standard-gateway.php: 38314 #: class/wc-paybox-threetime-gateway.php:6 4299 #: class/wc-paybox-standard-gateway.php:51 300 #: class/wc-paybox-threetime-gateway.php:68 315 301 msgid "Validity date:" 316 302 msgstr "Date de validité:" 317 303 318 #: class/wc-paybox-standard-gateway.php:40 319 #: class/wc-paybox-threetime-gateway.php:89 304 #: class/wc-paybox-standard-gateway.php:60 305 #: class/wc-paybox-threetime-gateway.php:77 306 msgid "3DS version:" 307 msgstr "Version 3DS:" 308 309 #: class/wc-paybox-standard-gateway.php:63 310 #: class/wc-paybox-threetime-gateway.php:100 320 311 msgid "Transaction:" 321 312 msgstr "Transaction:" 322 313 323 #: class/wc-paybox-standard-gateway.php: 41324 #: class/wc-paybox-threetime-gateway.php: 90314 #: class/wc-paybox-standard-gateway.php:64 315 #: class/wc-paybox-threetime-gateway.php:101 325 316 msgid "Call:" 326 317 msgstr "Appel:" 327 318 328 #: class/wc-paybox-standard-gateway.php: 42329 #: class/wc-paybox-threetime-gateway.php: 91319 #: class/wc-paybox-standard-gateway.php:65 320 #: class/wc-paybox-threetime-gateway.php:102 330 321 msgid "Authorization:" 331 322 msgstr "Autorisation:" 332 323 333 #: class/wc-paybox-standard-gateway.php: 44334 #: class/wc-paybox-threetime-gateway.php: 93324 #: class/wc-paybox-standard-gateway.php:67 325 #: class/wc-paybox-threetime-gateway.php:104 335 326 msgid "Payment information" 336 327 msgstr "Informations sur le paiement" 337 328 338 #: class/wc-paybox-threetime-gateway.php: 11329 #: class/wc-paybox-threetime-gateway.php:21 339 330 msgid "Paybox 3 times" 340 331 msgstr "Paybox paiement en trois fois" 341 332 342 #: class/wc-paybox-threetime-gateway.php: 69333 #: class/wc-paybox-threetime-gateway.php:82 343 334 msgid "First debit:" 344 335 msgstr "Premier paiement:" 345 336 346 #: class/wc-paybox-threetime-gateway.php: 76347 #: class/wc-paybox-threetime-gateway.php: 85337 #: class/wc-paybox-threetime-gateway.php:88 338 #: class/wc-paybox-threetime-gateway.php:96 348 339 msgid "Not achieved" 349 340 msgstr "Non traité" 350 341 351 #: class/wc-paybox-threetime-gateway.php: 78342 #: class/wc-paybox-threetime-gateway.php:90 352 343 msgid "Second debit:" 353 344 msgstr "Seconde échéance:" 354 345 355 #: class/wc-paybox-threetime-gateway.php: 87346 #: class/wc-paybox-threetime-gateway.php:98 356 347 msgid "Third debit:" 357 348 msgstr "Troisième échéance:" 358 349 359 #: class/wc-paybox.php:322 360 #, php-format 361 msgid "Unexpected 3-D Secure status %s" 362 msgstr "Statut 3-D Secure inattendu: %s" 363 364 #: class/wc-paybox.php:519 350 #: class/wc-paybox.php:644 365 351 msgid "Paybox not available. Please try again later." 366 352 msgstr "Paybox n'est pas disponible. Merci d'essayer plus tard." 367 353 368 #: woocommerce-paybox.php:122 354 #: woocommerce-paybox.php:40 355 msgid "WooCommerce must be activated" 356 msgstr "WooCommerce doit être activé" 357 358 #: woocommerce-paybox.php:129 369 359 msgid "HMAC key cannot be decrypted please re-enter or reinitialise it." 370 360 msgstr "" … … 372 362 "HMAC, la régénérer si besoin." 373 363 374 #~ msgid "IPN call from %s not allowed." 375 #~ msgstr "Appel IPN depuis %s non autorisé." 376 377 #~ msgid "Rank number provided by Paybox." 378 #~ msgstr "Le rang de votre site vous est fourni par Paybox" 379 380 #~ msgid "Unexpected 3D Secure status %s" 381 #~ msgstr "Satut 3D Secure %s inattendu" 382 383 #~ msgid "Depending on following conditions (and)" 384 #~ msgstr "Suivant les conditions ci-dessous (et)" 385 386 #~ msgid "Depending on following conditions (or)" 387 #~ msgstr "Suivant les conditions ci-dessous (ou)" 388 389 #~ msgid "Maximal order count" 390 #~ msgstr "Nombre maximal de commande" 391 392 #~ msgid "" 393 #~ "Enable 3D Secure for customer with less than this number of orders (empty " 394 #~ "to ignore this condition)" 395 #~ msgstr "" 396 #~ "Activer 3D Secure pour les clients ayant passé moins de for customer " 397 #~ "with less than this number of orders (laisser vide pour ignorer cette " 398 #~ "condition)" 399 400 #~ msgid "TODO" 401 #~ msgstr "TODO" 364 #: woocommerce-paybox.php:134 365 msgid "Woocommerce is not active !" 366 msgstr "WooCommerce n’est pas activé !" 367 368 #. Plugin Name of the plugin/theme 369 msgid "WooCommerce Paybox Payment plugin" 370 msgstr "Le client est redirigé vers la page de paiement Paybox" 371 372 #. Description of the plugin/theme 373 msgid "Paybox gateway payment plugins for WooCommerce" 374 msgstr "Extension Paybox - passerelle de paiement pour WooCommerce" 375 376 #. Author of the plugin/theme 377 msgid "Paybox Verifone" 378 msgstr "Paybox Verifone" 379 380 #. Author URI of the plugin/theme 381 msgid "http://www.paybox.com" 382 msgstr "" -
paybox-woocommerce-gateway/trunk/readme.txt
r2298641 r2501160 4 4 Tags: Payment Gateway, Orders, woocommerce, e-commerce, payment, Paybox 5 5 Requires at least: 3.0.1 6 Tested up to: 5. 4.17 Stable tag: 0.9.9 6 Tested up to: 5.7 7 Stable tag: 0.9.9.2 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.0.111 WC tested up to: 5.1.0 12 12 This plugin is a Paybox payment gateway for WooCommerce 3.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 Paybox 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 Paybox 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 Paybox 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 Paybox server will not be able to contact it. 53 The oder paid with Paybox 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 Paybox 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 Paybox 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.2 = 71 Force 3DSv2 for all cards 72 73 = 0.9.9.1 = 74 Add 3DSv2 support 75 70 76 = 0.9.9 = 71 77 Fix 3 times payment not displayed … … 81 87 82 88 = 0.9.8.6 = 83 Correcting 3x payments IPN 89 Correcting 3x payments IPN 84 90 85 91 = 0.9.8.5 = … … 117 123 118 124 = 0.9.6.7 = 119 Changed: 120 only rely on the $_SERVER data to check for the IP address: 125 Changed: 126 only rely on the $_SERVER data to check for the IP address: 121 127 this solves the non reception of the IPN (error 500) 122 128 123 129 = 0.9.6.6 = 124 Second release: 125 Fixed: 130 Second release: 131 Fixed: 126 132 -Missing table now created ok. 127 -"Syntax error: Unexpected token < " message when checking out, 133 -"Syntax error: Unexpected token < " message when checking out, 128 134 -Use of deprecated functions to get pages url: now we use endpoints. 129 135 -
paybox-woocommerce-gateway/trunk/woocommerce-paybox.php
r2298639 r2501160 3 3 * Plugin Name: WooCommerce Paybox Payment plugin 4 4 * Description: Paybox gateway payment plugins for WooCommerce 5 * Version: 0.9.9 5 * Version: 0.9.9.2 6 6 * Author: Paybox Verifone 7 7 * Author URI: http://www.paybox.com 8 8 * Text Domain: woocommerce-paybox 9 * 9 * 10 10 * @package WordPress 11 11 * @since 0.9.0 12 12 */ 13 13 14 // Ensure not called directly 14 15 if (!defined('ABSPATH')) { 15 exit;16 exit; 16 17 } 17 18 18 function isWoocommerceActive(){ 19 // Makes sure the plugin is defined before trying to use it 20 if ( !class_exists( 'WC_Payment_Gateway' ) ) { 21 return false; 22 } 23 return true; 19 function isWoocommerceActive() 20 { 21 // Makes sure the plugin is defined before trying to use it 22 if (!class_exists('WC_Payment_Gateway')) { 23 return false; 24 } 25 return true; 24 26 } 25 27 26 27 28 // Ensure WooCommerce is active 28 29 30 29 define('WC_PAYBOX_PLUGIN', 'woocommerce-paybox'); 31 define('WC_PAYBOX_VERSION', '0.9.9 ');30 define('WC_PAYBOX_VERSION', '0.9.9.2'); 32 31 define('WC_PAYBOX_KEY_PATH', ABSPATH . '/kek.php'); 33 32 33 function woocommerce_paybox_installation() 34 { 35 global $wpdb; 36 $installed_ver = get_option("WC_PAYBOX_PLUGIN.'_version'"); 34 37 35 function woocommerce_paybox_installation() { 36 global $wpdb; 37 $installed_ver = get_option( "WC_PAYBOX_PLUGIN.'_version'" ); 38 39 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 40 if(!isWoocommerceActive()) { 41 _e('WooCommerce must be activated', WC_PAYBOX_PLUGIN); 42 die(); 43 } 38 include_once(ABSPATH . 'wp-admin/includes/plugin.php'); 39 if (!isWoocommerceActive()) { 40 _e('WooCommerce must be activated', WC_PAYBOX_PLUGIN); 41 die(); 42 } 44 43 45 if ( $installed_ver != WC_PAYBOX_VERSION) {46 $tableName = $wpdb->prefix.'wc_paybox_payment';47 $sql = "CREATE TABLE $tableName (48 id int not null auto_increment,49 order_id bigint not null,50 type enum('capture', 'first_payment', 'second_payment', 'third_payment') not null,51 data varchar(2048) not null,52 KEY order_id (order_id),53 PRIMARY KEY (id))";44 if ($installed_ver != WC_PAYBOX_VERSION) { 45 $tableName = $wpdb->prefix.'wc_paybox_payment'; 46 $sql = "CREATE TABLE $tableName ( 47 id int not null auto_increment, 48 order_id bigint not null, 49 type enum('capture', 'first_payment', 'second_payment', 'third_payment') not null, 50 data varchar(2048) not null, 51 KEY order_id (order_id), 52 PRIMARY KEY (id))"; 54 53 55 require_once(ABSPATH.'wp-admin/includes/upgrade.php');54 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 56 55 57 dbDelta( $sql);56 dbDelta($sql); 58 57 59 update_option(WC_PAYBOX_PLUGIN.'_version', WC_PAYBOX_VERSION); 60 } 61 58 update_option(WC_PAYBOX_PLUGIN . '_version', WC_PAYBOX_VERSION); 59 } 62 60 } 63 function woocommerce_paybox_initialization() {64 if(!isWoocommerceActive()){65 return ("Woocommerce not Active") ;66 }67 $class = 'WC_Paybox_Abstract_Gateway';68 61 69 if (!class_exists($class)) { 70 require_once(dirname(__FILE__).'/class/wc-paybox-config.php'); 71 require_once(dirname(__FILE__).'/class/wc-paybox-iso4217currency.php'); 72 require_once(dirname(__FILE__).'/class/wc-paybox.php'); 73 require_once(dirname(__FILE__).'/class/wc-paybox-abstract-gateway.php'); 74 require_once(dirname(__FILE__).'/class/wc-paybox-standard-gateway.php'); 75 require_once(dirname(__FILE__).'/class/wc-paybox-threetime-gateway.php'); 76 require_once(dirname(__FILE__).'/class/wc-paybox-encrypt.php'); 77 } 62 function woocommerce_paybox_initialization() 63 { 64 if (!isWoocommerceActive()) { 65 return "Woocommerce not Active"; 66 } 67 $class = 'WC_Paybox_Abstract_Gateway'; 78 68 79 load_plugin_textdomain(WC_PAYBOX_PLUGIN, false, dirname(plugin_basename(__FILE__)).'/lang/'); 69 if (!class_exists($class)) { 70 require_once(dirname(__FILE__).'/class/wc-paybox-config.php'); 71 require_once(dirname(__FILE__).'/class/wc-paybox-iso4217currency.php'); 72 require_once(dirname(__FILE__).'/class/wc-paybox-iso3166-country.php'); 73 require_once(dirname(__FILE__).'/class/wc-paybox.php'); 74 require_once(dirname(__FILE__).'/class/wc-paybox-abstract-gateway.php'); 75 require_once(dirname(__FILE__).'/class/wc-paybox-standard-gateway.php'); 76 require_once(dirname(__FILE__).'/class/wc-paybox-threetime-gateway.php'); 77 require_once(dirname(__FILE__).'/class/wc-paybox-encrypt.php'); 78 } 80 79 81 $crypto = new PayboxEncrypt(); 82 if(!file_exists(WC_PAYBOX_KEY_PATH))$crypto->generateKey(); 83 84 if ( get_site_option( WC_PAYBOX_PLUGIN.'_version' ) != WC_PAYBOX_VERSION ) { 80 load_plugin_textdomain(WC_PAYBOX_PLUGIN, false, dirname(plugin_basename(__FILE__)).'/lang/'); 81 82 $crypto = new PayboxEncrypt(); 83 if (!file_exists(WC_PAYBOX_KEY_PATH)) { 84 $crypto->generateKey(); 85 } 86 87 if (get_site_option(WC_PAYBOX_PLUGIN . '_version') != WC_PAYBOX_VERSION) { 85 88 woocommerce_paybox_installation(); 86 89 } 87 90 } 88 91 89 function woocommerce_paybox_register(array $methods) { 90 $methods[] = 'WC_PbxStdGw'; 91 $methods[] = 'WC_Pbx3xGw'; 92 $methods[] = 'WC_Paybox_Threetime_Gateway'; 93 return $methods; 92 function woocommerce_paybox_register(array $methods) 93 { 94 $methods[] = 'WC_PbxStdGw'; 95 $methods[] = 'WC_Pbx3xGw'; 96 $methods[] = 'WC_Paybox_Threetime_Gateway'; 97 return $methods; 94 98 } 95 99 … … 98 102 add_filter('woocommerce_payment_gateways', 'woocommerce_paybox_register'); 99 103 100 function woocommerce_paybox_show_details(WC_Order $order) { 101 $method = get_post_meta($order->get_id(), '_payment_method', true); 102 switch ($method) { 103 case 'paybox_std': 104 $method = new WC_PbxStdGw(); 105 $method->showDetails($order); 106 break; 107 case 'paybox_3x': 108 $method = new WC_Pbx3xGw(); 109 $method->showDetails($order); 110 break; 111 } 104 function woocommerce_paybox_show_details(WC_Order $order) 105 { 106 $method = get_post_meta($order->get_id(), '_payment_method', true); 107 switch ($method) { 108 case 'paybox_std': 109 $method = new WC_PbxStdGw(); 110 $method->showDetails($order); 111 break; 112 case 'paybox_3x': 113 $method = new WC_Pbx3xGw(); 114 $method->showDetails($order); 115 break; 116 } 112 117 } 113 118 114 119 add_action('woocommerce_admin_order_data_after_billing_address', 'woocommerce_paybox_show_details'); 115 120 116 117 function Pbx_hmac_admin_notice(){ 118 119 if(isWoocommerceActive()){ 120 $temp = new WC_PbxStdGw(); 121 $plugin_data = get_plugin_data( __FILE__ ); 122 $plugin_name = $plugin_data['Name']; 123 if ( !$temp->checkCrypto() ) { 124 echo "<div class='notice notice-error is-dismissible'> 125 <p><strong>/!\ Attention ! plugin ".$plugin_name." : </strong>".__('HMAC key cannot be decrypted please re-enter or reinitialise it.', WC_PAYBOX_PLUGIN)."</p> 126 </div>"; 127 } 128 }else{ 129 echo "<div class='notice notice-error is-dismissible'> 130 <p><strong>/!\ Attention ! plugin Paybox : </strong>".__('Woocommerce is not active !.', 'woocommerce-paybox')."</p> 131 </div>"; 132 133 } 134 121 function Pbx_hmac_admin_notice() 122 { 123 if (isWoocommerceActive()) { 124 $temp = new WC_PbxStdGw(); 125 $plugin_data = get_plugin_data(__FILE__); 126 $plugin_name = $plugin_data['Name']; 127 if (!$temp->checkCrypto()) { 128 echo "<div class='notice notice-error is-dismissible'> 129 <p><strong>/!\ Attention ! plugin ".$plugin_name." : </strong>".__('HMAC key cannot be decrypted please re-enter or reinitialise it.', WC_PAYBOX_PLUGIN)."</p> 130 </div>"; 131 } 132 } else { 133 echo "<div class='notice notice-error is-dismissible'> 134 <p><strong>/!\ Attention ! plugin Paybox : </strong>".__('Woocommerce is not active !', 'woocommerce-paybox')."</p> 135 </div>"; 136 } 135 137 } 136 138 add_action('admin_notices', 'Pbx_hmac_admin_notice');
Note: See TracChangeset
for help on using the changeset viewer.