From 7af3e137d97474aa364a585359bbfb400f0594cf Mon Sep 17 00:00:00 2001 From: fbriere Date: Mon, 13 Feb 2006 21:10:31 +0000 Subject: Initial import --- t/20emit.t | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100755 t/20emit.t (limited to 't/20emit.t') diff --git a/t/20emit.t b/t/20emit.t new file mode 100755 index 0000000..a162f10 --- /dev/null +++ b/t/20emit.t @@ -0,0 +1,143 @@ +use Test::More tests => 4 + 2; + +BEGIN { use_ok('Business::OnlinePayment') }; +BEGIN { use_ok('Business::OnlinePayment::InternetSecure') }; +BEGIN { use_ok('XML::Simple', qw(xml_in)) }; +BEGIN { use_ok('Encode') }; + +use charnames ':full'; # Why doesn't this work with use_ok? + +use constant TRANSACTIONS => ( + { + _test => 0, + + action => 'Normal Authorization', + + type => 'Visa', + card_number => '0000000000000000', + exp_date => '2004-07', + cvv2 => '000', + + name => "Fr\N{LATIN SMALL LETTER E WITH ACUTE}d\N{LATIN SMALL LETTER E WITH ACUTE}ric Bri\N{LATIN SMALL LETTER E WITH GRAVE}re", + company => '', + address => '123 Street', + city => 'Metropolis', + state => 'ZZ', + zip => 'A1A 1A1', + country => 'CA', + phone => '(555) 555-1212', + email => 'fbriere@fbriere.net', + + amount => undef, + currency => 'CAD', + taxes => 'GST PST', + + description => [ + { + amount => 9.99, + quantity => 5, + sku => 'a:001', + description => 'Some product', + }, + { + amount => 5.65, + description => 'Shipping', + }, + { + amount => 10.00, + description => 'Some HST example', + taxes => 'HST', + }, + ], + }, + { + _test => 1, + + action => 'Normal Authorization', + + type => 'Visa', + card_number => '0000000000000000', + exp_date => '7/2004', + + name => "Fr\x{e9}d\x{e9}ric Bri\x{e8}re", + + amount => 12.95, + currency => 'USD', + taxes => '', + description => "Box o' goodies", + }, +); + + +my $txn = new Business::OnlinePayment 'InternetSecure', merchant_id => '0000'; + +$/ = ''; +foreach (TRANSACTIONS) { + $txn->test_transaction(delete $_->{_test}); + $txn->content(%$_); + is_deeply( + xml_in(Encode::encode('utf8', $txn->to_xml)), + xml_in(scalar ) + ); +} + + +__DATA__ + + + 0000 + 0000000000000000 + 07 + 2004 + 1 + 000 + 9.99::5::a 001::Some product::{CAD}{GST}{PST}|5.65::1::::Shipping::{CAD}{GST}{PST}|10.00::1::::Some HST example::{CAD}{HST} + Frédéric Brière + + 123 Street + Metropolis + ZZ + A1A 1A1 + CA + (555) 555-1212 + fbriere@fbriere.net + + + + + + + + + + + + + + 0000 + 0000000000000000 + 07 + 2004 + 0 + + 12.95::1::::Box o' goodies::{USD}{TEST} + Frédéric Brière + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1