1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl eWay.t'
5 BEGIN { plan tests => 24 };
6 use Business::OnlinePayment::eWay;
9 my ($tx, $txnum, $res);
10 ok($tx = new Business::OnlinePayment("eWay"));
14 login => '87654321', #ewayCustomerID
15 action => 'Normal Authorization',
16 description => 'Business::OnlinePayment test',
18 invoice_number => '100100',
20 card_number => '4646464646464646',
21 expiration => '11/08',
24 ok($tx->test_transaction(1));
26 ok($tx->is_success());
27 ok($tx->error_message(), '00, TRANSACTION APPROVED');
28 ok($tx->authorization(), '123456');
29 ok($res = $tx->server_response());
30 ok($res->{ewayReturnAmount}, 4995);
31 ok($txnum = $res->{ewayTrxnNumber});
35 ok(($tx->server_response->{ewayTrxnNumber} - $txnum) > 0);
37 # a test transaction with cvn
41 login => '87654321', #ewayCustomerID
42 action => 'Normal Authorization',
43 description => 'Business::OnlinePayment test',
45 invoice_number => '100100',
47 card_number => '4646464646464646',
48 expiration => '11/08',
49 option1 => 'first option',
54 ok($tx->is_success());
55 ok($tx->error_message(), '00,TRANSACTION APPROVED');
56 ok($tx->authorization(), '123456');
57 ok($tx->server_response->{ewayTrxnOption1}, 'first option');
59 # a failing transaction
63 login => '87654321', #ewayCustomerID
64 action => 'Normal Authorization',
65 description => 'Business::OnlinePayment test',
67 invoice_number => '100100',
71 email => 'tofu@example.com',
72 address => '1234 Bean Curd Lane, Sydney',
74 card_number => '4646464646464646',
75 expiration => '11/08',
79 ok($tx->test_transaction(0),0);
81 ok($tx->is_success(),0);
82 ok($tx->error_message(), 'Error: Invalid eWAYCustomerID. You have not been billed for this transaction.');
83 ok($tx->authorization(), '123456');