summaryrefslogtreecommitdiff
path: root/t/Business-OnlinePayment-Exact.t
blob: f51520ae08410f2ac2ad65b0ce27268a5ea300ac (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Business-OnlinePayment-Exact.t'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use Test::More;
use Term::ReadLine;
BEGIN { use_ok('Business::OnlinePayment::Exact') };

#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.

my $term = new Term::ReadLine 'E-Xact Test';
diag("Please enter a test account for E-Xact");
my $prompt = "ExactID: ";
my $login = $term->readline($prompt);
diag("Please enter the password for the test account $login");
$prompt = "Password: ";
my $pass = $term->readline($prompt);
diag("Please enter a valid credit card to test (it will not be charged)");
$prompt = "Card Number: ";
my $card = $term->readline($prompt);
diag("Please enter an expiry date for the card in the form MMYY");
$prompt = "Expiry: ";
my $expiry = $term->readline($prompt);
diag("Please enter a name to match the card");
$prompt = "Name: ";
my $name = $term->readline($prompt);

my $tx;
ok($tx = new Business::OnlinePayment('Exact'), 'New Exact');
ok($tx->content(
    amount => '0.01',
    card_number => $card,
    expiration => $expiry,
    name => $name,
    action => 'normal authorization',
    login => $login,
    password => $pass,
    referer => 'Business::OnlinePayment::Exact testing',
    ),
    'Add Some Content');

my $return = eval { $tx->test_transaction(1) };

my $error = $@;

ok($error, 'enable test mode dies');

ok($tx->submit(), 'submit');

ok($tx->is_success(), 'Success!!!')
  or diag "Card was rejected: ", $tx->error_message();

my $auth;
ok($auth = $tx->authorization(), "authorization $auth");
my $err;
ok($err = $tx->error_message(), "error $err");
my $on;
ok($on = $tx->order_number(), "order number $on");


done_testing();