diff options
author | mark <mark> | 2010-06-15 19:43:31 +0000 |
---|---|---|
committer | mark <mark> | 2010-06-15 19:43:31 +0000 |
commit | e74f5f0a651caeff48076605e220e3600118ae47 (patch) | |
tree | 2c239d1b0b43a37a339bb042a56d5648bde11ab8 /t/02-ach.t | |
parent | d1b9ecf606c0fd6a6b37a22e366c9ad8dbadc724 (diff) |
Cleanup for public release
Diffstat (limited to 't/02-ach.t')
-rw-r--r-- | t/02-ach.t | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/t/02-ach.t b/t/02-ach.t new file mode 100644 index 0000000..4ff80ff --- /dev/null +++ b/t/02-ach.t @@ -0,0 +1,59 @@ +use Test::More tests => 3; + +use Business::OnlinePayment; + +my %defaults = ( + name => 'Joe Tester', + address => '888', + city => 'Nowhere', + state => 'CA', + zip => '77777', + phone => '510-555-0021', + email => 'joe@example.com', + description => 'Business::OnlinePayment::NMI Test', + + action => 'Normal Authorization', + account_number => '222223333344', # meaningless + routing_code => '411151111', + amount => '13.00', + ); + +# SALE +my %content = %defaults; +my $ordernum = ok_test(\%content, 'echeck sale'); + +#VOID +%content = ( + action => 'Void', + order_number => $ordernum, +); +ok_test(\%content, 'echeck void'); + +#FAILURE +%content = %defaults; +$content{amount} = '0.10'; # amounts < 1.00 are declined on the demo account +$content{fail} = 1; +ok_test(\%content, 'echeck decline'); + +sub ok_test { + my ($content, $label) = @_; + my $fail = delete $content{fail} or 0; + my $trans = new Business::OnlinePayment('NMI'); + $trans->content( + login => 'demo', + password => 'password', + type => 'echeck', + %$content + ); + $trans->submit; + diag($trans->error_message) if (!$fail and $trans->error_message); + if($fail) { + ok(!$trans->is_success, $label) + } + else { + ok($trans->is_success, $label); + } + return $trans->order_number; +} + +1; |