use FS::Record qw( dbh qsearch qsearchs );
use FS::cust_pay;
use FS::Conf;
+use Business::CreditCard qw(cardtype);
@ISA = qw(FS::Record);
my $job = $param->{'job'};
$job->update_statustext(0) if $job;
+ my $conf = new FS::Conf;
+
my $filetype = $info->{'filetype'}; # CSV or fixed
my @fields = @{ $info->{'fields'}};
my $formatre = $info->{'formatre'}; # for fixed
}
# purge CVV when the batch is processed
- $new_cust_pay_batch->cust_main->remove_cvv
- if ( $payby eq 'CARD' or $payby eq 'DCRD' );
+ if ( $payby =~ /^(CARD|DCRD)$/ ) {
+ my $payinfo = $hash{'payinfo'} || $cust_pay_batch->payinfo;
+ if ( ! grep { $_ eq cardtype($payinfo) }
+ $conf->config('cvv-save') ) {
+ $new_cust_pay_batch->cust_main->remove_cvv;
+ }
+ }
if ( $new_cust_pay_batch->status =~ /Approved/i ) {
my $cust_pay = new FS::cust_pay ( {
'custnum' => $custnum,
'payby' => $payby,
- 'paybatch' => $self->batchnum,
+ 'paybatch' => $hash{'paybatch'} || $self->batchnum,
'payinfo' => ( $hash{'payinfo'} || $cust_pay_batch->payinfo ),
map { $_ => $hash{$_} } (qw( paid _date )),
} );
return $error;
}
- } # foreach $cust_event
+ }
- } # if(status eq 'Approved')
+ }
- } # foreach(@all_values)
+ }
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';