1 package FS::pay_batch::paymentech;
4 use vars qw(@ISA %import_info %export_info $name);
6 use Date::Format 'time2str';
7 use Date::Parse 'str2time';
11 my ($bin, $merchantID, $terminalID, $username);
16 xmlrow => [ qw(transResponse newOrderResp) ],
28 my ($hash, $oldhash) = @_;
29 my ($mon, $day, $year, $hour, $min, $sec) =
30 $hash->{'_date'} =~ /^(..)(..)(....)(..)(..)(..)$/;
31 $hash->{'_date'} = timelocal($sec, $min, $hour, $day, $mon-1, $year);
32 $hash->{'paid'} = $oldhash->{'amount'};
34 'approved' => sub { my $hash = shift;
35 $hash->{'approvalStatus'}
37 'declined' => sub { my $hash = shift;
38 ! $hash->{'approvalStatus'}
43 'personal checking' => 'C',
44 'personal savings' => 'S',
45 'business checking' => 'X',
46 'business savings' => 'X',
51 # Load this at run time
52 eval "use XML::Simple";
55 ($bin, $terminalID, $merchantID, $username) =
56 $conf->config('batchconfig-paymentech');
58 # Here we do all the work in the header function.
60 my $pay_batch = shift;
61 my @cust_pay_batch = @{(shift)};
63 XML::Simple::XMLout( {
65 RequestCount => scalar(@cust_pay_batch),
68 fileDateTime => time2str('%Y%m%d%H%M%s',time),
69 fileID => 'batch'.time2str('%Y%m%d',time),
72 # $_ here refers to a cust_pay_batch record.
73 BatchRequestNo => $count++,
77 merchantID => $merchantID,
78 terminalID => $terminalID,
79 ($_->payby eq 'CARD') ? (
81 ccAccountNum => $_->payinfo,
82 ccExp => time2str('%y%m',str2time($_->exp)),
84 # ECP (electronic check) stuff
85 ecpCheckRT => ($_->payinfo =~ /@(\d+)/),
86 ecpCheckDDA => ($_->payinfo =~ /(\d+)@/),
87 ecpBankAcctType => $paytype{lc($_->cust_main->paytype)},
91 avsAddress1 => $_->address1,
92 avsAddress2 => $_->address2,
94 avsState => $_->state,
95 avsName => $_->first . ' ' . $_->last,
96 avsCountryCode => $_->country,
97 orderID => $_->paybatchnum,
98 amount => $_->amount * 100,
102 BatchRequestNo => $count++,
104 merchantID => $merchantID,
105 terminalID => $terminalID
108 }, KeepRoot => 1, NoAttr => 1);