Use this routine if you are currently storing credit card numbers and ccv information in your database (you realy shouldn't, you know). It will work with plain numbers and if you have installed contrib 4359, Credit Card Number Encryption.It will replace all but the last four numbers with X's, counts the length so will work with all major cards. If you have ccv2 info, it will blank that field. When your customer views existing orders, they will see the last 4 digits of their card so they know which one they used.

More...