- Update for production URL
[Business-OnlinePayment-vSecureProcessing.git] / t / transaction.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     cvv2           => '111',
30     expiration     => expiration_date(),
31     amount         => '24.42',
32     name           => 'Murphy Law',
33     email          => 'fake@acme.com',
34     address        => '123 Anystreet',
35     zip            => '84058',
36 );
37
38 my $tx = new Business::OnlinePayment( 'vSecureProcessing', %opts );
39
40 $tx->content( %content );
41
42 $tx->test_transaction(1);
43
44 $tx->submit;
45
46 is( $tx->is_success, 1, 'purchase' )
47   or diag('Gateway error: '. $tx->error_message);
48
49 ###
50 # Refund
51 ###
52 my $auth = $tx->authorization;
53 $tx = new Business::OnlinePayment( 'vSecureProcessing', %opts );
54 $tx->content( %content,
55               action => 'Credit',
56               authorization => $auth );
57 $tx->test_transaction(1);
58
59 $tx->submit;
60
61 is( $tx->is_success, 1, 'refund' )
62   or diag('Gateway error: '. $tx->error_message);
63
64 1;