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

index f35fe4c..3f065b8 100644 (file)
@@ -1263,16 +1263,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->exists('encryption') ) {
-    @fields = grep  $_ ne 'payinfo' && $_ ne 'cvv2', @fields;
+  # If we're encrypting then don't store the payinfo in the history
+  if ( $conf->exists('encryption') ) {
+    @fields = grep { $_ ne 'payinfo' } @fields;
   }
+
   my @values = map { _quote( $self->getfield($_), $self->table, $_) } @fields;
 
   "INSERT INTO h_". $self->table. " ( ".
index 6adc736..7f35363 100644 (file)
@@ -86,6 +86,9 @@ sub upgrade_data {
 
   tie my %hash, 'Tie::IxHash', 
 
+    #cust_main (remove paycvv from history)
+    'cust_main' => [],
+
     #reason type and reasons
     'reason_type'     => [],
     'reason'          => [],
index 99ed9a6..4dc1a4f 100644 (file)
@@ -74,6 +74,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
@@ -6239,6 +6241,15 @@ sub _agent_plandata {
 
 }
 
+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