5 use POSIX qw(strftime);
8 use Business::OnlinePayment;
11 "to test set environment variables:"
12 . " (required) ELAVON_ACCOUNT, ELAVON_USERID, and ELAVON_PASSWORD"
13 . " (optional) DEBUG, ELAVON_SERVER, and ELAVON_PATH";
16 ( $ENV{"ELAVON_ACCOUNT"}
17 && $ENV{"ELAVON_USERID"}
18 && $ENV{"ELAVON_PASSWORD"} )
20 : ( skip_all => $runinfo )
24 "debug" => $ENV{"DEBUG"} || 0,
25 "default_ssl_user_id" => $ENV{"ELAVON_USERID"},
26 "default_ssl_salestax" => "0.00",
27 "default_ssl_customer_code" => "TESTCUSTOMER",
31 login => $ENV{"ELAVON_ACCOUNT"},
32 password => $ENV{"ELAVON_PASSWORD"},
33 action => "Normal Authorization",
35 description => "Business::OnlinePayment::ElavonVirtualMerchant test",
36 card_number => "4111111111111111",
38 expiration => "12/" . strftime( "%y", localtime ),
40 invoice_number => "Test1",
43 email => 'nobody@example.com',
44 address => "123 Anystreet",
51 { # valid card number test
52 my $tx = new Business::OnlinePayment( "ElavonVirtualMerchant", %opts );
53 $tx->content(%content);
56 desc => "valid card_number",
59 authorization => "123456",
62 order_number => "00000000-0000-0000-0000-00000000000",
66 { # invalid card number test
68 my $tx = new Business::OnlinePayment( "ElavonVirtualMerchant", %opts );
69 $tx->content( %content, card_number => "4111111111111112" );
72 desc => "invalid card_number",
75 authorization => undef,
77 cvv2_response => undef,
78 order_number => undef,
83 SKIP: { # avs_code() / AVSZIP and AVSADDR tests
85 skip "AVS tests broken", 18;
87 my $tx = new Business::OnlinePayment( "ElavonVirtualMerchant", %opts );
89 $tx->content( %content, "address" => "500 Any street" );
92 desc => "AVSADDR=N,AVSZIP=Y",
95 authorization => "123456",
98 order_number => "00000000-0000-0000-0000-00000000000",
101 $tx = new Business::OnlinePayment( "ElavonVirtualMerchant", %opts );
102 $tx->content( %content, "zip" => "99999" );
105 desc => "AVSADDR=Y,AVSZIP=N",
108 authorization => "123456",
110 cvv2_response => "P",
111 order_number => "00000000-0000-0000-0000-00000000000",
114 $tx = new Business::OnlinePayment( "ElavonVirtualMerchant", %opts );
115 $tx->content( %content, "address" => "500 Any street", "zip" => "99999" );
118 desc => "AVSADDR=N,AVSZIP=N",
121 authorization => "123456",
123 cvv2_response => "P",
124 order_number => "00000000-0000-0000-0000-00000000000",
128 SKIP: { # cvv2_response() / CVV2MATCH
130 skip "CVV2 tests broken", 6;
132 my $tx = new Business::OnlinePayment( "ElavonVirtualMerchant", %opts );
134 $tx->content( %content, "cvv2" => "301" );
137 desc => "wrong cvv2",
140 authorization => "123456",
142 cvv2_response => "N",
143 order_number => "00000000-0000-0000-0000-00000000000",
148 SKIP: { # refund test
150 skip "credit/refund tests broken", 6;
152 my $tx = new Business::OnlinePayment( "ElavonVirtualMerchant", %opts );
153 $tx->content( %content, 'action' => "Credit",
154 'card_number' => "4444333322221111",
158 desc => "refund/credit",
161 authorization => undef,
163 cvv2_response => undef,
164 order_number => "00000000-0000-0000-0000-00000000000",
172 $tx->test_transaction(1);
173 $tx->server($ENV{"ELAVON_SERVER"}) if defined($ENV{"ELAVON_SERVER"});
174 $tx->path($ENV{"ELAVON_PATH"}) if defined($ENV{"ELAVON_PATH"});
177 is( $tx->is_success, $o{is_success}, "$o{desc}: " . tx_info($tx) );
178 is( $tx->result_code, $o{result_code}, "result_code(): RESULT" );
179 is( $tx->authorization, $o{authorization}, "authorization() / AUTHCODE" );
180 is( $tx->avs_code, $o{avs_code}, "avs_code() / AVSADDR and AVSZIP" );
181 is( $tx->cvv2_response, $o{cvv2_response}, "cvv2_response() / CVV2MATCH" );
182 is( $tx->order_number, $o{order_number}, "order_number() / PNREF" );
188 no warnings 'uninitialized';
192 "is_success(", $tx->is_success, ")",
193 " order_number(", $tx->order_number, ")",
194 " result_code(", $tx->result_code, ")",
195 " auth_info(", $tx->authorization, ")",
196 " avs_code(", $tx->avs_code, ")",
197 " cvv2_response(", $tx->cvv2_response, ")",