milerwan Posted March 26, 2017 Share Posted March 26, 2017 (edited) Contributions concerned: - Paiment ATOS/SIPS RETOUR AUTO : http://addons.oscommerce.com/info/8253 - ATOS v1.0 : http://addons.oscommerce.com/info/8401 For users of the ATOS / SIPS RETURN AUTO contribution, which encounter a problem of duplicate order after payment, I propose a correction that definitively solves this bug. Here are some important points about the changes to the atos.php file: 1. Changes to the calculation of the decimals of the amount cashed (original is an intermittent error of 1 cent against the shop in relation to the exact amount of the order, this corrects it) 2. Fix duplicate order 3. Change to IP v6 (otherwise error / failure when paying for IP v6 users) In the atos.php file (includes/modules/payment/atos.php), modify/replace the makeRequest function from line 375 as follows: // ---------------------------------------------------------------- // makeRequest() // // Make the request by executing the request external application function makeRequest($amount, $currency) { global $customer_id, $_SERVER, $language; // $amount = sprintf("%03d", $amount * $this->_getCurrencyUnit($currency)); $amount = tep_round($amount,2) * $this->_getCurrencyUnit($currency); $pathfile = $this->_getPathFileName(); $command = MODULE_PAYMENT_ATOS_BIN_REQUEST; $command .= " " . $this->os_info['quote'] . "pathfile=" . $pathfile . $this->os_info['quote']; $command .= " merchant_id=" . MODULE_PAYMENT_ATOS_ID; $command .= " amount=" . $amount; $command .= " currency_code=" . $this->_getCurrencyCode(DEFAULT_CURRENCY); $command .= " language=" . $this->_getLanguageCode($language); //Retour automatique a la boutique apres paiement by brouillard s'embrouille $command .= " data=NO_RESPONSE_PAGE"; $command .= " " . $this->os_info['quote'] . "normal_return_url=" . tep_href_link('atos_response.php', '', 'SSL', false) . $this->os_info['quote']; $command .= " " . $this->os_info['quote'] . "cancel_return_url=" . tep_href_link('atos_response.php', '', 'SSL', false) . $this->os_info['quote']; //Fin Retour automatique a la boutique apres paiement by brouillard s'embrouille // BOF Fix doublon commande // $command .= " " . $this->os_info['quote'] . "automatic_response_url=" . tep_href_link(FILENAME_CHECKOUT_PROCESS, tep_session_name() . '=' . tep_session_id(), 'NONSSL', false) . $this->os_info['quote']; $command .= " " . $this->os_info['quote'] . "automatic_response_url=" . tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'NONSSL', false) . $this->os_info['quote']; // EOF Fix doublon commande $command .= " customer_id=" . $customer_id; // IP V6 fix // $command .= " customer_ip_address=" . $_SERVER['REMOTE_ADDR']; $command .= " customer_ip_address=" . substr($_SERVER['REMOTE_ADDR'], 0, 19); if (!@ini_get("safe_mode")) $command .= ' 2>&1'; $sips_result = exec($command); $sips = array(); $sips_values = preg_split ("/!/", $sips_result); $sips['code'] = $sips_values[1]; $sips['error'] = $sips_values[2]; $sips['message'] = $sips_values[3]; $sips['command'] = $command; $sips['output'] = $sips_result; if (!isset($sips['code'])) { $sips['code'] = -1; $sips['error'] = $sips_result; } if ($sips['code'] != 0) { $sips['amount'] = $amount; $sips['lang'] = $lang; $sips['id'] = tep_session_id(); } return $sips; } Obviously, this change preserves the automatic return to the shop. :) Edited March 26, 2017 by milerwan Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
milerwan Posted March 28, 2017 Author Share Posted March 28, 2017 Improvement code for the calculation of the rounding : // $amount = sprintf("%03d", $amount * $this->_getCurrencyUnit($currency)); $amount = tep_round($amount,2) * $this->_getCurrencyUnit($currency); $amount = sprintf("%03d", tep_round($amount,2)); NB: In case of currencies rates with decimals. Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
milerwan Posted May 12, 2017 Author Share Posted May 12, 2017 (edited) Improvement code for the calculation of the rounding : // $amount = sprintf("%03d", $amount * $this->_getCurrencyUnit($currency)); $amount = tep_round($amount,2) * $this->_getCurrencyUnit($currency); $amount = sprintf("%03d", tep_round($amount,2)); NB: In case of currencies rates with decimals. Sorry use this code, because tep_round is not good for sprintf occurence and redo the calculating error : // $amount = sprintf("%03d", $amount * $this->_getCurrencyUnit($currency)); $amount = tep_round($amount,2) * $this->_getCurrencyUnit($currency); $amount = sprintf("%03d", round($amount,2)); Edited May 12, 2017 by milerwan Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.