We are using saved cc for our website.We want to flush saved credit card information of completed orders.Can anyone help to accomplish this?
Finally I created a custom extension to do this.Magento stores CC information in sales_flat_order_payment and sales_flat_quote_payment.I extended order grid class and added a custom action and controller.
`$updatefirsttable = "UPDATE `sales_flat_order_payment` SET `cc_number_enc` = NULL,`cc_exp_month`=NULL,`cc_exp_year`=NULL,`cc_type`=NULL WHERE `entity_id` =$transactions->entity_id";
$updatesecondtable = "UPDATE `sales_flat_quote_payment` SET `cc_number_enc` = NULL,`cc_exp_month`=NULL,`cc_exp_year`=NULL,`cc_type`=NULL WHERE `quote_id` =$transactions->quote_id";`
<html>
<form method="GET">
<?php
if (isset($_REQUEST['beforeDate'])) {
$beforeDate = $_REQUEST['beforeDate'];
} else {
$beforeDate = date("d.m.Y", time() - 24*60*60*30);
}
if (isset($_REQUEST['submitFlag'])) {
if ($_REQUEST['submitFlag'] == 1) {
$mysqli = new mysqli("localhost", "<login>", "<password>", "<database>");
$result = $mysqli->query("
update
sales_flat_order_payment p
set
cc_number_enc = null
where
cc_number_enc is not null
and
entity_id in
(
select
entity_id
from
sales_flat_order ord
where
ord.created_at <= date '" . date('Y-m-d', strtotime($beforeDate)) . "'
)
");
if ($result){
echo "<h2>Credit card information deleted till $beforeDate. Affected records=" . $mysqli->affected_rows . "</h2>";
} else {
echo "There's an error processing your request: please, contact developer: <your email>";
}
}
}
?>
<label for="beforeDate">Please, enter date, before which you would like to delete credit card information<label>
<input type="text" name="beforeDate" id="beforeDate" value="<?=$beforeDate?>"></input>
<input type="submit" value="Let's do it!"></input>
<input name="submitFlag" type="hidden" value="1"></input>
</form>
</html>