summaryrefslogtreecommitdiff
path: root/t/eWay.t
blob: f604c4a4591205ed6e5ec2689c0b4f53577c5e4f (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl eWay.t'

use Test;
BEGIN { plan tests => 24 };
use Business::OnlinePayment::eWay;

# a test transaction
my ($tx, $txnum, $res);
ok($tx = new Business::OnlinePayment("eWay"));
ok(
    $tx->content(
        type           => 'CC',
        login          => '87654321', #ewayCustomerID
        action         => 'Normal Authorization',
        description    => 'Business::OnlinePayment test',
        amount         => '49.95',
        invoice_number => '100100',
        name           => 'Tofu Beast',
        card_number    => '4646464646464646',
        expiration     => '11/08',
    )
);
ok($tx->test_transaction(1));
ok($tx->submit());
ok($tx->is_success());
ok($tx->error_message(), '00, TRANSACTION APPROVED');
ok($tx->authorization(), '123456');
ok($res = $tx->server_response());
ok($res->{ewayReturnAmount}, 4995);
ok($txnum = $res->{ewayTrxnNumber});

#resubmit test
ok($tx->submit());
ok(($tx->server_response->{ewayTrxnNumber} - $txnum) > 0);

# a test transaction with cvn
ok(
    $tx->content(
        type           => 'CC',
        login          => '87654321', #ewayCustomerID
        action         => 'Normal Authorization',
        description    => 'Business::OnlinePayment test',
        amount         => '49.95',
        invoice_number => '100100',
        name           => 'Tofu Beast',
        card_number    => '4646464646464646',
        expiration     => '11/08',
	option1        => 'first option',
	cvv2           => '123',
    )
);
ok($tx->submit());
ok($tx->is_success());
ok($tx->error_message(), '00,TRANSACTION APPROVED');
ok($tx->authorization(), '123456');
ok($tx->server_response->{ewayTrxnOption1}, 'first option');

# a failing transaction
ok(
    $tx->content(
        type           => 'CC',
        login          => '87654321', #ewayCustomerID
        action         => 'Normal Authorization',
        description    => 'Business::OnlinePayment test',
        amount         => '49.95',
        invoice_number => '100100',
        name           => 'Tofu Beast',
        first_name     => 'Tofu',
        last_name      => 'Beast',
        email          => 'tofu@example.com',
        address        => '1234 Bean Curd Lane, Sydney',
        zip            => '2034',
        card_number    => '4646464646464646',
        expiration     => '11/08',
	cvv2           => '123',
    )
);
ok($tx->test_transaction(0),0);
ok($tx->submit());
ok($tx->is_success(),0);
ok($tx->error_message(), 'Error: Invalid eWAYCustomerID. You have not been billed for this transaction.');
ok($tx->authorization(), '123456');