anyone willing to look into this code?

mstefa <[email protected]>
Newsgroups gmane.comp.web.oscommerce.devel
Message-ID <3fd0f5d82f15efbfe5dc3b3e3617a65e@osCommerce-Forums>
This message was sent from: Development
http://forums.oscommerce.com/viewtopic.php?p=171460#171460
----------------------------------------------------------------

it installs, but it fails to redirect to payment gateway:

here is example: http://www.pcdealership.com

This is the look of the required string for their server:

 /*  https://www.beanstream.com/scripts/payment/payment.asp?merchant_id=100120000&trnOrd

erNumber=56647&trnAmount=57.60&

ordName=Sam+Shopper&ordAddress1=123+Any+Street&ordPhoneNumber=123-

4567&[email protected]

and here's module:
<?php
/*
  $Id: beanstream.php,v 0.1 2003/05/20 19:57:15 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class beanstream {
    var $code, $title, $description, $enabled;

// class constructor
    function beanstream() {
      global $order;

      $this->code = 'beanstream';
      $this->title = MODULE_PAYMENT_BEANSTREAM_TEXT_TITLE;
      $this->description = MODULE_PAYMENT_BEANSTREAM_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_PAYMENT_BEANSTREAM_SORT_ORDER;
      $this->enabled = ((MODULE_PAYMENT_BEANSTREAM_STATUS == 'True') ? true : false);

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

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

      $this->form_action_url = 'https://www.beanstream.com/scripts/payment/payment.asp';
    }

// class methods
    function update_status() {
      global $order;

      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_BEANSTREAM > 0) ) {
        $check_flag = false;
        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_BEANSTREAM . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
        while ($check = tep_db_fetch_array($check_query)) {
          if ($check['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check['zone_id'] == $order->billing['zone_id']) {
            $check_flag = true;
            break;
          }
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }
    }

    function javascript_validation() {
      return false;
    }

    function selection() {
      return array('id' => $this->code,
                   'module' => $this->title);
    }

    function pre_confirmation_check() {
      return false;
    }

    function confirmation() {
      return false;
    }

    function process_button() {
      global $order, $currencies, $currency;

     if (MODULE_PAYMENT_BEANSTREAM_CURRENCY == 'Selected Currency') {
        $my_currency = $currency;
      } else {
        $my_currency = substr(MODULE_PAYMENT_BEANSTREAM_CURRENCY, 5);
      }
      if (!in_array($my_currency, array('CAD', 'EUR', 'GBP', 'JPY', 'USD'))) {
        $my_currency = 'USD';
      }

      $process_button_string =
      						   tep_draw_hidden_field('merchant_id', 'MODULE_PAYMENT_BEANSTREAM_MERCHANT_ID') .
                               tep_draw_hidden_field('trnOrderNumber', $order->order_id) .
                               tep_draw_hidden_field('trnAmount',  number_format($order->info['total'], 2)) .
                               tep_draw_hidden_field('ordName', $order->customer['firstname'] . ' ' . $order->customer['lastname']) .
                               tep_draw_hidden_field('ordAddress1', $order->customer['street_address']) .
                               tep_draw_hidden_field('ordPhoneNumber', $order->customer['telephone']) .
                               tep_draw_hidden_field('ordEmailAddress', $order->customer['email_address']) ;


      return $process_button_string;
    }

    function before_process() {
      return false;
    }

    function after_process() {
      return false;
    }

    function output_error() {
      return false;
    }

    function check() {
      if (!isset($this->_check)) {
        $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_BEANSTREAM_STATUS'");
        $this->_check = tep_db_num_rows($check_query);
      }
      return $this->_check;
    }

    function install() {

      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable BEANSTREAM Module', 'MODULE_PAYMENT_BEANSTREAM_STATUS', 'True', 'Do you want to accept Beanstream payments?', '6', '3', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Merchant ID', 'MODULE_PAYMENT_BEANSTREAM_MERCHANT_ID', 'BEANSTREAM ACCOUNT', 'Beanstream account number address to use for the Beanstream service', '6', '4', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Currency', 'MODULE_PAYMENT_BEANSTREAM_CURRENCY', 'Selected Currency', 'The currency to use for credit card transactions', '6', '6', 'tep_cfg_select_option(array(\'Selected Currency\',\'Only USD\',\'Only CAD\',\'Only EUR\',\'Only GBP\',\'Only JPY\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_BEANSTREAM_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Type', 'MODULE_PAYMENT_BEANSTREAM_TRANSACTION_TYPE', 'P', 'P = Purchase (default) <br>PA = PreAuth <br>PAC = PreAuth Completion', '6', '4', 'tep_cfg_select_option(array(\'P\', \'PA\', \'PAC\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_BEANSTREAM_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");

    }

    function remove() {
      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_PAYMENT_BEANSTREAM_STATUS', 'MODULE_PAYMENT_BEANSTREAM_MERCHANT_ID', 'MODULE_PAYMENT_BEANSTREAM_TRANSACTION_TYPE', 'MODULE_PAYMENT_BEANSTREAM_ORDER_STATUS_ID');
    }
  }
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.