X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpay_batch.pm;h=4aeb33169470087498f44e50c6df3281e66cb318;hp=35c79f50b1d7f94c1f942e19ffc4f8b0be318c32;hb=61e54f288c3b6c93bcfdf128c8117f66965f463b;hpb=1259a17db297fa2352619b29f2c5bd34e313cd64 diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm index 35c79f50b..4aeb33169 100644 --- a/FS/FS/pay_batch.pm +++ b/FS/FS/pay_batch.pm @@ -9,11 +9,12 @@ use List::Util qw(sum); use Time::Local; use Text::CSV_XS; use Date::Parse qw(str2time); -use Business::CreditCard qw(cardtype); +use Business::CreditCard qw( 0.35 cardtype ); use FS::Record qw( dbh qsearch qsearchs ); use FS::Conf; use FS::cust_pay; use FS::Log; +use Try::Tiny; =head1 NAME @@ -614,7 +615,8 @@ sub import_from_gateway { my $error; my $paybatch = $gateway->gatewaynum . '-' . $gateway->gateway_module . - ':' . $item->authorization . ':' . $item->order_number; + ':' . ($item->authorization || '') . + ':' . ($item->order_number || ''); if ( $batch->incoming ) { # This is a one-way batch. @@ -1085,16 +1087,21 @@ sub export_to_gateway { return ''; } - my $batch = Business::BatchPayment->create(Batch => - batch_id => $self->batchnum, - items => \@items - ); - $processor->submit($batch); + try { + my $batch = Business::BatchPayment->create(Batch => + batch_id => $self->batchnum, + items => \@items + ); + $processor->submit($batch); - if ($batch->processor_id) { - $self->set('processor_id',$batch->processor_id); - $self->replace; - } + if ($batch->processor_id) { + $self->set('processor_id',$batch->processor_id); + $self->replace; + } + } catch { + $dbh->rollback if $oldAutoCommit; + die $_; + }; $dbh->commit or die $dbh->errstr if $oldAutoCommit; '';