Initial import
[Business-OnlinePayment-Vanco.git] / t / card_recurring.t
1 #!/usr/bin/perl -w
2
3 use Test::More;
4 require "t/lib/test_account.pl";
5
6 my($login, $password, %opts) = test_account_or_skip();
7 plan tests => 4;
8   
9 use_ok 'Business::OnlinePayment';
10
11 my $tx = Business::OnlinePayment->new("Vanco", %opts);
12 $tx->content(
13     type           => 'VISA',
14     login          => $login,
15     password       => $password,
16     action         => 'Recurring Authorization',
17     description    => 'Business::OnlinePayment visa test',
18     amount         => '49.95',
19     customer_id    => 'tofu',
20     name           => 'Tofu Beast',
21     address        => '123 Anystreet',
22     city           => 'Anywhere',
23     state          => 'UT',
24     zip            => '84058',
25     card_number    => '5105105105105100',
26     expiration     => expiration_date(),
27     interval       => '1 month',
28     start          => tomorrow(),
29     periods        => '3',
30 );
31 $tx->test_transaction(1); # test, dont really charge
32 $tx->submit();
33
34 ok($tx->is_success()) or diag $tx->error_message;
35
36 my $subscription = $tx->order_number();
37 like($subscription, qr/^[0-9]{1,13}$/, "Get order number");
38
39 SKIP: {
40
41   skip "No order number", 1 unless $subscription;
42
43   $tx->content(
44     login        => $login,
45     password     => $password,
46     action       => 'Cancel Recurring Authorization',
47     subscription => $subscription,
48   );
49   $tx->test_transaction(1);
50   $tx->submit();
51   ok($tx->is_success()) or diag $tx->error_message;
52 }