From: ivan Date: Sat, 19 May 2007 22:05:22 +0000 (+0000) Subject: finish echeck/ACH support, fix parsing of Auth field containing whitespace, fix order... X-Git-Tag: Business_OnlinePayment_TransactionCentral_0_03~1 X-Git-Url: http://git.freeside.biz/gitweb/?p=Business-OnlinePayment-TransactionCentral.git;a=commitdiff_plain;h=2e64453300da7fc60b2488b38ee46f2cd3f3f08c finish echeck/ACH support, fix parsing of Auth field containing whitespace, fix order_number return, add more tests --- diff --git a/Changes b/Changes index bf1f870..c747371 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,14 @@ Revision history for Perl extension Business::OnlinePayment::TransactionCentral. +0.03 Sat May 19 15:03:43 PDT 2007 + - add/finish ECHECK support (google of TCInterfaceGuide indicated + s/processcheck.asp/processcheckonline.asp/) + - fix another problem with transactions going through but coming back + denied: Returned "Auth" field can have trailing whitespace, wtf! + - trim " " tags off of return info. This + was preventing TransID (B:OP order_number) from being returned. + - add tests: order_number, check, bad_check + 0.02 Thu Apr 19 17:48:09 PDT 2007 - updated example in manpage s/Capstone/TransactionCentral/ - add debugging methods response_page, response_code, response_headers diff --git a/lib/Business/OnlinePayment/TransactionCentral.pm b/lib/Business/OnlinePayment/TransactionCentral.pm index a0765fc..06db369 100644 --- a/lib/Business/OnlinePayment/TransactionCentral.pm +++ b/lib/Business/OnlinePayment/TransactionCentral.pm @@ -8,7 +8,7 @@ use Business::OnlinePayment::HTTPS 0.02; use vars qw($VERSION @ISA $DEBUG); @ISA = qw(Business::OnlinePayment::HTTPS); -$VERSION = '0.02'; +$VERSION = '0.03'; $DEBUG = 0; sub set_defaults { @@ -65,7 +65,10 @@ sub submit { $content{'CCMonth'} = $month; $content{'CCYear'} = $year; - #push @required_fields, qw( amount card_numb + push @required_fields, qw( amount card_number expiration + name address zip + ); + } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) { croak "Authorizaiton Only is not supported by Transaction Central"; } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) { @@ -79,12 +82,19 @@ sub submit { croak "Unknown action $action"; } - } elsif ( $content{'type'} =~ /^check$/i ) { + } elsif ( $content{'type'} =~ /^e?check$/i ) { if ( $action =~ /^\s*normal\s*authorization\s*$/i ) { - $url .= 'processcheck.asp'; + $url .= 'processcheckonline.asp'; $content{'AccountNo'} = $content{'account_number'}; - $content{'TRANSTYPE'} = $content{'account_type'} =~ /^s/i ? 'SA' : 'CK'; + $content{'TRANSTYPE'} = + ( exists($content{account_type}) && $content{account_type} =~ /^s/i ) + ? 'SA' + : 'CK'; + + push @required_fields, qw( amount account_number routing_code + name + ); } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) { croak "Authorizaiton Only is not supported by Transaction Central"; @@ -102,6 +112,8 @@ sub submit { $self->path($url); $self->content(%content); + $self->required_fields(@required_fields); + my @fields = qw( MerchantID RegKey Amount REFID AccountNo CCMonth CCYear NameonAccount AVSADDR AVSZIP CCRURL CVV2 USER1 USER2 USER3 USER4 TrackData @@ -116,13 +128,9 @@ sub submit { $self->response_page( $page ); $self->response_headers( \%reply_headers ); - warn "\n" if $DEBUG > 1; - if ( $DEBUG > 2 ) { - warn "response: $response\n"; - # warn "reply headers: ". - # join(', ', map "$_ => $reply_headers{$_}", keys %reply_headers ). "\n"; - } - warn "raw response: $page\n" if $DEBUG > 1; + #trim off around the response we want + $page =~ s/^[\s\n]*[\s\n]*[\s\n]*//; + $page =~ s/[\s\n]*<\/body>[\s\n]*<\/html>[\s\n]*$//; my %return = map { /^(\w+)=(.*)$/ ? ( $1 => $2 ) : () } split(/&/, $page); @@ -132,7 +140,7 @@ sub submit { $self->avs_code( $return{'AVSCode'} ); $self->cvv2_response( $return{'CVV2ResponseMsg'} ); - if ( $return{'Auth'} =~ /^(\w+)$/ ) { + if ( $return{'Auth'} =~ /^\s*(\w+)\s*$/ ) { $self->is_success(1); $self->authorization( $return{'Auth'} ); @@ -171,11 +179,6 @@ Business::OnlinePayment::TransactionCentral - Transaction Central backend module =head1 SYNOPSIS - use Business::OnlinePayment::TransactionCentral; - blah blah blah - -=head1 DESCRIPTION - use Business::OnlinePayment; #### @@ -208,17 +211,31 @@ Business::OnlinePayment::TransactionCentral - Transaction Central backend module } else { print "Card was rejected: ".$tx->error_message."\n"; } +=head1 DESCRIPTION + +This is a Business::OnlinePayment backend module for the Transaction Central +(MerchantAnywhere, PRIMerchants) gateway. It is only useful if you have a +merchant account with MerchantAnywhere / PRIMerchants: + +http://www.merchantanywhere.com/ +http://www.merchantanywhere.com/ecshop/TC_elink.htm + +http://www.primerchants.com/ +http://www.primerchants.com/info/transactioncentral.asp =head1 SUPPORTED TRANSACTION TYPES =head2 CC, Visa, MasterCard, American Express, Discover -Content required: type, login, password, action, amount, card_number, expiration. +Content required: type, login, password, action, amount, card_number, expiration, name, address, zip. + +=head2 ECHECK + +Content required: type, login, password, action, amount, account_number, routing_code, name =head1 PREREQUISITES URI::Escape - #Tie::IxHash Net::SSLeay _or_ ( Crypt::SSLeay and LWP ) @@ -228,6 +245,13 @@ For detailed information see L. =head1 NOTE +The newest publicly available documentation is available at: + +http://www.merchantanywhere.com/ecshop/TC%20Interface%20NEW.pdf + +It is somewhat out-of-date and contains a few discrepancies. Google +"TCInterfaceGuide" for current documentation. + =head1 AUTHOR Ivan Kohler @@ -235,6 +259,7 @@ Ivan Kohler =head1 COPYRIGHT AND LICENSE Copyright (C) 2006 by Ivan Kohler +Copyright (C) 2007 Freeside Internet Services, Inc. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/t/bad_check.t b/t/bad_check.t new file mode 100644 index 0000000..8d56e55 --- /dev/null +++ b/t/bad_check.t @@ -0,0 +1,41 @@ +BEGIN { $| = 1; print "1..1\n"; } + +#print "ok 1 # Skipped: testing account won't accept ACH transactions\n"; exit; + +#eval "use Net::SSLeay;"; +#if ( $@ ) { +# print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit; +#} + +use Business::OnlinePayment; + +my $ctx = new Business::OnlinePayment("TransactionCentral"); + +$ctx->content( + type => 'ECHECK', + login => '10011', + password => 'KK48NPYEJHMAH6DK', #regkey + action => 'Normal Authorization', + amount => '49.95', + invoice_number => '100100', + customer_id => 'jsk', + name => 'Tofu Beast', + account_number => '12345', + #routing_code => '026009593', + routing_code => 'bad_routing_code', + bank_name => 'First National Test Bank', + phone => '420-420-5454', + #payee => 'Tofu Heavy Enterprises, GmbH', + check_number => '420', +); +$ctx->test_transaction(1); # test, dont really charge +$ctx->submit(); + +#print $ctx->is_success()."\n"; + +if($ctx->is_success()) { + #warn $ctx->error_message(); + print "not ok 1 (".$ctx->error_message().")\n"; +} else { + print "ok 1\n"; +} diff --git a/t/check.t b/t/check.t new file mode 100644 index 0000000..7c83d60 --- /dev/null +++ b/t/check.t @@ -0,0 +1,38 @@ +BEGIN { $| = 1; print "1..1\n"; } + +use Business::OnlinePayment; + +my $ctx = Business::OnlinePayment->new("TransactionCentral"); + +#$Business::OnlinePayment::TransactionCentral::DEBUG = 1; +#$Business::OnlinePayment::TransactionCentral::DEBUG = 1; + +$ctx->content( + type => 'CHECK', + login => '10011', + password => 'KK48NPYEJHMAH6DK', #regkey + action => 'Normal Authorization', + amount => '49.95', + invoice_number => '100100', + customer_id => 'jsk', + name => 'Tofu Beast', + account_number => '12345', + routing_code => '111000025', # BoA in Texas taken from Wikipedia + bank_name => 'First National Test Bank', + account_type => 'Checking', + license_num => '12345678', + license_state => 'OR', + license_dob => '1975-05-21', +); +$ctx->test_transaction(1); # test, dont really charge +$ctx->submit(); + +if($ctx->is_success()) { + print "ok 1\n"; +} else { + warn "error message : ". $ctx->error_message(). "\n"; + warn "response code : ". $ctx->response_code(). "\n"; + warn "response page : ". $ctx->response_page(). "\n"; + + print "not ok 1 (".$ctx->error_message().")\n"; +} diff --git a/t/order_number.t b/t/order_number.t new file mode 100644 index 0000000..9d752a4 --- /dev/null +++ b/t/order_number.t @@ -0,0 +1,45 @@ +BEGIN { $| = 1; print "1..1\n"; } + +eval "use Net::SSLeay;"; +if ( $@ ) { + print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit; +} + +use Business::OnlinePayment; + +my $tx = new Business::OnlinePayment("TransactionCentral"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::TransactionCentral::DEBUG = 1; +#$Business::OnlinePayment::TransactionCentral::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '10011', + password => 'KK48NPYEJHMAH6DK', #regkey + action => 'Normal Authorization', + description => 'Business::OnlinePayment::TransactionCentral test', + amount => '32', + card_number => '4012000000001', + expiration => '01/06', + cvv2 => '420', + name => 'Tofu Beast', + address => '123 Anystreet', + city => 'Anywhere', + state => 'UT', + zip => '84058', + country => 'US', + email => 'ivan-transactioncentral-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success() && $tx->order_number =~ /^(\w+)$/ ) { + print "ok 1\n"; +} else { + warn "order number: ". $tx->order_number."\n"; + #warn $tx->error_message. "\n"; + print "not ok 1\n"; +} +