0.03, cvv2 not required for all transactions (+add test, update MANIFEST), RT#32782
[Business-OnlinePayment-vSecureProcessing.git] / t / transaction_nocvv.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use POSIX qw(strftime);
6 use Test::More;
7 use Business::OnlinePayment;
8 require "t/lib/test_account.pl";
9
10 my %opts = test_account('card');
11
12 if (!$opts{'login'} || !$opts{'password'}) {
13   plan skip_all => "no test credentials provided; fill out t/lib/test_account.pl to test communication with the gateway.",
14   1;
15   exit(0);
16 }
17
18 plan tests => 2;
19
20 ###
21 # Purchase
22 ###
23 my %content = (
24     login          => delete($opts{'login'}),
25     password       => delete($opts{'password'}),
26     action         => 'Normal Authorization',
27     description    => 'Business::OnlinePayment visa test',
28     card_number    => '4111111111111111',
29     expiration     => expiration_date(),
30     amount         => '24.42',
31     name           => 'Murphy Law',
32     email          => 'fake@acme.com',
33     address        => '123 Anystreet',
34     zip            => '84058',
35 );
36
37 my $tx = new Business::OnlinePayment( 'vSecureProcessing', %opts );
38
39 $tx->content( %content );
40
41 $tx->test_transaction(1);
42
43 $tx->submit;
44
45 is( $tx->is_success, 1, 'purchase' )
46   or diag('Gateway error: '. $tx->error_message);
47
48 ###
49 # Refund
50 ###
51 my $auth = $tx->authorization;
52 $tx = new Business::OnlinePayment( 'vSecureProcessing', %opts );
53 $tx->content( %content,
54               action => 'Credit',
55               authorization => $auth );
56 $tx->test_transaction(1);
57
58 $tx->submit;
59
60 is( $tx->is_success, 1, 'refund' )
61   or diag('Gateway error: '. $tx->error_message);
62
63 1;