Forums / Addon Payment Modules / Pre Auth all Payments

Pre Auth all Payments

Locked

Started by freerangepc on 15 Aug 2006, 6:36 PM · Views: 2,192

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
15 Aug 2006, 6:36 PM
#1
freerangepc avatar

freerangepc

New Zenner

Join Date:
Apr 2006
Posts:
65
Plugin Contributions:
0

Pre Auth all Payments

Hi there

I have been sucessfully using the metacharge payment module but I wish to include this : I need all the captured payment through metacharge to be preauth as stock fluctuates and people often want to cancel. I have been given this instruction...
If you would like to make all orders pre-auths, you can send in a variable called intAuthMode and set it to 2 when you are initiating a payment request. This should be another hidden variable in the form that includes the payment amount, currency, your installation ID, etc.

If you want to retain the safety of being able to not worry about having to capture funds, you could go to your installation properties in Account Management and set all pre-auths to automatically capture after a number of days.

this is the code for metacharge

class metacharge {

var $code, $title, $description, $enabled;

function metacharge($metacharge_cart_id = '') {
	global $order;
	if (zen_not_null($metacharge_cart_id)) {
		$this->query($metacharge_cart_id);
	} else {
		$this->code = 'metacharge';
		$this->title = MODULE_PAYMENT_METACHARGE_TEXT_TITLE;
		$this->description = MODULE_PAYMENT_METACHARGE_TEXT_DESCRIPTION;
		$this->sort_order = MODULE_PAYMENT_METACHARGE_SORT_ORDER;
		$this->enabled = ((MODULE_PAYMENT_METACHARGE_STATUS == 'True') ? true : false);
  		$this->form_action_url = "https://secure.metacharge.com/mcpe/purser";
  		if ((int)MODULE_PAYMENT_METACHARGE_ORDER_STATUS_ID > 0) {
  			$this->order_status = MODULE_PAYMENT_METACHARGE_ORDER_STATUS_ID;
  		}
  		if (is_object($order)) $this->update_status();
  		$this->form_metacharge_url = 'https://secure.metacharge.com/mcpe/purser';
  	}
  	
}

function currency() {
	return $_SESSION["currency"];
}


function update_status() {
	global $order, $db;	
	$this->enabled = true;
}

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 $_SERVER, $order;
	
	$metacharge_fail = zen_session_name(). '=' .zen_session_id() . '&shipping_selected='.$shipping_selected;
	$metacharge_success = zen_session_name(). '=' .zen_session_id() . '&shipping_selected='.$shipping_selected . '&shipping_cost='.$shipping_cost.'&shipping_method='.$shipping_method;
	$process_button_string = 
	
	zen_draw_hidden_field('intInstID', MODULE_PAYMENT_METACHARGE_ID).
	zen_draw_hidden_field('strCurrency', $this->currency()).
	zen_draw_hidden_field('strDesc', 'Purchase from '.STORE_NAME).
	zen_draw_hidden_field('strCartID', STORE_NAME.' : '.$order->customer['firstname'].' '.$order->customer['lastname']).
	zen_draw_hidden_field('fltAmount', number_format($order->info['total'],2,'.','')).
	zen_draw_hidden_field('intTestMode', MODULE_PAYMENT_METACHARGE_MODE) .
	zen_draw_hidden_field('strCardHolder', $order->customer['firstname'] . ' ' . $order->customer['lastname']) .
	zen_draw_hidden_field('strAddress', $order->customer['street_address']).
	zen_draw_hidden_field('strCity', $order->customer['city']) .
	zen_draw_hidden_field('strState', $order->customer['state']).
	zen_draw_hidden_field('strPostcode', $order->customer['postcode']) .
	zen_draw_hidden_field('strEmail', $order->customer['email_address']) .
	zen_draw_hidden_field('strCountry', $order->customer['country']['iso_code_2']) .
	zen_draw_hidden_field('strTel', $order->customer['telephone']) .
	zen_draw_hidden_field('strFax', $order->customer['fax']) .

	zen_draw_hidden_field('PT_return_url', zen_href_link(FILENAME_CHECKOUT_PROCESS, $metacharge_fail, 'SSL')).
	zen_draw_hidden_field('PT_return_url', zen_href_link(FILENAME_CHECKOUT_PROCESS, $metacharge_fail, 'SSL')) .
	zen_draw_hidden_field('email', $order->customer['email_address']) .

	zen_draw_hidden_field(zen_session_name(), zen_session_id());
	
	return $process_button_string;
}

function before_process() {
	if ($_POST['intStatus'] == 1) return;
	
	zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message='.urlencode("Your purchase was declined."), 'SSL', true, false));
}

function after_process() {
	return false;
}

function output_error() {
	return false;
}

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

function install() {
	global $db;
	$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 Metacharge Module', 'MODULE_PAYMENT_METACHARGE_STATUS', 'True', 'Do you want to accept Metacharge 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 ('MCPE Installation ID', 'MODULE_PAYMENT_METACHARGE_ID', '00000', 'Your MCPE Installation ID', '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 ('Test Mode', 'MODULE_PAYMENT_METACHARGE_MODE', '1', 'The mode you are working in (1 = Test Mode, 0 = Live', '6', '3', now())");

}


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

function keys() {
	return array('MODULE_PAYMENT_METACHARGE_STATUS', 'MODULE_PAYMENT_METACHARGE_ID','MODULE_PAYMENT_METACHARGE_MODE');
}

}

where and how do i put the variable!

Thanks

16 Aug 2006, 8:03 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Pre Auth all Payments

put it under testmode, like this:```php
zen_draw_hidden_field('intTestMode', MODULE_PAYMENT_METACHARGE_MODE) .

zen_draw_hidden_field('intAuthMode', '2') .

.
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.

18 Aug 2006, 9:13 AM
#3
freerangepc avatar

freerangepc

New Zenner

Join Date:
Apr 2006
Posts:
65
Plugin Contributions:
0

Re: Pre Auth all Payments

Thanks for that works like a dream and saves me a lot of headaches!!