X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=64ce7ecb532dd9ba668d4ebd15c062999998cd58;hb=18af4f3316291938fa8f0a74e083209f62eac4fa;hp=86e7968a2cb416523e80163a21990f3aa7d88a79;hpb=b3cc20aeca25e4351c6ec3b795a951e6124f6376;p=freeside.git diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 86e7968a2..64ce7ecb5 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -97,6 +97,10 @@ Payment Type (See L for valid values) Payment Information (See L for data format) +=item paycardtype + +Credit card type, if appropriate; autodetected. + =item paymask Masked payinfo (See L for how this works) @@ -536,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(@_); } @@ -1206,14 +1211,35 @@ sub _upgrade_data { #class method } } - # unsuspendauto upgrade - # could just as easily go in cust_credit, or even cust_bill or cust_main - # but here works - if ($conf->exists('unsuspendauto') && !$conf->config('unsuspend_balance')) { - $conf->set('unsuspend_balance','Zero'); - $conf->delete('unsuspendauto'); - } - + ### + # set paycardtype + ### + $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 {