summaryrefslogtreecommitdiff
path: root/t/t_transaction_decline.t
blob: ce21cb7546c781273191b7dea9f3fb5e8f89d335 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl

use strict;
use warnings;
use POSIX qw(strftime);
use Test::More;
use Business::OnlinePayment;
require "t/lib/test_account.pl";

my %opts = test_account_or_skip('card');

if (!$opts{'gid'} || !$opts{'appid'}) {
  plan skip_all => "no test credentials provided; fill out t/lib/test_account.pl to test communication with the gateway.",
  1;
  exit(0);
}

plan tests => 2;
my %content = (
    appid          => $opts{'appid'},
    action         => 'Normal Authorization',
    description    => 'Business::OnlinePayment visa test',
    card_number    => '4111111111111112', # trigger failure
    cvv2           => '111',
    expiration     => expiration_date(),
    amount         => '24.42',
    name           => 'Murphy Law',
    email          => 'fake@acme.com',
    address        => '123 Anystreet',
    zip            => '84058',
);

my $tx = new Business::OnlinePayment( 'vSecureProcessing', \%opts );

$tx->content( %content );

$tx->test_transaction(1);

$tx->submit;

is( $tx->is_success, 0, 'declined purchase')
  or diag('Test transaction should have failed, but succeeded');
is( $tx->failure_status, 'nsf', 'failure status' )
  or diag('Failure status reported as '.$tx->failure_status);

1;