unbreak this code
[Business-OnlinePayment-vSecureProcessing.git] / test.pl
1 #!/usr/bin/perl -w -d
2
3 #
4 # Make sure to copy Business::OnlinePayment::vSecureProcessing into its
5 # proper system directory (aka /usr/share/perl5/Business/Onlinepayment)
6 #
7
8 use strict;
9 use Business::OnlinePayment;
10
11 my %opt = (
12     server =>'dvrotsos2.kattare.com',
13     platform => 'Buypass',
14     gid => '1432479912596791',
15     tid => '01',
16     userid=> 'tom@yiptv.com',
17     port => 443,
18     env => 'test'
19 );
20
21
22 my %content = (
23     appid          => 'yiptv',
24     action         => 'Normal Authorization',
25     description    => 'Business::OnlinePayment visa test',
26 #    card_number    => '4007000000027',
27     card_number    => '4111111111111111',
28     cvv2           => '111',
29     expiration     => expiration_date(),
30     amount         => '42.24',
31     name           => 'Murphy Law',
32     email          => 'fake@acme.com',
33     address        => '123 Anystreet',
34     zip            => '84058',
35 );
36
37 main();
38
39 sub main {
40     my $transaction = Business::OnlinePayment->new("vSecureProcessing", %opt);
41     #$transaction->server('localhost');
42     #$transaction->path('/cgi-bin/test.cgi');
43     $transaction->content(%content);
44     $DB::single = 1;
45     eval { $transaction->submit(); };
46
47     if ( $@ ) {
48     
49     print "Error: $@\n";
50     
51     } else {
52     
53         if ( $transaction->is_success() ) {
54             print "Card processed successfully: ". $transaction->authorization()."\n";
55         } else {
56             print "Card was rejected: ". $transaction->error_message(). "\n";
57         }
58     
59     }
60 }
61
62
63 sub expiration_date {
64     my($month, $year) = (localtime)[4,5];
65     $month += 1;
66     $year++;       # So we expire next year.
67     $year %= 100;  # y2k?  What's that?
68
69     return sprintf("%02d/%02d", $month, $year);
70 }