Author Topic: [SOLVED] Start Date and Issue NUmber for Credit Card Processing  (Read 12662 times)

adam.hughes

  • Beginner
  • *
  • Posts: 17
[SOLVED] Start Date and Issue NUmber for Credit Card Processing
« on: February 28, 2006, 09:15:42 am »
I have modifed an 'out of the box' Virtuemart 1.0.2 installation to include the taking of credit card start date's and issue numbers. I will request Soreen if would put the code into the next release of Virtuemart but I'll also post the details here.

To add start date and issue number's to credit card processing :

1. Update the config page to add the ability to enable or disable taking the new start date and issue number details. Edit file : /administrator/com_virtuemart/html/admin.show_cfg.php
After the lines
Code: [Select]
else
echo '<input type="hidden" name="conf_PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS" value="'.PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS.'" />';
?>
</table>
</fieldset>
add lines
Code: [Select]
<fieldset>
<legend>
<?php echo $VM_LANG->_PHPSHOP_ADMIN_CFG_CC_OPT_SETTINGS ?></legend>
<table class="adminform">
<?php
<tr>
<
td class="labelcell">
<
label for="conf_PSHOP_REQUIRE_STARTDATE"><?php echo $VM_LANG->_PHPSHOP_ADMIN_CFG_REQUIRE_STARTDATE ?>

</label>
</td>
<td>
<input type="checkbox" id="conf_PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS" name="conf_PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS" class="inputbox" <?php if (PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS == '1') echo "checked=\"checked\""?> value="1" />
</td>
<td>
<?php echo $VM_LANG->_PHPSHOP_ADMIN_CFG_REQUIRE_STARTDATE_EXPLAIN ?>
</td>
</tr>
<tr>
<td class="labelcell">
<label for="conf_PSHOP_REQUIRE_ISSUENUMBER"><?php echo $VM_LANG->_PHPSHOP_ADMIN_CFG_REQUIRE_ISSUENUMBER ?>
</label>
</td>
<td>
<input type="checkbox" id="conf_PSHOP_REQUIRE_ISSUENUMBER" name="conf_PSHOP_REQUIRE_ISSUENUMBER" class="inputbox" <?php if (PSHOP_REQUIRE_ISSUENUMBER == '1') echo "checked=\"checked\""?> value="1" />
</td>
<td>
<?php echo VM_LANG->_PHPSHOP_ADMIN_CFG_REQUIRE_ISSUENUMBER_EXPLAIN ?>
</td>
</tr>
</table>
</fieldset>
2. Update administrator/com_virtuemart/classes/ps_config.php to ensure that the new config variable to written to the config.
Add line
Code: [Select]
"PSHOP_REQUIRE_STARTDATE" => "conf_PSHOP_REQUIRE_STARTDATE",
"PSHOP_REQUIRE_ISSUENUMBER" => "conf_PSHOP_REQUIRE_ISSUENUMBER",
After line (line 100)
Code: [Select]
"PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS" => "conf_PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS",
3. Add default settings (in case users don't set it)
Update administrator/com_virtuemart/virtuemart.cfg.php
After line
Code: [Select]
define('PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS', '1');
Add lines
Code: [Select]
define('PSHOP_REQUIRE_STARTDATE', '0');
define('PSHOP_REQUIRE_ISSUENUMBER', '0');
4. Add a new function in administrator/components/com_virtuemart/classes/ps_html.php
This function is used by the startdate to create a list of prior years
After the listyear function add
Code: [Select]
function list_prioryear($list_name,$selected_item="") {
$current = date("Y");
for ($i=$current-5; $i<$current+1; $i++)
$list[$i] = $i;
$this->dropdown_display($list_name, $selected_item, $list);
return 1;
}
5. Update language file : administrator/com_virtuemart/language/english.php
This adds the text on each page
Add lines
Code: [Select]
var $_PHPSHOP_CHECKOUT_CONF_PAYINFO_ISSUENUMBER = 'Issue Number';
var $_PHPSHOP_CUSTOMER_ISSUENUMBER_TOOLTIP = 'Issue number\'s are only required on switch cards';
var $_PHPSHOP_CHECKOUT_CONF_PAYINFO_STARTDATE = 'Start Date';
var $_PHPSHOP_ADMIN_CFG_CC_OPT_SETTINGS = 'Credit Card Optional Settings';
var $_PHPSHOP_ADMIN_CFG_REQUIRE_STARTDATE = 'Require Start Date';
var $_PHPSHOP_ADMIN_CFG_REQUIRE_STARTDATE_EXPLAIN = 'Select if you wish to collect start date when processing credit cards';
var $_PHPSHOP_ADMIN_CFG_REQUIRE_ISSUENUMBER = 'Require Issue Number';
var $_PHPSHOP_ADMIN_CFG_REQUIRE_ISSUENUMBER_EXPLAIN = 'Select if you wish to collect the issue number processing credit cards';
6. Update to database structure (to allow capture of start date and issue number)
Add the following column into the vm_order_payment table
Code: [Select]
order_payment_startdate : INTEGER : Can be null
order_payment_issuenumber : INTEGER : Can be null
7. Update to administrator/components/com_virtuemart/html/checkout.paymentradio.php
Before section
Code: [Select]
<tr>
<td nowrap width="10%" align="right"><?php echo $VM_LANG->_PHPSHOP_CHECKOUT_CONF_PAYINFO_EXDATE ?>:</td>
<td>
<?php $ps_html->list_month("order_payment_expire_month", @$_SESSION['ccdata']['order_payment_expire_month']);
echo 
"/";
$ps_html->list_year("order_payment_expire_year", @$_SESSION['ccdata']['order_payment_expire_year']) ?>

</td>
</tr>
Add section
Code: [Select]
<?php if( PSHOP_REQUIRE_STARTDATE == '1' ) { ?>
<tr>
<td nowrap width="10%" align="right"><?php echo $VM_LANG->_PHPSHOP_CHECKOUT_CONF_PAYINFO_STARTDATE ?>
:
</td>
<td>
<?php 
$ps_html
->list_month("order_payment_startdate_month", @$_SESSION['ccdata']['order_payment_startdate_month']);
echo 
"/";
$ps_html->list_prioryear("order_payment_startdate_year", @$_SESSION['ccdata']['order_payment_startdate_year']) ?>

</td>
</tr>
<?php ?>
The above adds the start date to the checkout process for the end user.
Then After section
Code: [Select]
<tr valign="top">
<td nowrap width="10%" align="right">
<label for="credit_card_code">Credit Card Security Code:</label></td>
<td>
<input type="text" class="inputbox" id="credit_card_code" name="credit_card_code" value="" />
<?php echo mm_ToolTip$VM_LANG->_PHPSHOP_CUSTOMER_CVV2_TOOLTIP); ?>
</td>
Add section
Code: [Select]
<?php if( PSHOP_REQUIRE_ISSUENUMBER == '1' ) { ?>
<tr>
<td nowrap width="10%" align="right">
<?php 
echo $VM_LANG->_PHPSHOP_CHECKOUT_CONF_PAYINFO_ISSUENUMBER;
echo 
":";
 
?>

</td>
<td>
<input type="text" class="inputbox" id="order_payment_issuenumber" name="order_payment_issuenumber" value="<?php if(!empty($_SESSION['ccdata']['order_payment_issuenumber'])) echo $_SESSION['ccdata']['order_payment_issuenumber'?>" />
<?php
echo mm_ToolTip$VM_LANG->_PHPSHOP_CUSTOMER_ISSUENUMBER_TOOLTIP); 
?>

</td>
</tr>
<?php 
?>


8. Update to administrator/components/com_phpshop/html/order.order_print.php
Add the issue number details to the order page
This adds the start date into the order when viewed by the administrator
After lines
Code: [Select]
<tr>
<td width="13%"><?php $dbpm->p("payment_method_name");?> </td>
<td width="40%"><?php $dbpm->p("order_payment_name");?></td>
<td width="30%"><?php echo ps_checkout::asterisk_pad$dbaccount->f("account_number"), 4true );
if( 
$dbaccount->f('order_payment_code')) 
{
echo 
'<br/>(CVV Code: '.$dbaccount->f('order_payment_code').') ';
}
?>

</td>
<td width="17%"><?php echo date("M-Y"$dbpm->f("order_payment_expire")); ?></td>
</tr>
Add lines
Code: [Select]
<tr class="sectiontableheader">
<th colspan="2">
<?php echo $VM_LANG->_PHPSHOP_CHECKOUT_CONF_PAYINFO_ISSUENUMBER ?>
</th>
<th colspan="2">
<?php echo $VM_LANG->_PHPSHOP_CHECKOUT_CONF_PAYINFO_STARTDATE ?>
</th>
</tr>
<tr>
<th colspan="2">
<?php echo $dbpm->p("order_payment_issuenumber");?>
</th>
<th colspan="2">
<?php echo date("M-Y"$dbpm->f("order_payment_startdate")); ?>
</th>
</tr>

9. Finally : Update to administrator/components/com_virtuemart/classes/ps_checkout.php
Add the start date to the update table class
These add the process of putting the startdate and issue number details into the database
First the startdate items
Before line
Code: [Select]
$d["order_payment_expire"] = "";
add line
Code: [Select]
$d["order_payment_startdate"] = "";
after line
Code: [Select]
$d["credit_card_code"] = "";
add line
Code: [Select]
$d["order_payment_issuenumber"] = "";
Before line
Code: [Select]
$_SESSION['ccdata']['order_payment_expire_month'] = "";
Add lines
Code: [Select]
$_SESSION['ccdata']['order_payment_startdate_month'] = "";
$_SESSION['ccdata']['order_payment_startdate_year'] = "";
After line
Code: [Select]
$_SESSION['ccdata']['credit_card_code'] = "";
Add line
Code: [Select]
$_SESSION['ccdata']['order_payment_issuenumber'] = "";
      
Before line
Code: [Select]
$HTTP_POST_VARS["order_payment_expire"] = "";
Add line
Code: [Select]
$HTTP_POST_VARS["order_payment_startdate"] = "";
Before lines
Code: [Select]
$expire_timestamp = @mktime(0,0,0,$_SESSION["ccdata"]["order_payment_expire_month"], 1,$_SESSION["ccdata"]["order_payment_expire_year"]);
$_SESSION["ccdata"]["order_payment_expire"] = $expire_timestamp;
Add lines
Code: [Select]
$startdate_timestamp = @mktime(0,0,0,$_SESSION["ccdata"]["order_payment_startdate_month"], 1,$_SESSION["ccdata"]["order_payment_startdate_year"]);
$_SESSION["ccdata"]["order_payment_startdarte"] = $startdate_timestamp;
Before lines      
Code: [Select]
$_SESSION['ccdata']['order_payment_expire_month'] = @$d['order_payment_expire_month'];
$_SESSION['ccdata']['order_payment_expire_year'] = @$d['order_payment_expire_year'];
Add lines
Code: [Select]
$_SESSION['ccdata']['order_payment_startdate_month'] = @$d['order_payment_startdate_month'];
$_SESSION['ccdata']['order_payment_startdate_year'] = @$d['order_payment_startdate_year'];
After line
Code: [Select]
$_SESSION['ccdata']['credit_card_code'] = @$d['credit_card_code'];
Add lines
Code: [Select]
// Issue Number
$_SESSION['ccdata']['order_payment_issuenumber'] = @$d['order_payment_issuenumber'];
   
Update lines
Code: [Select]
$q .= "(order_id, order_payment_code, payment_method_id, order_payment_number, ";
"order_payment_expire, order_payment_log, order_payment_name, order_payment_trans_id) ";
to
Code: [Select]
$q .= "(order_id, order_payment_code, order_payment_issuenumber, payment_method_id, order_payment_number, ";
"order_payment_startdate, order_payment_expire, order_payment_log, order_payment_name, order_payment_trans_id) ";
and before line
Code: [Select]
$q .= "'" . @$_SESSION["ccdata"]["order_payment_expire"] . "',";
add
Code: [Select]
$q .= "'" . $_SESSION["ccdata"]["order_payment_startdate"] . "',";
Also after line
Code: [Select]
$q .= "'" . $d["order_payment_code"] . "', ";
Add line
Code: [Select]
$q .= "'" . $_SESSION["ccdata"]["order_payment_issuenumber"] . "', ";

All these changes will be available on www.questtech.co.uk to download direct in about 2 days.

adam.hughes

  • Beginner
  • *
  • Posts: 17
Re: Start Date and Issue NUmber for Credit Card Processing
« Reply #1 on: February 28, 2006, 09:22:00 am »
I forgot to add that once all the changes have been done if you go into the virtuemart configuration
1. Start your browser
2. Go to http://yoursite/adminisrator
3. Log in with your admin id
4. Click on components / virtuemart
5. Click on configuration
6. : You'll now have two new options : This enable you to enable or disable the copllection of start date and or issue number during the credit card processing.

TheMachine

  • Beginner
  • *
  • Posts: 4
Re: [SOLVED] Start Date and Issue NUmber for Credi
« Reply #2 on: July 20, 2007, 16:55:59 pm »
Hi guys, exellent fix and certainly what I needed.

One thing though, the start date isnt showing up in the checkout, even though I have edited all files and enabled in VM config.

Any ideas?

TheMachine

  • Beginner
  • *
  • Posts: 4
Re: [SOLVED] Start Date and Issue NUmber for Credi
« Reply #3 on: July 24, 2007, 17:55:07 pm »
Anyone ?

bbd_russ

  • Beginner
  • *
  • Posts: 10
Re: [SOLVED] Start Date and Issue NUmber for Credit Card Processing
« Reply #4 on: June 30, 2008, 14:42:02 pm »
This should be easy enough to integrate into Viruemart 1.1.0 and Joomla 1.5, however, the only point i'm struggling to manually write all this code in is the language files (step 5.). In which language file would be best to paste these new variables?

iain_darkflare

  • Beginner
  • *
  • Posts: 16
Re: [SOLVED] Start Date and Issue NUmber for Credit Card Processing
« Reply #5 on: September 04, 2008, 17:39:00 pm »
Is there a fix for this in VM 1.1.2 yet?