- Quiet an uninit value warning when customer_org is not set.
- Fix t/credit_card.t test to use a date 11 months in the future as
the expiration date, and to print the error message on failure.
+ - Update tests to use Test::More
3.15 Wed Mar 16 01:10:51 PST 2005
- Ask for ',' delimiter and '"' quote explicitly to prevent problems
use ExtUtils::MakeMaker;
-# See lib/ExtUtils/MakeMaker.pm for details of how to influence
-# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'Business::OnlinePayment::AuthorizeNet',
'VERSION_FROM' => 'AuthorizeNet.pm', # finds $VERSION
'AUTHOR' => 'Ivan Kohler <ivan-authorizenet@420.am>', #really just
#the maintainer
- #'NORECURS' => 1, # dont descend into subdirectories
'PREREQ_PM' => { 'Net::SSLeay' => 0,
'Text::CSV_XS' => 0,
'Business::OnlinePayment' => 0,
+ 'Test::More' => 0.42,
},
- #'dist' => {CI => 'ci -l'},
);
-BEGIN { $| = 1; print "1..1\n"; }
-END {print "not ok 1\n" unless $loaded;}
-use Business::OnlinePayment;
-$loaded = 1;
-print "ok 1\n";
+#!/usr/bin/perl -w
+
+use Test::More tests => 1;
+
+use_ok 'Business::OnlinePayment';
-BEGIN { $| = 1; print "1..2\n"; }
+#!/usr/bin/perl -w
-#testing/testing is valid and seems to work... (but not for auth + capture)
-print "ok 1 # Skipped: need a valid Authorize.Net login/password to test\n";
-print "ok 2 # Skipped: need a valid Authorize.Net login/password to test\n";
-exit;
+use Test::More;
+require "t/lib/test_account.pl";
-use Business::OnlinePayment;
+my($login, $password) = test_account_or_skip();
+plan tests => 4;
-my $tx = new Business::OnlinePayment("AuthorizeNet");
+use_ok 'Business::OnlinePayment';
+
+my $tx = Business::OnlinePayment->new("AuthorizeNet");
+$tx->server('test.authorize.net');
$tx->content(
type => 'VISA',
- login => 'testing',# CHANGE THESE TO TEST
- password => 'testing',#
+ login => $login,
+ password => $password,
action => 'Authorization Only',
description => 'Business::OnlinePayment visa test',
amount => '49.95',
state => 'UT',
zip => '84058',
card_number => '4007000000027',
- expiration => '08/06',
+ expiration => expiration_date(),
);
$tx->test_transaction(1); # test, dont really charge
$tx->submit();
-unless($tx->is_success()) {
- print "not ok 1\n";
- print "not ok 2\n";
-} else {
- my $order_number = $tx->order_number;
- warn $order_number;
- print "ok 1\n";
+ok($tx->is_success()) or diag $tx->error_message;
- my $settle_tx = new Business::OnlinePayment("AuthorizeNet");
- $settle_tx->content(
- type => 'VISA',
- login => 'testing', # CHANGE THESE TO TEST
- password => 'testing', #
- action => 'Post Authorization',
- description => 'Business::OnlinePayment visa test',
- amount => '49.95',
- invoice_number => '100100',
- order_number => '111',
- card_number => '4007000000027',
- expiration => '08/06',
- );
+my $order_number = $tx->order_number;
+like $order_number, qr/^\d+$/;
- $settle_tx->test_transaction(1); # test, dont really charge
- $settle_tx->submit();
+my $settle_tx = Business::OnlinePayment->new("AuthorizeNet");
+$settle_tx->server('test.authorize.net');
+$settle_tx->content(
+ type => 'VISA',
+ login => $login,
+ password => $password,
+ action => 'Post Authorization',
+ description => 'Business::OnlinePayment visa test',
+ amount => '49.95',
+ invoice_number => '100100',
+ order_number => '111',
+ card_number => '4007000000027',
+ expiration => expiration_date(),
+);
- if($settle_tx->is_success()) {
- print "ok 2\n";
- } else {
- warn $settle_tx->error_message;
- print "not ok 2\n";
- }
+$settle_tx->test_transaction(1); # test, dont really charge
+$settle_tx->submit();
-}
+ok($settle_tx->is_success()) || diag $settle_tx->error_message;
-BEGIN { $| = 1; print "1..1\n"; }
+#!/usr/bin/perl -w
-print "ok 1 # Skipped: testing account won't accept ACH transactions\n"; exit;
+use Test::More;
+require "t/lib/test_account.pl";
-use Business::OnlinePayment;
+my($login, $password) = test_account_or_skip();
+plan tests => 2;
-# checks are broken it seems
-my $ctx = new Business::OnlinePayment("AuthorizeNet");
+use_ok 'Business::OnlinePayment';
+
+my $ctx = Business::OnlinePayment->new("AuthorizeNet");
+$ctx->server('test.authorize.net');
$ctx->content(
type => 'CHECK',
- login => 'testing',
- password => 'testing',
+ login => $login,
+ password => $password,
action => 'Normal Authorization',
amount => '49.95',
invoice_number => '100100',
customer_id => 'jsk',
first_name => 'Tofu',
last_name => 'Beast',
+ account_name => 'Tofu Beast',
account_number => '12345',
- routing_code => '123456789',
+ 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();
-print $ctx->is_success()."\n";
+SKIP: {
+ skip $ctx->error_message, 1 if $ctx->result_code == 18;
-if($ctx->is_success()) {
- print "ok 1\n";
-} else {
- print "not ok 1 (".$ctx->error_message().")\n";
+ ok( $ctx->is_success() ) || diag $ctx->error_message;
}
-BEGIN { $| = 1; print "1..1\n"; }
+#!/usr/bin/perl -w
-#testing/testing is valid and seems to work...
-#print "ok 1 # Skipped: need a valid Authorize.Net login/password to test\n"; exit;
+use Test::More;
+require "t/lib/test_account.pl";
-use Business::OnlinePayment;
+my($login, $password) = test_account_or_skip();
+plan tests => 2;
+
+use_ok 'Business::OnlinePayment';
-my($month, $year) = (localtime)[4,5];
-$year++; # So we expire next year.
-$year %= 100; # y2k? What's that?
-
-my $tx = new Business::OnlinePayment("AuthorizeNet");
+my $tx = Business::OnlinePayment->new("AuthorizeNet");
+$tx->server('test.authorize.net');
$tx->content(
type => 'VISA',
- login => 'testing',
- password => 'testing',
+ login => $login,
+ password => $password,
action => 'Normal Authorization',
description => 'Business::OnlinePayment visa test',
amount => '49.95',
state => 'UT',
zip => '84058',
card_number => '4007000000027',
- expiration => sprintf("%02d/%02d", $month, $year),
+ expiration => expiration_date(),
);
$tx->test_transaction(1); # test, dont really charge
$tx->submit();
-if($tx->is_success()) {
- print "ok 1\n";
-} else {
- warn $tx->error_message;
- print "not ok 1\n";
-}
+ok($tx->is_success()) or diag $tx->error_message;
--- /dev/null
+sub test_account_or_skip {
+ my($login, $password) = test_account();
+
+ unless( defined $login ) {
+ plan skip_all => "No test account";
+ }
+
+ return($login, $password);
+}
+
+sub test_account {
+ open TEST_ACCOUNT, "t/test_account" or return;
+ my($login, $password) = <TEST_ACCOUNT>;
+ chomp $login;
+ chomp $password;
+
+ return($login, $password);
+}
+
+sub expiration_date {
+ my($month, $year) = (localtime)[4,5];
+ $year++; # So we expire next year.
+ $year %= 100; # y2k? What's that?
+
+ return sprintf("%02d/%02d", $month, $year);
+}
+
+1;
-BEGIN { $| = 1; print "1..1\n"; }
-END {print "not ok 1\n" unless $loaded;}
-use Business::OnlinePayment::AuthorizeNet;
-$loaded = 1;
-print "ok 1\n";
+#!/usr/bin/perl -w
+
+use Test::More tests => 1;
+
+use_ok 'Business::OnlinePayment::AuthorizeNet';
--- /dev/null
+cnpdev6024
+authnet001