4

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!

2 Answers 2

5

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
5
  • I tried to do this but I think I must be doing it wrong because I get Error messages and I don't think it actually executes. Would you please look at my update above in the original post? Commented Sep 21, 2018 at 10:11
  • I added mg_ and it works now. Thanks! :o) Commented Sep 21, 2018 at 10:45
  • Is there any way to avoid the save card data for security purpose in Magento 2 due to PCI compliance? Commented Feb 21, 2020 at 5:49
  • @Ketan yes, do not use the "saved cc" payment method, there are plenty alternatives with third party providers Commented Feb 21, 2020 at 6:04
  • Thanks for your valuable information :) Commented Feb 21, 2020 at 6:17
1

You will also need to use the same command on sales_flat_quote_payment as credit card numbers are stored in this table as well.

2
  • I tried to do this but I think I must be doing it wrong because I get Error messages and I don't think it actually executes. Would you please look at my update above in the original post? Commented Sep 21, 2018 at 10:11
  • I added mg_ in front of the code and it works now. Thanks! :o) Commented Sep 21, 2018 at 10:46

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.