1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# vim:set syntax=perl:
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 => '4111 1111 1111 1111',
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 => 'MasterCard',
card_number => '5111-1111-1111-1111',
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(%$_);
my $data = do {
# Work around bug #17687
local $/ = '';
scalar <DATA>;
};
is_deeply(
xml_in($txn->to_xml),
xml_in($data)
);
}
__DATA__
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<TranxRequest>
<MerchantNumber>0000</MerchantNumber>
<xxxCard_Number>4111111111111111</xxxCard_Number>
<xxxCCMonth>07</xxxCCMonth>
<xxxCCYear>2004</xxxCCYear>
<CVV2>1</CVV2>
<CVV2Indicator>000</CVV2Indicator>
<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>
<xxxName>Frédéric Brière</xxxName>
<xxxCompany></xxxCompany>
<xxxAddress>123 Street</xxxAddress>
<xxxCity>Metropolis</xxxCity>
<xxxProvince>ZZ</xxxProvince>
<xxxPostal>A1A 1A1</xxxPostal>
<xxxCountry>CA</xxxCountry>
<xxxPhone>(555) 555-1212</xxxPhone>
<xxxEmail>fbriere@fbriere.net</xxxEmail>
<xxxShippingName></xxxShippingName>
<xxxShippingCompany></xxxShippingCompany>
<xxxShippingAddress></xxxShippingAddress>
<xxxShippingCity></xxxShippingCity>
<xxxShippingProvince></xxxShippingProvince>
<xxxShippingPostal></xxxShippingPostal>
<xxxShippingCountry></xxxShippingCountry>
<xxxShippingPhone></xxxShippingPhone>
<xxxShippingEmail></xxxShippingEmail>
</TranxRequest>
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<TranxRequest>
<MerchantNumber>0000</MerchantNumber>
<xxxCard_Number>5111111111111111</xxxCard_Number>
<xxxCCMonth>07</xxxCCMonth>
<xxxCCYear>2004</xxxCCYear>
<CVV2>0</CVV2>
<CVV2Indicator></CVV2Indicator>
<Products>12.95::1::::Box o' goodies::{USD}{TEST}</Products>
<xxxName>Frédéric Brière</xxxName>
<xxxCompany></xxxCompany>
<xxxAddress></xxxAddress>
<xxxCity></xxxCity>
<xxxProvince></xxxProvince>
<xxxPostal></xxxPostal>
<xxxCountry></xxxCountry>
<xxxPhone></xxxPhone>
<xxxEmail></xxxEmail>
<xxxShippingName></xxxShippingName>
<xxxShippingCompany></xxxShippingCompany>
<xxxShippingAddress></xxxShippingAddress>
<xxxShippingCity></xxxShippingCity>
<xxxShippingProvince></xxxShippingProvince>
<xxxShippingPostal></xxxShippingPostal>
<xxxShippingCountry></xxxShippingCountry>
<xxxShippingPhone></xxxShippingPhone>
<xxxShippingEmail></xxxShippingEmail>
</TranxRequest>
|