function uc_credit_cron in Ubercart 6.2
Same name and namespace in other branches
- 5 payment/uc_credit/uc_credit.module \uc_credit_cron()
Implements hook_cron().
File
- payment/
uc_credit/ uc_credit.module, line 219 - Defines the credit card payment method and hooks in payment gateways.
Code
function uc_credit_cron() {
// Truncate stored data when in debug per the credit card method settings.
if (variable_get('uc_credit_debug', FALSE)) {
$time = strtotime(variable_get('uc_credit_number_duration', '1') . ' ' . variable_get('uc_credit_number_unit', 'years') . ' ago');
$key = uc_credit_encryption_key();
$crypt = new uc_encryption_class();
$result = db_query("SELECT order_id FROM {uc_orders} WHERE payment_method = 'credit' AND modified <= %d AND order_status = '%s'", $time, variable_get('uc_credit_clear_status', uc_order_state_default('completed')));
while ($order = db_fetch_array($result)) {
// Load up the existing data array.
$data = db_result(db_query("SELECT data FROM {uc_orders} WHERE order_id = %d", $order['order_id']));
$data = unserialize($data);
$cache = uc_credit_cache('save', $data['cc_data']);
// Save only some limited, PCI compliant data.
$cache['cc_number'] = substr($cache['cc_number'], -4);
unset($cache['cc_cvv']);
$data['cc_data'] = $crypt
->encrypt(uc_credit_encryption_key(), base64_encode(serialize($cache)));
uc_store_encryption_errors($crypt, 'uc_credit');
// Save it again.
db_query("UPDATE {uc_orders} SET data = '%s' WHERE order_id = %d", serialize($data), $order['order_id']);
}
}
}