0.05: patch from Randall Whitman to fix follow-up transactions
[Business-OnlinePayment-eSelectPlus.git] / t / capture_ca.t
1 #!/usr/bin/perl -w
2
3 # B:OP eSelectPlus Canadian Pre-Auth & Capture
4 # Portions loosely adapted from B:OP AuthorizeNet via B:OP Exact
5
6 use Test::More;
7 plan tests => 5;
8
9 use_ok 'Business::OnlinePayment';
10
11 my $amount;
12 $amount = '1.00';
13 my $order_id;
14 $order_id = 'B:OP' . time;  # Caller generates order_id; cf. capture-us.t;
15
16 my $tx = new Business::OnlinePayment("eSelectPlus");
17 $tx->content(
18     login          => 'moot',
19     password       => 'moot',
20     action         => 'Authorization Only',
21     order_id       => $order_id,
22 #    description    => 'Business::OnlinePayment visa test',
23     amount         => $amount,
24     currency       => 'CAD',
25 #    name           => 'eSelectPlus Tester',
26     card_number    => '4242424242424242',
27     expiration     => '12/14',
28 );
29
30 $tx->test_transaction(1); # test, dont really charge
31
32 $tx->submit();
33
34 my $flag =
35     ok($tx->is_success(), 'Pre-Auth') or diag $tx->error_message;
36
37 # note: long
38 # use Data::Dumper;
39 # diag(Dumper $tx);
40
41 my $auth = $tx->authorization;             # TransID
42 my $order_number = $tx->order_number;
43 #$order_id = $tx->order_id;
44 like $auth, qr/\d+/, 'authorization';
45 like $order_number, qr/\d+/, 'order number';
46 #ok $order_id, 'order ID';
47
48 #warn "auth: $auth\n";
49 #warn "order_number: $order_number\n";
50 SKIP: {
51     skip 'Need pre-auth success, in order to test capture', 1
52         unless $flag;
53
54 my $settle_tx = new Business::OnlinePayment("eSelectPlus");
55 $settle_tx->content(
56     login          => 'moot',
57     password       => 'moot',
58     action         => 'Post Authorization',
59 #    description    => 'Business::OnlinePayment visa test',
60     currency       => 'CAD',
61     amount         => $amount,
62     authorization  => $auth,
63 #    order_id       => $order_id,
64     order_number   => $order_number,
65 #    name           => 'eSelectPlus Tester',
66 #    card_number    => '4242424242424242',
67 #    expiration     => '12/12',
68 );
69
70 $settle_tx->test_transaction(1); # test, dont really charge
71 $settle_tx->submit();
72
73 ok($settle_tx->is_success(), 'Capture') || diag $settle_tx->error_message;
74 }  # /skip or test