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/01-cc.t | |
parent | d1b9ecf606c0fd6a6b37a22e366c9ad8dbadc724 (diff) |
Cleanup for public release
Diffstat (limited to 't/01-cc.t')
-rw-r--r-- | t/01-cc.t | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/t/01-cc.t b/t/01-cc.t new file mode 100644 index 0000000..2444480 --- /dev/null +++ b/t/01-cc.t @@ -0,0 +1,79 @@ +use Test::More tests => 6; + +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', + card_number => '5431111111111111', + expiration => '10/10', + amount => '12.00', + ); + +# SALE +my %content = %defaults; +my $ordernum = ok_test(\%content, 'credit card sale'); + +# REFUND +%content = ( + action => 'Credit', + order_number => $ordernum, + amount => '6.00', +); +ok_test(\%content, 'credit card refund'); + +# AUTH/CAPTURE +%content = %defaults; +$content{'action'} = 'Authorization Only'; +$ordernum = ok_test(\%content, 'credit card auth'); + +%content = ( + action => 'Post Authorization', + order_number => $ordernum, + amount => '12.00', +); +ok_test(\%content, 'credit card capture'); + +#VOID +%content = ( + action => 'Void', + order_number => $ordernum, +); +ok_test(\%content, 'credit card void'); + +#FAILURE +%content = %defaults; +$content{amount} = '0.10'; # amounts < 1.00 are declined on the demo account +$content{fail} = 1; +ok_test(\%content, 'credit card 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 => 'CC', + %$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; |