X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fagent.pm;h=3794d3f1dc26daf1bfd0b1aafd2a8c357721a444;hp=5fbe2c46d5d69f41c65563be681ce490a88d256b;hb=d6741df87df9e3352d7ae47a02d0e3f46154fef9;hpb=8c804ba59c8b284e1294e9928b5412fdf31e412c diff --git a/FS/FS/agent.pm b/FS/FS/agent.pm index 5fbe2c46d..3794d3f1d 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 @@ -244,7 +247,7 @@ sub payment_gateway { #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'; @@ -266,18 +269,27 @@ sub payment_gateway { cardtype => '', taxclass => '', } ); - my $payment_gateway = new FS::payment_gateway; + my $payment_gateway; + my $conf = new FS::Conf; if ( $override ) { #use a payment gateway override $payment_gateway = $override->payment_gateway; + $payment_gateway->gateway_namespace('Business::OnlinePayment') + unless $payment_gateway->gateway_namespace; + } else { #use the standard settings from the config + # the standard settings from the config could be moved to a null agent # 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'; @@ -294,6 +306,8 @@ sub payment_gateway { "did you set the business-onlinepayment configuration value?\n" unless $processor; + $payment_gateway = new FS::payment_gateway; + $payment_gateway->gateway_namespace( $conf->config('business-onlinepayment-namespace') || 'Business::OnlinePayment'); $payment_gateway->gateway_module($processor); @@ -304,6 +318,13 @@ sub payment_gateway { } + unless ( $payment_gateway->gateway_namespace ) { + $payment_gateway->gateway_namespace( + scalar($conf->config('business-onlinepayment-namespace')) + || 'Business::OnlinePayment' + ); + } + $payment_gateway; }