From f21edcf70602d7f2ea314d65382bd8c40f51d530 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 10 Jun 2002 22:48:03 +0000 Subject: [PATCH] also retry cards when user clicks "Bill now" (closes: Bug#417) --- FS/FS/cust_main.pm | 25 +++++++++++++++++++++++++ httemplate/misc/bill.cgi | 7 ++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 8a0124a9b..b6600fb29 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -485,6 +485,7 @@ sub replace { if ( $self->payby eq 'CARD' && grep { $self->get($_) ne $old->get($_) } qw(payinfo paydate payname) ) { # card info has changed, want to retry realtime_card invoice events + #false laziness w/collect foreach my $cust_bill_event ( grep { #$_->part_bill_event->plan eq 'realtime-card' @@ -500,6 +501,7 @@ sub replace { return "error scheduling invoice events for retry: $error"; } } + #eslaf } @@ -1192,6 +1194,8 @@ invoice_time - Use this time when deciding when to print invoices and late notices on those invoices. The default is now. It is specified as a UNIX timestamp; see L). Also see L and L for conversion functions. +retry_card - Retry cards even when not scheduled by invoice events. + batch_card - This option is deprecated. See the invoice events web interface to control whether cards are batched or run against a realtime gateway. @@ -1224,6 +1228,26 @@ sub collect { return ''; } + if ( exists($options{'retry_card'}) && $options{'retry_card'} ) { + #false laziness w/replace + foreach my $cust_bill_event ( + grep { + #$_->part_bill_event->plan eq 'realtime-card' + $_->part_bill_event->eventcode eq '$cust_bill->realtime_card();' + && $_->status eq 'done' + && $_->statustext + } + $self->open_cust_bill->cust_bill_event + ) { + my $error = $cust_bill_event->retry; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "error scheduling invoice events for retry: $error"; + } + } + #eslaf + } + foreach my $cust_bill ( $self->cust_bill ) { #this has to be before next's @@ -1242,6 +1266,7 @@ sub collect { next unless $amount > 0; + foreach my $part_bill_event ( sort { $a->seconds <=> $b->seconds || $a->weight <=> $b->weight diff --git a/httemplate/misc/bill.cgi b/httemplate/misc/bill.cgi index 6f523a52c..f048e5559 100755 --- a/httemplate/misc/bill.cgi +++ b/httemplate/misc/bill.cgi @@ -18,9 +18,10 @@ unless ( $error ) { $error = $cust_main->collect( # 'invoice-time'=>$time, - # 'batch_card'=> 'yes', - 'batch_card'=> 'no', - 'report_badcard'=> 'yes', + #'batch_card'=> 'yes', + #'batch_card'=> 'no', + #'report_badcard'=> 'yes', + 'retry_card' => 'yes', ); } #&eidiot($error) if $error; -- 2.11.0