5 use POSIX qw(strftime);
8 use Business::OnlinePayment;
11 "to test set environment variables:"
12 . " (required) PNP_ACCOUNT and PNP_PASSWORD";
16 && $ENV{"PNP_PASSWORD"} )
18 : ( skip_all => $runinfo )
26 login => $ENV{"PNP_ACCOUNT"},
27 password => $ENV{"PNP_PASSWORD"},
28 action => "Normal Authorization",
30 description => "Business::OnlinePayment::PlugnPay test",
31 card_number => "4111111111111111",
32 expiration => "12/" . strftime( "%y", localtime ),
36 invoice_number => "Test1",
37 email => 'plugnpay@weasellips.com',
38 address => "123 Anystreet",
43 ship_first_name=> "Tofu",
44 ship_last_name => "Beast",
45 ship_address => "456 Anystreet",
46 ship_city => "Somewhere",
52 { # valid card number test
53 my $tx = new Business::OnlinePayment( "PlugnPay", %opts );
54 $tx->content(%content);
57 desc => "valid card_number",
60 authorization => "TSTAUT",
63 order_number => qr/^([0-9]{19})$/,
67 { # invalid card number test
69 my $tx = new Business::OnlinePayment( "PlugnPay", %opts );
70 $tx->content( %content, card_number => "4111111111111112" );
73 desc => "invalid card_number",
78 cvv2_response => undef,
79 order_number => qr/^([0-9]{19})$/,
83 { # dubious faked bad card test
85 my $tx = new Business::OnlinePayment( "PlugnPay", %opts );
86 $tx->content( %content, amount => "1000.01" );
89 desc => "faked bad card",
94 cvv2_response => undef,
95 order_number => qr/^([0-9]{19})$/,
99 { # dubious faked problem test
101 my $tx = new Business::OnlinePayment( "PlugnPay", %opts );
102 $tx->content( %content, amount => "2000.01" );
105 desc => "faked problem",
107 result_code => "P35",
110 cvv2_response => undef,
111 order_number => qr/^([0-9]{19})$/,
116 SKIP: { # refund test
118 skip "credit/refund tests broken", 6;
120 my $tx = new Business::OnlinePayment( "PlugnPay", %opts );
121 $tx->content( %content, 'action' => "Credit",
125 desc => "refund/credit",
126 is_success => 0, # :\
127 result_code => undef,
128 authorization => undef,
130 cvv2_response => undef,
131 order_number => qr/^([0-9]{19})$/,
141 is( $tx->is_success, $o{is_success}, "$o{desc}: " . tx_info($tx) );
142 is( $tx->result_code, $o{result_code}, "result_code(): RESULT" );
143 is( $tx->authorization, $o{authorization}, "authorization() / AUTHCODE" );
144 is( $tx->avs_code, $o{avs_code}, "avs_code() / AVSADDR and AVSZIP" );
145 is( $tx->cvv2_response, $o{cvv2_response}, "cvv2_response() / CVV2MATCH" );
146 like( $tx->order_number, $o{order_number}, "order_number() / PNREF" );
152 no warnings 'uninitialized';
156 "is_success(", $tx->is_success, ")",
157 " order_number(", $tx->order_number, ")",
158 " result_code(", $tx->result_code, ")",
159 " auth_info(", $tx->authorization, ")",
160 " avs_code(", $tx->avs_code, ")",
161 " cvv2_response(", $tx->cvv2_response, ")",