debian package for 3.24 release
[Business-OnlinePayment-AuthorizeNet.git] / t / mixed_operation.t
1 #!/usr/bin/perl -w
2
3 BEGIN { push @INC, "t/lib" };
4
5 use Test::More;
6
7 require "t/lib/test_account.pl";
8
9
10 my($arblogin, $arbpassword) = test_account_or_skip('arb');
11 my($aimlogin, $aimpassword) = test_account_or_skip();
12 plan tests => 9;
13   
14 use_ok 'Business::OnlinePayment';
15 my $tx = Business::OnlinePayment->new("AuthorizeNet", 
16                                       fraud_detect => '_Fake',
17                                       fraud_detect_faked_result => '0',
18                                       fraud_detect_faked_score => '2',
19                                       maximum_fraud_score => '1',
20                                      );
21 $tx->content(
22     type           => 'VISA',
23     login          => $arblogin,
24     password       => $arbpassword,
25     action         => 'Recurring Authorization',
26     description    => 'Business::OnlinePayment::ARB mixed test',
27     amount         => '1.05',
28     first_name     => 'Tofu',
29     last_name      => 'Beast',
30     card_number    => '4007000000027',
31     expiration     => expiration_date(),
32     interval       => '1 month',
33     start          => tomorrow(),
34     periods        => '6',
35 );
36 $tx->test_transaction(1); # test, dont really charge
37 $tx->submit();
38
39 ok(!$tx->is_success()) or diag "ARB Fraud detection unexpectedly did not fail.";
40
41 $tx->fraud_detect_faked_result(1);
42 $tx->submit();
43
44 ok(!$tx->is_success()) or diag "ARB Fraud detection unexpectedly did not deny.";
45
46 $tx->fraud_detect_faked_score(0);
47 $tx->submit();
48
49 ok($tx->is_success()) or diag $tx->error_message();
50
51 my $subscription = $tx->order_number();
52 like($subscription, qr/^[0-9]{1,13}$/, "Get order number");
53
54 SKIP: {
55
56   skip "No order number", 1 unless $subscription;
57
58   $tx->content(
59     login        => $arblogin,
60     password     => $arbpassword,
61     action       => 'Cancel Recurring Authorization',
62     subscription => $subscription,
63   );
64   $tx->test_transaction(1);
65   $tx->submit();
66   ok($tx->is_success()) or diag $tx->error_message;
67 }
68
69 $tx->server('test.authorize.net');
70 $tx->path('/gateway/transact.dll');
71 $tx->content(
72     type           => 'VISA',
73     login          => $aimlogin,
74     password       => $aimpassword,
75     action         => 'Normal Authorization',
76     description    => 'Business::OnlinePayment::AIM mixed test',
77     amount         => '1.06',
78     first_name     => 'Tofu',
79     last_name      => 'Beast',
80     card_number    => '4007000000027',
81     expiration     => expiration_date(),
82 );
83 $tx->test_transaction(1); #test, don't really charge
84 $tx->fraud_detect_faked_result(0);
85 $tx->fraud_detect_faked_score(2);
86 $tx->submit();
87
88 ok(!$tx->is_success()) or diag "AIM Fraud detection unexpectedly did not fail.";
89
90 $tx->submit();
91 $tx->fraud_detect_faked_result(1);
92
93 ok(!$tx->is_success()) or diag "AIM Fraud detection unexpectedly did not deny.";
94
95 $tx->fraud_detect_faked_score(0);
96 $tx->submit();
97 ok($tx->is_success()) or diag $tx->error_message;
98