X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fagent.pm;h=8aff96a8dec573dd90cc242dbb3e769ec16c7996;hb=b0888dc8399fc4e8d75c874c00d01366eacf5596;hp=b97e9b9b4af6d20d98559162aac3b7dc64fcb3bf;hpb=51f97ec141f77064ca020634e7eccd85d9ead753;p=freeside.git diff --git a/FS/FS/agent.pm b/FS/FS/agent.pm index b97e9b9b4..8aff96a8d 100644 --- a/FS/FS/agent.pm +++ b/FS/FS/agent.pm @@ -239,8 +239,7 @@ sub ticketing_queue { Returns a payment gateway object (see L) for this agent. -Currently available options are I, 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. @@ -295,7 +294,15 @@ sub payment_gateway { } } - my $override = qsearchs('agent_payment_gateway', { agentnum => $self->agentnum } ); + my $cardtype_search = "AND ( cardtype IS NULL OR cardtype <> 'ACH')"; + $cardtype_search = "AND ( cardtype IS NULL OR cardtype = 'ACH' )" if $options{method} eq 'ECHECK'; + + my $override = + qsearchs({ + "table" => 'agent_payment_gateway', + "hashref" => { agentnum => $self->agentnum, }, + "extra_sql" => $cardtype_search, + }); my $payment_gateway = FS::payment_gateway->by_key_or_default( gatewaynum => $override ? $override->gatewaynum : '',