eliminate all trace of cvv from history records, RT#5093
authorivan <ivan>
Wed, 8 Apr 2009 07:32:24 +0000 (07:32 +0000)
committerivan <ivan>
Wed, 8 Apr 2009 07:32:24 +0000 (07:32 +0000)
FS/FS/Record.pm
FS/FS/Upgrade.pm
FS/FS/cust_main.pm

index 1689845..3e3af52 100644 (file)
@@ -1747,16 +1747,18 @@ sub _h_statement {
 
   $time ||= time;
 
+  my %nohistory = map { $_=>1 } $self->nohistory_fields;
+
   my @fields =
-    grep { defined($self->getfield($_)) && $self->getfield($_) ne "" }
+    grep { defined($self->get($_)) && $self->get($_) ne "" && ! $nohistory{$_} }
     real_fields($self->table);
   ;
 
-  # If we're encrypting then don't ever store the payinfo or CVV2 in the history....
-  # You can see if it changed by the paymask...
-  if ($conf && $conf->exists('encryption') ) {
-    @fields = grep  $_ ne 'payinfo' && $_ ne 'cvv2', @fields;
+  # If we're encrypting then don't store the payinfo in the history
+  if ( $conf && $conf->exists('encryption') ) {
+    @fields = grep { $_ ne 'payinfo' } @fields;
   }
+
   my @values = map { _quote( $self->getfield($_), $self->table, $_) } @fields;
 
   "INSERT INTO h_". $self->table. " ( ".
index 5abfa69..7cf4051 100644 (file)
@@ -91,6 +91,9 @@ sub upgrade_data {
 
   tie my %hash, 'Tie::IxHash', 
 
+    #cust_main (remove paycvv from history)
+    'cust_main' => [],
+
     #msgcat
     'msgcat' => [],
 
index e696e1b..a39ac34 100644 (file)
@@ -76,6 +76,8 @@ $skip_fuzzyfiles = 0;
 $ignore_expired_card = 0;
 
 @encrypted_fields = ('payinfo', 'paycvv');
+sub nohistory_fields { ('paycvv'); }
+
 @paytypes = ('', 'Personal checking', 'Personal savings', 'Business checking', 'Business savings');
 
 #ask FS::UID to run this stuff for us later
@@ -8429,6 +8431,15 @@ sub queued_bill {
       );
 }
 
+sub _upgrade_data { #class method
+  my ($class, %opts) = @_;
+
+  my $sql = 'UPDATE h_cust_main SET paycvv = NULL';
+  my $sth = dbh->prepare($sql) or die dbh->errstr;
+  $sth->execute or die $sth->errstr;
+
+}
+
 =back
 
 =head1 BUGS