7c4f08a3d10c194a15620fbe9e9a9d934cd253e0
[Business-OnlinePayment-Bambora.git] / t / 052-action-fail.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More;
5
6 use lib 't';
7 use TestFixtures;
8 use Business::OnlinePayment;
9 use Data::Dumper;
10     $Data::Dumper::Sortkeys = 1;
11     $Data::Dumper::Indent = 1;
12
13 my $merchant_id = $ENV{BAMBORA_MERCHANT_ID};
14 my $api_key     = $ENV{BAMBORA_API_KEY};
15
16 SKIP: {
17   skip 'Missing env vars BAMBORA_MERCHANT_ID and BAMBORA_API_KEY', 6
18     unless $merchant_id && $api_key;
19
20   #
21   # Attempt with invalid action name
22   # Expect fail
23   #
24
25   my %content_fail = (
26     common_content(),
27
28     login => $merchant_id,
29     password => $api_key,
30
31     action => 'Norml Authorzatin',
32     amount => '24.95',
33   );
34
35   my ( $tr_fail, $response_fail ) = make_api_request( \%content_fail );
36
37   inspect_transaction(
38     $tr_fail,
39     { is_success => 0 },
40     [qw/ error_message /],
41   );
42
43   ok( $tr_fail->error_message =~ /action is unsupported/i,
44       'Saw expected error_message'
45   );
46 }
47
48 done_testing;