use Test::More tests => 1 + 2 * 6; BEGIN { use_ok('Business::OnlinePayment') }; use constant FIELDS => (qw( result_code authorization total_amount error_message )); use constant RESULTS => ( [ 1, '2000', 'T00000', 3.88, 'Test Approved' ], [ 0, '98e05', undef, 3.88, 'Real error message' ], ); 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 Real error message 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}