ignore weight when editing DCRD/DCHK payment methods, #71176
[freeside.git] / FS / FS / cust_payby.pm
index fd75567..62fa9be 100644 (file)
@@ -217,14 +217,14 @@ sub replace {
     $self->payinfo($new_account.'@'.$new_aba);
   }
 
-  # don't preserve paycvv if it was passed blank and payinfo changed
-  unless ( $self->payby =~ /^(CARD|DCRD)$/
-       && $old->payinfo ne $self->payinfo
-       && $old->paymask ne $self->paymask
-       && $self->paycvv =~ /^\s*$/ )
-  {
-    if ( length($old->paycvv) && $self->paycvv =~ /^\s*[\*x]*\s*$/ ) {
+  # only unmask paycvv if payinfo stayed the same
+  if ( $self->payby =~ /^(CARD|DCRD)$/ and $self->paycvv =~ /^\s*[\*x]+\s*$/ ) {
+    if ( $old->payinfo eq $self->payinfo
+         && $old->paymask eq $self->paymask
+    ) {
       $self->paycvv($old->paycvv);
+    } else {
+      $self->paycvv('');
     }
   }
 
@@ -715,6 +715,9 @@ sub cgi_hash_callback {
     'CARD' => 'DCRD',
     'CHEK' => 'DCHK',
   );
+  # the payby selector gives the choice of CARD or CHEK (or others, but
+  # those are the ones with auto and on-demand versions). if the user didn't
+  # choose a weight, then they mean DCRD/DCHK.
   $hashref->{payby} = $noauto{$hashref->{payby}}
     if ! $hashref->{weight} && exists $noauto{$hashref->{payby}};