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,
23 uuid => 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
24 guid => 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
28 result_code => '98e05',
29 authorization => undef,
30 error_message => 'Real error message',
31 receipt_number => '1096021915.5853',
33 date => '2003/12/17 10:31:58',
35 avs_response => undef,
36 cvv2_response => undef,
44 use Test::More tests => 1 + scalar(RESULTS) * (1 + 1 + scalar(FIELDS));
46 BEGIN { use_ok('Business::OnlinePayment') };
50 my $txn = new Business::OnlinePayment 'InternetSecure', merchant_id => '0000';
53 foreach my $results (RESULTS) {
55 $txn->parse_response($xml);
57 is($txn->server_response, $xml, 'server_response');
59 if ($results->{is_success}) {
60 ok($txn->is_success, 'expecting success');
62 ok(!$txn->is_success, 'expecting failure');
67 is($txn->$_, $results->{$_}, $_);
73 <?xml version="1.0" encoding="UTF-8"?>
75 <MerchantNumber>4994</MerchantNumber>
76 <ReceiptNumber>1096019995.5012</ReceiptNumber>
77 <SalesOrderNumber>0</SalesOrderNumber>
78 <xxxName>John Smith</xxxName>
79 <Date>2003/12/17 09:59:58</Date>
80 <CardType>Test Card Number</CardType>
82 <ApprovalCode>T00000</ApprovalCode>
83 <Verbiage>Test Approved</Verbiage>
84 <TotalAmount>3.88</TotalAmount>
88 <description>Test Product 1</description>
89 <quantity>1</quantity>
91 <subtotal>3.10</subtotal>
100 <description>Test Product 2</description>
101 <quantity>1</quantity>
103 <subtotal>0.20</subtotal>
111 <description>Test Product 3</description>
112 <quantity>1</quantity>
114 <subtotal>0.33</subtotal>
122 <description>Canadian GST Charged</description>
123 <quantity>1</quantity>
125 <subtotal>0.25</subtotal>
128 <flag>{CALCULATED}</flag>
132 <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>
135 <GUID>f81d4fae-7dec-11d0-a765-00a0c91e6bf6</GUID>
138 <?xml version="1.0" encoding="UTF-8"?>
140 <MerchantNumber>4994</MerchantNumber>
141 <ReceiptNumber>1096021915.5853</ReceiptNumber>
142 <SalesOrderNumber>729</SalesOrderNumber>
143 <xxxName>John Smith</xxxName>
144 <Date>2003/12/17 10:31:58</Date>
145 <CardType>VI</CardType>
148 <Verbiage>Incorrect Card Number - Please Retry</Verbiage>
149 <Error>Real error message</Error>
150 <TotalAmount>3.88</TotalAmount>
154 <description>Test Product 1</description>
155 <quantity>1</quantity>
157 <subtotal>3.10</subtotal>
165 <description>Test Product 2</description>
166 <quantity>1</quantity>
168 <subtotal>0.20</subtotal>
175 <description>Test Product 3</description>
176 <quantity>1</quantity>
178 <subtotal>0.33</subtotal>
185 <description>Canadian GST Charged</description>
186 <quantity>1</quantity>
188 <subtotal>0.25</subtotal>
191 <flag>{CALCULATED}</flag>
195 <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>