5 use FS::UID qw(adminsuidsetup dbh);
6 use FS::Record qw(qsearch qsearchs);
7 use Time::Local 'timelocal';
8 use Date::Format 'time2str';
11 getopts('vnd:', \%opt);
13 my $user = shift or die &usage;
15 $FS::UID::AutoCommit = 0;
16 $FS::Record::nowarn_identical = 1;
18 my $extra_sql = FS::cust_main->cancel_sql;
19 $extra_sql = "WHERE $extra_sql
20 AND cust_main.payby IN('CARD','DCRD','CHEK','DCHK')
24 $opt{'d'} =~ /^(\d+)$/ or die &usage;
25 my $time = timelocal(0,0,0,(localtime(time-(86400*$1)))[3..5]);
26 print "Excluding customers canceled after ".time2str("%D",$time)."\n"
28 $extra_sql .= ' AND 0 = (' . FS::cust_main->select_count_pkgs_sql .
29 " AND cust_pkg.cancel > $time)";
32 foreach my $cust_main ( qsearch({
33 'table' => 'cust_main',
35 'extra_sql' => $extra_sql
38 print $cust_main->name, "\n";
41 $cust_main->payinfo('');
42 $cust_main->paydate('');
43 $cust_main->payby('BILL');
44 # can't have a CARD or CHEK without a valid payinfo
46 $cust_main->paycvv('');
47 my $error = $cust_main->replace;
50 die "$error (changes reverted)\n";
56 "Usage:\n\n freeside-wipe-cvv [ -v ] [ -n ] [ -d days ] user\n"
61 freeside-wipe-cvv - Wipe sensitive payment information from customer records.
65 freeside-wipe-cvv [ -v ] [ -n ] [ -d days ] user
69 freeside-wipe-cvv deletes the CVV numbers (and, optionally, credit
70 card or bank account numbers) of customers who have no non-canceled
71 packages. Normally CVV numbers are deleted as soon as a payment is
72 processed; if the customer is canceled before a payment is processed,
73 this may not happen and the CVV will remain indefinitely, violating
74 good security practice and (possibly) your merchant agreement.
75 Running freeside-wipe-cvv will remove this data.
79 -n: Remove card and account numbers in addition to CVV numbers. This
80 will also set the customer's payment method to 'BILL'.
82 -d days: Only remove CVV/card numbers from customers who have been
83 inactive for at least that many days. Optional; will default to
84 all canceled customers.