- my $taxclass = '';
- if ( $options{invnum} ) {
-
- my $cust_bill = qsearchs('cust_bill', { 'invnum' => $options{invnum} } );
- die "invnum ". $options{'invnum'}. " not found" unless $cust_bill;
-
- my @part_pkg =
- map { $_->part_pkg }
- grep { $_ }
- map { $_->cust_pkg }
- $cust_bill->cust_bill_pkg;
-
- 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} ) {
- if ( $options{method} eq 'CC' && $options{payinfo} ) {
- $cardtype = cardtype($options{payinfo});
- } elsif ( $options{method} eq 'ECHECK' ) {
- $cardtype = 'ACH';
- } else {
- $cardtype = $options{method}
- }
+ my ($override, $payment_gateway);
+ if (exists $options{'load_gatewaynum'}) { # no agent overrides if this opt is in use
+ if ($options{'load_gatewaynum'}) {
+ $payment_gateway = qsearchs('payment_gateway', { gatewaynumnum => $options{'load_gatewaynum'} } );
+ # always fatal
+ die "Could not load payment gateway ".$options{'load_gatewaynum'} unless $payment_gateway;
+ } # else use default, loaded below
+ } else {
+ $override = qsearchs('agent_payment_gateway', { agentnum => $self->agentnum } );