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