3 use constant FIELDS => qw(
4 result_code authorization error_message
5 receipt_number sales_number
8 avs_response cvv2_response
9 total_amount tax_amounts
12 use constant RESULTS => (
15 result_code => '2000',
16 authorization => 'T00000',
17 error_message => undef,
18 receipt_number => '1096019995.5012',
20 date => '2003/12/17 09:59:58',
22 avs_response => undef,
23 cvv2_response => undef,
25 tax_amounts => { GST => 0.25 },
26 uuid => 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
27 guid => 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
31 result_code => '98e05',
32 authorization => undef,
33 error_message => 'Real error message',
34 receipt_number => '1096021915.5853',
36 date => '2003/12/17 10:31:58',
38 avs_response => undef,
39 cvv2_response => undef,
41 tax_amounts => { GST => 0.25,
49 use Test::More tests => 1 + scalar(RESULTS) * (1 + 1 + scalar(FIELDS));
51 BEGIN { use_ok('Business::OnlinePayment') };
55 my $txn = new Business::OnlinePayment 'InternetSecure', merchant_id => '0000';
58 foreach my $results (RESULTS) {
60 $txn->parse_response($xml);
62 is($txn->server_response, $xml, 'server_response');
64 if ($results->{is_success}) {
65 ok($txn->is_success, 'expecting success');
67 ok(!$txn->is_success, 'expecting failure');
72 is_deeply($txn->$_, $results->{$_}, $_);
78 <?xml version="1.0" encoding="UTF-8"?>
80 <MerchantNumber>4994</MerchantNumber>
81 <ReceiptNumber>1096019995.5012</ReceiptNumber>
82 <SalesOrderNumber>0</SalesOrderNumber>
83 <xxxName>John Smith</xxxName>
84 <Date>2003/12/17 09:59:58</Date>
85 <CardType>Test Card Number</CardType>
87 <ApprovalCode>T00000</ApprovalCode>
88 <Verbiage>Test Approved</Verbiage>
89 <TotalAmount>3.88</TotalAmount>
93 <description>Test Product 1</description>
94 <quantity>1</quantity>
96 <subtotal>3.10</subtotal>
105 <description>Test Product 2</description>
106 <quantity>1</quantity>
108 <subtotal>0.20</subtotal>
116 <description>Test Product 3</description>
117 <quantity>1</quantity>
119 <subtotal>0.33</subtotal>
127 <description>Canadian GST Charged</description>
128 <quantity>1</quantity>
130 <subtotal>0.25</subtotal>
133 <flag>{CALCULATED}</flag>
137 <DoubleColonProducts>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}</DoubleColonProducts>
140 <GUID>f81d4fae-7dec-11d0-a765-00a0c91e6bf6</GUID>
143 <?xml version="1.0" encoding="UTF-8"?>
145 <MerchantNumber>4994</MerchantNumber>
146 <ReceiptNumber>1096021915.5853</ReceiptNumber>
147 <SalesOrderNumber>729</SalesOrderNumber>
148 <xxxName>John Smith</xxxName>
149 <Date>2003/12/17 10:31:58</Date>
150 <CardType>VI</CardType>
153 <Verbiage>Incorrect Card Number - Please Retry</Verbiage>
154 <Error>Real error message</Error>
155 <TotalAmount>3.88</TotalAmount>
159 <description>Test Product 1</description>
160 <quantity>1</quantity>
162 <subtotal>3.10</subtotal>
171 <description>Test Product 2</description>
172 <quantity>1</quantity>
174 <subtotal>0.20</subtotal>
182 <description>Test Product 3</description>
183 <quantity>1</quantity>
185 <subtotal>0.33</subtotal>
193 <description>Canadian GST Charged</description>
194 <quantity>1</quantity>
196 <subtotal>0.25</subtotal>
199 <flag>{CALCULATED}</flag>
204 <description>PST Charged</description>
205 <quantity>1</quantity>
207 <subtotal>0.27</subtotal>
210 <flag>{CALCULATED}</flag>
214 <DoubleColonProducts>3.10::1::001::Test Product 1::{USD}{GST}{PST}|0.20::1::010::Test Product 2::{GST}{PST}|0.33::1::020::Test Product 3::{GST}{PST}|0.25::1::GST::Canadian GST Charged::{TAX}{CALCULATED}|0.27::1::PST::PST Charged::{TAX}{CALCULATED}</DoubleColonProducts>