1 use constant FIELDS => qw(
2 result_code authorization error_message
3 receipt_number sales_number
5 avs_response cvv2_response
9 use constant RESULTS => (
12 result_code => '2000',
13 authorization => 'T00000',
14 error_message => 'Test Approved',
15 receipt_number => '1096019995.5012',
18 avs_response => undef,
19 cvv2_response => undef,
24 result_code => '98e05',
25 authorization => undef,
26 error_message => 'Real error message',
27 receipt_number => '1096021915.5853',
30 avs_response => undef,
31 cvv2_response => undef,
37 use Test::More tests => 1 + scalar(RESULTS) * (1 + 1 + scalar(FIELDS));
39 BEGIN { use_ok('Business::OnlinePayment') };
43 my $txn = new Business::OnlinePayment 'InternetSecure', merchant_id => '0000';
46 foreach my $results (RESULTS) {
48 $txn->parse_response($xml);
50 is($txn->server_response, $xml, 'server_response');
52 if ($results->{is_success}) {
53 ok($txn->is_success, 'expecting success');
55 ok(!$txn->is_success, 'expecting failure');
60 is($txn->$_, $results->{$_}, $_);
66 <?xml version="1.0" encoding="UTF-8"?>
68 <MerchantNumber>4994</MerchantNumber>
69 <ReceiptNumber>1096019995.5012</ReceiptNumber>
70 <SalesOrderNumber>0</SalesOrderNumber>
71 <xxxName>John Smith</xxxName>
72 <Date>2003/12/17 09:59:58</Date>
73 <CardType>Test Card Number</CardType>
75 <ApprovalCode>T00000</ApprovalCode>
76 <Verbiage>Test Approved</Verbiage>
77 <TotalAmount>3.88</TotalAmount>
81 <description>Test Product 1</description>
82 <quantity>1</quantity>
84 <subtotal>3.10</subtotal>
93 <description>Test Product 2</description>
94 <quantity>1</quantity>
96 <subtotal>0.20</subtotal>
104 <description>Test Product 3</description>
105 <quantity>1</quantity>
107 <subtotal>0.33</subtotal>
115 <description>Canadian GST Charged</description>
116 <quantity>1</quantity>
118 <subtotal>0.25</subtotal>
121 <flag>{CALCULATED}</flag>
125 <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>
130 <?xml version="1.0" encoding="UTF-8"?>
132 <MerchantNumber>4994</MerchantNumber>
133 <ReceiptNumber>1096021915.5853</ReceiptNumber>
134 <SalesOrderNumber>729</SalesOrderNumber>
135 <xxxName>John Smith</xxxName>
136 <Date>2003/12/17 10:31:58</Date>
137 <CardType>VI</CardType>
140 <Verbiage>Incorrect Card Number - Please Retry</Verbiage>
141 <Error>Real error message</Error>
142 <TotalAmount>3.88</TotalAmount>
146 <description>Test Product 1</description>
147 <quantity>1</quantity>
149 <subtotal>3.10</subtotal>
157 <description>Test Product 2</description>
158 <quantity>1</quantity>
160 <subtotal>0.20</subtotal>
167 <description>Test Product 3</description>
168 <quantity>1</quantity>
170 <subtotal>0.33</subtotal>
177 <description>Canadian GST Charged</description>
178 <quantity>1</quantity>
180 <subtotal>0.25</subtotal>
183 <flag>{CALCULATED}</flag>
187 <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>