1 use constant FIELDS => qw(
2 result_code authorization error_message
3 receipt_number sales_number
6 avs_response cvv2_response
10 use constant RESULTS => (
13 result_code => '2000',
14 authorization => 'T00000',
15 error_message => 'Test Approved',
16 receipt_number => '1096019995.5012',
18 date => '2003/12/17 09:59:58',
20 avs_response => undef,
21 cvv2_response => undef,
26 result_code => '98e05',
27 authorization => undef,
28 error_message => 'Real error message',
29 receipt_number => '1096021915.5853',
31 date => '2003/12/17 10:31:58',
33 avs_response => undef,
34 cvv2_response => undef,
40 use Test::More tests => 1 + scalar(RESULTS) * (1 + 1 + scalar(FIELDS));
42 BEGIN { use_ok('Business::OnlinePayment') };
46 my $txn = new Business::OnlinePayment 'InternetSecure', merchant_id => '0000';
49 foreach my $results (RESULTS) {
51 $txn->parse_response($xml);
53 is($txn->server_response, $xml, 'server_response');
55 if ($results->{is_success}) {
56 ok($txn->is_success, 'expecting success');
58 ok(!$txn->is_success, 'expecting failure');
63 is($txn->$_, $results->{$_}, $_);
69 <?xml version="1.0" encoding="UTF-8"?>
71 <MerchantNumber>4994</MerchantNumber>
72 <ReceiptNumber>1096019995.5012</ReceiptNumber>
73 <SalesOrderNumber>0</SalesOrderNumber>
74 <xxxName>John Smith</xxxName>
75 <Date>2003/12/17 09:59:58</Date>
76 <CardType>Test Card Number</CardType>
78 <ApprovalCode>T00000</ApprovalCode>
79 <Verbiage>Test Approved</Verbiage>
80 <TotalAmount>3.88</TotalAmount>
84 <description>Test Product 1</description>
85 <quantity>1</quantity>
87 <subtotal>3.10</subtotal>
96 <description>Test Product 2</description>
97 <quantity>1</quantity>
99 <subtotal>0.20</subtotal>
107 <description>Test Product 3</description>
108 <quantity>1</quantity>
110 <subtotal>0.33</subtotal>
118 <description>Canadian GST Charged</description>
119 <quantity>1</quantity>
121 <subtotal>0.25</subtotal>
124 <flag>{CALCULATED}</flag>
128 <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>
133 <?xml version="1.0" encoding="UTF-8"?>
135 <MerchantNumber>4994</MerchantNumber>
136 <ReceiptNumber>1096021915.5853</ReceiptNumber>
137 <SalesOrderNumber>729</SalesOrderNumber>
138 <xxxName>John Smith</xxxName>
139 <Date>2003/12/17 10:31:58</Date>
140 <CardType>VI</CardType>
143 <Verbiage>Incorrect Card Number - Please Retry</Verbiage>
144 <Error>Real error message</Error>
145 <TotalAmount>3.88</TotalAmount>
149 <description>Test Product 1</description>
150 <quantity>1</quantity>
152 <subtotal>3.10</subtotal>
160 <description>Test Product 2</description>
161 <quantity>1</quantity>
163 <subtotal>0.20</subtotal>
170 <description>Test Product 3</description>
171 <quantity>1</quantity>
173 <subtotal>0.33</subtotal>
180 <description>Canadian GST Charged</description>
181 <quantity>1</quantity>
183 <subtotal>0.25</subtotal>
186 <flag>{CALCULATED}</flag>
190 <DoubleColonProducts>3.10::1::001::Test Product 1::{USD}{GST}|0.20::1::010::Test Product 2::{GST}|0.33::1::020::Test Product 3::{GST}|0.25::1::GST::Canadian GST Charged::{TAX}{CALCULATED}</DoubleColonProducts>