Make that test transaction truly minimal
[Business-OnlinePayment-InternetSecure.git] / t / 20emit.t
1 # vim:set syntax=perl:
2
3 use Test::More tests => 4 + 2;
4
5 BEGIN { use_ok('Business::OnlinePayment') };
6 BEGIN { use_ok('Business::OnlinePayment::InternetSecure') };
7 BEGIN { use_ok('XML::Simple', qw(xml_in)) };
8 BEGIN { use_ok('Encode') };
9
10 use charnames ':full';  # Why doesn't this work with use_ok?
11
12 use constant TRANSACTIONS => (
13         {
14                 _test           => 0,
15
16                 action          => 'Normal Authorization',
17
18                 type            => 'Visa',
19                 card_number     => '4111 1111 1111 1111',
20                 exp_date        => '2004-07',
21                 cvv2            => '000',
22
23                 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",
24                 company         => '',
25                 address         => '123 Street',
26                 city            => 'Metropolis',
27                 state           => 'ZZ',
28                 zip             => 'A1A 1A1',
29                 country         => 'CA',
30                 phone           => '(555) 555-1212',
31                 email           => 'fbriere@fbriere.net',
32
33                 amount          => undef,
34                 currency        => 'USD',
35                 taxes           => 'GST PST',
36
37                 description => [
38                                 {
39                                 amount          => 9.99,
40                                 quantity        => 5,
41                                 sku             => 'a:001',
42                                 description     => 'Some product',
43                                 },
44                                 {
45                                 amount          => 5.65,
46                                 description     => 'Shipping',
47                                 },
48                                 {
49                                 amount          => 10.00,
50                                 description     => 'Some HST example',
51                                 taxes           => 'HST',
52                                 },
53                                 ],
54         },
55         {
56                 _test           => 1,
57
58                 action          => 'Normal Authorization',
59
60                 card_number     => '5111-1111-1111-1111',
61                 exp_date        => '7/2004',
62
63                 name            => "Fr\x{e9}d\x{e9}ric Bri\x{e8}re",
64
65                 amount          => 12.95,
66         },
67 );
68
69
70 my $txn = new Business::OnlinePayment 'InternetSecure', merchant_id => '0000';
71
72 foreach (TRANSACTIONS) {
73         $txn->test_transaction(delete $_->{_test});
74         $txn->content(%$_);
75
76         my $data = do {
77                 # Work around bug #17687
78                 local $/ = '';
79                 scalar <DATA>;
80         };
81
82         is_deeply(
83                 xml_in($txn->to_xml),
84                 xml_in($data)
85         ); 
86 }
87
88
89 __DATA__
90 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
91 <TranxRequest>
92   <MerchantNumber>0000</MerchantNumber>
93   <xxxCard_Number>4111111111111111</xxxCard_Number>
94   <xxxCCMonth>07</xxxCCMonth>
95   <xxxCCYear>2004</xxxCCYear>
96   <CVV2>1</CVV2>
97   <CVV2Indicator>000</CVV2Indicator>
98   <Products>9.99::5::a 001::Some product::{USD}{GST}{PST}|5.65::1::::Shipping::{USD}{GST}{PST}|10.00::1::::Some HST example::{USD}{HST}</Products>
99   <xxxName>Frédéric Brière</xxxName>
100   <xxxCompany></xxxCompany>
101   <xxxAddress>123 Street</xxxAddress>
102   <xxxCity>Metropolis</xxxCity>
103   <xxxProvince>ZZ</xxxProvince>
104   <xxxPostal>A1A 1A1</xxxPostal>
105   <xxxCountry>CA</xxxCountry>
106   <xxxPhone>(555) 555-1212</xxxPhone>
107   <xxxEmail>fbriere@fbriere.net</xxxEmail>
108   <xxxShippingName></xxxShippingName>
109   <xxxShippingCompany></xxxShippingCompany>
110   <xxxShippingAddress></xxxShippingAddress>
111   <xxxShippingCity></xxxShippingCity>
112   <xxxShippingProvince></xxxShippingProvince>
113   <xxxShippingPostal></xxxShippingPostal>
114   <xxxShippingCountry></xxxShippingCountry>
115   <xxxShippingPhone></xxxShippingPhone>
116   <xxxShippingEmail></xxxShippingEmail>
117 </TranxRequest>
118
119 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
120 <TranxRequest>
121   <MerchantNumber>0000</MerchantNumber>
122   <xxxCard_Number>5111111111111111</xxxCard_Number>
123   <xxxCCMonth>07</xxxCCMonth>
124   <xxxCCYear>2004</xxxCCYear>
125   <CVV2>0</CVV2>
126   <CVV2Indicator></CVV2Indicator>
127   <Products>12.95::1::::::{CAD}{TEST}</Products>
128   <xxxName>Frédéric Brière</xxxName>
129   <xxxCompany></xxxCompany>
130   <xxxAddress></xxxAddress>
131   <xxxCity></xxxCity>
132   <xxxProvince></xxxProvince>
133   <xxxPostal></xxxPostal>
134   <xxxCountry></xxxCountry>
135   <xxxPhone></xxxPhone>
136   <xxxEmail></xxxEmail>
137   <xxxShippingName></xxxShippingName>
138   <xxxShippingCompany></xxxShippingCompany>
139   <xxxShippingAddress></xxxShippingAddress>
140   <xxxShippingCity></xxxShippingCity>
141   <xxxShippingProvince></xxxShippingProvince>
142   <xxxShippingPostal></xxxShippingPostal>
143   <xxxShippingCountry></xxxShippingCountry>
144   <xxxShippingPhone></xxxShippingPhone>
145   <xxxShippingEmail></xxxShippingEmail>
146 </TranxRequest>
147