+ if ( !$gateway ) {
+ # find a gateway configuration that has the same merchantID
+ # as the batch config, if there is one. If not, leave
+ # gateway out entirely.
+ my $merchant = (FS::Conf->new->config('batchconfig-paymentech'))[2];
+ my $g = qsearchs({
+ 'table' => 'payment_gateway',
+ 'addl_from' => ' JOIN payment_gateway_option USING (gatewaynum) ',
+ 'hashref' => { disabled => '',
+ optionname => 'merchant_id',
+ optionvalue => $merchant,
+ },
+ });
+ $gateway = ($g ? $g->gatewaynum . '-' : '') . 'PaymenTech';
+ }