diff options
author | Mark Wells <mark@freeside.biz> | 2016-12-21 15:25:35 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2016-12-21 15:39:12 -0800 |
commit | 5a97f3f545d11966801077b9740e5f91fb2bbf6a (patch) | |
tree | 90086b90a96238e90f1072d4ca3bf84793ca2748 /FS/FS/cust_pay.pm | |
parent | bc1b0f58caeecdfb63f1450968a05db050d6758b (diff) |
fix payinfo_used on batch payments with encrypted payinfo, related to #19571
Diffstat (limited to 'FS/FS/cust_pay.pm')
-rw-r--r-- | FS/FS/cust_pay.pm | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index e0a7143..64ce7ec 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -540,7 +540,8 @@ otherwise returns false. sub replace { my $self = shift; - return "Can't modify closed payment" if $self->closed =~ /^Y/i; + return "Can't modify closed payment" + if $self->closed =~ /^Y/i && !$FS::payinfo_Mixin::allow_closed_replace; $self->SUPER::replace(@_); } @@ -1215,6 +1216,30 @@ sub _upgrade_data { #class method ### $class->upgrade_set_cardtype; + # for batch payments, make sure paymask is set + do { + local $FS::payinfo_Mixin::allow_closed_replace = 1; + local $FS::payinfo_Mixin::ignore_masked_payinfo = 1; + + my $cursor = FS::Cursor->new({ + table => 'cust_pay', + extra_sql => ' WHERE paymask IS NULL AND payinfo IS NOT NULL + AND payby IN(\'CARD\', \'CHEK\') + AND batchnum IS NOT NULL', + }); + + # records from cursors for some reason don't decrypt payinfo, so + # call replace_old to fetch the record "normally" + while (my $cust_pay = $cursor->fetch) { + $cust_pay = $cust_pay->replace_old; + $cust_pay->set('paymask', $cust_pay->mask_payinfo); + my $error = $cust_pay->replace; + if ($error) { + die "$error (setting masked payinfo on payment#". $cust_pay->paynum. + ")\n" + } + } + }; } sub process_upgrade_paybatch { |