Saving current state of code, and adding test script i'm using. just put the new...
[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     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->content(%content);
42     eval { $transaction->submit(); };
43
44     if ( $@ ) {
45     
46     print "Error: $@\n";
47     
48     } else {
49     
50         if ( $transaction->is_success() ) {
51             print "Card processed successfully: ". $transaction->authorization()."\n";
52         } else {
53             print "Card was rejected: ". $transaction->error_message(). "\n";
54         }
55     
56     }
57 }
58
59
60 sub expiration_date {
61     my($month, $year) = (localtime)[4,5];
62     $month += 1;
63     $year++;       # So we expire next year.
64     $year %= 100;  # y2k?  What's that?
65
66     return sprintf("%02d/%02d", $month, $year);
67 }