4 require "t/lib/test_account.pl";
6 my($login, $password, %opt) = test_account_or_skip('card');
9 use_ok 'Business::OnlinePayment';
14 password => $password,
15 action => 'Normal Authorization',
16 description => 'Business::OnlinePayment visa test',
17 # card_number => '4007000000027',
18 card_number => '4111111111111111',
20 expiration => expiration_date(),
23 email => 'ippay@weasellips.com',
24 address => '123 Anystreet',
28 country => 'US', # will be forced to USA
34 my $voidable_amount = 0;
36 # valid card number test
38 my $tx = Business::OnlinePayment->new("IPPay", %opt);
39 $tx->content(%content);
42 desc => "valid card_number",
45 error_message => 'APPROVED',
46 authorization => qr/TEST\d{2}/,
47 # avs_code => 'U', # so rather pointless :\
48 avs_code => 'Y', # so very pointless :\
49 cvv2_response => 'P', # ...
51 $voidable = $tx->order_number if $tx->is_success;
52 $voidable_auth = $tx->authorization if $tx->is_success;
53 $voidable_amount = $content{amount} if $tx->is_success;
56 # invalid card number test
58 my $tx = Business::OnlinePayment->new("IPPay", %opt);
59 $tx->content(%content, card_number => "4111111111111112" );
62 desc => "invalid card_number",
64 result_code => '900', #'912' with old jetpay gw
65 error_message => 'Invalid card number. ', #'INVALID CARD NUMBER' w/old gw
66 authorization => qr/^$/,
67 avs_code => '', # so rather pointless :\
68 cvv2_response => '', # ...
72 # authorization only test
74 my $tx = Business::OnlinePayment->new("IPPay", %opt);
75 $tx->content(%content, action => 'authorization only', amount => '3.00' );
78 desc => "authorization only",
81 error_message => 'APPROVED',
82 authorization => qr/TEST\d{2}/,
83 # avs_code => 'U', # so rather pointless :\
84 avs_code => 'Y', # so very pointless :\
85 cvv2_response => 'P', # ...
87 $postable = $tx->order_number if $tx->is_success;
88 $postable_auth = $tx->authorization if $tx->is_success;
89 $postable_amount = $content{amount} if $tx->is_success;
92 # authorization void test
94 #XXX void is returning "The transaction type is not a valid transaction type."
95 # with current IPPay. did something change about the API, is this broken?
96 skip 'Reverse Authorization not currently working (against test account?)', 7;
98 my $tx = Business::OnlinePayment->new("IPPay", %opt);
99 $tx->content(%content, action => 'authorization only', amount => '3.00' );
100 $tx->test_transaction(1);
103 if ($tx->is_success) {
104 my $void_tx = Business::OnlinePayment->new("IPPay", %opt );
106 $tx->content(%content, action => 'reverse authorization',
107 order_number => $tx->order_number );
110 desc => "reverse authorization",
112 result_code => '000',
113 error_message => 'APPROVED',
114 authorization => qr/TEST\d{2}/,
115 avs_code => '', # so rather pointless :\
116 cvv2_response => '', # ...
124 # post authorization test
126 my $tx = new Business::OnlinePayment( "IPPay", %opt );
127 $tx->content( %content, 'action' => "post authorization",
128 'amount' => $postable_amount, # not required
129 'order_number' => $postable,
133 desc => "post authorization",
135 result_code => '000',
136 error_message => 'APPROVED',
137 authorization => qr/^$postable_auth$/,
145 my $tx = new Business::OnlinePayment( "IPPay", %opt );
146 $tx->content( %content, 'action' => "Void",
147 'order_number' => $voidable,
148 'authorization' => $voidable_auth,
154 result_code => '000',
155 error_message => 'VOID PROCESSED',
156 authorization => qr/^$voidable_auth$/,
164 my $tx = new Business::OnlinePayment( "IPPay", %opt );
165 $tx->content( %content, 'action' => "credit");
170 result_code => '000',
171 error_message => 'RETURN ACCEPTED',
172 authorization => qr/\d{6}/,
183 $tx->test_transaction(1);
186 is( $tx->is_success, $o{is_success}, "$o{desc}: " . tx_info($tx) );
187 is( $tx->result_code, $o{result_code}, "result_code(): RESULT" );
188 is( $tx->error_message, $o{error_message}, "error_message() / RESPMSG" );
189 like( $tx->authorization, $o{authorization}, "authorization() / AUTHCODE" );
190 is( $tx->avs_code, $o{avs_code}, "avs_code() / AVSADDR and AVSZIP" );
191 is( $tx->cvv2_response, $o{cvv2_response}, "cvv2_response() / CVV2MATCH" );
192 like( $tx->order_number, qr/^\w{18}/, "order_number() / PNREF" );
198 no warnings 'uninitialized';
202 "is_success(", $tx->is_success, ")",
203 " order_number(", $tx->order_number, ")",
204 " error_message(", $tx->error_message, ")",
205 " result_code(", $tx->result_code, ")",
206 " auth_info(", $tx->authorization, ")",
207 " avs_code(", $tx->avs_code, ")",
208 " cvv2_response(", $tx->cvv2_response, ")",