2e15eb2a064af957ea0c78085d845a097897d429
[Business-OnlinePayment-vSecureProcessing.git] / t / t_transaction_decline.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use POSIX qw(strftime);
6 use Test::More;
7 use Business::OnlinePayment;
8 require "t/lib/test_account.pl";
9
10 my %opts = test_account('card');
11
12 if (!$opts{'gid'} || !$opts{'appid'}) {
13   plan skip_all => "no test credentials provided; fill out t/lib/test_account.pl to test communication with the gateway.",
14   1;
15   exit(0);
16 }
17
18 plan tests => 2;
19 my %content = (
20     appid          => $opts{'appid'},
21     action         => 'Normal Authorization',
22     description    => 'Business::OnlinePayment visa test',
23     card_number    => '4111111111111112', # trigger failure
24     cvv2           => '111',
25     expiration     => expiration_date(),
26     amount         => '24.42',
27     name           => 'Murphy Law',
28     email          => 'fake@acme.com',
29     address        => '123 Anystreet',
30     zip            => '84058',
31 );
32
33 my $tx = new Business::OnlinePayment( 'vSecureProcessing', \%opts );
34
35 $tx->content( %content );
36
37 $tx->test_transaction(1);
38
39 $tx->submit;
40
41 is( $tx->is_success, 0, 'declined purchase')
42   or diag('Test transaction should have failed, but succeeded');
43 is( $tx->failure_status, 'nsf', 'failure status' )
44   or diag('Failure status reported as '.$tx->failure_status);
45
46 1;