How to Purge Credit Card Numbers Stored on Magento 1.9.1.0

databasemagento-1.9payment-methodsSecurity

We used the 'Saved CC' payment method in our Magento 1.9.1.0 store and now we would like to delete the credit card numbers for security reasons.

What is the easiest procedure to delete all credit card numbers?



UPDATE ON SEPTEMBER 21st, 2018:

I just tried to do that. I go to phpMyAdmin in the cPanel. There are 2 databases:

  1. mySITE_mySITE

  2. information schema

I highlight either, click on SQL, and enter the following lines (one at a time):

UPDATE sales_flat_order_payment SET cc_number_enc=NULL;
UPDATE sales_flat_order_payment SET cc_type=NULL;
UPDATE sales_flat_order_payment SET cc_last4=NULL;
UPDATE sales_flat_order_payment SET cc_owner=NULL;
UPDATE sales_flat_order_payment SET cc_exp_month=NULL;
UPDATE sales_flat_order_payment SET cc_exp_year=NULL;


UPDATE sales_flat_quote_payment SET cc_number_enc=NULL;
UPDATE sales_flat_quote_payment SET cc_type=NULL;
UPDATE sales_flat_quote_payment SET cc_last4=NULL;
UPDATE sales_flat_quote_payment SET cc_owner=NULL;
UPDATE sales_flat_quote_payment SET cc_exp_month=NULL;
UPDATE sales_flat_quote_payment SET cc_exp_year=NULL;

But then it gives me the following Errors:

Error
SQL query:
UPDATE sales_flat_order_payment SET cc_number_enc=NULL
MySQL said:  
#1146 - Table 'mySITE_mySITER.sales_flat_order_payment' doesn't exist



Error
SQL query:
UPDATE sales_flat_order_payment SET cc_number_enc=NULL
MySQL said:  
#1109 - Unknown table 'sales_flat_order_payment' in information_schema


What am I doing wrong?


Another UPDATE on September 21st:

it turns out that all that I needed to do was to add mg_ in front of the code like this:

UPDATE mg_sales_flat_order_payment SET cc_number_enc=NULL;
UPDATE mg_sales_flat_order_payment SET cc_type=NULL;
UPDATE mg_sales_flat_order_payment SET cc_last4=NULL;
UPDATE mg_sales_flat_order_payment SET cc_owner=NULL;
UPDATE mg_sales_flat_order_payment SET cc_exp_month=NULL;
UPDATE mg_sales_flat_order_payment SET cc_exp_year=NULL;


UPDATE mg_sales_flat_quote_payment SET cc_number_enc=NULL;
UPDATE mg_sales_flat_quote_payment SET cc_type=NULL;
UPDATE mg_sales_flat_quote_payment SET cc_last4=NULL;
UPDATE mg_sales_flat_quote_payment SET cc_owner=NULL;
UPDATE mg_sales_flat_quote_payment SET cc_exp_month=NULL;
UPDATE mg_sales_flat_quote_payment SET cc_exp_year=NULL;

And now it works!

Best Answer

The encrypted credit card numbers are stored in the cc_number_enc column of the sales_flat_order_payment table. With this SQL query you can delete them all:

UPDATE sales_flat_order_payment SET cc_number_enc=NULL;

To delete all credit card data, do the same with the other columns that start with cc_:

  • cc_type
  • cc_number_enc
  • cc_last4
  • cc_owner
  • cc_exp_month
  • cc_exp_year
Related Topic