From 9751024873641a07657bec7f11597ae18cf63207 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 28 Mar 2006 14:11:47 +0000 Subject: [PATCH] added changelog, boilerplate POD and README, tests. use test_transaction flag, use B:OP:HTTPS instead of Net::SSLeay directly, add ability to handle void and credit actions --- Changes | 28 +++ MANIFEST | 21 +- README | 11 + Skipjack.pm | 490 ++++++++++++++++++++++++++++++++---- t/Business-OnlinePayment-Skipjack.t | 17 ++ t/bad_card_mc.t | 44 ++++ t/bad_card_visa.t | 44 ++++ t/bop.t | 5 + t/credit_card_mc.t | 43 ++++ t/credit_card_visa.t | 44 ++++ t/crypt_bad_card_mc.t | 48 ++++ t/crypt_bad_card_visa.t | 48 ++++ t/crypt_credit_card_mc.t | 47 ++++ t/crypt_credit_card_visa.t | 48 ++++ t/crypt_load.t | 13 + t/load.t | 12 + t/return_card_mc.t | 72 ++++++ t/return_card_visa.t | 130 ++++++++++ t/void_card_mc.t | 69 +++++ t/void_card_visa.t | 69 +++++ 20 files changed, 1248 insertions(+), 55 deletions(-) create mode 100644 Changes create mode 100644 README create mode 100644 t/Business-OnlinePayment-Skipjack.t create mode 100644 t/bad_card_mc.t create mode 100644 t/bad_card_visa.t create mode 100644 t/bop.t create mode 100644 t/credit_card_mc.t create mode 100644 t/credit_card_visa.t create mode 100644 t/crypt_bad_card_mc.t create mode 100644 t/crypt_bad_card_visa.t create mode 100644 t/crypt_credit_card_mc.t create mode 100644 t/crypt_credit_card_visa.t create mode 100644 t/crypt_load.t create mode 100644 t/load.t create mode 100644 t/return_card_mc.t create mode 100644 t/return_card_visa.t create mode 100644 t/void_card_mc.t create mode 100644 t/void_card_visa.t diff --git a/Changes b/Changes new file mode 100644 index 0000000..35af8f5 --- /dev/null +++ b/Changes @@ -0,0 +1,28 @@ +Revision history for Perl extension Business::OnlinePayment::SkipJack + +0.2 Thu Mar 2 14:27:11 PST 2006 + - this mostly boring update by Ivan Kohler + - added this changelog, boilerplate POD and README + - added tests + - use test_transaction flag + - use B:OP:HTTPS (uses either Net::SSLeay or Crypt::SSLeay) instead of + Net::SSLeay directly + - add ability to handle void and credit actions + - ready for CPAN upload if licensing can be clarified... + +0.1.1 Wed Jan 4 23:01:55 2006 UTC + - Fixed bug that broke expiration dates >2009 (khoff) + +0.1 Mon Sep 9 19:14:45 2002 UTC + - 'Adapted' (completely rewritten) for Business::OnlinePayment + by Fire2Wire Internet Services (http://www.fire2wire.com) + Mark Wells + Kristian Hoffmann + James Switzer + +Modified for GetCareer.com by Slipstream.com +Troy Davis + +Original Skipjack.pm developed by New York Connect Net (http://nyct.net) +Michael Bacarella + diff --git a/MANIFEST b/MANIFEST index 18ea7b2..a94183c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,2 +1,21 @@ -Skipjack.pm +Changes +Makefile.PL MANIFEST +README +Skipjack.pm +t/bad_card_mc.t +t/bad_card_visa.t +t/bop.t +t/Business-OnlinePayment-Skipjack.t +t/credit_card_mc.t +t/credit_card_visa.t +t/crypt_bad_card_mc.t +t/crypt_bad_card_visa.t +t/crypt_credit_card_mc.t +t/crypt_credit_card_visa.t +t/crypt_load.t +t/load.t +t/return_card_visa.t +t/return_card_mc.t +t/void_card_mc.t +t/void_card_visa.t diff --git a/README b/README new file mode 100644 index 0000000..b26cb93 --- /dev/null +++ b/README @@ -0,0 +1,11 @@ + +This is Business::OnlinePayment::Skipjack, an Business::OnlinePayment backend +module for the Skipjack transaction network. It is only useful if you have an +account with SkipJack: +http://www.skipjack.com/transactionnetwork/index.html + +Business::OnlinePayment is a generic interface for processing payments through +online credit card processors, online check acceptance houses, etc. (If you +like buzzwords, call it an "multiplatform ecommerce-enabling middleware +solution"). + diff --git a/Skipjack.pm b/Skipjack.pm index 3484a3d..e20eaf1 100644 --- a/Skipjack.pm +++ b/Skipjack.pm @@ -21,21 +21,16 @@ package Business::OnlinePayment::Skipjack; use strict; -use Business::OnlinePayment; -use Net::SSLeay qw(post_https make_form); -use Text::CSV; -use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION); +use Carp; +use Business::OnlinePayment 3; +use Business::OnlinePayment::HTTPS; +use Text::CSV_XS; +use vars qw( @ISA $VERSION $DEBUG ); -$VERSION="0.1.1"; +$VERSION = "0.2"; +$DEBUG = 0; -require Exporter; - -@ISA = qw(Exporter AutoLoader Business::OnlinePayment); -# Items to export into callers namespace by default. Note: do not export -# names by default without a very good reason. Use EXPORT_OK instead. -# Do not simply export all your public functions/methods/constants. -@EXPORT = qw(); -@EXPORT_OK = qw(); +@ISA = qw( Business::OnlinePayment::HTTPS ); my %CC_ERRORS = ( '-1' => 'Invalid length (-1)', @@ -55,7 +50,7 @@ my %CC_ERRORS = ( '-61' => 'Length of shipto state (-61)', '-62' => 'Length of order string (-62)', '-64' => 'Invalid phone number (-64)', - '-65' => 'Empty name (-65)', + '-65' => 'Empty name (-65)', '-66' => 'Empty email (-66)', '-67' => 'Empty street address (-66)', '-68' => 'Empty city (-68)', @@ -100,7 +95,7 @@ my %FIELDS = ( city => 'City', state => 'State', zip => 'Zipcode', - invoice_number => 'Ordernumber', + order_number => 'Ordernumber', card_number => 'Accountnumber', exp_month => 'Month', exp_year => 'Year', @@ -110,6 +105,122 @@ my %FIELDS = ( login => 'Serialnumber', ); +my %CHANGE_STATUS_FIELDS = ( + login => 'szSerialNumber', + password => 'szDeveloperSerialNumber', + order_number => 'szOrderNumber', + # => 'szTransactionId', + amount => 'szAmount', +); + +my @CHANGE_STATUS_RESPONSE = ( + 'Serial Number', + 'Error Code', + 'NumRecs', + #'Reserved', + #'Reserved', + #'Reserved', + #'Reserved', + #'Reserved', + #'Reserved', + #'Reserved', + #'Reserved', +); + +my @CHANGE_STATUS_RESPONSE_RECORD = ( + 'Serial Number (Record)', + 'Amount', + 'Desired Status', + 'Status Response', + 'Status Response Message', + 'Order Number', + 'Transaction Id' +); + +my %CHANGE_STATUS_ERROR_CODES = ( + '0' => 'Success', + '-1' => 'Invalid Command', + '-2' => 'Parameter Missing', + '-3' => 'Failed retrieving response', + '-4' => 'Invalid Status', + '-5' => 'Failed reading security flags', + '-6' => 'Developer serial number not found', + '-7' => 'Invalid Serial Number', + '-8' => 'Expiration year not four characters', + '-9' => 'Credit card expired', + '-10' => 'Invalid starting date (recurring payment)', + '-11' => 'Failed adding recurring payment', + '-12' => 'Invalid frequency (recurring payment)', +); + +my %GET_STATUS_FIELDS = ( + login => 'szSerialNumber', + password => 'szDeveloperSerialNumber', + order_number => 'szOrderNumber', + #date => 'szDate', # would probably need some massaging + # and parse_SJAPI_TransactionStatusRequest would + # need to handle multiple records... +); + +my @GET_STATUS_RESPONSE = ( + 'Serial Number', + 'Error Code', + 'NumRecs', + #'Reserved', + #'Reserved', + #'Reserved', + #'Reserved', + #'Reserved', + #'Reserved', + #'Reserved', + #'Reserved', +); + +my @GET_STATUS_RESPONSE_RECORD = ( + 'Serial Number (Record)', + 'Amount', + 'Transaction Status Code', + 'Transaction Status Message', + 'Order Number', + 'Transaction Date', + 'Transaction Id', + 'Approval Code', + 'Batch Number', +); + +my %GET_STATUS_ERROR_CODES = ( + '0' => 'Success', + '-1' => 'Invalid Command', + '-2' => 'Parameter Missing', + '-3' => 'Failed retrieving response', + '-4' => 'Invalid Status', + '-5' => 'Failed reading security flags', + '-6' => 'Developer serial number not found', + '-7' => 'Invalid Serial Number', + '-8' => 'Expiration year not four characters', + '-9' => 'Credit card expired', +); + +my %CUR_STATUS_CODES = ( + '0' => 'Idle', + '1' => 'Authorized', + '2' => 'Denied', + '3' => 'Settled', + '4' => 'Credited', + '5' => 'Deleted', + '6' => 'Archived', + '7' => 'Pre-Auth', +); + +my %PEND_STATUS_CODES = ( + '0' => 'Idle', + '1' => 'Pending Credit', + '2' => 'Pending Settlement ', + '3' => 'Pending Delete', + '4' => 'Pending Authorization', + '5' => 'Pending Settle Force (for Manual Accts)', + '6' => 'Pending Recurring', +); sub _gen_ordernum { return int(rand(4000000000)); } @@ -119,15 +230,6 @@ sub set_defaults # For production $self->server('www.skipjackic.com'); - $self->path('/scripts/evolvcc.dll?AuthorizeAPI'); - - # For auth testing - #$self->server('developer.skipjackic.com'); # test mode - #$self->path('/scripts/evolvcc.dll?AuthorizeAPI'); - - # For comms testing - #$self->server('www.skipjackic.com'); - #$self->path('/secure/echo.asp'); $self->port(443); @@ -140,40 +242,79 @@ sub submit my $self = shift; my %c = $self->content; my (%input, %output); - my ($page, $response, %reply_headers); -# if($c{type} and $c{type} ne 'normal authorization') { - if($c{type} eq 'credit') { - warn 'Business::OnlinePayment::Skipjack does not support "' . - $c{type}. '"transactions'; - return; + unless ( $c{type} =~ /(cc|visa|mastercard|american express|discover)/i ) { + croak 'Business::OnlinePayment::Skipjack does not support "' . + $c{type}. '" transactions'; } - # FIXME! - # This should be set from %processor_info. + # skipjack kicks out "Length of transaction amount (-57)" or "Invalid amount" + # if the amount is missing .XX + $c{amount} = sprintf('%.2f', $c{amount}) + if defined($c{amount}) && length($c{amount}); + + if ( lc($c{action}) eq 'normal authorization' ) { + $self->{_action} = 'normal authorization'; + $self->path('/scripts/evolvcc.dll?AuthorizeAPI'); + + $c{expiration} =~ /(\d\d?)\D*(\d\d?)/; # Slightly less crude way to extract the exp date. + $c{exp_month} = sprintf('%02d',$1); + $c{exp_year} = sprintf('%02d',$2); + + $c{order_number} = _gen_ordernum unless $c{order_number}; + + $c{orderstring} = '0~'.$c{description}.'~'.$c{amount}.'~1~N~||' + unless $c{orderstring}; + + %input = map { ($FIELDS{$_} || $_), $c{$_} } keys(%c); + + } elsif ( $c{action} =~ /^(credit|void|post authorization)$/i ) { + + $self->path('/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest'); + + %input = map { ($CHANGE_STATUS_FIELDS{$_} || $_), $c{$_} } keys %c; + + if ( lc($c{action} ) eq 'credit' ) { + $self->{_action} = 'credit'; + $input{szDesiredStatus} = 'CREDIT'; + } elsif ( lc($c{action} ) eq 'void' ) { + $self->{_action} = 'void'; + $input{szDesiredStatus} = 'DELETE'; + } elsif ( lc($c{action} ) eq 'post authorization' ) { + $self->{_action} = 'postauth'; + $input{szDesiredStatus} = 'SETTLE'; + } else { + die "fatal: $c{action} is not credit or void!"; + } - # Or, if we want, from $c{login}. + } elsif ( lc($c{action}) eq 'status' ) { - $c{expiration} =~ /(\d\d?)\D*(\d\d?)/; # Slightly less crude way to extract the exp date. - $c{exp_month} = sprintf('%02d',$1); - $c{exp_year} = sprintf('%02d',$2); + $self->{_action} = 'status'; + $self->path('/scripts/evolvcc.dll?SJAPI_TransactionStatusRequest'); + %input = map { ($GET_STATUS_FIELDS{$_} || $_), $c{$_} } keys(%c); - $c{invoice_number} = _gen_ordernum unless $c{invoice_number}; + } else { - $c{orderstring} = '0~'.$c{description}.'~'.$c{amount}.'~1~N~||' - unless $c{orderstring}; + croak 'Business::OnlinePayment::Skipjack does not support "'. + $c{action}. '" actions'; - %input = map { ($FIELDS{$_} || $_), $c{$_} } keys(%c); + } - ($page, $response, %reply_headers) = - post_https($self->server, - $self->port, - $self->path, - '', - make_form(%input)); + $self->server('developer.skipjackic.com') # test mode + if $self->test_transaction(); + my( $page, $response ) = $self->https_post( %input ); + warn "\n$page\n" if $DEBUG; - %output = parse_Authorize_API($page); + if ( $self->{_action} eq 'normal authorization' ) { + %output = parse_Authorize_API($page); + } elsif ( $self->{_action} =~ /^(credit|void|postauth)$/ ) { + %output = parse_SJAPI_TransactionChangeStatusRequest($page); + } elsif ( $self->{_action} eq 'status' ) { + %output = parse_SJAPI_TransactionStatusRequest($page); + } else { + die "fatal: unknown action: ". $self->{_action}; + } $self->{_result} = \%output; $self->authorization($output{'AUTHCODE'}); @@ -184,7 +325,24 @@ sub is_success { my $self = shift; - return ($self->{_result}->{'szIsApproved'} == 1); + if ( $self->{_action} eq 'normal authorization' ) { + + return( $self->{_result}->{'szIsApproved'} == 1 ); + + } elsif ( $self->{_action} =~ /^(credit|void|postauth)$/ ) { + + return( $self->{_result}{'Error Code'} eq '0' # == 0 matches '' + && uc($self->{_result}{'Status Response'}) eq 'SUCCESSFUL' + ); + + } elsif ( $self->{_action} eq 'status' ) { + + return( $self->{_result}{'Error Code'} eq '0' ); # == 0 matches '' + + } else { + die "fatal: unknown action: ". $self->{_action}; + } + } sub error_message @@ -193,9 +351,55 @@ sub error_message my $r; if($self->is_success) { return ''; } - if(($r = $self->{_result}->{'szReturnCode'}) < 0) { return $CC_ERRORS{$r}; } - if($r = $self->{_result}->{'szAVSResponseMessage'}) { return $r; } - if($r = $self->{_result}->{'szAuthorizationDeclinedMessage'}) { return $r; } + + if ( $self->{_action} eq 'normal authorization' ) { + + if(($r = $self->{_result}->{'szReturnCode'}) < 0) { return $CC_ERRORS{$r}; } + if($r = $self->{_result}->{'szAVSResponseMessage'}) { return $r; } + if($r = $self->{_result}->{'szAuthorizationDeclinedMessage'}) { return $r; } + + } elsif ( $self->{_action} =~ /^(credit|void|postauth)$/ ) { + + if ( ( $r = $self->{_result}{'Error Code'} ) < 0 ) { + return $CHANGE_STATUS_ERROR_CODES{$r}; + } else { + return $self->{_result}{'Status Response Message'}; + } + + } elsif ( $self->{_action} eq 'status' ) { + + if ( ( $r = $self->{_result}{'Error Code'} ) < 0 ) { + return $CHANGE_STATUS_ERROR_CODES{$r}; + } else { + return $self->{_result}{'Status Response Message'}; + } + + } else { + die "fatal: unknown action: ". $self->{_action}; + } + +} + + +#sub result_code { shift->{_result}->{'ezIsApproved'}; } +sub authorization { shift->{_result}{'szAuthorizationResponseCode'}; } +sub avs_code { shift->{_result}{'szAVSResponseCode'}; } +sub order_number { shift->{_result}{'szOrderNumber'}; } +sub cvv2_response { shift->{_result}{'szCVV2ResponseCode'}; } +sub cavv_response { shift->{_result}{'szCAVVResponseCode'}; } + +sub status { + my $self = shift; + $CUR_STATUS_CODES{ + substr( $self->{_result}{'Transaction Status Code'}, 0, 1 ) + }; +} + +sub pending_status { + my $self = shift; + $PEND_STATUS_CODES{ + substr( $self->{_result}{'Transaction Status Code'}, 1, 2 ) + }; } sub parse_Authorize_API @@ -203,8 +407,8 @@ sub parse_Authorize_API my $page = shift; my %output; - my $csv_keys = new Text::CSV; - my $csv_values = new Text::CSV; + my $csv_keys = new Text::CSV_XS; + my $csv_values = new Text::CSV_XS; my ($keystring, $valuestring) = split(/\r\n/, $page); $csv_keys->parse($keystring); @@ -215,7 +419,185 @@ sub parse_Authorize_API } -__END__ +sub parse_SJAPI_TransactionChangeStatusRequest +{ + my $page = shift; + + my $csv = new Text::CSV_XS; + + my %output; + + my @records = split(/\r\n/, $page); + + $csv->parse(shift @records) or die $csv->error; + @output{@CHANGE_STATUS_RESPONSE} = $csv->fields(); + + # we only handle a single record reponse, as that's all this module will + # currently submit... + $csv->parse(shift @records) or die $csv->error; + @output{@CHANGE_STATUS_RESPONSE_RECORD} = $csv->fields(); + + return %output; + +} + +sub parse_SJAPI_TransactionStatusRequest +{ + my $page = shift; + + my $csv = new Text::CSV_XS; + + my %output; + + my @records = split(/\r\n/, $page); + + $csv->parse(shift @records) or die $csv->error; + @output{@GET_STATUS_RESPONSE} = $csv->fields(); + + # we only handle a single record reponse, as that's all this module will + # currently submit... + $csv->parse(shift @records) or die $csv->error; + @output{@GET_STATUS_RESPONSE_RECORD} = $csv->fields(); + + return %output; + +} 1; +__END__ + +=head1 NAME + +Business::OnlinePayment::Skipjack - Skipjack backend module for Business::OnlinePayment + +=head1 SYNOPSIS + + use Business::OnlinePayment; + + #### + # One step transaction, the simple case. + #### + + my $tx = new Business::OnlinePayment("Skipjack"); + $tx->content( + type => 'VISA', + login => '000178101827', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment test', + amount => '49.95', + invoice_number => '100100', + customer_id => 'jsk', + first_name => 'Jason', + last_name => 'Kohles', + address => '123 Anystreet', + city => 'Anywhere', + state => 'UT', + zip => '84058', + card_number => '4007000000027', + expiration => '09/02', + cvv2 => '1234', #optional + #referer => 'http://valid.referer.url/', + ); + $tx->submit(); + + if($tx->is_success()) { + print "Card processed successfully: ".$tx->authorization."\n"; + } else { + print "Card was rejected: ".$tx->error_message."\n"; + } + + ### + # Process a credit... + ### + + my $tx = new Business::OnlinePayment( "Skipjack" ); + + $tx->content( + type => 'VISA', + login => '000178101827', # "HTML serial number" + password => '100594217288', # "developer serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment test', + amount => '49.95', + invoice_number => '100100', + customer_id => 'jsk', + first_name => 'Jason', + last_name => 'Kohles', + address => '123 Anystreet', + city => 'Anywhere', + state => 'UT', + zip => '84058', + card_number => '4007000000027', + expiration => '09/02', + cvv2 => '1234', #optional + #referer => 'http://valid.referer.url/', + ); + $tx->submit(); + + if($tx->is_success()) { + print "Card credited successfully: ".$tx->authorization."\n"; + } else { + print "Credit was rejected: ".$tx->error_message."\n"; + } + + +=head1 SUPPORTED TRANSACTION TYPES + +=head2 CC, Visa, MasterCard, American Express, Discover + +Content required for Normal Authorization : login, action, amount, card_number, +expiration, name, address, city, state, zip, phone, email + +Content required for Void or Credit: login, password, action, order_number + +=head1 DESCRIPTION + +For detailed information see L + +=head1 PREREQUISITES + +Net::SSLeay _or_ ( Crypt::SSLeay and LWP ) + +=head1 NOTE ON CREDITS + +If you want to process credits, you must have your developer serial number +applied to your production account. See +http://www.skipjack.com/resources/Education/serialnumbers.htm + +=head1 STATUS + +This modules supports a non-standard "status" action that corresponds to +Skipjack's TransactionStatusRequest. It should be documented. + +=head1 AUTHOR + +Original Skipjack.pm developed by New York Connect Net (http://nyct.net) +Michael Bacarella + +Modified for GetCareer.com by Slipstream.com +Troy Davis + +'Adapted' (completely rewritten) for Business::OnlinePayment +by Fire2Wire Internet Services (http://www.fire2wire.com) +Mark Wells +Kristian Hoffmann +James Switzer + +Boring 0.2 update by Ivan Kohler + +=head1 COPYRIGHT + +original license unknown, pending contact from Michael Bacarella / nyct.net. +assuming it is okay... + +Business::OnlinePayment rewrite: +Copyright (c) 2006 Fire2Wire Internet Services (http://www.fire2wire.com) +All rights reserved. This program is free software; you can redistribute it +and/or modify it under the same terms as Perl itself. + +=head1 SEE ALSO + +L + +=cut diff --git a/t/Business-OnlinePayment-Skipjack.t b/t/Business-OnlinePayment-Skipjack.t new file mode 100644 index 0000000..3a8ee45 --- /dev/null +++ b/t/Business-OnlinePayment-Skipjack.t @@ -0,0 +1,17 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl Business-OnlinePayment-Skipjack.t' + +######################### + +# change 'tests => 1' to 'tests => last_test_to_print'; + +use Test; +BEGIN { plan tests => 1 }; +use Business::OnlinePayment::Skipjack; +ok(1); # If we made it this far, we're ok. + +######################### + +# Insert your test code below, the Test::More module is use()ed here so read +# its man page ( perldoc Test::More ) for help writing this test script. + diff --git a/t/bad_card_mc.t b/t/bad_card_mc.t new file mode 100644 index 0000000..5f6fc81 --- /dev/null +++ b/t/bad_card_mc.t @@ -0,0 +1,44 @@ +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("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000944785470', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + #card_number => '5212345678901234', + card_number => '5222222222222222', + expiration => '03/10', + name => 'Tofu Beast', + address => '123 Anystreet', + city => 'Anywhere', + state => 'UT', + zip => '84058', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "not ok 1\n"; +} else { + #warn $tx->server_response."\n"; + #warn $tx->error_message. "\n"; + print "ok 1\n"; +} + diff --git a/t/bad_card_visa.t b/t/bad_card_visa.t new file mode 100644 index 0000000..6e869b2 --- /dev/null +++ b/t/bad_card_visa.t @@ -0,0 +1,44 @@ +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("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000368452762', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + card_number => '4111111111111', + expiration => '03/10', + cvv2 => '999', + name => 'Tofu Beast', + address => '8320', + city => 'Anywhere', + state => 'UT', + zip => '85284', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "not ok 1\n"; +} else { + #warn $tx->server_response."\n"; + #warn $tx->error_message. "\n"; + print "ok 1\n"; +} + diff --git a/t/bop.t b/t/bop.t new file mode 100644 index 0000000..64332c5 --- /dev/null +++ b/t/bop.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n"; } +END {print "not ok 1\n" unless $loaded;} +use Business::OnlinePayment; +$loaded = 1; +print "ok 1\n"; diff --git a/t/credit_card_mc.t b/t/credit_card_mc.t new file mode 100644 index 0000000..aa11a26 --- /dev/null +++ b/t/credit_card_mc.t @@ -0,0 +1,43 @@ +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("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000944785470', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + card_number => '5121212121212124', + expiration => '03/10', + name => 'Tofu Beast', + address => '123 Anystreet', + city => 'Anywhere', + state => 'UT', + zip => '84058', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "ok 1\n"; +} else { + #warn $tx->server_response."\n"; + warn $tx->error_message. "\n"; + print "not ok 1\n"; +} + diff --git a/t/credit_card_visa.t b/t/credit_card_visa.t new file mode 100644 index 0000000..79a27b1 --- /dev/null +++ b/t/credit_card_visa.t @@ -0,0 +1,44 @@ +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("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000368452762', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + card_number => '4445999922225', + expiration => '03/10', + cvv2 => '999', + name => 'Tofu Beast', + address => '8320', + city => 'Anywhere', + state => 'UT', + zip => '85284', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "ok 1\n"; +} else { + #warn $tx->server_response."\n"; + warn $tx->error_message. "\n"; + print "not ok 1\n"; +} + diff --git a/t/crypt_bad_card_mc.t b/t/crypt_bad_card_mc.t new file mode 100644 index 0000000..2339591 --- /dev/null +++ b/t/crypt_bad_card_mc.t @@ -0,0 +1,48 @@ +BEGIN { + $| = 1; print "1..1\n"; + $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1; + $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1; +} + +eval "use Crypt::SSLeay;"; +if ( $@ ) { + print "ok 1 # Skipped: Crypt::SSLeay is not installed\n"; exit; +} + +use Business::OnlinePayment; + +my $tx = new Business::OnlinePayment("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000944785470', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + #card_number => '5212345678901234', + card_number => '5222222222222222', + expiration => '03/10', + name => 'Tofu Beast', + address => '123 Anystreet', + city => 'Anywhere', + state => 'UT', + zip => '84058', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "not ok 1\n"; +} else { + #warn $tx->server_response."\n"; + #warn $tx->error_message. "\n"; + print "ok 1\n"; +} + diff --git a/t/crypt_bad_card_visa.t b/t/crypt_bad_card_visa.t new file mode 100644 index 0000000..b618670 --- /dev/null +++ b/t/crypt_bad_card_visa.t @@ -0,0 +1,48 @@ +BEGIN { + $| = 1; print "1..1\n"; + $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1; + $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1; +} + +eval "use Crypt::SSLeay;"; +if ( $@ ) { + print "ok 1 # Skipped: Crypt::SSLeay is not installed\n"; exit; +} + +use Business::OnlinePayment; + +my $tx = new Business::OnlinePayment("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000368452762', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + card_number => '4111111111111', + expiration => '03/10', + cvv2 => '999', + name => 'Tofu Beast', + address => '8320', + city => 'Anywhere', + state => 'UT', + zip => '85284', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "not ok 1\n"; +} else { + #warn $tx->server_response."\n"; + #warn $tx->error_message. "\n"; + print "ok 1\n"; +} + diff --git a/t/crypt_credit_card_mc.t b/t/crypt_credit_card_mc.t new file mode 100644 index 0000000..fca30ab --- /dev/null +++ b/t/crypt_credit_card_mc.t @@ -0,0 +1,47 @@ +BEGIN { + $| = 1; print "1..1\n"; + $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1; + $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1; +} + +eval "use Crypt::SSLeay;"; +if ( $@ ) { + print "ok 1 # Skipped: Crypt::SSLeay is not installed\n"; exit; +} + +use Business::OnlinePayment; + +my $tx = new Business::OnlinePayment("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000944785470', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + card_number => '5121212121212124', + expiration => '03/10', + name => 'Tofu Beast', + address => '123 Anystreet', + city => 'Anywhere', + state => 'UT', + zip => '84058', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "ok 1\n"; +} else { + #warn $tx->server_response."\n"; + warn $tx->error_message. "\n"; + print "not ok 1\n"; +} + diff --git a/t/crypt_credit_card_visa.t b/t/crypt_credit_card_visa.t new file mode 100644 index 0000000..80fc5bb --- /dev/null +++ b/t/crypt_credit_card_visa.t @@ -0,0 +1,48 @@ +BEGIN { + $| = 1; print "1..1\n"; + $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1; + $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1; +} + +eval "use Crypt::SSLeay;"; +if ( $@ ) { + print "ok 1 # Skipped: Crypt::SSLeay is not installed\n"; exit; +} + +use Business::OnlinePayment; + +my $tx = new Business::OnlinePayment("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000368452762', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + card_number => '4445999922225', + expiration => '03/10', + cvv2 => '999', + name => 'Tofu Beast', + address => '8320', + city => 'Anywhere', + state => 'UT', + zip => '85284', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "ok 1\n"; +} else { + #warn $tx->server_response."\n"; + warn $tx->error_message. "\n"; + print "not ok 1\n"; +} + diff --git a/t/crypt_load.t b/t/crypt_load.t new file mode 100644 index 0000000..22f71d7 --- /dev/null +++ b/t/crypt_load.t @@ -0,0 +1,13 @@ +BEGIN { + $| = 1; print "1..1\n"; + eval "use Crypt::SSLeay;"; + if ( $@ ) { + print "ok 1 # Skipped: Crypt::SSLeay is not installed\n"; exit; + } + $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1; + $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1; +} +END {print "not ok 1\n" unless $loaded;} +use Business::OnlinePayment::Skipjack; +$loaded = 1; +print "ok 1\n"; diff --git a/t/load.t b/t/load.t new file mode 100644 index 0000000..7c5c531 --- /dev/null +++ b/t/load.t @@ -0,0 +1,12 @@ +BEGIN { + $| = 1; print "1..1\n"; + eval "use Net::SSLeay;"; + if ( $@ ) { + print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit; + } + +} +END {print "not ok 1\n" unless $loaded;} +use Business::OnlinePayment::Skipjack; +$loaded = 1; +print "ok 1\n"; diff --git a/t/return_card_mc.t b/t/return_card_mc.t new file mode 100644 index 0000000..75e2af7 --- /dev/null +++ b/t/return_card_mc.t @@ -0,0 +1,72 @@ +BEGIN { $| = 1; print "1..2\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("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000944785470', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + card_number => '5121212121212124', + expiration => '03/10', + cvv2 => '999', + name => 'Tofu Beast', + address => '8320', + city => 'Anywhere', + state => 'UT', + zip => '85284', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "ok 1\n"; +} else { + #warn $tx->server_response."\n"; + warn $tx->error_message. "\n"; + print "not ok 1\n"; +} + +print "ok 2 # Skipped: Credit needs a settled transaction\n"; exit; + +my $cr_tx = new Business::OnlinePayment("Skipjack"); + +$cr_tx->content( + type => 'VISA', + login => '000944785470', # "HTML serial number" + password => '100594217288', # "developer serial number" + action => 'Credit', + description => 'Business::OnlinePayment::Skipjack test', + amount => 11, + order_number => $tx->order_number(), +); + +$cr_tx->test_transaction(1); # test, dont really charge +$cr_tx->submit(); + +if($cr_tx->is_success()) { + print "ok 2\n"; +} else { + #warn $cr_tx->server_response."\n"; + warn $cr_tx->error_message. "\n"; + print "not ok 2\n"; +} + + + + diff --git a/t/return_card_visa.t b/t/return_card_visa.t new file mode 100644 index 0000000..c717d79 --- /dev/null +++ b/t/return_card_visa.t @@ -0,0 +1,130 @@ +BEGIN { $| = 1; print "1..4\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("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000368452762', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + card_number => '4445999922225', + expiration => '03/10', + cvv2 => '999', + name => 'Tofu Beast', + address => '8320', + city => 'Anywhere', + state => 'UT', + zip => '85284', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "ok 1\n"; +} else { + #warn $tx->server_response."\n"; + warn $tx->error_message. "\n"; + print "not ok 1\n"; +} + +# ------- + +my $pa_tx = new Business::OnlinePayment("Skipjack"); + +$pa_tx->content( + type => 'VISA', + login => '000368452762', # "HTML serial number" + password => '100594217288', # "developer serial number" + action => 'Post Authorization', + description => 'Business::OnlinePayment::Skipjack test', + order_number => $tx->order_number(), +); + +$pa_tx->test_transaction(1); #test +$pa_tx->submit(); + +if($pa_tx->is_success()) { + print "ok 2\n"; + +# warn "STATUS : ". $st_tx->status(). "\n"; +# warn "PENDING: ". $st_tx->pending_status(). "\n"; + +} else { + #warn $pa_tx->server_response."\n"; + warn $pa_tx->error_message. "\n"; + print "not ok 2\n"; +} + +# ------- + +my $st_tx = new Business::OnlinePayment("Skipjack"); + +$st_tx->content( + type => 'VISA', + login => '000368452762', # "HTML serial number" + password => '100594217288', # "developer serial number" + action => 'Status', + description => 'Business::OnlinePayment::Skipjack test', + order_number => $tx->order_number(), +); + +$st_tx->test_transaction(1); #test +$st_tx->submit(); + +if($st_tx->is_success()) { + print "ok 3\n"; + + #warn "STATUS : ". $st_tx->status(). "\n"; + #warn "PENDING: ". $st_tx->pending_status(). "\n"; + +} else { + #warn $st_tx->server_response."\n"; + warn $st_tx->error_message. "\n"; + print "not ok 3\n"; +} + +# ------- + +print "ok 4 # Skipped: Credit needs a settled transaction\n"; exit; + +my $cr_tx = new Business::OnlinePayment("Skipjack"); + +$cr_tx->content( + type => 'VISA', + login => '000368452762', # "HTML serial number" + password => '100594217288', # "developer serial number" + action => 'Credit', + description => 'Business::OnlinePayment::Skipjack test', + amount => 11, + order_number => $tx->order_number(), +); + +$cr_tx->test_transaction(1); # test, dont really charge +$cr_tx->submit(); + +if($cr_tx->is_success()) { + print "ok 4\n"; +} else { + #warn $cr_tx->server_response."\n"; + warn $cr_tx->error_message. "\n"; + print "not ok 4\n"; +} + + + + diff --git a/t/void_card_mc.t b/t/void_card_mc.t new file mode 100644 index 0000000..2749466 --- /dev/null +++ b/t/void_card_mc.t @@ -0,0 +1,69 @@ +BEGIN { $| = 1; print "1..2\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("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000944785470', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + card_number => '5121212121212124', + expiration => '03/10', + cvv2 => '999', + name => 'Tofu Beast', + address => '8320', + city => 'Anywhere', + state => 'UT', + zip => '85284', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "ok 1\n"; +} else { + #warn $tx->server_response."\n"; + warn $tx->error_message. "\n"; + print "not ok 1\n"; +} + +my $v_tx = new Business::OnlinePayment("Skipjack"); + +$v_tx->content( + type => 'VISA', + login => '000944785470', # "HTML serial number" + password => '100594217288', # "developer serial number" + action => 'Void', + description => 'Business::OnlinePayment::Skipjack test', + order_number => $tx->order_number(), +); + +$v_tx->test_transaction(1); # test, dont really charge +$v_tx->submit(); + +if($v_tx->is_success()) { + print "ok 2\n"; +} else { + #warn $v_tx->server_response."\n"; + warn $v_tx->error_message. "\n"; + print "not ok 2\n"; +} + + + + diff --git a/t/void_card_visa.t b/t/void_card_visa.t new file mode 100644 index 0000000..451278a --- /dev/null +++ b/t/void_card_visa.t @@ -0,0 +1,69 @@ +BEGIN { $| = 1; print "1..2\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("Skipjack"); + +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::HTTPS::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; +#$Business::OnlinePayment::Skipjack::DEBUG = 1; + +$tx->content( + type => 'VISA', + login => '000368452762', # "HTML serial number" + action => 'Normal Authorization', + description => 'Business::OnlinePayment::Skipjack test', + amount => '32', + card_number => '4445999922225', + expiration => '03/10', + cvv2 => '999', + name => 'Tofu Beast', + address => '8320', + city => 'Anywhere', + state => 'UT', + zip => '85284', + phone => '415-420-5454', + email => 'ivan-skipjack-test@420.am', +); +$tx->test_transaction(1); # test, dont really charge +$tx->submit(); + +if($tx->is_success()) { + print "ok 1\n"; +} else { + #warn $tx->server_response."\n"; + warn $tx->error_message. "\n"; + print "not ok 1\n"; +} + +my $v_tx = new Business::OnlinePayment("Skipjack"); + +$v_tx->content( + type => 'VISA', + login => '000368452762', # "HTML serial number" + password => '100594217288', # "developer serial number" + action => 'Void', + description => 'Business::OnlinePayment::Skipjack test', + order_number => $tx->order_number(), +); + +$v_tx->test_transaction(1); # test, dont really charge +$v_tx->submit(); + +if($v_tx->is_success()) { + print "ok 2\n"; +} else { + #warn $v_tx->server_response."\n"; + warn $v_tx->error_message. "\n"; + print "not ok 2\n"; +} + + + + -- 2.11.0