version 0.01
[Business-OnlinePayment-FirstDataGlobalGateway.git] / 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
9 my $login = $ENV{BOP_TEST_LOGIN};
10 my $password = $ENV{BOP_TEST_PASSWORD};
11 if (!$login) {
12   plan skip_all => "no test credentials provided; set BOP_TEST_LOGIN and BOP_TEST_PASSWORD to test communication with the gateway.",
13   1;
14   exit(0);
15 }
16
17 plan tests => 2;
18 my %content = (
19   login    => $login,
20   password => $password,
21   action         => "Normal Authorization",
22   type           => "CC",
23   description    => "Business::OnlinePayment::FirstDataGlobalGateway test",
24   card_number    => '4111111111111111',
25   cvv2           => '123',
26   expiration     => '12/20',
27   amount         => '5521.00', # trigger error 521
28   first_name     => 'Tofu',
29   last_name      => 'Beast',
30   address        => '1234 Soybean Ln.',
31   city           => 'Soyville',
32   state          => 'CA', #where else?
33   zip            => '54545',
34 );
35
36 my $tx = new Business::OnlinePayment( 'FirstDataGlobalGateway' );
37
38 $tx->content( %content );
39
40 $tx->test_transaction(1);
41
42 $tx->submit;
43
44 is( $tx->is_success, 0, 'declined purchase')
45   or diag('Test transaction should have failed, but succeeded');
46 is( $tx->failure_status, 'nsf', 'failure status' )
47   or diag('Failure status reported as '.$tx->failure_status);
48
49 1;