0754ac3356ae3db19f6c118ceb5ac95711966ab7
[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 tests => 8;
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 => '9.95',
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 ok($tx->submit(), 'submit');
49 ok($tx->is_success(), 'Success!!!');
50 my $auth;
51 ok($auth = $tx->authorization(), "authorization $auth");
52 my $err;
53 ok($err = $tx->error_message(), "error $err");
54 my $on;
55 ok($on = $tx->order_number(), "order number $on");
56
57