X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fagent.pm;h=9b322093b394eeab678433a7a6c5e1eeea6c1e15;hb=a1a0800de7c69fe5ee414b79e408ceacd4a1c2c3;hp=f17427517e8c274def42fcdde19c3a53fd05f9c4;hpb=624b2d44625f69d71175c3348cae635d580c890b;p=freeside.git diff --git a/FS/FS/agent.pm b/FS/FS/agent.pm index f17427517..9b322093b 100644 --- a/FS/FS/agent.pm +++ b/FS/FS/agent.pm @@ -216,7 +216,7 @@ an attempt will be made to select a gateway suited for the taxes paid on the invoice. The I and I options can be used to influence the choice -as well. Presently only 'CC' and 'ECHECK' methods are meaningful. +as well. Presently only 'CC', 'ECHECK', and 'PAYPAL' methods are meaningful. When the I is 'CC' then the card number in I can direct this routine to route to a gateway suited for that type of card. @@ -246,13 +246,17 @@ sub payment_gateway { } #look for an agent gateway override first - my $cardtype; - if ( $options{method} && $options{method} eq 'CC' && $options{payinfo} ) { - $cardtype = cardtype($options{payinfo}); - } elsif ( $options{method} && $options{method} eq 'ECHECK' ) { - $cardtype = 'ACH'; - } else { - $cardtype = $options{method} || ''; + my $cardtype = ''; + if ( $options{method} ) { + if ( $options{method} eq 'CC' && $options{payinfo} ) { + $cardtype = cardtype($options{payinfo}); + } elsif ( $options{method} eq 'ECHECK' ) { + $cardtype = 'ACH'; + } elsif ( $options{method} eq 'PAYPAL' ) { + $cardtype = 'PayPal'; + } else { + $cardtype = $options{method} + } } my $override = @@ -269,16 +273,20 @@ 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; unless ( $conf->exists('business-onlinepayment') ) { if ( $options{'nofatal'} ) { return ''; @@ -302,6 +310,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); @@ -312,6 +322,13 @@ sub payment_gateway { } + unless ( $payment_gateway->gateway_namespace ) { + $payment_gateway->gateway_namespace( + scalar($conf->config('business-onlinepayment-namespace')) + || 'Business::OnlinePayment' + ); + } + $payment_gateway; }