X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2Fpay_batch.pm;h=1c0a28ab67cacba28f385133d66fb43adfabe185;hb=345dfc58a6230d9bc5e88c063a3fc14f3647e68d;hp=528b0d59743e1635727aeead31573d57cc59a529;hpb=48daaf7dd667869e033ce9463829cbfec47fab4e;p=freeside.git diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm index 528b0d597..1c0a28ab6 100644 --- a/FS/FS/pay_batch.pm +++ b/FS/FS/pay_batch.pm @@ -14,6 +14,7 @@ use Scalar::Util 'blessed'; use IO::Scalar; use FS::Misc qw(send_email); # for error notification use List::Util qw(sum); +use Try::Tiny; @ISA = qw(FS::Record); @@ -1080,16 +1081,21 @@ sub export_to_gateway { my $processor = $gateway->batch_processor(%proc_opt); my @items = map { $_->request_item } $self->cust_pay_batch; - 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; '';