function uc_credit_encrypt_existing in Ubercart 5
1 string reference to 'uc_credit_encrypt_existing'
- uc_credit_menu in payment/
uc_credit/ uc_credit.module - Implementation of hook_menu().
File
- payment/
uc_credit/ uc_credit.module, line 1556 - Defines the credit card payment method and hooks in payment gateways.
Code
function uc_credit_encrypt_existing() {
// Check to make sure encryption has been setup first.
if (($key = uc_credit_encryption_key()) === FALSE) {
return t('You must first setup your credit card encryption key filepath.');
}
// Check to make sure this action hasn't already been performed.
if (variable_get('uc_credit_existing_cc_encrypted', FALSE)) {
return t('This action may not be repeated.');
}
// Display a help messaage to make sure the admin wants to do this now.
if (arg(5) !== 'process') {
return t('Existing credit card numbers should be encrypted for future usage. The encryption process may take a few moments if you have a lot of data that needs to be encrypted. Click <a href="!url">this link</a> to update them now.', array(
'!url' => url('admin/store/settings/payment/cc_encrypt/process'),
));
}
// Setup our encryption object.
$crypt = new uc_encryption_class();
// Query the database for existing CC details.
$result = db_query("SELECT * FROM {uc_payment_credit} WHERE cc_number REGEXP ('[0-9]')");
while ($row = db_fetch_array($result)) {
// Save the data to the order.
_save_cc_data_to_order($row, $row['order_id']);
// Delete the completed row.
db_query("DELETE FROM {uc_payment_credit} WHERE credit_id = %d", $row['credit_id']);
}
// Log any errors to the watchdog.
uc_store_encryption_errors($crypt, 'uc_credit');
// Mark the process as having been completed.
variable_set('uc_credit_existing_cc_encrypted', TRUE);
drupal_set_message(t('Your existing credit card data has been encrypted.'));
drupal_goto('admin/store/settings/payment/cc_encrypt');
}