Jump to content



- - - - -

writing a custom payment method, need help


  • Please log in to reply
1 reply to this topic

#1   jabz_ali

jabz_ali
  • Members
  • 1 posts
  • Real Name:Jabz

Posted 23 June 2005 - 02:47 PM

I want to create a custom payment mod for my mobile phone store. When a user selects a 'pay monthly' phone i want to ask them additional questions during checkout for example maritial status, how long they have been living at their current address and so forth. This information is then sent to the network provider who decides whether to offer the customer a connection or not.

I am having problems populating tep_draw_pull_down_menu with the relevant data though. When i try creating an array to populate the menu, i only get the last item of data which has been entered

I am modifying the cc.php credit card payment method to create my own, therefore there are some redundant elements within the code which will be removed

Here is the code so far

<?php
/*
  $Id: dd.php

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

  Copyright © 2003 osCommerce

  Released under the GNU General Public License
*/

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

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

      $this->code = 'dd';
      $this->title = MODULE_PAYMENT_DD_TEXT_TITLE;
      $this->description = MODULE_PAYMENT_DD_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_PAYMENT_DD_SORT_ORDER;
      $this->enabled = ((MODULE_PAYMENT_DD_STATUS == 'True') ? true : false);

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

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

      $this->email_footer = MODULE_PAYMENT_DD_TEXT_EMAIL_FOOTER;
    }

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

      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_DD_ZONE > 0) ) {
        $check_flag = false;
        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_DD_ZONE . "' 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 selection() {
      global $order;

      for ($i=1; $i<13; $i++) {
        $expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));
      }

      $today = getdate();
      for ($i=$today['year']; $i < $today['year']+10; $i++) {
        $expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i)));
      }

      $selection = array('id' => $this->code,
                         'module' => $this->title,
                         'fields' => array(array('title' => "Account Name",
                                                 'field' => ''),
                                           array('title' => "Maritial Status",
                                                 'field' => ''),
                                           array('title' => "Occupational Status etc",
                                                 'field' => '')));

      return $selection;
    }



    function pre_confirmation_check() {
      return false;
    }

    function confirmation() {
      return array('title' => MODULE_PAYMENT_DD_TEXT_DESCRIPTION);
    }

    function process_button() {
      return false;
    }

    function before_process() {
      return false;
    }

    function after_process() {
      return false;
    }

    function get_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_DD_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 Direct Debit Payment Method', 'MODULE_PAYMENT_DD_STATUS', 'True', 'Do you want to enable DD payments?', '6', '1', '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 ('Sort order of display.', 'MODULE_PAYMENT_DD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");

    }

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

    function keys() {
      return array('MODULE_PAYMENT_DD_STATUS', 'MODULE_PAYMENT_DD_SORT_ORDER');
    }
  }
?>

#2   Mibble

Mibble
  • Members
  • 13,404 posts
  • Real Name:JAO
  • Location:MA (US): 42n22, 71w04, Massachusetts

Posted 23 June 2005 - 02:51 PM

you would be better off to create a separate credit card application, to get the customer pre-approved, then have them select their package
John Oligario

Knowledge Base   Contributions