From 7af3e137d97474aa364a585359bbfb400f0594cf Mon Sep 17 00:00:00 2001 From: fbriere Date: Mon, 13 Feb 2006 21:10:31 +0000 Subject: Initial import --- t/30parse.t | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100755 t/30parse.t (limited to 't/30parse.t') diff --git a/t/30parse.t b/t/30parse.t new file mode 100755 index 0000000..8780731 --- /dev/null +++ b/t/30parse.t @@ -0,0 +1,163 @@ +use Test::More tests => 1 + 2 * 5; + +BEGIN { use_ok('Business::OnlinePayment') }; + + +use constant FIELDS => (qw( result_code authorization total_amount )); + +use constant RESULTS => ( + [ 1, '2000', 'T00000', 3.88 ], + [ 0, '98e05', undef, 3.88 ], + ); + + +my $txn = new Business::OnlinePayment 'InternetSecure', merchant_id => '0000'; + +$/ = ''; +foreach (RESULTS) { + my @results = @$_; + + my $xml = ; + $txn->parse_response($xml); + + is($txn->server_response, $xml, 'server_response'); + + if (shift @results) { + ok($txn->is_success, 'expecting success'); + } else { + ok(!$txn->is_success, 'expecting failure'); + } + + foreach (FIELDS) { + no strict 'refs'; + is($txn->$_, shift @results, $_); + } +} + + +__DATA__ + + + 4994 + 1096019995.5012 + 0 + John Smith + 2003/12/17 09:59:58 + Test Card Number + 2000 + T00000 + Test Approved + 3.88 + + + 001 + Test Product 1 + 1 + 3.10 + 3.10 + + {USD} + {GST} + {TEST} + + + + 010 + Test Product 2 + 1 + 0.20 + 0.20 + + {GST} + {TEST} + + + + 020 + Test Product 3 + 1 + 0.33 + 0.33 + + {GST} + {TEST} + + + + GST + Canadian GST Charged + 1 + 0.25 + 0.25 + + {TAX} + {CALCULATED} + + + + 3.10::1::001::Test Product 1::{USD}{GST}{TEST}|0.20::1::010::Test Product 2::{GST}{TEST}|0.33::1::020::Test Product 3::{GST}{TEST}|0.25::1::GST::Canadian GST Charged::{TAX}{CALCULATED} + + + + + + + 4994 + 1096021915.5853 + 729 + John Smith + 2003/12/17 10:31:58 + VI + 98e05 + + Incorrect Card Number - Please Retry + 3.88 + + + 001 + Test Product 1 + 1 + 3.10 + 3.10 + + {USD} + {GST} + + + + 010 + Test Product 2 + 1 + 0.20 + 0.20 + + {GST} + + + + 020 + Test Product 3 + 1 + 0.33 + 0.33 + + {GST} + + + + GST + Canadian GST Charged + 1 + 0.25 + 0.25 + + {TAX} + {CALCULATED} + + + + 3.10::1::001::Test Product 1::{USD}{GST}|0.20::1::010::Test Product 2::{GST}|0.33::1::020::Test Product 3::{GST}|0.25::1::GST::Canadian GST Charged::{TAX}{CALCULATED} + + + + -- cgit v1.2.1