5 use POSIX qw(strftime);
8 use Business::OnlinePayment;
11 "to test set environment variables:"
12 . " (required) PFPRO_VENDOR PFPRO_USER PFPRO_PWD and CLIENTCERTID (for X-VPS-VIT-CLIENT-CERTIFICATION-ID); "
13 . " (optional) PFPRO_PARTNER PFPRO_CERT_PATH";
16 ( $ENV{"PFPRO_USER"} && $ENV{"PFPRO_VENDOR"} && $ENV{"PFPRO_PWD"} )
18 : ( skip_all => $runinfo )
23 "vendor" => $ENV{PFPRO_VENDOR},
24 "partner" => $ENV{PFPRO_PARTNER} || "verisign",
25 "client_certification_id" => $ENV{CLIENTCERTID},
29 login => $ENV{"PFPRO_USER"},
30 password => $ENV{"PFPRO_PWD"},
31 action => "Normal Authorization",
33 description => "Business::OnlinePayment::PayflowPro test",
34 card_number => "4111111111111111",
36 expiration => "12/" . strftime( "%y", localtime ),
40 email => 'ivan-payflowpro@420.am',
41 address => "123 Anystreet",
48 { # valid card number test
49 my $tx = new Business::OnlinePayment( "PayflowPro", %opts );
50 $tx->content(%content);
53 desc => "valid card_number",
56 error_message => "Approved",
57 authorization => "010101",
63 { # invalid card number test
65 my $tx = new Business::OnlinePayment( "PayflowPro", %opts );
66 $tx->content( %content, card_number => "4111111111111112" );
69 desc => "invalid card_number",
72 error_message => "Invalid account number",
73 authorization => undef,
75 cvv2_response => undef,
80 SKIP: { # avs_code() / AVSZIP and AVSADDR tests
82 skip "AVS tests broken", 28;
84 my $tx = new Business::OnlinePayment( "PayflowPro", %opts );
86 # IF first 3 chars of STREET <= 334 and >= 666 THEN AVSADDR == "N"
87 $tx->content( %content, "address" => "500 Any street" );
90 desc => "AVSADDR=N,AVSZIP=Y",
93 error_message => "Under review by Fraud Service",
94 authorization => "010101",
99 # IF first 3 chars of STREET >= 667 THEN AVSADDR == "X" (and AVSZIP="X")
100 $tx = new Business::OnlinePayment( "PayflowPro", %opts );
101 $tx->content( %content, "address" => "700 Any street" );
104 desc => "AVSADDR=X,AVSZIP=X",
107 error_message => "Approved",
108 authorization => "010101",
110 cvv2_response => "Y",
113 # # IF ZIP <= 50001 and >= 99999 THEN AVSZIP == "N"
114 $tx = new Business::OnlinePayment( "PayflowPro", %opts );
115 $tx->content( %content, "zip" => "99999" );
118 desc => "AVSADDR=Y,AVSZIP=N",
121 error_message => "Under review by Fraud Service",
122 authorization => "010101",
124 cvv2_response => "Y",
127 # Both AVSADDR and AVSZIP == "N"
128 $tx = new Business::OnlinePayment( "PayflowPro", %opts );
129 $tx->content( %content, "address" => "500 Any street", "zip" => "99999" );
132 desc => "AVSADDR=N,AVSZIP=N",
135 error_message => "Under review by Fraud Service",
136 authorization => "010101",
138 cvv2_response => "Y",
142 SKIP: { # cvv2_response() / CVV2MATCH
144 skip "CVV2 tests broken", 14;
146 my $tx = new Business::OnlinePayment( "PayflowPro", %opts );
148 # IF CVV2 >= 301 and <= 600 THEN CVV2MATCH == "N"
149 $tx->content( %content, "cvv2" => "301" );
155 error_message => "Under review by Fraud Service",
156 authorization => "010101",
158 cvv2_response => "N",
161 # IF CVV2 >= 601 THEN CVV2MATCH == "X"
162 $tx = new Business::OnlinePayment( "PayflowPro", %opts );
163 $tx->content( %content, "cvv2" => "601" );
169 error_message => "Under review by Fraud Service",
170 authorization => "010101",
172 cvv2_response => "X",
180 $tx->test_transaction(1);
183 is( $tx->is_success, $o{is_success}, "$o{desc}: " . tx_info($tx) );
184 is( $tx->result_code, $o{result_code}, "result_code(): RESULT" );
185 is( $tx->error_message, $o{error_message}, "error_message() / RESPMSG" );
186 is( $tx->authorization, $o{authorization}, "authorization() / AUTHCODE" );
187 is( $tx->avs_code, $o{avs_code}, "avs_code() / AVSADDR and AVSZIP" );
188 is( $tx->cvv2_response, $o{cvv2_response}, "cvv2_response() / CVV2MATCH" );
189 like( $tx->order_number, qr/^\w{12}/, "order_number() / PNREF" );
195 no warnings 'uninitialized';
199 "is_success(", $tx->is_success, ")",
200 " order_number(", $tx->order_number, ")",
201 " error_message(", $tx->error_message, ")",
202 " result_code(", $tx->result_code, ")",
203 " auth_info(", $tx->authorization, ")",
204 " avs_code(", $tx->avs_code, ")",
205 " cvv2_response(", $tx->cvv2_response, ")",