Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Jun 2013
    Posts
    47
    Plugin Contributions
    0

    help question Payment module ATOS for PHP5.3 ?

    http://www.zen-cart.com/downloads.php?do=file&id=728
    this Atos payment module works for PHP5.2, but it doesn't work for PHP5.3,

    i tried modifying the file /includes/modules/payment/atos.php to make it compatible with PHP5.3

    two parts, FROM
    PHP Code:
    if (eregi('<form [^>]*action="([^"]*)"[^>]*>(.*)</form>'$sips['message'], $regs)) { 
    TO
    PHP Code:
    if (preg_match('/<form.*action="([^"]*)"[^>]*>(.*)</form>/i'$sips['message'], $regs) ) { 
    FROM
    PHP Code:
    $cc split('\.'$response['card_number']); 
    TO
    PHP Code:
    $cc preg_split('/\./'$response['card_number']); 
    two parts, FROM
    PHP Code:
    $link ereg_replace('&amp;''&'$link); 
    TO
    PHP Code:
    $link preg_replace('/&amp;/''&'$link); 
    FROM
    PHP Code:
    $sips_values     split ("!"$sips_result); 
    TO
    PHP Code:
    $sips_values     explode ("/!/"$sips_result); 
    FROM
    PHP Code:
    $sips_resp split "!"$sips_resp ); 
    TO
    PHP Code:
    $sips_resp explode "/!/"$sips_resp ); 
    two parts, FROM
    PHP Code:
    $data split('\.'$file); 
    TO
    PHP Code:
    $data preg_split('/\./'$file); 

    but this doesn't work
    is there anything wrong i did or is there anything i missed ?

  2. #2
    Join Date
    Jun 2013
    Posts
    47
    Plugin Contributions
    0

    Default Re: Payment module ATOS for PHP5.3 ?

    the origin code of file /includes/modules/payment/atos.php

    PHP Code:
    <?

    define('DIR_FS_ATOS', DIR_FS_CATALOG . 'atos/');

      class atos {

        // ----------------------------------------------------------------
        // MEMBERS
        // ----------------------------------------------------------------

        // List of supported currencies by the ATOS system.
        var $currencies = array(
                    'EUR' => '978',
                    'USD' => '840',
                    'CHF' => '756',
                    'GBP' => '826',
                    'CAD' => '124',
                    'JPY' => '392',
                    'MXP' => '484',
                    'TRL' => '792',
                    'AUD' => '036',
                    'NZD' => '554',
                    'NOK' => '578',
                    'BRC' => '986',
                    'ARP' => '032',
                    'KHR' => '116',
                    'TWD' => '901',
                    'SEK' => '752',
                    'DKK' => '208',
                    'KRW' => '410',
                    'SGD' => '702',
                    );

        // List of supported languages by the ATOS system
        var $languages = array(
                   'english' => 'en',
                   'german'  => 'de',
                   'espanol' => 'es',
                   'french'  => 'fr',
                   );
        

        // ATOS Payment module code used by the OSC core
        // to identified this module.
        var $code = 'atos';

        // Title : this title is displayed in the checkout_payment.php
        // page.
        var $title;

        // Short description
        var $description;

        // Flag to know whether the module is installed and available
        // as a selectable payment method or not
        var $enabled;
        
         // Any text to display when sending the confirmation mail order
        // to the customer.
        var $email_footer;

        // Flag to know whether the module has to be used in its production
        // or not. At this level, production means that any order using
        // this payment method and has been confirmed by ATOS will be
        // registered in the shop orders.
        var $production;

        // Operating System specific information (like name, command
        // line parameter delimiter, path separator).
        var $os_info;

        // ----------------------------------------------------------------
        // PUBLIC METHODS
        // ----------------------------------------------------------------

        // ----------------------------------------------------------------
        // atos()
        //
        // Initialize the ATOS payment module using the configuration
        // variables.
        function atos() {
          global $order;

          $this->description  = MODULE_PAYMENT_ATOS_TEXT_DESCRIPTION;
          $this->title        = MODULE_PAYMENT_ATOS_TEXT_TITLE;
            $this->email_footer = MODULE_PAYMENT_ATOS_TEXT_EMAIL_FOOTER;
          $this->production   = MODULE_PAYMENT_ATOS_PRODUCTION_MODE == 'production' ? true : false;
          $this->sort_order   = MODULE_PAYMENT_ATOS_SORT_ORDER;

          $this->os_info      = $this->_getOperatingSystemInfo();

          $this->enabled = ((MODULE_PAYMENT_ATOS_STATUS == 'True') ? true : false);

          if ((int)MODULE_PAYMENT_ATOS_ORDER_STATUS_ID > 0) {
              $this->order_status = MODULE_PAYMENT_ATOS_ORDER_STATUS_ID;
          }

          if (is_object($order)) $this->update_status();
        }

        // ----------------------------------------------------------------
        // update_status()
        //
        // Update whether the module is enabled or not. If the a specific
        // zone has been configured, the module will be only available
        // iff the billing address is in the zone.
        function update_status() {
          global $order, $db;

          if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_ATOS_ZONE > 0) ) {
            $check_flag = false;
            $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_ATOS_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
            while (!$check->EOF) {
              if ($check->fields['zone_id'] < 1) {
                $check_flag = true;
                break;
              } elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
                $check_flag = true;
                break;
              }
              $check->MoveNext();
            }
        
            if ($check_flag == false) {
              $this->enabled = false;
            }
          }
          
        }
        
        // ----------------------------------------------------------------
        // javascript_validation()
        //
        // Any javascript code to be used with this payment method.
        // Required by the OSC core.
        function javascript_validation() {
          return false;
        }

        // ----------------------------------------------------------------
        // selection()
        //
        // Information to display in the checkout_payment.php when this
        // module is enabled.
        // Required by the OSC core.
        function selection() {
          
          return array('id'     => $this->code,
                 'module' => $this->title);

        }

        // ----------------------------------------------------------------
        // pre_confirmation_check()
        //
        // Called in the checkout_confirmation.php page to do any
        // processes at this level.
        // Required by the OSC core.
            // Permet de calculer form_action_url
            // Cette valeur est assign閑 ?la variable $form_action_url dans le module header_php.php 
            //  de la page checkout_confirmation_default
        function pre_confirmation_check() {
          global $order;
          $currency = $_SESSION['currency'];
            $sips = $this->makeRequest($order->info['total'], $currency);
        
            if ($sips['error']) {
                $this->error   = 1;
                $this->message = MODULE_PAYMENT_ATOS_CALL_REQUEST_ERROR . ': ' . $sips['command'] . '<br>' . $sips['error'];
        } else {
                $regs = array();
                $this->error   = 0;
                $this->message = $sips['message'];
                if (eregi('<form [^>]*action="([^"]*)"[^>]*>(.*)</form>', $sips['message'], $regs)) {
                   $this->message = $regs[2];
                   $this->form_action_url = $regs[1];
                } else {
                   $this->error = 1;
                   $this->message = MODULE_PAYMENT_ATOS_CALL_REQUEST_ERROR;
                   }
          }

        return false;
        }

        // ----------------------------------------------------------------
        // confirmation()
        //
        // Called in the checkout_confirmation.php page to validate the
        // order payment : prepare the data to be sent to the ATOS
        // server (encoding data).
        // Required by the OSC core.
        function confirmation() {
          return false;
        }


        // ----------------------------------------------------------------
        // process_button()
        //
        // Text to display in the checkout_confirmation.php page at the
        // bottom of the order summary.
        // It display the list of available payment methods (credit card
        // type, ...).
        // Required by the OSC core.
            //
            // Permet de pr閜arer le message ?envoyer au serveur mon閠ique avec le bon montant incluant les taxes
            // et prenant en compte les bons de r閐uction.
            // Permet aussi de pr閜arer le code HTML d'affichage des icones des moyens de paiement
        function process_button() {
              global $order;
              $currency = $_SESSION['currency'];

                $sips = $this->makeRequest($order->info['total'], $currency);
          
          if (!$this->production) $this->sendNotification("ATOS Request Made", $sips);

          if ($sips['error']) {
                     $this->error   = 1;
                     $this->message = MODULE_PAYMENT_ATOS_CALL_REQUEST_ERROR . ': ' . $sips['command'] . '<br>' . $sips['error'];
             } else {
                     $regs = array();
                     $this->error   = 0;
                     $this->message = $sips['message'];

                     if (eregi('<form [^>]*action="([^"]*)"[^>]*>(.*)</form>', $sips['message'], $regs)) {
                             $this->message = $regs[2];
                          $this->form_action_url = $regs[1];
                        } else {
                              $this->error = 1;
                          $this->message = MODULE_PAYMENT_ATOS_CALL_REQUEST_ERROR;
                   }
          }

          if ($this->error) {
            /* An internal error occurs: inform the customer and invite him to contact
               our service and team */
            $this->sendNotification('ATOS Request Error', $sips, "The following error occurs while encoding the request\n" . $sips['error']);

                    $this->form_action_url = zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'NONSSL', false);
              return '<table border="0" width="100%" cellspacing="0" cellpadding="2"><tr><td class="highlight" align="center">'
                      . $this->message . '</td></tr></table><br>';
          }            

          return $this->message;
        }

        // ----------------------------------------------------------------
        // before_process()
        //
        // Call by the checkout_process.php before accepting the order.
        // This method decodes incoming data and analyse result.
        // Return true if the data can be decoded and the payment has
        // been accepted by ATOS. Return false and send a notification
        // to the notification email otherwise.
        // Required by the OSC core.
        function before_process() {
          global $order, $_SERVER, $_POST;

          // Verify remote ip
          if (MODULE_PAYMENT_ATOS_IP) {
                  $deny_access = true;
                  foreach (preg_split('/[,\s]+/', MODULE_PAYMENT_ATOS_IP) as $authorized_ip) {
                if ($_SERVER['REMOTE_ADDR'] == $authorized_ip) {
                   $deny_access = false;
                   break;
                     }
                  }
                  if ($deny_access) {
                /* Ignore not allowed ip */
                     $this->sendNotification('ATOS AutoResponse Status', '',
                        $_SERVER['REMOTE_ADDR'] . " tries to connect to " . $GLOBALS['PHP_SELF']
                        . "\nAllowed ip is : " . MODULE_PAYMENT_ATOS_IP);
                        zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
                  }
          }

          /* check response data and code and update session information */
          $response = $this->decodeResponse($_POST['DATA']);
          if ($response['code'] != 0) {
                /* An internal error occurs: inform the customer and invite him to contact
             our service and team */
            // FIXME
            $this->sendNotification('ATOS AutoResponse Error', $response);
            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
              }

          if ($response['merchant_id'] != MODULE_PAYMENT_ATOS_ID) {
                    $this->sendNotification('ATOS AutoResponse Error',
                    $response,
                    "merchant_id differ:\nMerchant id expected = " . MODULE_PAYMENT_ATOS_ID);
                    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
          }

          // Check whether response code is ok
          if ($response['response_code'] != '00') {
                     if ($response['response_code'] != '17') {
               // Send a notification if the customer has not cancelled its transaction
                $this->sendNotification('ATOS Notification - Response Code ' . $response['response_code'],
                      $response,
                      MODULE_PAYMENT_ATOS_NOT_APPROVED_TEXT1
                      . $response['response_code']. ' ('
                      . atos_getMessageResponseCode($response['response_code']) 
                      . ').'
                      . "\n" . MODULE_PAYMENT_ATOS_NOT_APPROVED_TEXT2 );
                }
            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
          }

          // Check whether the production mode is on or off
          if (!$this->production) {
            $this->sendNotification('ATOS checkout_process', $response, 'demo mode');
            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT,
                       'info_message=' . urlencode(MODULE_PAYMENT_ATOS_TEXT_CHECKOUT_DEMO), 'SSL', false));
          }

          // Update credit card info and transaction id
          $order->info['transaction_id'] = $response['transaction_id'];
          //$constant = 'MODULE_PAYMENT_ATOS_PAYMENT_MEANS_' . $response['payment_means'];
          //define($constant, $response['payment_means']);
          //$order->info['cc_type']        = constant($constant);
          $order->info['cc_type']        = $response['payment_means'];
          $cc = split('\.', $response['card_number']);
          $order->info['cc_number']      = $cc[0] . ' #### #### ##' . $cc[1];

          return false;
        }

        function after_order_create($zf_order_id) {
          global $db, $order;
          // Mise ?jour du statut de la commande
          //if (MODULE_PAYMENT_CC_COLLECT_CVV == 'True')  {
          //$db->execute("update "  . TABLE_ORDERS . " set cc_cvv ='" . $order->info['cc_cvv'] . "' where orders_id = '" . $zf_order_id ."'");
          //}
        }

        // ----------------------------------------------------------------
        // after_process()
        //
        // Called in checkout_process.php to make any processes after
        // the order has been registered in the shop database.
        // Required by the OSC core.
        function after_process() {
          return false;
        }

        // ----------------------------------------------------------------
        // check()
        //
        // Check whether the ATOS module is installed or not.
        // Required by the OSC core.
        function check() {
          // V閞ifier si le module est install?
          global $db;

          if (!isset($this->_check)) {
              $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_ATOS_STATUS'");
            $this->_check = $check_query->RecordCount();
          }
          return $this->_check;
        }

        // ----------------------------------------------------------------
        // install()
        //
        // Install the module by registered ATOS configuration variables
        // into the database.
        // Required by the OSC core.
        function install() {
          global $db;

          $install_atos_email  = STORE_OWNER_EMAIL_ADDRESS;

          $certificate = atos::FindACertificate();
          $install_merchant_id  = $certificate['id'];

          $install_parmcom_file = $certificate['parmcom'];
          if (!$install_parmcom_file || !file_exists($this->_getExternalFileName($install_parmcom_file))) {
                     $install_parmcom_file = atos::FindAParmcomFile();
          }

          $atos_bin_request  = str_replace('\\', '/', $this->_getExternalFileName("request" . $this->os_info['bin_suffix']));
          $atos_bin_response = str_replace('\\', '/', $this->_getExternalFileName("response" . $this->os_info['bin_suffix']));

          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('ACCEPTER le PAIEMENT ATOS-SIPS:', 'MODULE_PAYMENT_ATOS_STATUS', 'True', 'Voulez vous accepter les paiements ATOS?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Identifiant de Commer鏰nt:', 'MODULE_PAYMENT_ATOS_ID', '" . zen_db_input($install_merchant_id) . "', 'Votre ID marchand provenant d\'ATOS. A demander a votre banque.  Pour plus d\'information http://www.sips-atos.com.', '6', '2', 'atos::ConfigPullDownCertificates(', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Nom du fichier de param鑤res g閚閞als:', 'MODULE_PAYMENT_ATOS_PARMCOM_FILE', '" . zen_db_input($install_parmcom_file) . "', 'Choisissez le nom du fichier pour les param鑤res g閚閞ales.', '6', '4','atos::ConfigPullDownParmcomFiles(', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('<u>IMPORTANT</u> L\'IP autoris??donner la confirmation d\'achat. Laissez vide pour ne pas faire de v閞ification sur l\'IP (d閒aut). Vous pouvez entrer plusieurs IPs en les s閜arant par des virgules ou des espaces. Les IPs connus pour les serveurs de paiement ATOS sont: 193.56.46.96,193.56.46.97 et 193.56.46.18', 'MODULE_PAYMENT_ATOS_IP', '193.56.46.96,193.56.46.97,193.56.46.18', 'Entrer le No IP du serveur h閎ergeant le CGI qui fera l\'appel ?votre serveur pour confirmer/infirmer l\'achat. Seul ce serveur est autoris??contacter votre serveur une fois la transaction effectu閑 ou annul閑', '6', '4', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Nom de l\'application pour construire la requ阾e', 'MODULE_PAYMENT_ATOS_BIN_REQUEST', '" . zen_db_input($atos_bin_request) . "', 'Chemin complet de l\'executable permettant de formatter la requ阾e.', '6', '5', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Nom de l\'application pour lire la r閜onse', 'MODULE_PAYMENT_ATOS_BIN_RESPONSE', '" . zen_db_input($atos_bin_response) . "', 'Chemin complet de l\'executable pour d閏oder la r閜onse envoy閑 sur le script de r閜onse normale ou sur le script d\'auto-r閜onse', '6', '6', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Nom du fichier pathfile', 'MODULE_PAYMENT_ATOS_PATHFILE', '', 'Pour laissez le module g閞er lui-m阭e le fichier pathfile, laissez ce champ vide (recommand?dans la majorit?des utilisations). Si vous voulez utiliser un fichier sp閏ifique, alors saisissez le chemin complet pour ce fichier.', '6', '6', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Mise en production du module de paiement', 'MODULE_PAYMENT_ATOS_PRODUCTION_MODE', 'production', 'Si la valeur de ce champ vaut <tt>demo</tt>, les commandes client ne seront pas enregistr閑s dans la base de donn閑s. Conserver cette valeur uniquement pour un mode d閙onstration. Pour la mise en production, mettez ce champ ?<tt>production</tt>', '6', '7', 'zen_cfg_select_option(array(\'demo\', \'production\'),', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Adresse e-mail o?envoyer les notifications (erreurs)', 'MODULE_PAYMENT_ATOS_EMAIL_FOR_NOTIFICATION', '" . zen_db_input($install_atos_email) . "', 'Renseigner ce champ pour recevoir par email les erreurs survenues lors du traitement des transactions ATOS/SIPS', '6', '8', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Ordre de tri', 'MODULE_PAYMENT_ATOS_SORT_ORDER', '0', 'Ordre de tri pour l\'affichage (trier par nombres croissants).', '6', '9', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Zone de Paiement', 'MODULE_PAYMENT_ATOS_ZONE', '0', 'Si une zone est s閘ectionn閑, ce mode de paiement ne sera disponible uniquement pour cette zone.', '6', '10', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('蓆at initial de la commande', 'MODULE_PAYMENT_ATOS_ORDER_STATUS_ID', '0', 'Positionnez l\'閠at initial de la commande, lorsque le client utilise ce mode de paiement', '6', '11', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
        }
    ?>

  3. #3
    Join Date
    Jun 2013
    Posts
    47
    Plugin Contributions
    0

    Default Re: Payment module ATOS for PHP5.3 ?

    PHP Code:
    <?
        // ----------------------------------------------------------------
        // remove()
        //
        // Uninstall the module by removing all configuration variables
        // from the database.
        // Required by the OSC core.
        function remove() {
          global $db;
          $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
        }

        // ----------------------------------------------------------------
        // keys()
        //
        // Get the list of ATOS configuration variables.
        function keys() {
          $keys = array(
                'MODULE_PAYMENT_ATOS_STATUS',
                'MODULE_PAYMENT_ATOS_ID',
                'MODULE_PAYMENT_ATOS_PARMCOM_FILE',
                'MODULE_PAYMENT_ATOS_IP',
                'MODULE_PAYMENT_ATOS_BIN_REQUEST',
                'MODULE_PAYMENT_ATOS_BIN_RESPONSE',
                'MODULE_PAYMENT_ATOS_PATHFILE',
                'MODULE_PAYMENT_ATOS_PRODUCTION_MODE',
                'MODULE_PAYMENT_ATOS_EMAIL_FOR_NOTIFICATION',
                'MODULE_PAYMENT_ATOS_SORT_ORDER',
                'MODULE_PAYMENT_ATOS_ZONE',
                'MODULE_PAYMENT_ATOS_ORDER_STATUS_ID'
                );
          return $keys;
        }

        // ----------------------------------------------------------------
        // INTERNAL METHODS
        // ----------------------------------------------------------------

        // ----------------------------------------------------------------
        // _getExternalFileName()
        //
        // Get file name in the ATOS protected directory handling
        // external files required by the ATOS SDK.
        function _getExternalFileName($name) {
          $name = DIR_FS_ATOS . $name;

          if ($this->os_info['path_separator'] != '/')
                     $name = str_replace('/', $this->os_info['path_separator'], $name);
          return $name;
        }
        
        // ----------------------------------------------------------------
        // _getLanguageCode()
        //
        // Get the language code from the internal representation to the
        // value expected by ATOS/SIPS.
        // The list of supported languages are in the array 'languages;
        // set at the constructor level.
        function _getLanguageCode($language) {
          $value = $this->languages[$language];
        
          if ($value)
                     return $value;

          echo '<pre>';
          echo 'Sorry, language ', $language, ' not configured', "\n";
          print_r($this->languages);
          echo '</pre>';
          die;
        }

        // ----------------------------------------------------------------
        // _getCurrencyCode()
        //
        // Get the currency code from the internal representation to the
        // representation expected by ATOS/SIPS.
        // The list of supported languages are in the array 'languages;
        // set at the constructor level.
        function _getCurrencyCode($currency) {
          $value = $this->currencies[$currency];
        
          if ($value)
                     return $value;
        
          echo '<pre>';
          echo 'Sorry, currency "', $currency, '" not configured', "\n";
          print_r($this->currencies);
          echo '</pre>';
          die;
        }

        // ----------------------------------------------------------------
        // _getCurrencyUnit()
        //
        // Get the currency unit factor.
        // This information is calculated using the number of decimal to
        // print for a currency, powered by 10.
        function _getCurrencyUnit($currency) {
          global $currencies;
        
          return pow(10, intval($currencies->currencies[$currency]['decimal_places']));
        }

        // ----------------------------------------------------------------
        // _getOperatingSystemInfo()
        //
        // Get information about the OS
        function _getOperatingSystemInfo() {
          $info = array(
                'name'           => PHP_OS,
                'quote'          => "'",
                'path_separator' => "/",
                'bin_suffix'     => "",
                );

          if (substr($info['name'], 0, 3) == 'WIN') {
              $info['quote']          = "";
              $info['path_separator'] = "\\";
              $info['bin_suffix']     = ".exe";
          }

          return $info;
        }

        // ----------------------------------------------------------------
        // makeRequest()
        //
        // Make the request by executing the request external application.
        function makeRequest($amount, $currency) {
          //global $customer_id, $_SERVER;
          //global $language;
              $customer_id = $_SESSION['customer_id'];
          $language = $_SESSION['language'];

          $amount = sprintf("%03d", $amount * $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);

          //$command .= " " . $this->os_info['quote'] . "normal_return_url=" . HTTPS_SERVER . DIR_WS_CATALOG . 'atos_response.php?' . zen_session_name() . '=' . zen_session_id() . $this->os_info['quote'];

          //$command .= " " . $this->os_info['quote'] . "cancel_return_url=" . HTTPS_SERVER . DIR_WS_CATALOG . 'atos_response.php?' . zen_session_name() . '=' . zen_session_id() . $this->os_info['quote'];


          $link = zen_href_link(FILENAME_ATOS_RESPONSE, zen_session_name() . '=' . zen_session_id(), 'SSL', false);
          $link = ereg_replace('&amp;', '&', $link);
          $command .= " " . $this->os_info['quote'] . "normal_return_url=" . $link . $this->os_info['quote'];
          $command .= " " . $this->os_info['quote'] . "cancel_return_url=" . $link . $this->os_info['quote'];

          $link = zen_href_link(FILENAME_CHECKOUT_PROCESS, zen_session_name() . '=' . zen_session_id(), 'NONSSL', false);
          $link = ereg_replace('&amp;', '&', $link);
          $command .= " " . $this->os_info['quote'] . "automatic_response_url=" . $link . $this->os_info['quote'];

          $command .= " customer_id=" . $customer_id;
          $command .= " customer_ip_address=" . $_SERVER['REMOTE_ADDR'];
          //$command .= " transaction_id=$insert_id";
        
          $sips_result = shell_exec("$command 2>&1");

          $sips = array();
          $sips_values     = 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']     = zen_session_id();
          }
        
          return $sips;
        }

        // ----------------------------------------------------------------
        // decodeResponse()
        //
        // Decode DATA coming from the ATOS payment serveur. Called the
        // external application response.
        function decodeResponse($data = '') {

          if (!$data) $data = $_POST['DATA'];

          $pathfile = $this->_getPathFileName();

          $command  = MODULE_PAYMENT_ATOS_BIN_RESPONSE;
          $command .= " " . $this->os_info['quote'] . "pathfile=" . $pathfile . $this->os_info['quote'];
          $command .= " message=$data";

          $sips_resp = shell_exec ( "$command 2>&1" );
      
          $hash = array ();
          $sips_resp = split ( "!", $sips_resp );
          list (,
            $hash['code'],
            $hash['error'],
            $hash['merchant_id'],
            $hash['merchant_country'],
            $hash['amount'],
            $hash['transaction_id'],
            $hash['payment_means'],
            $hash['transmission_date'],
            $hash['payment_time'],
            $hash['payment_date'],
            $hash['response_code'],
            $hash['payment_certificate'],
            $hash['authorisation_id'],
            $hash['currency_code'],
            $hash['card_number'],
            $hash['cvv_flag'],
            $hash['cvv_response_code'],
            $hash['bank_response_code'],
            $hash['complementary_code'],
            $hash['return_context'],
            $hash['caddie'],
            $hash['receipt_complement'],
            $hash['merchant_language'],
            $hash['language'],
            $hash['customer_id'],
            $hash['order_id'],
            $hash['customer_email'],
            $hash['customer_ip_address'],
            $hash['capture_day'],
            $hash['capture_mode'],
            $hash['data']
            ) = $sips_resp;
        
          $hash['command'] = $command;
          $hash['output']  = $sips_resp;

          return $hash;
        }

        // ----------------------------------------------------------------
        // _getPathFileName()
        //
        // Make the pathfile if it does not exists.
        // Return the pathfile to be used when calling one of the ATOS
        // external applications.
        function _getPathFileName() {
          if (MODULE_PAYMENT_ATOS_PATHFILE) return MODULE_PAYMENT_ATOS_PATHFILE;

          $pathfile = $this->_getExternalFileName('pathfile.' . MODULE_PAYMENT_ATOS_PARMCOM_FILE);

          if (!file_exists($pathfile)) {
        ob_start();
        echo "#########################################################################\n";
        echo "#\n";
        echo "#    Pathfile \n";
        echo "#\n";
        echo "#    Liste fichiers parametres utilis閟 par le module de paiement\n";
        echo "#\n";
        echo "#########################################################################\n";
        echo "\n";
        echo "# ------------------------------------------------------------------------\n";
        echo "# Chemin vers le r閜ertoire des logos depuis le web alias  \n";
        echo "# Exemple pour le r閜ertoire www.merchant.com/cyberplus/payment/logo/\n";
        echo "# indiquer:\n";
        echo "# ------------------------------------------------------------------------\n";
        echo "#\n";
        echo "D_LOGO!", DIR_WS_IMAGES, "atos/!\n";
        echo "#\n";
        echo "#------------------------------------------------------------------------\n";
        echo "#  Fichiers parametres lies a l'api cyberplus paiement    \n";
        echo "#------------------------------------------------------------------------\n";
        echo "#\n";
        echo "# Certificat du commercant\n";
        echo "#\n";
        echo "F_CERTIFICATE!", $this->_getExternalFileName('certif'), "!\n";
        echo "#\n";
        echo "# Fichier param鑤re commercant\n";
        echo "#\n";
        echo "F_PARAM!", $this->_getExternalFileName('parmcom'), "!\n";
        echo "#\n";
        echo "# Fichier des param鑤res communs\n";
        echo "#\n";
        echo "F_DEFAULT!", $this->_getExternalFileName(MODULE_PAYMENT_ATOS_PARMCOM_FILE), "!\n";
        echo "#\n";
        echo "# --------------------------------------------------------------------------\n";
        echo "#     end of file\n";
        echo "# --------------------------------------------------------------------------\n";
        $pathfile_content = ob_get_contents();
        ob_end_clean();
        
        if ($fp = fopen($pathfile, 'w')) {
          fputs($fp, $pathfile_content);
          fclose($fp);
        }
          }

          return $pathfile;
        }

        // ----------------------------------------------------------------
        // sendNotification()
        //
        // Send an email to the ATOS Notification address
        function sendNotification($subject, $sips = '', $message = '') {

          if (!MODULE_PAYMENT_ATOS_EMAIL_FOR_NOTIFICATION) return;

          $string  = '';
          $string .= '<span style="font-family: Verdana, Arial, sans-serif; font-size: 13px">';
          $string .= '<font color="#ff0000"><b>';
          $string .= ($message ? nl2br($message) . '<br>' : '');
          $string .= 'Error occurs in ' . $GLOBALS['PHP_SELF'];
          $string .= '</font><br>';

          $string .= '<table border="0" cellspacing="0" cellpadding="3" width="100%">';
          foreach (array(array('title' => 'SERVER VARIABLES', 'data' => $_SERVER),
                 array('title' => 'HTTP GET',         'data' => $_GET),
                 array('title' => 'HTTP POST',        'data' => $_POST),
                 array('title' => 'SIPS',             'data' => $sips)) as $info) {
          $string .= '<tr><td><td width="100%"><br></td>';
          $string .= '<tr><td colspan="2" style="font-weight: bold; font-size: 13px; color: #ffffff; background-color: #404040">' . $info['title'] . '</td></tr>';
      
          $index = 0;
          if (is_array($info['data'])) {
            reset($info['data']);
            while (list($key, $value) = each($info['data'])) {
              if ($info['title']=='SIPS') {
                $type_card = $info['data']['payment_means'];
      
                if ($key=='response_code') $value = atos_getMessageResponseCode($value) . '(code '.$value.')';        
                elseif ($key=='bank_response_code') $value = atos_getMessageBankResponseCode($type_card, $value) . '(code '.$value.')';        
                elseif ($key=='cvv_flag') $value = atos_getMessageCvvFlag($value) . '(code '.$value.')';        
                elseif ($key=='cvv_response_code') $value = atos_getMessageCvvResponseCode($value) . '(code '.$value.')';
            }

            $bgcolor = ($index++ % 2 == 0 ? '#f7f7f7' : '#f0f0f0');
            $string .= '<tr bgcolor="' . $bgcolor . '">';
            $string .= '<td valign="top" style="font-family: Verdana, Arial, sans-serif; font-size: 11px"><b>' . htmlentities("$key") . '</b></td>';
            $string .= '<td valign="top" style="font-family: Verdana, Arial, sans-serif; font-size: 11px">' . htmlentities("$value") . '</td>';
            $string .= '</tr>';
          }
        }
          }
          $string .= '</table>';
          $string .= '</span>';

            zen_mail(STORE_NAME . ': ATOS', MODULE_PAYMENT_ATOS_EMAIL_FOR_NOTIFICATION, $subject,
               $string,
               STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, '');

        }

        // ----------------------------------------------------------------
        // GetPredefinedCertificates()
        //
        // Get the list of test certificates and information about them
        function GetPredefinedCertificates() {
          global $ATOS_PREDEFINED_CERTIFICATES;
        
          if (!$ATOS_PREDEFINED_CERTIFICATES) {
            $ATOS_PREDEFINED_CERTIFICATES = array();
            $ATOS_PREDEFINED_CERTIFICATES['013044876511111'] =
            array(
            'id'      => '013044876511111',
            'parmcom' => 'parmcom.e-transactions',
            'text'    => MODULE_PAYMENT_ATOS_CERTIFICATE_NAME_ETRANSACTION,
            'test'    => true
            );
            $ATOS_PREDEFINED_CERTIFICATES['014213245611111'] =
          array(
            'id'      => '014213245611111',
            'parmcom' => 'parmcom.sogenactif',
            'text'    => MODULE_PAYMENT_ATOS_CERTIFICATE_NAME_SOGENACTIF,
            'test'    => true
            );
            $ATOS_PREDEFINED_CERTIFICATES['038862749811111'] =
          array(
            'id'      => '038862749811111',
            'parmcom' => 'parmcom.cyberplus',
            'text'    => MODULE_PAYMENT_ATOS_CERTIFICATE_NAME_CYBERPLUS,
            'test'    => true
            );
            $ATOS_PREDEFINED_CERTIFICATES['082584341411111'] =
          array(
            'id'      => '082584341411111',
            'parmcom' => 'parmcom.mercanet',
            'text'    => MODULE_PAYMENT_ATOS_CERTIFICATE_NAME_MERCANET,
            'test'    => true
            );
            $ATOS_PREDEFINED_CERTIFICATES['014141675911111'] =
          array(
            'id'      => '014141675911111',
            'parmcom' => 'parmcom.scellius',
            'text'    => MODULE_PAYMENT_ATOS_CERTIFICATE_NAME_SCELLIUS,
            'test'    => true
            );
            $ATOS_PREDEFINED_CERTIFICATES['014295303911111'] =
          array(
            'id'      => '014295303911111',
            'parmcom' => 'parmcom.sherlocks',
            'text'    => MODULE_PAYMENT_ATOS_CERTIFICATE_NAME_SHERLOCKS,
            'test'    => true
            );
          }

          return $ATOS_PREDEFINED_CERTIFICATES;
        }

        // ----------------------------------------------------------------
        // GetCertificateInfo()
        //
        // Get a certificate name
        function GetCertificateInfo($id) {
          $certificates = atos::GetPredefinedCertificates();

          if ($certificates[$id]) return $certificates[$id];

          return array(
               'id'   => $id,
               'text' => $id,
               'test' => false
               );
        }

        // ----------------------------------------------------------------
        // GetInstalledCertificates()
        //
        // Get the list of installed certificates
        function GetInstalledCertificates() {
          $certificates = array();
          if ($dir = @dir(DIR_FS_ATOS)) {
                while ($file = $dir->read()) {
              $data = split('\.', $file);
              $n = sizeof($data) - 1;
              if ($data[0] == 'certif')
                $certificates[] = atos::GetCertificateInfo($data[$n]);
            }
            sort($certificates);
            $dir->close();
          }
          return $certificates;
        }

        // ----------------------------------------------------------------
        // FindACertificate()
        //
        // Find a certificate to install
        function FindACertificate() {
          $certificate = null;
          foreach (atos::GetInstalledCertificates() as $current) {
            if (!$current['test'])
              return $current;
            if (!$certificate)
                      $certificate = $current;
          }
          return $certificate;
        }

        // ----------------------------------------------------------------
        // GetInstalledParmcomFiles()
        //
        // Get the list of installed certificates
        function GetInstalledParmcomFiles() {
          $parmcom_files = array();
          if ($dir = @dir(DIR_FS_ATOS)) {
                while ($file = $dir->read()) {
            $data = split('\.', $file);
            if (($data[0] == 'parmcom') && !file_exists(DIR_FS_ATOS . 'certif.fr.' . $data[1]))
              $parmcom_files[] = array(
                           'id'   => $file,
                           'text' => $file
                           );
            }
            sort($parmcom_files);
            $dir->close();
          }
          return $parmcom_files;
        }

        // ----------------------------------------------------------------
        // FindAParmcomFile()
        //
        // Find a parmcom file to install
        function FindAParmcomFile() {
          $parmcom_files = atos::GetInstalledParmcomFiles();
          return $parmcom_files[0]['id'];
        }

        // ----------------------------------------------------------------
        // ConfigPullDownCertificates()
        //
        // Pull down list to select certificate
        function ConfigPullDownCertificates($value, $key) {
          $certificates = atos::GetInstalledCertificates();
        
          $field_name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');
        
          if (sizeof($certificates) > 0)
                        return zen_draw_pull_down_menu($field_name, $certificates, $value);
        
          return zen_draw_input_field($field_name, $value['value']);
        }

        // ----------------------------------------------------------------
        // ConfigPullDownParmcomFiles()
        //
        // Pull down list to select certificate
        function ConfigPullDownParmcomFiles($value, $key) {
          $parmcom_files = atos::GetInstalledParmcomFiles();
        
          $field_name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');
        
          if (sizeof($parmcom_files) > 0)
                     return zen_draw_pull_down_menu($field_name, $parmcom_files, $value);
        
          return zen_draw_input_field($field_name, $value['value']);
        }
      }
    ?>

  4. #4
    Join Date
    Jun 2013
    Posts
    47
    Plugin Contributions
    0

    Default Re: Payment module ATOS for PHP5.3 ?

    i guess i should have posted this question to General Questions?
    this is about to modify one customized zen cart file to make it comfortable with PHP5.3
    the file works only with php5.2, it doesn't work for php5.3

    i did the modification above, but it seems that i missed something
    anyone who is good at code zen cart and php could help?

  5. #5
    Join Date
    Jan 2004
    Posts
    66,374
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Payment module ATOS for PHP5.3 ?

    What is the error message it is giving you?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Jun 2013
    Posts
    47
    Plugin Contributions
    0

    Default Re: Payment module ATOS for PHP5.3 ?

    the error message is from here
    (the second part "preg_match('/<form.*action="([^"]*)"[^>]*>(.*)</form>/i'[/COLOR], $sips['message'], $regs) ) {")
    PHP Code:
                     if (preg_match('/<form.*action="([^"]*)"[^>]*>(.*)</form>/i'$sips['message'], $regs) ) {
                             
    $this->message $regs[2];
                          
    $this->form_action_url $regs[1];
                        } else {
                              
    $this->error 1;
                          
    $this->message MODULE_PAYMENT_ATOS_CALL_REQUEST_ERROR
                   

    if i change it back to
    PHP Code:
    if (eregi('<form [^>]*action="([^"]*)"[^>]*>(.*)</form>'$sips['message'], $regs)) {
    no error message displays (there is a problem with the module function)

    if i change it to
    PHP Code:
    if (preg_match('/<form.*action="([^"]*)"[^>]*>(.*)</form>/i'$sips['message'], $regs) ) {
    the error message shows up on the web "MODULE_PAYMENT_ATOS_CALL_REQUEST_ERROR"
    Last edited by xav2; 13 Jun 2013 at 07:26 AM.

  7. #7
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Payment module ATOS for PHP5.3 ?

    Post the exact error message please.

  8. #8
    Join Date
    Jan 2004
    Posts
    66,374
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Payment module ATOS for PHP5.3 ?

    Quote Originally Posted by xav2 View Post
    PHP Code:
    $sips_values     explode ("/!/"$sips_result); 
    PHP Code:
    $sips_resp explode "/!/"$sips_resp ); 
    I think both of those "/!/" should have just been '!' instead.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  9. #9
    Join Date
    Jun 2013
    Posts
    47
    Plugin Contributions
    0

    Default Re: Payment module ATOS for PHP5.3 ?

    Quote Originally Posted by gjh42 View Post
    Post the exact error message please.
    if without error, on the checkout_confirmation page, it would display all the card icons (visa, mastercard ...), then you can click on the icon to be redirected to the bank payment page.

    but after the modification to make the mod comfortable with php5.3, now on the checkout_confirmation page, it displays the error message instead of the card icons:

    Une erreur inattendue est arrivée au cours de la demande.
    Merci de choisir un autre moyen de paiement
    in english is
    An unexpected error occurred during the request.
    Thank you to choose another payment method
    this message is from the define language file here:
    define('MODULE_PAYMENT_ATOS_CALL_REQUEST_ERROR', 'Une erreur inattendue est arrivée au cours de la demande.<br>Merci de choisir un autre moyen de paiement.<br>');
    Last edited by xav2; 14 Jun 2013 at 12:27 AM.

  10. #10
    Join Date
    Jun 2013
    Posts
    47
    Plugin Contributions
    0

    Default Re: Payment module ATOS for PHP5.3 ?

    Quote Originally Posted by DrByte View Post
    I think both of those "/!/" should have just been '!' instead.
    i tried changing
    PHP Code:
    $sips_values     explode ("/!/"$sips_result);
    $sips_resp explode "/!/"$sips_resp ); 
    to
    PHP Code:
    $sips_values     explode ('!'$sips_result);
    $sips_resp explode '!'$sips_resp ); 
    but sitll no luck
    anything else i missed?

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Convert osC Payment module Atos for PHP5.3 into Zen cart - Need Help
    By xav2 in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 2 Dec 2013, 09:18 AM
  2. Replies: 47
    Last Post: 7 Jul 2013, 10:36 PM
  3. Atos payment module for 1.3.9h
    By meth0d in forum Addon Payment Modules
    Replies: 1
    Last Post: 19 Oct 2011, 03:54 PM
  4. question of ATOS payment module
    By bear1728 in forum Addon Payment Modules
    Replies: 1
    Last Post: 21 Jul 2009, 11:05 PM
  5. [French] atos / sips module payment
    By djimmy in forum Addon Payment Modules
    Replies: 1
    Last Post: 12 Mar 2007, 06:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR