diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2016-06-02 02:34:14 -0500 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2016-06-02 02:34:14 -0500 |
commit | 95502dabd865c34d1483b20c583523b12fe9332d (patch) | |
tree | 0d923c04418076bdcf4c00369e0402d347944e97 /FS | |
parent | 36245fa05ae5d9fb0ef893cdfe5ad98f88fd7e77 (diff) |
RT#42394: paycvv during cust_payby replace (v4+ only) [fixed paycvv removal]
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_main.pm | 29 | ||||
-rw-r--r-- | FS/FS/cust_main/Billing_Realtime.pm | 18 | ||||
-rw-r--r-- | FS/FS/cust_payby.pm | 14 |
3 files changed, 42 insertions, 19 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index bf5baa986..afecb83f5 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2336,6 +2336,8 @@ Removes the I<paycvv> field from the database directly. If there is an error, returns the error, otherwise returns false. +DEPRECATED. Use L</remove_cvv_from_cust_payby> instead. + =cut sub remove_cvv { @@ -4522,6 +4524,33 @@ PAYBYLOOP: } +=item remove_cvv_from_cust_payby PAYINFO + +Removes paycvv from associated cust_payby with matching PAYINFO. + +=cut + +sub remove_cvv_from_cust_payby { + my ($self,$payinfo) = @_; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + foreach my $cust_payby ( qsearch('cust_payby',{ custnum => $self->custnum }) ) { + next unless $cust_payby->payinfo eq $payinfo; # can't qsearch on payinfo + $cust_payby->paycvv(''); + my $error = $cust_payby->replace; + if ($error) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; +} + =back =head1 CLASS METHODS diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index c676607da..9fea1bb33 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -510,11 +510,8 @@ sub realtime_bop { $paydate =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; $content{expiration} = "$2/$1"; - my $paycvv = exists($options{'paycvv'}) - ? $options{'paycvv'} - : $self->paycvv; - $content{cvv2} = $paycvv - if length($paycvv); + $content{cvv2} = $options{'paycvv'} + if length($options{'paycvv'}); my $paystart_month = exists($options{'paystart_month'}) ? $options{'paystart_month'} @@ -764,10 +761,10 @@ sub realtime_bop { ### # compare to FS::cust_main::save_cust_payby - check both to make sure working correctly - if ( length($self->paycvv) + if ( length($options{'paycvv'}) && ! grep { $_ eq cardtype($options{payinfo}) } $conf->config('cvv-save') ) { - my $error = $self->remove_cvv; + my $error = $self->remove_cvv_from_cust_payby($options{payinfo}); if ( $error ) { warn "WARNING: error removing cvv: $error\n"; } @@ -1790,11 +1787,8 @@ sub realtime_verify_bop { $paydate =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; $content{expiration} = "$2/$1"; - my $paycvv = exists($options{'paycvv'}) - ? $options{'paycvv'} - : $self->paycvv; - $content{cvv2} = $paycvv - if length($paycvv); + $content{cvv2} = $options{'paycvv'} + if length($options{'paycvv'}); my $paystart_month = exists($options{'paystart_month'}) ? $options{'paystart_month'} diff --git a/FS/FS/cust_payby.pm b/FS/FS/cust_payby.pm index fd75567e6..623a44efc 100644 --- a/FS/FS/cust_payby.pm +++ b/FS/FS/cust_payby.pm @@ -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(''); } } |