README
1NAME
2 PayflowPro - Library for accessing PayPal's Payflow Pro HTTP interface
3
4SYNOPSIS
5 use PayflowPro qw(pfpro);
6 my $data = {
7 USER=>'MyUserId',
8 VENDOR=>'MyVendorId',
9 PARTNER=>'MyPartnerId',
10 PWD=>'MyPassword',
11
12 AMT=> '42.24',
13 TAXAMT=>'0.00', # no tax charged, but specifying it lowers cost
14 INVNUM=>$$,
15 DESC=>"Test invoice $$",
16 COMMENT1=>"Comment 1 $$",
17 COMMENT2=>"Comment 2 $$",
18 CUSTCODE=>$$ . 'a' . $$,
19
20 TRXTYPE=>'S', # sale
21 TENDER=>'C', # credit card
22
23 # Commercial Card additional info
24 PONUM=>$$.'-'.$$,
25 SHIPTOZIP=>'20850', # for AmEx Level 2
26 DESC4=>'FRT0.00', # for AmEx Level 2
27
28 # verisign tracking info
29 STREET => '123 AnyStreet',
30 CITY => 'Anytown',
31 COUNTRY => 'us',
32 FIRSTNAME => 'Firsty',
33 LASTNAME => 'Lasty',
34 STATE => 'md',
35 ZIP => '20850',
36
37 ACCT => '5555555555554444',
38 EXPDATE => '1009',
39 CVV2 => '123',
40 };
41
42 my $res = pfpro($data);
43
44 if ($res->{RESULT} == 0) {
45 print "Woohooo! We charged the card!\n";
46 }
47
48DESCRIPTION
49 Interface to HTTP gateway for PayPal's Payflow Pro service. Implements
50 the pfpro() function to simplify replacing the old PFProAPI perl module.
51
52 Methods implemented are:
53
54 pftestmode($testmode)
55 Set test mode on or off. Test mode means it uses the testing server
56 rather than the live one. Default mode is live ($testmode == 0).
57
58 Returns true.
59
60 pfdebug($mode)
61 Set debug mode on or off. Turns on some warn statements to track
62 progress of the request. Default mode is off ($mode == 0).
63
64 Returns current setting.
65
66 pfpro($data)
67 Process request as per hash ref $data. See PFPro API docs on name/value
68 pairs to pass in. All we do here is convert them into an HTTP request,
69 then convert the response back into a hash and return the reference to
70 it. This emulates the pfpro() function in the original API.
71
72 Additionally, we honor a "TIMEOUT" value which specifies the number of
73 seconds to wait for a response from the server. The default is 30
74 seconds. Normally for production you should not need to alter this
75 value. The test servers are slower so may need larger timeout. The
76 minimum value that PayPal will accept is 5 seconds.
77
78 It uses the time and the "INVNUM" (Invoice Number) field of input to
79 generate the unique request ID, so don't try to process the same INVNUM
80 more than once per second. "INVNUM" is a required datum to be passed
81 into this function. Bad things happen if you don't.
82
83 Upon communications failure, it fakes up a response message with
84 "RESULT" = -1. Internally, the library tries several times to process
85 the transaction if there are network problems before returning this
86 failure mode.
87
88 To validate the SSL certificate, you need a ca-bundle file with a list
89 of valid certificate signers. Then set the environment variable
90 HTTPS_CA_FILE to point to that file. This assumes you are using the
91 "Crypt::SSLeay" SSL driver for LWP (should be the default). In your
92 code, add some lines like this:
93
94 # CA cert peer verification
95 $ENV{HTTPS_CA_FILE} = '/path/to/ca-bundle.crt';
96
97 It is likely to be in /etc/ssl or /usr/local/etc/ssl or /usr/local/certs
98 depending on your OS version. The script mk-ca-bundle.pl included with
99 this module can be used to create the bundle file based on the current
100 Mozilla certificate data if you don't already have such a file. One is
101 also included in the source for this module, but it may be out of date
102 so it is recommended that you run the mk-ca-bundle.pl script to ensure
103 you have the latest information. This program is copied from the CURL
104 project "https://github.com/bagder/curl/blob/master/lib/mk-ca-bundle.pl"
105
106 If you do not set HTTPS_CA_FILE it will still work, but you don't get
107 the certificate validation to ensure you're speaking to the authentic
108 site. You will also get in the HTTPS response headers
109
110 Client-SSL-Warning: Peer certificate not verified
111
112 but you'll only see that if you turn on debugging.
113
114AUTHOR
115 Vivek Khera <"vivek@khera.org">
116
117LICENSE
118 This module is Copyright 2007-2009 Khera Communications, Inc. It is
119 licensed under the same terms as Perl itself.
120
121