X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=Paymentech.pm;h=027bbeef12b3b93fc856fb72e689cbe8f3a0bcf7;hb=9ab92d47962317a7d87de290a12a1720ad8e7963;hp=7fa2e442745e65706341c05abd13d592b2a49f18;hpb=eabacc85da1879f947797698461efa97a27c7b50;p=Business-BatchPayment-Paymentech.git diff --git a/Paymentech.pm b/Paymentech.pm index 7fa2e44..027bbee 100644 --- a/Paymentech.pm +++ b/Paymentech.pm @@ -3,16 +3,12 @@ package Business::BatchPayment::Paymentech; use 5.006; use strict; use warnings; -our $VERSION = '0.01'; +our $VERSION = '0.03'; =head1 NAME Business::BatchPayment::Paymentech - Chase Paymentech XML batch format. -=head1 VERSION - -Version 0.01 - =head1 USAGE See L for general usage notes. @@ -71,14 +67,14 @@ with 'Business::BatchPayment::TestMode'; # could have some validation on all of these has [ qw(merchantID terminalID bin industryType login password) ] => ( - is => 'ro', - isa => 'Str', + is => 'ro', + isa => 'Str', required => 1, ); has 'fileDateTime' => ( - is => 'ro', - isa => 'Str', + is => 'ro', + isa => 'Str', default => sub { DateTime->now->strftime('%Y%m%d%H%M%S') }, @@ -91,6 +87,8 @@ my %BankAcctType = ( 'business savings' => 'X', ); +my %paymentech_countries = map { $_ => 1 } qw( US CA GB UK ); + sub default_transport { my $self = shift; Business::BatchPayment::Paymentech::Transport->new( @@ -108,8 +106,8 @@ sub format_request { my $output; my $xml = XML::Writer->new( - OUTPUT => \$output, - DATA_MODE => 1, + OUTPUT => \$output, + DATA_MODE => 1, DATA_INDENT => 2, ); $self->format_header($batch, $xml); @@ -143,40 +141,43 @@ sub format_item { if ( $item->action eq 'payment' ) { $xml->startTag('newOrder', BatchRequestNo => $count); my @order = ( - industryType => $self->industryType, - transType => 'AC', - bin => $self->bin, - merchantID => $self->merchantID, - terminalID => $self->terminalID, + industryType => $self->industryType, + transType => 'AC', + bin => $self->bin, + merchantID => $self->merchantID, + terminalID => $self->terminalID, ); if ($item->payment_type eq 'CC') { push @order, ( - ccAccountNum => $item->card_number, - ccExp => $item->expiration, + ccAccountNum => $item->card_number, + ccExp => $item->expiration, ); } elsif ( $item->payment_type eq 'ECHECK' ) { push @order, ( - cardBrand => 'EC', - ecpCheckRT => $item->routing_code, - ecpCheckDDA => $item->account_number, + cardBrand => 'EC', + ecpCheckRT => $item->routing_code, + ecpCheckDDA => $item->account_number, ecpBankAcctType => $BankAcctType{ $item->account_type }, - ecpDelvMethod => 'A', + ecpDelvMethod => 'A', ); } else { die "payment type ".$item->type." not supported"; } push @order, ( - avsZip => $item->zip, - avsAddress1 => substr($item->address, 0, 30), - avsAddress2 => substr($item->address2, 0, 30), - avsCity => substr($item->city, 0, 20), - avsState => $item->state, - avsName => substr($item->first_name .' '. $item->last_name, 0, 30), - avsCountryCode => $item->country, - orderID => $item->tid, - amount => int( $item->amount * 100 ), + avsZip => $item->zip, + avsAddress1 => substr($item->address, 0, 30), + avsAddress2 => substr($item->address2, 0, 30), + avsCity => substr($item->city, 0, 20), + avsState => substr($item->state, 0, 2), + avsName => substr($item->first_name. ' '. $item->last_name, 0, 30), + ( $paymentech_countries{ $item->country } + ? ( avsCountryCode => $item->country ) + : () + ), + orderID => $item->tid, + amount => int( $item->amount * 100 ), ); while (@order) { my $key = shift @order;