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');
}
}
?>
Latest News: (loading..)
writing a custom payment method, need help
Started by jabz_ali, Jun 23 2005 02:47 PM
1 reply to this topic









