]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/support-scripts/test-scripts/payment_test.pl
Fix empty statuses filter
[working/Evergreen.git] / Open-ILS / src / support-scripts / test-scripts / payment_test.pl
1 #!/usr/bin/perl
2
3 #----------------------------------------------------------------
4 # Simple example
5 #----------------------------------------------------------------
6
7 require '../oils_header.pl';
8 use strict; use warnings;
9
10 use Getopt::Long;
11
12 sub usage {
13     return <<END_OF_USAGE;
14 $0 [-h] --login=UserName --password==MyPass [OPTIONS] [Transaction data]
15
16 Required Arguments:
17     -l --login      Assigned by your processor API (specified in -t)
18     -p --password   Assigned by your processor API (specified in -t)
19     -o --org-unit   What library/branch is making this payment (numeric)
20
21 Options:
22     -t --target       Payment processor (default PayPal)
23     -s --signature    A "long password" required by PayPal in leiu of certificates
24     -r --server       Use a specific server with a processor (AuthorizeNet)
25     -c --config_file  opensrf_core.xml file (default /openils/conf/opensrf_core.xml)
26
27 Transaction data:
28     -a --amount    Monetary value, no dollar sign, default a random value under 25.00
29     -i --id        Patron ID#, default 5 (for no reason)
30     -n --number    Credit card number to be charged
31     -x --expires   Date (MM-YYYY) of card expiration, default 12-2014
32
33 Example:
34
35 $0  --login=seller_1254418209_biz_api1.example.org \\
36     --password=1254618222 \\
37     --signature=AiPC9xjkCyDFQXbSkoZcgqH3hpacAVPVw5GcZgNKVA9SGKcbrqLuhLks \\
38     --amount=32.75 \\
39     --id=13042
40
41 END_OF_USAGE
42 }
43
44 ### DEFAULTS
45 my $config    = '/openils/conf/opensrf_core.xml';
46 my $processor = 'PayPal';
47 my $number    = '4123000011112228';
48 my $expires   = '12-2014';
49 my $id        = 5;
50
51 ### Empties
52 my ($login, $password, $ou, $signature, $help, $amount, $server);
53
54 GetOptions(
55     'config_file=s' => \$config,
56     'target=s'      => \$processor,
57     'org-unit=i'    => \$ou,
58     'login=s'       => \$login,
59     'password=s'    => \$password,
60     's|signature=s' => \$signature,
61     'amount=f'      => \$amount,
62     'id=i'          => \$id,
63     'number=s'      => \$number,
64     'x|expires=s'   => \$expires,
65     'r|server=s'    => \$server,
66     'help|?'        => \$help,
67 );
68
69 $help and print usage and exit;
70
71 unless ($login and $processor and $password and $ou) {
72     print usage;
73     exit;
74 }
75 osrf_connect($config);
76
77 $amount or $amount = int(rand(25)) . '.' . sprintf("%02d", int(rand(99)));
78
79 print <<END_OF_DUMP;
80 Attempting transaction:
81 \{
82     processor => $processor,
83         login => $login,
84      password => $password,
85     signature => $signature,
86            ou => $ou,
87        amount => $amount,
88            cc => $number,
89    expiration => $expires,
90        server => $server,
91      testmode => 1,
92     patron_id => $id,
93       country => US,
94   description => test transaction processid $$
95 \}
96
97 END_OF_DUMP
98
99 my( $user, $evt ) = simplereq('open-ils.credit', 'open-ils.credit.process', 
100 {
101     processor => $processor,
102         login => $login,
103      password => $password,
104     signature => $signature,
105            ou => $ou,
106        amount => $amount,
107            cc => $number,
108    expiration => $expires,
109        server => $server,
110      testmode => 1,
111     patron_id => $id,
112       country => "US",
113   description => "test transaction processid $$"
114 }
115 );
116 oils_event_die($evt); # this user was not found / not all methods return events..
117 print debug($user);
118