reduced price of test transaction to minimum, exercising new test_transaction method...
[Business-OnlinePayment-Exact.git] / t / Business-OnlinePayment-Exact.t
1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl Business-OnlinePayment-Exact.t'
3
4 #########################
5
6 # change 'tests => 1' to 'tests => last_test_to_print';
7
8 use Test::More;
9 use Term::ReadLine;
10 BEGIN { use_ok('Business::OnlinePayment::Exact') };
11
12 #########################
13
14 # Insert your test code below, the Test::More module is use()ed here so read
15 # its man page ( perldoc Test::More ) for help writing this test script.
16
17 my $term = new Term::ReadLine 'E-Xact Test';
18 diag("Please enter a test account for E-Xact");
19 my $prompt = "ExactID: ";
20 my $login = $term->readline($prompt);
21 diag("Please enter the password for the test account $login");
22 $prompt = "Password: ";
23 my $pass = $term->readline($prompt);
24 diag("Please enter a valid credit card to test (it will not be charged)");
25 $prompt = "Card Number: ";
26 my $card = $term->readline($prompt);
27 diag("Please enter an expiry date for the card in the form MMYY");
28 $prompt = "Expiry: ";
29 my $expiry = $term->readline($prompt);
30 diag("Please enter a name to match the card");
31 $prompt = "Name: ";
32 my $name = $term->readline($prompt);
33
34 my $tx;
35 ok($tx = new Business::OnlinePayment('Exact'), 'New Exact');
36 ok($tx->content(
37     amount => '0.01',
38     card_number => $card,
39     expiration => $expiry,
40     name => $name,
41     action => 'normal authorization',
42     login => $login,
43     password => $pass,
44     referer => 'Business::OnlinePayment::Exact testing',
45     ),
46     'Add Some Content');
47
48 my $return = eval { $tx->test_transaction(1) };
49
50 my $error = $@;
51
52 ok($error, 'enable test mode dies');
53
54 ok($tx->submit(), 'submit');
55
56 ok($tx->is_success(), 'Success!!!')
57   or diag "Card was rejected: ", $tx->error_message();
58
59 my $auth;
60 ok($auth = $tx->authorization(), "authorization $auth");
61 my $err;
62 ok($err = $tx->error_message(), "error $err");
63 my $on;
64 ok($on = $tx->order_number(), "order number $on");
65
66
67 done_testing();