Re: Future Versions. I've played

Posts: 79
Joined: 10/29/2007
Bug Finder

I had to do a little hack, and I'd like to figure out if this can be done w/o hacking the module. Before enabling this module, I had overrided the validation on the uc_cart_checkout to see if the expiration date was going to be expiring soon. I did this becuase I'm selling a product that is billed over several months, and I would like to get credit cards that are not expiring in the next few month. Anyway, I was using the values posted into the exp_month and exp_year to check this.

if (strcmp('uc_cart_checkout_form', $form_id) != 0) return;
$form['#validate'] = array('credit_check_expdate' => array());

When I installed the CIM module, I have a field when they enter a new credit card, but if they had an existing card stored, I could not check the date. I inserted 2 lines into the uc_cim.module at 774 and 792 (during review). These call the date checker, but I hate to modify contrib code. Is there a way to hook into this form my module.

These 2 lines were added to cim:
check_leap_date($arg1->payment_details['cc_exp_month'], $arg1->payment_details['cc_exp_year']); // at 774

check_leap_date($profile['cc_exp_month'], $profile['cc_exp_year']); // at 793

Then I have this function in my module

<?php
function check_leap_date($month, $year) {
      
   
$items = uc_cart_get_contents();
    for (
$i=0; $i < count($items); $i++) {
         if (
$items[$i]->model == 'LEAP')
        {
       
$mk_time mktime(0, 0, 0, date("m")+4, 0,   date("Y"));
       
$cc_exp_mktime mktime(0, 0, 0, $month, 0,   $year);
        if (
$mk_time >= $cc_exp_mktime)
            {
               
form_set_error('error', 'Your Credit Card expires Within the Next 5 months, Please enter a Credit Card that will not expire for the next 5 months');
               
drupal_goto("cart/checkout");
            }
        }       
    } 
//end for   
   
}
?>

Reuse Credit Card By: VitaLife (25 replies) Sun, 04/27/2008 - 11:45