3 use constant FIELDS => qw(
4 result_code authorization error_message
5 receipt_number sales_number
8 avs_response cvv2_response
12 use constant RESULTS => (
15 result_code => '2000',
16 authorization => 'T00000',
17 error_message => 'Test Approved',
18 receipt_number => '1096019995.5012',
20 date => '2003/12/17 09:59:58',
22 avs_response => undef,
23 cvv2_response => undef,
25 uuid => 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
26 guid => 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
30 result_code => '98e05',
31 authorization => undef,
32 error_message => 'Real error message',
33 receipt_number => '1096021915.5853',
35 date => '2003/12/17 10:31:58',
37 avs_response => undef,
38 cvv2_response => undef,
46 use Test::More tests => 1 + scalar(RESULTS) * (1 + 1 + scalar(FIELDS));
48 BEGIN { use_ok('Business::OnlinePayment') };
52 my $txn = new Business::OnlinePayment 'InternetSecure', merchant_id => '0000';
55 foreach my $results (RESULTS) {
57 $txn->parse_response($xml);
59 is($txn->server_response, $xml, 'server_response');
61 if ($results->{is_success}) {
62 ok($txn->is_success, 'expecting success');
64 ok(!$txn->is_success, 'expecting failure');
69 is($txn->$_, $results->{$_}, $_);
75 <?xml version="1.0" encoding="UTF-8"?>
77 <MerchantNumber>4994</MerchantNumber>
78 <ReceiptNumber>1096019995.5012</ReceiptNumber>
79 <SalesOrderNumber>0</SalesOrderNumber>
80 <xxxName>John Smith</xxxName>
81 <Date>2003/12/17 09:59:58</Date>
82 <CardType>Test Card Number</CardType>
84 <ApprovalCode>T00000</ApprovalCode>
85 <Verbiage>Test Approved</Verbiage>
86 <TotalAmount>3.88</TotalAmount>
90 <description>Test Product 1</description>
91 <quantity>1</quantity>
93 <subtotal>3.10</subtotal>
102 <description>Test Product 2</description>
103 <quantity>1</quantity>
105 <subtotal>0.20</subtotal>
113 <description>Test Product 3</description>
114 <quantity>1</quantity>
116 <subtotal>0.33</subtotal>
124 <description>Canadian GST Charged</description>
125 <quantity>1</quantity>
127 <subtotal>0.25</subtotal>
130 <flag>{CALCULATED}</flag>
134 <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>
137 <GUID>f81d4fae-7dec-11d0-a765-00a0c91e6bf6</GUID>
140 <?xml version="1.0" encoding="UTF-8"?>
142 <MerchantNumber>4994</MerchantNumber>
143 <ReceiptNumber>1096021915.5853</ReceiptNumber>
144 <SalesOrderNumber>729</SalesOrderNumber>
145 <xxxName>John Smith</xxxName>
146 <Date>2003/12/17 10:31:58</Date>
147 <CardType>VI</CardType>
150 <Verbiage>Incorrect Card Number - Please Retry</Verbiage>
151 <Error>Real error message</Error>
152 <TotalAmount>3.88</TotalAmount>
156 <description>Test Product 1</description>
157 <quantity>1</quantity>
159 <subtotal>3.10</subtotal>
167 <description>Test Product 2</description>
168 <quantity>1</quantity>
170 <subtotal>0.20</subtotal>
177 <description>Test Product 3</description>
178 <quantity>1</quantity>
180 <subtotal>0.33</subtotal>
187 <description>Canadian GST Charged</description>
188 <quantity>1</quantity>
190 <subtotal>0.25</subtotal>
193 <flag>{CALCULATED}</flag>
197 <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>