'inetsecure/form', 'title' => t('Credit Card Payment'),
'callback' => 'inetsecure_page', 'access' => true, 'type' => MENU_CALLBACK);
$items[] = array('path' => 'inetsecure/script', 'title' => t('Return Script Page'),
'callback' => 'inetsecure_script', 'access' => true, 'type' => MENU_CALLBACK);
}
return $items;
}
/**
* Implementation of hook_help().
*/
function inetsecure_help($section = 'admin/help#inetsecure') {
switch ($section) {
case 'admin/modules#description':
return t('Process payments using internetsecure.com.');
case 'admin/settings/inetsecure':
return t("You need to have an Internet Secure merchant account in order to use this module. See here for more information.");
case 'inetsecure/form_submit_guidlines':
return t("After entering your credit card information, please be sure to click the complete payment button to return to the site.");
}
}
function inetsecure_ec_settings() {
$output = '';
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Main settings'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
$form['settings']['inetsecure_help'] = array(
'#type' => 'textarea',
'#title' => t('Explanation or submission guidelines'),
'#default_value' => variable_get('inetsecure_help', inetsecure_help('inetsecure/form_submit_guidlines')),
'#cols' => 70,
'#rows' => 5,
'#description' => t('This text will be displayed at the top of the credit card submission form.'),
);
$form['settings']['inetsecure_login'] = array(
'#type' => 'textfield',
'#title' => t('Login ID'),
'#default_value' => variable_get('inetsecure_login', ''),
'#size' => 70,
'#maxlength' => 180,
'#description' => t("Enter your merchant login ID."),
);
$form['settings']['inetsecure_url'] = array(
'#type' => 'textfield',
'#title' => t('Internet Secure processing URL'),
'#default_value' => variable_get('inetsecure_url', 'https://secure.internetsecure.com/process.cgi'),
'#size' => 70,
'#maxlength' => 180,
'#description' => t('URL of the secure payment processing page.'),
);
$form['settings']['inetsecure_success_url'] = array(
'#type' => 'textfield',
'#title' => t('Successful payment URL'),
'#default_value' => variable_get('inetsecure_success_url', '/'),
'#size' => 70,
'#maxlength' => 180,
'#description' => t("This is the destination to which you would like to send your customers when their payment has been successfully completed. The URL must be a Drupal system path. If you are not using clean URLs, specify the part after '?q='. If unsure, specify '/'."),
);
$form['settings']['inetsecure_debug'] = array(
'#type' => 'radios',
'#title' => t('Internet Secure test mode'),
'#default_value' => variable_get('inetsecure_debug', 0),
'#options' => array(t('Disabled'), t('Enabled')),
'#description' => t('If enabled, transactions will be sent in test mode and cards will not be charged.'),
);
$form['settings']['inetsecure_debug_decline'] = array(
'#type' => 'radios',
'#title' => t('Internet Secure test mode (decline)'),
'#default_value' => variable_get('inetsecure_debug_decline', 0),
'#options' => array(t('Disabled'), t('Enabled')),
'#description' => t('If enabled, transactions will be sent in test mode and cards will not be charged. Will force a processor decline. Overrides test mode (above).'),
);
$form['settings']['inetsecure_email_customer'] = array(
'#type' => 'radios',
'#title' => t('Email Internet Secure Reciept'),
'#default_value' => variable_get('inetsecure_email_customer', 1),
'#options' => array(t('Disabled'), t('Enabled')),
'#description' => t('If enabled, the customer will recieve a payment confirmation email from Internet Secure. Keep in mind the ecommerce package sends its own transaction summary as well. Enabling this option is recommended because it provides the customer with an accurate confirmation of the amount you have charged.'),
);
$form['settings']['inetsecure_shipping'] = array(
'#type' => 'radios',
'#title' => t('Shipping Option'),
'#default_value' => variable_get('inetsecure_shipping', 2),
'#options' => array(t('No shipping calculations'), t('Pass shipping calculation as product')),
'#description' => t("If pass is chosen, an additional product is added on called 'Shipping' with a sku of 'shp', the cost is taken from the shipping cost in transaction array at txn->misc."),
);
$form['settings']['inetsecure_tax'] = array(
'#type' => 'radios',
'#title' => t('Tax Option'),
'#default_value' => variable_get('inetsecure_tax', 2),
'#options' => array(t('No tax calculations'), t('Pass tax calculation as product')),
'#description' => t("If pass is chosen, an additional product is added on called 'tax' with a sku of 'tax', the cost is taken from the tax cost in transaction array at txn->misc."),
);
$form['settings']['inetsecure_confusr'] = array(
'#type' => 'textfield',
'#title' => t('Username for Return (Export) Script'),
'#default_value' => variable_get('inetsecure_confusr', ''),
'#size' => 70,
'#maxlength' => 180,
'#description' => t("If you are using an export script, this is the username that you specify at InternetSecure.
Export scripts are set up by default, set the web page in the merchant area to /inetsecure/script."),
);
$form['settings']['inetsecure_confpwd'] = array(
'#type' => 'textfield',
'#title' => t('Password for Return (Export) Script'),
'#default_value' => variable_get('inetsecure_confpwd', ''),
'#size' => 70,
'#maxlength' => 180,
);
$form['settings']['inetsecure_confstr'] = array(
'#type' => 'textfield',
'#title' => t('Confirmation String for Return (Export) Script'),
'#default_value' => variable_get('inetsecure_confstr', ''),
'#size' => 70,
'#maxlength' => 180,
'#description' => t("If you are using an export script, this is the confirmation string that you specify at InternetSecure.
Export scripts are set up by default, set the web page in the merchant area to /inetsecure/script."),
);
return $form;
}
/**
* Implementation of hook_paymentapi().
*/
function inetsecure_paymentapi(&$txn, $op) {
switch ($op) {
case 'display name':
return t('Pay with credit card');
case 'payment page':
return inetsecure_goto($txn);
}
}
/**
* Implementation of hook_ec_transactionapi().
*/
function inetsecure_ec_transactionapi(&$txn, $op, $a3 = NULL, $a4 = NULL) {
if ($txn->payment_method != 'inetsecure') return NULL;
switch ($op) {
case 'load':
$txn->payment = db_fetch_object(db_query("SELECT * FROM {ec_inetsecure} WHERE txnid = %d", $txn->txnid));
break;
case 'insert':
case 'update':
inetsecure_save($txn);
break;
case 'delete':
inetsecure_delete($txn);
break;
}
}
function inetsecure_delete($txn) {
db_query('DELETE FROM {ec_inetsecure} WHERE txnid = %d', $txn->txnid);
}
/**
* Called immediately after the user has clicked the checkout button.
*
* Redirect the user to the secure server to collect credit card information.
*/
function inetsecure_goto($txn) {
global $base_url;
$payment_url = str_replace('https://', 'http://', $base_url). '/'. url("inetsecure/form/". $txn->txnid);
/*
* Switch to https at internet secure
*/
header("Location: $payment_url");
exit();
}
/**
* Controller for collecting and processing credit card data.
*/
function inetsecure_page($txnid = null) {
$edit = $_POST['edit'];
$op = $_POST['op'];
if(isset($_POST['xxxName'])){ //this is a ReturnCGI from Internet Secure
$output = inetsecure_returncgi();
// We want to go to a http, not https.
$base = str_replace('https://', 'http://', $base_url);
header("Location: ".$base. "/". variable_get('inetsecure_success_url', 'node')."?status=".$output['status']);
exit();
}
else {
$output = inetsecure_form($txnid);
}
print theme('page', $output, $title);
}
/**
* Build the credit card transaction.
*/
function inetsecure_form($txnid) {
global $user, $base_url;
$t = store_transaction_load($txnid);
//Make sure the user owns the transaction or is admin.
if ($user->uid != $t->uid && $user->uid != 1) {
drupal_access_denied();
}
//Make sure the user is connected via SSL
//if (!$_SERVER['HTTPS']) {
// drupal_access_denied();
//}
$output = t('