Saving simple test script to repo for now.
[Business-OnlinePayment-vSecureProcessing.git] / test.pl
1 #!/usr/bin/perl -w
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     url =>'dvrotsos2.kattare.com',
13     platform => 'Buypass',
14     gid => '1432479912596791',
15     tid => '01',
16     userid=> 'tom@yiptv.com',
17     port => 443
18 );
19
20
21 my %content = (
22     appid          => 'yiptv',
23     action         => 'Normal Authorization',
24     description    => 'Business::OnlinePayment visa test',
25 #    card_number    => '4007000000027',
26     card_number    => '4111111111111111',
27     cvv2           => '111',
28     expiration     => expiration_date(),
29     amount         => '42.24',
30     name           => 'Murphy Law',
31     email          => 'fake@acme.com',
32     address        => '123 Anystreet',
33     zip            => '84058',
34 );
35
36 main();
37
38 sub main {
39     my $transaction = Business::OnlinePayment->new("vSecureProcessing", %opt);
40     $transaction->content(%content);
41     eval { $transaction->submit(); };
42
43     if ( $@ ) {
44     
45     print "Error: $@\n";
46     
47     } else {
48     
49         if ( $transaction->is_success() ) {
50             print "Card processed successfully: ". $transaction->authorization()."\n";
51         } else {
52             print "Card was rejected: ". $transaction->error_message(). "\n";
53         }
54     
55     }
56 }
57
58
59 sub expiration_date {
60     my($month, $year) = (localtime)[4,5];
61     $month += 1;
62     $year++;       # So we expire next year.
63     $year %= 100;  # y2k?  What's that?
64
65     return sprintf("%02d/%02d", $month, $year);
66 }