summaryrefslogtreecommitdiff
path: root/FS/FS/cust_main.pm
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2016-06-02 02:34:14 -0500
committerJonathan Prykop <jonathan@freeside.biz>2016-06-03 19:38:54 -0500
commit1ceeee1c6b8c46805c103fbcfc1bbee768b12609 (patch)
treef9d32132d2fe9d40faeda6ff9198beb284d5ce9d /FS/FS/cust_main.pm
parent1a11b9ba4171a706ad168c0ba615d88cba9d512b (diff)
RT#42394: paycvv during cust_payby replace (v4+ only) [fixed paycvv removal]
Diffstat (limited to 'FS/FS/cust_main.pm')
-rw-r--r--FS/FS/cust_main.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index f12d63a..2c092ee 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -2568,6 +2568,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 {
@@ -4752,6 +4754,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