summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2016-12-16 11:57:52 -0800
committerMark Wells <mark@freeside.biz>2016-12-16 16:41:41 -0800
commit4d4dc3e852e5ff1ca883e2003b0b2e95db0e5414 (patch)
treece526f2e438f047a4ce7d9baa4d3ea938ec765e9
parent6f9169776574d40f7df14329d7a896707d0d42c8 (diff)
prevent B:BP batches from being marked in-transit if uploading the batch fails, #71837
-rw-r--r--FS/FS/pay_batch.pm24
1 files changed, 15 insertions, 9 deletions
diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm
index 104975100..4aeb33169 100644
--- a/FS/FS/pay_batch.pm
+++ b/FS/FS/pay_batch.pm
@@ -14,6 +14,7 @@ use FS::Record qw( dbh qsearch qsearchs );
use FS::Conf;
use FS::cust_pay;
use FS::Log;
+use Try::Tiny;
=head1 NAME
@@ -1086,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;
'';