X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fagent.pm;h=f17427517e8c274def42fcdde19c3a53fd05f9c4;hb=e078ca418dcf3c7b92efcd371ce761df3314c369;hp=e471e04a5fffb4d8ad1a3e0e48b6fa83a7d6c489;hpb=32db3ad86bcf04e4f34705a396b718061d333f20;p=freeside.git diff --git a/FS/FS/agent.pm b/FS/FS/agent.pm index e471e04a5..f17427517 100644 --- a/FS/FS/agent.pm +++ b/FS/FS/agent.pm @@ -206,7 +206,10 @@ sub ticketing_queue { Returns a payment gateway object (see L) for this agent. -Currently available options are I, I, and I. +Currently available options are I, I, I, and I. + +If I is set, and no gateway is available, then the empty string +will be returned instead of throwing a fatal exception. If I is set to the number of an invoice (see L) then an attempt will be made to select a gateway suited for the taxes paid on @@ -225,21 +228,26 @@ sub payment_gateway { my $taxclass = ''; if ( $options{invnum} ) { + my $cust_bill = qsearchs('cust_bill', { 'invnum' => $options{invnum} } ); die "invnum ". $options{'invnum'}. " not found" unless $cust_bill; - my @taxclasses = - map { $_->part_pkg->taxclass } + + my @part_pkg = + map { $_->part_pkg } grep { $_ } map { $_->cust_pkg } $cust_bill->cust_bill_pkg; - unless ( grep { $taxclasses[0] ne $_ } @taxclasses ) { #unless there are - #different taxclasses $taxclass = $taxclasses[0]; - } + + my @taxclasses = map $_->taxclass, @part_pkg; + + $taxclass = $taxclasses[0] + unless grep { $taxclasses[0] ne $_ } @taxclasses; #unless there are + #different taxclasses } #look for an agent gateway override first my $cardtype; - if ( $options{method} && $options{method} eq 'CC' ) { + if ( $options{method} && $options{method} eq 'CC' && $options{payinfo} ) { $cardtype = cardtype($options{payinfo}); } elsif ( $options{method} && $options{method} eq 'ECHECK' ) { $cardtype = 'ACH'; @@ -271,8 +279,13 @@ sub payment_gateway { # agent_payment_gateway referenced payment_gateway my $conf = new FS::Conf; - die "Real-time processing not enabled\n" - unless $conf->exists('business-onlinepayment'); + unless ( $conf->exists('business-onlinepayment') ) { + if ( $options{'nofatal'} ) { + return ''; + } else { + die "Real-time processing not enabled\n"; + } + } #load up config my $bop_config = 'business-onlinepayment';