fix expired card
[Business-OnlinePayment-CardFortress.git] / t / transaction.t
1 use Test::More tests => 4;
2 use File::Slurp;
3 use Business::OnlinePayment;
4
5 my @opt = (
6   'CardFortress',
7     'gateway' => 'IPPay',
8     'gateway_login' => 'TESTMERCHANT',
9     'gateway_password' => '',,
10 );
11
12 my $tx = new Business::OnlinePayment(@opt);
13
14 $tx->test_transaction(1);
15
16 $tx->content(
17     type           => 'VISA',
18     login          => 'user',
19     password       => 'secret',
20     action         => 'Normal Authorization',
21     description    => 'Business::OnlinePayment test',
22     amount         => '49.95',
23     customer_id    => 'tfb',
24
25     #have to specify both for now... maybe some auto-transforming later
26     name           => 'Tofu Beast',
27     first_name     => 'Tofu',
28     last_name      => 'Beast',
29
30     address        => '123 Anystreet',
31     city           => 'Anywhere',
32     state          => 'UT',
33     zip            => '84058',
34     card_number    => '4007000000027',
35     expiration     => '09/22',
36     cvv2           => '1234', #optional (not stored)
37 );
38 $tx->submit();
39
40 ok($tx->is_success, 'Transaction successful');
41 warn $tx->error_message."\n" unless $tx->is_success;
42
43 #use Data::Dumper; warn Dumper($tx);
44
45 my $token = $tx->card_token;
46 ok(length($token), 'Token returned');
47
48
49 SKIP: {
50   my $private_key = read_file('t/private_key.txt') or skip 'no private key', 2;
51
52   like( $private_key, qr/-----BEGIN RSA PRIVATE KEY-----/, 'private key good' );
53
54   my $rx = new Business::OnlinePayment( @opt,
55                                         'private_key' => $private_key,
56                                       );
57
58   $rx->test_transaction(1);
59
60   $rx->content(
61       type           => 'VISA',
62       login          => 'user',
63       password       => 'secret',
64       action         => 'Normal Authorization',
65       description    => 'Business::OnlinePayment test',
66       amount         => '12.95',
67       #card_token     => $token
68       card_number     => $token,
69   );
70   $rx->submit();
71
72   ok($rx->is_success, 'Token transaction successful');
73
74   #use Data::Dumper; warn Dumper($rx);
75
76 }
77