X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpay_batch%2Fpaymentech.pm;h=a5b6f276d287b01dd8bf208b87cef8b72a0840d8;hb=387c96b0d8f224f3ade27bed9348f37b432bbb8a;hp=b75f256e65cd1200f4b8577c8746eeb7f08053fa;hpb=7be6febddf3f7f6f28e4637a95b56e3f39bd220f;p=freeside.git diff --git a/FS/FS/pay_batch/paymentech.pm b/FS/FS/pay_batch/paymentech.pm index b75f256e6..a5b6f276d 100644 --- a/FS/FS/pay_batch/paymentech.pm +++ b/FS/FS/pay_batch/paymentech.pm @@ -2,6 +2,7 @@ package FS::pay_batch::paymentech; use strict; use vars qw(@ISA %import_info %export_info $name); +use FS::Record 'qsearchs'; use Time::Local; use Date::Format 'time2str'; use Date::Parse 'str2time'; @@ -12,6 +13,8 @@ my $conf; my ($bin, $merchantID, $terminalID, $username); $name = 'paymentech'; +my $gateway; + %import_info = ( filetype => 'XML', xmlrow => [ qw(transResponse newOrderResp) ], @@ -19,18 +22,42 @@ $name = 'paymentech'; 'paybatchnum', '_date', 'approvalStatus', + 'order_number', + 'authorization', ], xmlkeys => [ 'orderID', 'respDateTime', 'approvalStatus', + 'txRefNum', + 'authorizationCode', ], 'hook' => sub { + 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'; + } my ($hash, $oldhash) = @_; my ($mon, $day, $year, $hour, $min, $sec) = $hash->{'_date'} =~ /^(..)(..)(....)(..)(..)(..)$/; $hash->{'_date'} = timelocal($sec, $min, $hour, $day, $mon-1, $year); $hash->{'paid'} = $oldhash->{'amount'}; + $hash->{'paybatch'} = join(':', + $gateway, + $hash->{'authorization'}, + $hash->{'order_number'}, + ); }, 'approved' => sub { my $hash = shift; $hash->{'approvalStatus'} @@ -66,7 +93,7 @@ my %paytype = ( $xml->startTag('transRequest', RequestCount => scalar(@cust_pay_batch) + 1); $xml->startTag('batchFileID'); $xml->dataElement(userID => $username); - $xml->dataElement(fileDateTime => time2str('%Y%m%d%H%M%s', time)); + $xml->dataElement(fileDateTime => time2str('%Y%m%d%H%M%S', time)); $xml->dataElement(fileID => 'FILEID'); $xml->endTag('batchFileID'); @@ -87,12 +114,12 @@ my %paytype = ( ecpBankAcctType => $paytype{lc($_->cust_main->paytype)}, ecpDelvMethod => 'A', ), - avsZip => $_->zip, - avsAddress1 => $_->address1, - avsAddress2 => $_->address2, - avsCity => $_->city, + avsZip => substr($_->zip, 0, 10), + avsAddress1 => substr($_->address1, 0, 30), + avsAddress2 => substr($_->address2, 0, 30), + avsCity => substr($_->city, 0, 20), avsState => $_->state, - avsName => $_->first . ' ' . $_->last, + avsName => substr($_->first . ' ' . $_->last, 0, 30), avsCountryCode => $_->country, orderID => $_->paybatchnum, amount => $_->amount * 100,