Hi

I am trying to port the oscommerce payment module ccbill dynamic pricing and have completed the changes laid out in the wiki.

The problem I have encountered is Fatal error: Call to a member function Execute() on a non-object in C:\wamp\www\zen-cart\zen-cart\includes\modules\payment\ccBillDynamicPricing.php on line 49

I have tried out the fixes for that error I have found in the forum and cant make it work.

I am using v1.3.8a
PHP 5.2.6
MySQL 5.1.36

This is the code where the error is showing
Code:
function check(){
		if (!isset($this->_check)) {
			$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " 
				where configuration_key = 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_STATUS'");
		$this->_check = $check_query->RecordCount();
		}
		return $this->_check;
	}
This is the code I created from using the wiki
Code:
<?php

class ccBillDynamicPricing {
	var $code, $title, $description, $enable;

	function ccBillDynamicPricing(){
		global $order;

		$this->code = 'ccBillDynamicPricing';
		$this->title = MODULE_PAYMENT_CCBILL_DYNAMICPRICING_TEXT_TITLE;
		$this->description = MODULE_PAYMENT_CCBILL_DYNAMICPRICING_TEXT_DESCRIPTION;
		$this->sort_order = MODULE_PAYMENT_CCBILL_DYNAMICPRICING_SORT_ORDER;		
		$this->enabled = ((MODULE_PAYMENT_CCBILL_DYNAMICPRICING_STATUS == 'True') ? true : false);

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

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

		$this->form_action_url = 'https://bill.ccbill.com/jpost/signup.cgi';
	}

	function update_status(){
		global $order;
	
		if (($this->enabled == true) && ((int)MODULE_PAYMENT_CCBILL_DYNAMICPRICING_ZONE > 0)){
			$check_flag = false;
			$check_query = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_CCBILL_DYNAMICPRICING_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;
				}
			}

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

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

	function javascript_validation(){
		return false;
	}
	
	//this is the selection processor area before processing
	function selection(){
		return array('id' => $this->code,
			'module' => $this->title);
	}

	//Done after a processor is selected above..
	function pre_confirmation_check(){
		return false;
	}

	//runs afer pre_confirmation 
	function confirmation(){
		return false;
	}

	//after confirmation
	function process_button(){
		global $order, $currencies, $currency, $language;

		$state = zen_get_zone_code($order->billing['country']['id'], $order->billing['zone_id'], $order->billing['state']);
		$total = number_format(($order->info['total'] * $currencies->get_value($currency)), $currencies->currencies[$currency]['decimal_places'], '.', '');
		$formPeriod = 3;

		//map the currency to the correct currency code
		switch (MODULE_PAYMENT_CCBILL_DYNAMICPRICING_CURRENCY){
			case 'Default Currency':
				$currencyCode = $this->mapCurrencyToCode(DEFAULT_CURRENCY);
				$total = number_format(($order->info['total'] * $currencies->get_value(DEFAULT_CURRENCY)), $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'], '.', '');
				break;
			case 'Any Currency':
				$currencyCode = $this->mapCurrencyToCode($currency);
				break;
			default:
				$currencyCode = $this->mapCurrencyToCode($currency);
				$break;
		}

		//Force payment into USD as the currency selected is not supported
		if ($currencyCode == 0){
			$currencyCode = 840;
			$total = number_format(($order->info['total'] * $currencies->get_value('USD')), $currencies->currencies['USD']['decimal_places'], '.', '');
		}

		$formDigest = md5($total . $formPeriod .  $currencyCode . MODULE_PAYMENT_CCBILL_DYNAMICPRICING_SALT);
		$process_button_string = zen_draw_hidden_field('clientAccnum',  MODULE_PAYMENT_CCBILL_DYNAMICPRICING_CLIENTACCNUM) .
														zen_draw_hidden_field('clientSubacc',  MODULE_PAYMENT_CCBILL_DYNAMICPRICING_SUBACC) .
														zen_draw_hidden_field('formName',  MODULE_PAYMENT_CCBILL_DYNAMICPRICING_FORMNAME) .
														zen_draw_hidden_field('formPeriod', $formPeriod) .
														zen_draw_hidden_field('formPrice', $total) .
														zen_draw_hidden_field('customer_fname',  $order->billing['firstname']) .
														zen_draw_hidden_field('customer_lname',  $order->billing['lastname']) .
														zen_draw_hidden_field('email',  $order->customer['email_address']) .
														zen_draw_hidden_field('address1',  $order->billing['street_address']) .
														zen_draw_hidden_field('city', $order->billing['city']) .
														zen_draw_hidden_field('state', $state) .
														zen_draw_hidden_field('zipcode', $order->billing['postcode']) .
														zen_draw_hidden_field('country', $order->billing['country']['iso_code_2']) . 
														zen_draw_hidden_field('currencyCode', $currencyCode) . 
														zen_draw_hidden_field('language', $this->mapLanguage($language)) . 
														zen_draw_hidden_field('formDigest', $formDigest) . 
														zen_draw_hidden_field(zen_session_name(), zen_session_id());

		return $process_button_string;
	}

	//After processing
	function before_process(){
		
		//Check to ensure all needed information is passed back
		if (($_get['subscription_id'] == '' || $_get['responseDigest'] == '') && ($_get['reasonForDecline'] == '')){
			zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, zen_session_name() . '=' . $_get[zen_session_name()] . '&payment_error=' . $this->code . "&reasonForDecline=" . urlencode("Error in configuration, please contact website owner"), 'SSL', false, false));
		}

		if ($_get['subscription_id'] != ''){	
			//valid the subscription_id with the md5 and salt
			$responseDigest = md5($_get['subscription_id'] . 1 . MODULE_PAYMENT_CCBILL_DYNAMICPRICING_SALT);

			//If Digest Does not match fail transaction (hacking attempt)
			if (strcmp($responseDigest, $_get['responseDigest']) != 0){
				zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, zen_session_name() . '=' . $_get[zen_session_name()] . '&payment_error=' . $this->code . "&reasonForDecline=" . urlencode("Digest Does Not Match"), 'SSL', false, false));
			}
		}
		else {
			//Transaction failed, redirect back to checkout page with the decline reason
			zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, zen_session_name() . '=' . $_get[zen_session_name()] . '&payment_error=' . $this->code . "&reasonForDecline=" . urlencode($_get['reasonForDecline']), 'SSL', false, false));
		}
	}

	function after_process(){
		return false;
	}

	//Return Decline Reason
	function get_error(){
		
		if (isset($_get['reasonForDecline']) && (strlen($_get['reasonForDecline']) > 0)) {
			$error = stripslashes(urldecode($_get['reasonForDecline']));
		}
		else {
			$error = MODULE_PAYMENT_CCBILL_DYNAMICPRICING_TEXT_ERROR_MESSAGE;
		}

		return array('title' => MODULE_PAYMENT_CCBILL_DYNAMICPRICING_TEXT_ERROR,
			'error' => $error);
	}

	function install(){
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable CCBill Dynamic Pricing', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_STATUS', 'True', 'Do you want to accept CCBill Dynamic Pricing payments?', '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, date_added) values ('Client Accnum', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_CLIENTACCNUM', 'empty', 'Client Accnum for CCBill', '6', '2', now())");
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Client Subacc', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_SUBACC', 'empty', 'Client Subacc for CCBill', '6', '2', now())");
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Form Name', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_FORMNAME', 'empty', 'Form Name for CCBill', '6', '2', now())");
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Salt', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_SALT', 'empty', 'Salt for CCBill', '6', '2', 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 ('Transaction Currency', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_CURRENCY', 'Any Currency', 'The currency to use for credit card transactions', '6', '2', 'zen_cfg_select_option(array(\'Any Currency\', \'Default Currency\'), ', now())");
		$db->Execute("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_CCBILL_DYNAMICPRICING_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', 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 ('Payment Zone', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', '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 ('Set Order Status', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
	}

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

	function keys(){
		return array('MODULE_PAYMENT_CCBILL_DYNAMICPRICING_STATUS', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_CLIENTACCNUM', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_SUBACC', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_FORMNAME', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_SALT', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_SORT_ORDER', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_ORDER_STATUS_ID', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_ZONE', 'MODULE_PAYMENT_CCBILL_DYNAMICPRICING_CURRENCY');
	}

	function mapCurrencyToCode($currency){
		switch ($currency){
			case 'USD':
				return 840;
			case 'EUR':
				return 978;
			case 'AUD':
				return 036;
			case 'CAD':
				return 124;
			case 'GBP':
				return 826;
			case 'JPY':
				return 392;
			default:
				return 0;
		}
	}

	function mapLanguage($language){
		switch ($language){
			case 'espanol':
				return 'spanish';
			case 'deutsch':
				return 'german';
			case 'francais':
				return 'french';
			case 'italiano':
				return 'italian';
			case 'japanese':
				return 'japanese';
			case 'korean':
				return 'korean';
			case 'cantonese':
				return 'cantonese';
			case 'mandarin':
				return 'mandarin';
			default:
				return 'english';
		}
	}
			

}

?>
If there is anyone who could help or steer me in the right direction it would be very appreciated.

Thanks