File Coverage

blib/lib/Business/PayPal.pm
Criterion Covered Total %
statement 73 85 85.8
branch 25 52 48.0
condition n/a
subroutine 11 11 100.0
pod 5 6 83.3
total 114 154 74.0


line stmt bran cond sub pod time code
1             package Business::PayPal;
2              
3 1     1   13518 use 5.6.1;
  1         3  
4 1     1   3 use strict;
  1         1  
  1         16  
5 1     1   3 use warnings;
  1         3  
  1         40  
6              
7             our $VERSION = '0.18';
8              
9 1     1   588 use Net::SSLeay 1.14;
  1         11483  
  1         44  
10 1     1   5 use Digest::MD5 qw(md5_hex);
  1         1  
  1         951  
11              
12             our $Cert;
13             our $Certcontent;
14              
15             my @certificates;
16             # added to 0.12 on 2014.04.19
17             push @certificates, <<'CERT';
18             -----BEGIN CERTIFICATE-----
19             MIIGCDCCBPCgAwIBAgIQCDTkU9Q6aFcjr/uxM85FfDANBgkqhkiG9w0BAQUFADCB
20             ujELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
21             ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug
22             YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykwNjE0MDIGA1UEAxMr
23             VmVyaVNpZ24gQ2xhc3MgMyBFeHRlbmRlZCBWYWxpZGF0aW9uIFNTTCBDQTAeFw0x
24             NDA0MTUwMDAwMDBaFw0xNTA0MDIyMzU5NTlaMIIBCTETMBEGCysGAQQBgjc8AgED
25             EwJVUzEZMBcGCysGAQQBgjc8AgECEwhEZWxhd2FyZTEdMBsGA1UEDxMUUHJpdmF0
26             ZSBPcmdhbml6YXRpb24xEDAOBgNVBAUTBzMwMTQyNjcxCzAJBgNVBAYTAlVTMRMw
27             EQYDVQQRFAo5NTEzMS0yMDIxMRMwEQYDVQQIEwpDYWxpZm9ybmlhMREwDwYDVQQH
28             FAhTYW4gSm9zZTEWMBQGA1UECRQNMjIxMSBOIDFzdCBTdDEVMBMGA1UEChQMUGF5
29             UGFsLCBJbmMuMRQwEgYDVQQLFAtDRE4gU3VwcG9ydDEXMBUGA1UEAxQOd3d3LnBh
30             eXBhbC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC+rkZNmW5t
31             bDVLiDI4u9zQCZXQmuQ2558KsPLX0jBiAx+txvRtEIT3eRu8dMCo44L+1AqTLj1L
32             EiStrV9d7RzJHG8Te+LBJU5GX087LlrLwVq0gs+to2XohjO17R14mafH1foQLvsR
33             TiNYBpaHcXVRc4wP9Mp8j5EleRPcsPDeCAcBC2TMV2oShmIXPl25Yj1Yeypu9qYw
34             QQL87GRyM9XVP2ttl/PBYb84O6tBR9TCA9c7WVed4aEq1njog1093apdF/2U1uV6
35             7wJjxqPGLVszCIv1pQO0/vIdq79enrh4OSAraGFP5JnyqsJNS0jLaMIQP/qausVq
36             U48i89fJ7aTVAgMBAAGjggG2MIIBsjBnBgNVHREEYDBegg53d3cucGF5cGFsLmNv
37             bYISaGlzdG9yeS5wYXlwYWwuY29tggx0LnBheXBhbC5jb22CDGMucGF5cGFsLmNv
38             bYIOdG1zLnBheXBhbC5jb22CDHRtcy5lYmF5LmNvbTAJBgNVHRMEAjAAMA4GA1Ud
39             DwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwZgYDVR0g
40             BF8wXTBbBgtghkgBhvhFAQcXBjBMMCMGCCsGAQUFBwIBFhdodHRwczovL2Quc3lt
41             Y2IuY29tL2NwczAlBggrBgEFBQcCAjAZGhdodHRwczovL2Quc3ltY2IuY29tL3Jw
42             YTAfBgNVHSMEGDAWgBT8ilC6nrklWntVhU+VAGOP6VhrQzArBgNVHR8EJDAiMCCg
43             HqAchhpodHRwOi8vc2Euc3ltY2IuY29tL3NhLmNybDBXBggrBgEFBQcBAQRLMEkw
44             HwYIKwYBBQUHMAGGE2h0dHA6Ly9zYS5zeW1jZC5jb20wJgYIKwYBBQUHMAKGGmh0
45             dHA6Ly9zYS5zeW1jYi5jb20vc2EuY3J0MA0GCSqGSIb3DQEBBQUAA4IBAQB2CKtk
46             9vQL5IG9WbI+pPz1A3UEWWq1/hI0KgScic3L4TxsIDnU6m8nNH9iHEVyETnARaoq
47             NVy2BuMIp48Ir4CyEM6lKFscSVUR62sqgMEJ7YJySMoZi+U0lDxQJndrGmO6b2PR
48             WO0rHbenbgQlmcOUA5DsD0yTgzWG43CEDTzOr06AStORP1UzLx9nhy8JokHAEEos
49             xIigb5Ms7zjSYcfs8zd9yTKlXB5IDoVsRyp/xjBewvYu3eNNrP/vSCbHUXRHMkYL
50             zXoKXVvFje0XvN4JvOmTqXyFnIimg7zW5R8FEN+yT6LFlwCLV8cN58dXV4d9E59c
51             XPfzzQCJDYWaonDa
52             -----END CERTIFICATE-----
53             CERT
54              
55             # added to 0.14 on 2015.04.01
56             push @certificates, <<'CERT';
57             -----BEGIN CERTIFICATE-----
58             MIIGvjCCBaagAwIBAgIQWK6vRldyZAffQNciCpwKZzANBgkqhkiG9w0BAQUFADB3
59             MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAd
60             BgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMTH1N5bWFudGVj
61             IENsYXNzIDMgRVYgU1NMIENBIC0gRzIwHhcNMTUwMzEyMDAwMDAwWhcNMTUxMDMx
62             MjM1OTU5WjCCAQkxEzARBgsrBgEEAYI3PAIBAxMCVVMxGTAXBgsrBgEEAYI3PAIB
63             AhMIRGVsYXdhcmUxHTAbBgNVBA8TFFByaXZhdGUgT3JnYW5pemF0aW9uMRAwDgYD
64             VQQFEwczMDE0MjY3MQswCQYDVQQGEwJVUzETMBEGA1UEERQKOTUxMzEtMjAyMTET
65             MBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxQIU2FuIEpvc2UxFjAUBgNVBAkU
66             DTIyMTEgTiAxc3QgU3QxFTATBgNVBAoUDFBheVBhbCwgSW5jLjEUMBIGA1UECxQL
67             Q0ROIFN1cHBvcnQxFzAVBgNVBAMUDnd3dy5wYXlwYWwuY29tMIIBIjANBgkqhkiG
68             9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqko1WvJvFcFF1v4GUgNuMBHrNVqFClp72D76
69             Waua/+BGR1RVPT09jHXoV36FQcdRo1+c1fZmR5T+LCK28gY9UxsKPYm3M6eD9dHS
70             SzbbqEwQHmSNUSyAzq24f6lNAyFd+/+dSVbv6Ufc87WFIlN9GrXkDTDh7DI+aihS
71             UVZeaiPk+imBgFlwbuFYsEhrtBDNMcxUzC+5+T5w5YXF9S2WEkxQqhygZ+5IJl7h
72             g0tuoM8GE9+7rKckYor30ha4m40RCp7jDQhSnEsejGznblDNUBoOo0XaINI+5LHG
73             fZonCVvo5XaerZHiABl+eABYXMN2i2xRVQ2RG++hZvxZF+ZESQIDAQABo4ICsDCC
74             AqwwWAYDVR0RBFEwT4IMYy5wYXlwYWwuY29tgg1jNi5wYXlwYWwuY29tghJoaXN0
75             b3J5LnBheXBhbC5jb22CDHQucGF5cGFsLmNvbYIOd3d3LnBheXBhbC5jb20wCQYD
76             VR0TBAIwADAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsG
77             AQUFBwMCMGYGA1UdIARfMF0wWwYLYIZIAYb4RQEHFwYwTDAjBggrBgEFBQcCARYX
78             aHR0cHM6Ly9kLnN5bWNiLmNvbS9jcHMwJQYIKwYBBQUHAgIwGRoXaHR0cHM6Ly9k
79             LnN5bWNiLmNvbS9ycGEwHwYDVR0jBBgwFoAUS/ot5O4zMuLfDQGhhtOgOzq5rK4w
80             KwYDVR0fBCQwIjAgoB6gHIYaaHR0cDovL3N0LnN5bWNiLmNvbS9zdC5jcmwwVwYI
81             KwYBBQUHAQEESzBJMB8GCCsGAQUFBzABhhNodHRwOi8vc3Quc3ltY2QuY29tMCYG
82             CCsGAQUFBzAChhpodHRwOi8vc3Quc3ltY2IuY29tL3N0LmNydDCCAQUGCisGAQQB
83             1nkCBAIEgfYEgfMA8QB2AKS5CZC0GFgUh7sTosxncAo8NZgE+RvfuON3zQ7IDdwQ
84             AAABTBAIx7wAAAQDAEcwRQIgUYscJgszMFrBx1zbtdYs7DsNnDyeiq570NWMnm0/
85             2R0CIQCe+byVBqzuGe1SvVzZg2sDM/juENHN6afDVITPPlOwfgB3AFYUBpov18Ls
86             0/XhvUSyPsdGdrm8mRFcwO+UmFXWidDdAAABTBAIyawAAAQDAEgwRgIhANRNmPtV
87             ATw4FYVuGXESDyBU6d07gkcUsEUeVY0dD95WAiEAqBns/Pr3MX8RD1bLGriQduHO
88             tJ1FJKvWpvaSEbb6VRUwDQYJKoZIhvcNAQEFBQADggEBAJj9TEgvOyp7fqaAIUK5
89             bWkRbGCsSbUxNW4yxZxNjXwIvoI89IQwGydZkqRX7//fiKEW7iMFWN6nQXxrHKfQ
90             46DQdN8WgnLf2CqJZN3kwQrJdhsV+DJrplMJXN96QFrRXgM/BCC4e2h2dryJYsDE
91             2JKKUuU6s2DhZMJ/qnyrrFTnmTQeYwIwWdcC6txdZl3VZv+EbCZEHQDUpFvdQVmR
92             kasn+9reKda5JGTuBl22OHsF+5WWHL2nYM2Fnv1sRFOWzQfQFcIVcWbl1OdUV6SQ
93             cQRRhHyM6jwWBsVJxP5H/1byHeXZTvDRl6EaU5RRCoFZEaqWPD24X+8SRkkgkV9Y
94             n64=
95             -----END CERTIFICATE-----
96             CERT
97              
98             push @certificates, <<'CERT';
99             -----BEGIN CERTIFICATE-----
100             MIIG0jCCBbqgAwIBAgIQB2T3ui0CFx+cSA3+e2W7bzANBgkqhkiG9w0BAQUFADB3
101             MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAd
102             BgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMTH1N5bWFudGVj
103             IENsYXNzIDMgRVYgU1NMIENBIC0gRzIwHhcNMTUwNDIyMDAwMDAwWhcNMTUxMDMx
104             MjM1OTU5WjCCAQkxEzARBgsrBgEEAYI3PAIBAxMCVVMxGTAXBgsrBgEEAYI3PAIB
105             AhMIRGVsYXdhcmUxHTAbBgNVBA8TFFByaXZhdGUgT3JnYW5pemF0aW9uMRAwDgYD
106             VQQFEwczMDE0MjY3MQswCQYDVQQGEwJVUzETMBEGA1UEERQKOTUxMzEtMjAyMTET
107             MBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxQIU2FuIEpvc2UxFjAUBgNVBAkU
108             DTIyMTEgTiAxc3QgU3QxFTATBgNVBAoUDFBheVBhbCwgSW5jLjEUMBIGA1UECxQL
109             Q0ROIFN1cHBvcnQxFzAVBgNVBAMUDnd3dy5wYXlwYWwuY29tMIIBIjANBgkqhkiG
110             9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwPisQKaRu+4RFWHn4T5QUeeoQ0H5U6KXTdXp
111             EfjvdCDhAJQjDA4qwHw514zBcgrVIV/c22yUsr+RBnBYZ/rdlCiZGPT0kVYal9ts
112             XJyBFfvS3q2XMAzBg5I171geP7G46VbMBXfVkAoH1zND7O7AcNjb7z44oJgELvym
113             almQzTrfmN7RPjosfGJrQzCnMATT0Up94yIt1Imv5yCavWrIY1ImcuSjUMxTHaRy
114             D3jtnp2aBC+jhfoZYJ8a2uM6+j5h0gYpaEsLq5ilFWpvsHoKa1ZQit2/p/yE9+6U
115             oCAuJHYJRicHMNv3EdZMt7xVi5MKFCX7H+ZOmHHuZidDeL0gUQIDAQABo4ICxDCC
116             AsAwbgYDVR0RBGcwZYIMYy5wYXlwYWwuY29tgg1jNi5wYXlwYWwuY29tghRkZXZl
117             bG9wZXIucGF5cGFsLmNvbYISaGlzdG9yeS5wYXlwYWwuY29tggx0LnBheXBhbC5j
118             b22CDnd3dy5wYXlwYWwuY29tMAkGA1UdEwQCMAAwDgYDVR0PAQH/BAQDAgWgMB0G
119             A1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBmBgNVHSAEXzBdMFsGC2CGSAGG
120             +EUBBxcGMEwwIwYIKwYBBQUHAgEWF2h0dHBzOi8vZC5zeW1jYi5jb20vY3BzMCUG
121             CCsGAQUFBwICMBkaF2h0dHBzOi8vZC5zeW1jYi5jb20vcnBhMB8GA1UdIwQYMBaA
122             FEv6LeTuMzLi3w0BoYbToDs6uayuMCsGA1UdHwQkMCIwIKAeoByGGmh0dHA6Ly9z
123             dC5zeW1jYi5jb20vc3QuY3JsMFcGCCsGAQUFBwEBBEswSTAfBggrBgEFBQcwAYYT
124             aHR0cDovL3N0LnN5bWNkLmNvbTAmBggrBgEFBQcwAoYaaHR0cDovL3N0LnN5bWNi
125             LmNvbS9zdC5jcnQwggEDBgorBgEEAdZ5AgQCBIH0BIHxAO8AdgCkuQmQtBhYFIe7
126             E6LMZ3AKPDWYBPkb37jjd80OyA3cEAAAAUzjP5slAAAEAwBHMEUCIFvjUjcbhLRI
127             0c2PUzTVMSItRsGRsoZqdz433/3MnXilAiEA3paAILaCCR6OSp/H7js1R4IxsdCx
128             Y/d9UhzFxUFevxoAdQBWFAaaL9fC7NP14b1Esj7HRna5vJkRXMDvlJhV1onQ3QAA
129             AUzjP5waAAAEAwBGMEQCICcbFi1Lzw4R+ptZUnTBHJGRSTUUjptEljDAVNZmI7Xi
130             AiAM/Gly9qoF18kqaPIRZIibSoh+JnYYFuTpec2vNi12XzANBgkqhkiG9w0BAQUF
131             AAOCAQEAoUACGhsYuAMEt+420Y+q97KpGBGfRDw+5mJFuER1e3p69KAsFZRBufJb
132             BjJCbY3yWgqnNTvF+klDvok499g8I51+3fo/wdROX+fyeor+0W8Nv7Q/tNQ3J5gZ
133             CaoNT4yYOdT2wyswOzHLaQJhNNcTlbxy0lEh3f3S04MnhpB4jVCakRvORlU0FD2R
134             G4oHGhNJqthJc54f5yvlvhXi5ac9hHd8n+G86dS6QI/QWvkg2EXm0/6huSLP2Bvt
135             z6CSbS+tefVGVei0hvFvlM/ZVkaWGyJvQXli9MnQd1Fh+CkhGgOJSaGJ2/PM47zz
136             Gp3OLqh4jMEbNLobkIdLkZ2F9jYMDw==
137             -----END CERTIFICATE-----
138             CERT
139              
140             # added to 0.17 on 2015.10.02
141             push @certificates, <<'CERT';
142             -----BEGIN CERTIFICATE-----
143             MIIHTTCCBjWgAwIBAgIQf8Ays2+fnhrB7auXE2UpNTANBgkqhkiG9w0BAQsFADB3
144             MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAd
145             BgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMTH1N5bWFudGVj
146             IENsYXNzIDMgRVYgU1NMIENBIC0gRzMwHhcNMTUwOTAyMDAwMDAwWhcNMTcxMDMw
147             MjM1OTU5WjCCAQkxEzARBgsrBgEEAYI3PAIBAxMCVVMxGTAXBgsrBgEEAYI3PAIB
148             AgwIRGVsYXdhcmUxHTAbBgNVBA8TFFByaXZhdGUgT3JnYW5pemF0aW9uMRAwDgYD
149             VQQFEwczMDE0MjY3MQswCQYDVQQGEwJVUzETMBEGA1UEEQwKOTUxMzEtMjAyMTET
150             MBEGA1UECAwKQ2FsaWZvcm5pYTERMA8GA1UEBwwIU2FuIEpvc2UxFjAUBgNVBAkM
151             DTIyMTEgTiAxc3QgU3QxFTATBgNVBAoMDFBheVBhbCwgSW5jLjEUMBIGA1UECwwL
152             Q0ROIFN1cHBvcnQxFzAVBgNVBAMMDnd3dy5wYXlwYWwuY29tMIIBIjANBgkqhkiG
153             9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3G8cYNqcMviCcnf9UYBZa9vFajZNbopJg951
154             H5DLtlO5PEK5HLVTr1CIjeiof6amHw0h1FxvDDN+OhlY2V0B0wji0llUqcerTcb/
155             BaYLv7YREjTq1yPOPmAhvv7N22Ucr2KWPnO9CAVu6jMe1VnCcaXlIs7QF6XSrHzc
156             6ui6cBaL5ZBsfKC0eXNQXiaIo1/4R2NzUmIfxuLq9fYhQF3yGfJzBSU572/PoITp
157             pO9XrGwlzXx81DQkIAfdDQlFvZip7oPV8osFoik3DPRiF8InV53jA+OrAp36yf+B
158             FqsqlJs+BLd4L+l9djsihbZFn0JVNirLSQrA+7gPW4XRhyYb6QIDAQABo4IDPzCC
159             AzswbgYDVR0RBGcwZYIMYy5wYXlwYWwuY29tgg1jNi5wYXlwYWwuY29tghRkZXZl
160             bG9wZXIucGF5cGFsLmNvbYISaGlzdG9yeS5wYXlwYWwuY29tggx0LnBheXBhbC5j
161             b22CDnd3dy5wYXlwYWwuY29tMAkGA1UdEwQCMAAwDgYDVR0PAQH/BAQDAgWgMB0G
162             A1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBmBgNVHSAEXzBdMFsGC2CGSAGG
163             +EUBBxcGMEwwIwYIKwYBBQUHAgEWF2h0dHBzOi8vZC5zeW1jYi5jb20vY3BzMCUG
164             CCsGAQUFBwICMBkaF2h0dHBzOi8vZC5zeW1jYi5jb20vcnBhMB8GA1UdIwQYMBaA
165             FAFZq+fdOgtZpmRj1s8gB1fVkedqMCsGA1UdHwQkMCIwIKAeoByGGmh0dHA6Ly9z
166             ci5zeW1jYi5jb20vc3IuY3JsMFcGCCsGAQUFBwEBBEswSTAfBggrBgEFBQcwAYYT
167             aHR0cDovL3NyLnN5bWNkLmNvbTAmBggrBgEFBQcwAoYaaHR0cDovL3NyLnN5bWNi
168             LmNvbS9zci5jcnQwggF+BgorBgEEAdZ5AgQCBIIBbgSCAWoBaAB2AKS5CZC0GFgU
169             h7sTosxncAo8NZgE+RvfuON3zQ7IDdwQAAABT5BxKnwAAAQDAEcwRQIhALSBH+ef
170             tqIGyQuTuyGHJ2UFAS1mQGQUHxNt8UuakU9TAiA3Fw34Zr39bP5VYi3NvHkLCj+B
171             kc7VhicRoRhiV1TrjwB2AFYUBpov18Ls0/XhvUSyPsdGdrm8mRFcwO+UmFXWidDd
172             AAABT5BxKtsAAAQDAEcwRQIhAOiqWJCHdJZc+2kog+8uQNVX/1qEZWUuJ0xMkeUU
173             sb/4AiAPE2v5U5jJrIGgCVLdhQe31YNw32iWoU38gAPsaIhftQB2AGj2mPgfZIK+
174             OozuuSgdTPxxUV1nk9RE0QpnrLtPT/vEAAABT5BxKnEAAAQDAEcwRQIhALUKK1wh
175             kGZHnBKN1FyOmFs1SI0MuXeyNrvuDGJ/BD28AiBays0D+G2vJXUVC6SVR5oEJEnL
176             eRiHwSh1XUc3RQYbazANBgkqhkiG9w0BAQsFAAOCAQEAm4EBf+YSO2RRvyX/Gvks
177             jxHsFVvIfKF8y7k3pKqL5RWuH8wub+qg0CKXBK40uMF47mcG4o7cKEjY3Wrxruu6
178             uO8bG23u9Pnzky9I1wXHCElCW5ja/MZ+oKvIxfYLbBtfQ1aLkD73xyP1qMQh+oBw
179             jtn19UGev1qLvOrmyugKDVjcsaP9WD1M3WUcQxPpOJ9Dx3KyGe8qUuOH1GPpWjfr
180             3iHPxRDtcejvdKLWvB/K2lCfef8TXSja+a5ml0ATYNQDRJwmZFzobM/GLrl4modk
181             JdIGuJhwGjvYvVfglJ+dXEFcThb76lJ1/A3p5ieSNpPCjIBAK0To1RS/RRiNWcfI
182             nA==
183             -----END CERTIFICATE-----
184             CERT
185              
186             # added to 0.18 on 2016.08.02
187             push @certificates, <<'CERT';
188             -----BEGIN CERTIFICATE-----
189             MIIHWTCCBkGgAwIBAgIQLNGVEFQ30N5KOSAFavbCfzANBgkqhkiG9w0BAQsFADB3
190             MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAd
191             BgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMTH1N5bWFudGVj
192             IENsYXNzIDMgRVYgU1NMIENBIC0gRzMwHhcNMTYwMjAyMDAwMDAwWhcNMTcxMDMw
193             MjM1OTU5WjCCAQkxEzARBgsrBgEEAYI3PAIBAxMCVVMxGTAXBgsrBgEEAYI3PAIB
194             AgwIRGVsYXdhcmUxHTAbBgNVBA8TFFByaXZhdGUgT3JnYW5pemF0aW9uMRAwDgYD
195             VQQFEwczMDE0MjY3MQswCQYDVQQGEwJVUzETMBEGA1UEEQwKOTUxMzEtMjAyMTET
196             MBEGA1UECAwKQ2FsaWZvcm5pYTERMA8GA1UEBwwIU2FuIEpvc2UxFjAUBgNVBAkM
197             DTIyMTEgTiAxc3QgU3QxFTATBgNVBAoMDFBheVBhbCwgSW5jLjEUMBIGA1UECwwL
198             Q0ROIFN1cHBvcnQxFzAVBgNVBAMMDnd3dy5wYXlwYWwuY29tMIIBIjANBgkqhkiG
199             9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2kPIs6YzXYPAYxRH/Wsivb9Op0MRVesgi+Rh
200             E+7efsbiRTSjol9+SV5RN5pKFfOnvpgbAUQUGPu6cLI5PYdFuLUG6NGxkYQGRk8R
201             +90ma7lNae+aFN19jfKHAtAQXXZQPeyj7XKTYmNKidkvU14V5G6fcD25BBkrlUfB
202             9/HnkxqEiBdAdzC8g1YioT46cPv/gQ44JfAQDYKEZAUEvTCDxQhtJLkZRh47mwJK
203             fm7M3+6yx/GMNu7tYrVUkGdPmhRmjbly9NSbh5SAjDDvLkC0ldGqotXuRI5+doaS
204             6+v1d6JT/6S2eR5tP59+XtexehUAxQFptRAWpYX4/QeEmskUkQIDAQABo4IDSzCC
205             A0cwfAYDVR0RBHUwc4ISaGlzdG9yeS5wYXlwYWwuY29tggx0LnBheXBhbC5jb22C
206             DGMucGF5cGFsLmNvbYINYzYucGF5cGFsLmNvbYIUZGV2ZWxvcGVyLnBheXBhbC5j
207             b22CDHAucGF5cGFsLmNvbYIOd3d3LnBheXBhbC5jb20wCQYDVR0TBAIwADAOBgNV
208             HQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMGYGA1Ud
209             IARfMF0wWwYLYIZIAYb4RQEHFwYwTDAjBggrBgEFBQcCARYXaHR0cHM6Ly9kLnN5
210             bWNiLmNvbS9jcHMwJQYIKwYBBQUHAgIwGRoXaHR0cHM6Ly9kLnN5bWNiLmNvbS9y
211             cGEwHwYDVR0jBBgwFoAUAVmr5906C1mmZGPWzyAHV9WR52owKwYDVR0fBCQwIjAg
212             oB6gHIYaaHR0cDovL3NyLnN5bWNiLmNvbS9zci5jcmwwVwYIKwYBBQUHAQEESzBJ
213             MB8GCCsGAQUFBzABhhNodHRwOi8vc3Iuc3ltY2QuY29tMCYGCCsGAQUFBzAChhpo
214             dHRwOi8vc3Iuc3ltY2IuY29tL3NyLmNydDCCAXwGCisGAQQB1nkCBAIEggFsBIIB
215             aAFmAHYA3esdK3oNT6Ygi4GtgWhwfi6OnQHVXIiNPRHEzbbsvswAAAFSpFZ5PQAA
216             BAMARzBFAiB6j3nYN/CojD81wKOoDOhcUiK0EU32KilH3synHO5XEwIhAM2eM8Ws
217             vGK6rfGe8nJ4fGs9QMmXI3bTnRxcdWSeCem7AHUApLkJkLQYWBSHuxOizGdwCjw1
218             mAT5G9+443fNDsgN3BAAAAFSpFZ5bgAABAMARjBEAiApYKfEn4BLd4uZERNZ9/4e
219             w3NlCcoN9KcCVKesPx7OKwIgEyKaNe98YBdY9b4nw+KcJRzjZZIFJVIu7R53cfO1
220             wv4AdQBo9pj4H2SCvjqM7rkoHUz8cVFdZ5PURNEKZ6y7T0/7xAAAAVKkVnlXAAAE
221             AwBGMEQCIHQpjXQ06MfOV9DjzEnQm2CLPnui8P/lLyZrM6sEZvCNAiAziNOuyunX
222             wsaILVE7FMjg96sY02A0dsW/mGVPps7lJDANBgkqhkiG9w0BAQsFAAOCAQEAS6lk
223             IMx3CzCraVDTf97cfOL7k4T9eKcG6BQDmcDkSu/DXRUqgaG5/9w6r82A8HyPjh1X
224             BWlw0Zr6JZ87V8IxdYV/UQWKQLRnnEp9yaRT/4f/fbS9ObsQH3YmMbLDs2I2zAIB
225             ZdZuwaOv/PAR29XusH8fY//HNR2I2wTXGg8Ztpad6KT9gIqFfHvfSZ8VDSU9IdjN
226             fDlUABWAm1B+nDxoZWlyvHHmmOgw6m4wm5ANFul1hjAWeaR/TlWd20lj7iXUt+dW
227             GN/QMQ3a55rjwNQnA3s2WWuHGPaE/jMG17iiL2O/hUdIvLE9+wA+fWrey5//74xl
228             NeQitYiySDIepHGnng==
229             -----END CERTIFICATE-----
230             CERT
231              
232             # NEXT @certificates comes here
233             # added to 0.17 on 2015.10.02
234             # push @certificates, <<'CERT';
235             # CERT
236              
237             chomp(@certificates);
238              
239             my @cert_contents;
240             push @cert_contents, <<'CERTCONTENT';
241             Subject Name: /1.3.6.1.4.1.311.60.2.1.3=US/1.3.6.1.4.1.311.60.2.1.2=Delaware/businessCategory=Private Organization/serialNumber=3014267/C=US/postalCode=95131-2021/ST=California/L=San Jose/street=2211 N 1st St/O=PayPal, Inc./OU=CDN Support/CN=www.paypal.com
242             Issuer Name: /C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)06/CN=VeriSign Class 3 Extended Validation SSL CA
243             CERTCONTENT
244              
245             push @cert_contents, <<'CERTCONTENT';
246             Subject Name: /1.3.6.1.4.1.311.60.2.1.3=US/1.3.6.1.4.1.311.60.2.1.2=Delaware/businessCategory=Private Organization/serialNumber=3014267/C=US/postalCode=95131-2021/ST=California/L=San Jose/street=2211 N 1st St/O=PayPal, Inc./OU=CDN Support/CN=www.paypal.com
247             Issuer Name: /C=US/O=Symantec Corporation/OU=Symantec Trust Network/CN=Symantec Class 3 EV SSL CA - G2
248             CERTCONTENT
249              
250             # added to 0.17 on 2015.10.02
251             push @cert_contents, <<'CERTCONTENT';
252             Subject Name: /1.3.6.1.4.1.311.60.2.1.3=US/1.3.6.1.4.1.311.60.2.1.2=Delaware/businessCategory=Private Organization/serialNumber=3014267/C=US/postalCode=95131-2021/ST=California/L=San Jose/street=2211 N 1st St/O=PayPal, Inc./OU=CDN Support/CN=www.paypal.com
253             Issuer Name: /C=US/O=Symantec Corporation/OU=Symantec Trust Network/CN=Symantec Class 3 EV SSL CA - G3
254             CERTCONTENT
255              
256              
257             chomp(@cert_contents);
258              
259             # creates new PayPal object. Assigns an id if none is provided.
260             sub new {
261 4     4 1 5399 my $class = shift;
262              
263 4         16 my $self = {
264             id => undef,
265             address => 'https://www.paypal.com/cgi-bin/webscr',
266             check_cert => 1,
267             @_,
268             };
269 4         6 bless $self, $class;
270 4 100       72 $self->{id} = md5_hex(rand()) unless $self->{id};
271              
272 4         8 return $self;
273             }
274              
275             sub check_cert {
276 2     2 0 2030 my ($self, $value) = @_;
277 2         3 $self->{check_cert} = $value;
278 2         3 return;
279             }
280              
281             # returns current PayPal id
282             sub id {
283 2     2 1 821 my ($self) = @_;
284              
285 2         3 return $self->{id};
286             }
287              
288             #creates a PayPal button
289             sub button {
290 3     3 1 275 my $self = shift;
291              
292             my %buttonparam = (
293             cmd => '_ext-enter',
294             redirect_cmd => '_xclick',
295             button_image => qq{},
296             business => undef,
297             item_name => undef,
298             item_number => undef,
299             image_url => undef,
300             no_shipping => 1,
301             return => undef,
302             cancel_return => undef,
303             no_note => 1,
304             undefined_quantity => 0,
305             notify_url => undef,
306             first_name => undef,
307             last_name => undef,
308             shipping => undef,
309             shipping2 => undef,
310             quantity => undef,
311             amount => undef,
312             address1 => undef,
313             address2 => undef,
314             city => undef,
315             state => undef,
316             zip => undef,
317             night_phone_a => undef,
318             night_phone_b => undef,
319             night_phone_c => undef,
320             day_phone_a => undef,
321             day_phone_b => undef,
322             day_phone_c => undef,
323             receiver_email => undef,
324             invoice => undef,
325             currency_code => undef,
326             custom => $self->{id},
327 3         65 @_,
328             );
329 3         5 my $key;
330 3         3 my $form_id = '';
331 3 100       10 if (defined $buttonparam{form_id}) {
332 1         4 $form_id = qq{id="$buttonparam{form_id}"};
333 1         2 delete $buttonparam{form_id};
334             }
335 3         10 my $content = qq{
\n};
336              
337 3         45 foreach my $param (sort keys %buttonparam) {
338 106 100       153 next if not defined $buttonparam{$param};
339 38 100       44 next if $param eq 'button_image';
340 35         67 $content .= qq{\n};
341             }
342 3         10 $content .= "$buttonparam{button_image}\n";
343 3         6 $content .= qq{\n};
344              
345 3         20 return $content;
346             }
347              
348              
349             # takes a reference to a hash of name value pairs, such as from a CGI query
350             # object, which should contain all the name value pairs which have been
351             # posted to the script by PayPal's Instant Payment Notification
352             # posts that data back to PayPal, checking if the ssl certificate matches,
353             # and returns success or failure, and the reason.
354             sub ipnvalidate {
355 3     3 1 881 my ($self, $query) = @_;
356              
357 3         6 $query->{cmd} = '_notify-validate';
358 3         4 my $id = $self->{id};
359 3         8 my ($succ, $reason) = $self->postpaypal($query);
360              
361 3 0       10 return (wantarray ? ($id, $reason) : $id ) if $succ;
    50          
362 3 100       23 return (wantarray ? (undef, $reason) : undef);
363             }
364              
365             # this method should not normally be used unless you need to test, or if
366             # you are overriding the behaviour of ipnvalidate. It takes a reference
367             # to a hash containing the query, posts to PayPal with the data, and returns
368             # success or failure, as well as PayPal's response.
369             sub postpaypal {
370 3     3 1 4 my ($self, $query) = @_;
371              
372 3         5 my $address = $self->{address};
373 3         4 my ($site, $port, $path);
374              
375             #following code splits an url into site, port and path components
376 3         12 my @address = split /:\/\//, $address, 2;
377 3         16 @address = split /(?=\/)/, $address[1], 2;
378 3 50       10 if ($address[0] =~ /:/) {
379 0         0 ($site, $port) = split /:/, $address[0];
380             }
381             else {
382 3         6 ($site, $port) = ($address[0], '443');
383             }
384 3         5 $path = $address[1];
385 3         63 my ($page,
386             $response,
387             $headers,
388             $ppcert,
389             ) = Net::SSLeay::post_https3($site,
390             $port,
391             $path,
392             '',
393             Net::SSLeay::make_form(%$query));
394              
395 3 0       2660030 return (wantarray ? (undef, "No PayPal cert found") : undef)
    50          
396             unless $ppcert;
397              
398 3         95 my $ppx509 = Net::SSLeay::PEM_get_string_X509($ppcert);
399 3         97 my $ppcertcontent =
400             'Subject Name: '
401             . Net::SSLeay::X509_NAME_oneline(
402             Net::SSLeay::X509_get_subject_name($ppcert))
403             . "\nIssuer Name: "
404             . Net::SSLeay::X509_NAME_oneline(
405             Net::SSLeay::X509_get_issuer_name($ppcert))
406             . "\n";
407              
408 3         34 chomp $ppx509;
409 3         6 chomp $ppcertcontent;
410              
411 3         15 my @certs = @certificates;
412 3 50       9 if ($Cert) {
413             # TODO added in 0.12
414 0         0 warn "The global variable \$Cert is deprecated and will be removed soon. Pass a certificate to the constructor using the 'cert' parameter.\n";
415 0         0 push @certs, $Cert;
416             }
417 3         9 my @cert_cont = @cert_contents;
418 3 50       9 if ($Certcontent) {
419             # TODO added in 0.12
420 0         0 warn "The global variable \$Certcontent is deprecated and will be removed soon. Pass a certificate to the constructor using the 'certcontent' parameter.\n";
421 0         0 push @cert_cont, $Certcontent;
422             }
423              
424 3 50       16 if ($self->{addcert}) {
425 0         0 push @certs, $self->{cert};
426             }
427 3 50       9 if ($self->{addcertcontent}) {
428 0         0 push @cert_cont, $self->{certcontent};
429             }
430              
431 3 50       16 if ($self->{cert}) {
432 0         0 @certs = $self->{cert};
433             }
434 3 50       13 if ($self->{certcontent}) {
435 0         0 @cert_cont = $self->{certcontent};
436             }
437              
438 3 100       11 if ($self->{check_cert}) {
439             return (wantarray ? (undef, "PayPal cert failed to match:\n$ppx509") : undef)
440 2 0       5 unless grep {$_ eq $ppx509} @certs;
  10 50       18  
441             return (wantarray ? (undef, "PayPal cert contents failed to match:\n$ppcertcontent") : undef)
442 2 0       4 unless grep { $_ eq $ppcertcontent } @cert_cont;
  6 50       11  
443             }
444 3 50       33 return (wantarray ? (undef, 'PayPal says transaction INVALID') : undef)
    50          
445             if $page eq 'INVALID';
446 0 0         return (wantarray ? (1, 'PayPal says transaction VERIFIED') : 1)
    0          
447             if $page eq 'VERIFIED';
448 0           warn "Bad stuff happened\n$page";
449 0 0         return (wantarray ? (undef, "Bad stuff happened") :undef);
450             }
451              
452              
453              
454             1;
455              
456             =head1 NAME
457              
458             Business::PayPal - Perl extension for automating PayPal transactions
459              
460             =head1 ABSTRACT
461              
462             Business::PayPal makes the automation of PayPal transactions as simple
463             as doing credit card transactions through a regular processor. It includes
464             methods for creating PayPal buttons and for validating the Instant Payment
465             Notification that is sent when PayPal processes a payment.
466              
467             =head1 SYNOPSIS
468              
469             To generate a PayPal button for use on your site
470             Include something like the following in your CGI
471              
472             use Business::PayPal;
473             my $paypal = Business::PayPal->new;
474             my $button = $paypal->button(
475             business => 'dr@dursec.com',
476             item_name => 'CanSecWest Registration Example',
477             return => 'http://www.cansecwest.com/return.cgi',
478             cancel_return => 'http://www.cansecwest.com/cancel.cgi',
479             amount => '1600.00',
480             quantity => 1,
481             notify_url => http://www.cansecwest.com/ipn.cgi
482             );
483             my $id = $paypal->id;
484              
485             Store $id somewhere so we can get it back again later
486              
487             Store current context with $id.
488              
489             Print button to the browser.
490              
491             Note, button is an HTML form, already enclosed in
tags
492              
493              
494              
495             To validate the Instant Payment Notification from PayPal for the
496             button used above include something like the following in your
497             'notify_url' CGI.
498              
499             use CGI;
500             my $query = CGI->new;
501             my %query = $query->Vars;
502             my $id = $query{custom};
503             my $paypal = Business::PayPal->new(id => $id);
504             my ($txnstatus, $reason) = $paypal->ipnvalidate(\%query);
505             die "PayPal failed: $reason" unless $txnstatus;
506             my $money = $query{payment_gross};
507             my $paystatus = $query{payment_status};
508              
509             Check if paystatus eq 'Completed'.
510             Check if $money is the amount you expected.
511             Save payment status information to store as $id.
512              
513              
514             To tell the user if their payment succeeded or not, use something like
515             the following in the CGI pointed to by the 'return' parameter in your
516             PayPal button.
517              
518             use CGI;
519             my $query = CGI->new;
520             my $id = $query{custom};
521              
522             #get payment status from store for $id
523             #return payment status to customer
524              
525             In order to use the sandbox provided by PayPal, you can provide the address of the sandbox
526             in the constructor:
527              
528             my $pp = Business::PayPal->new( address => 'https://www.sandbox.paypal.com/cgi-bin/webscr' );
529              
530             =head1 DESCRIPTION
531              
532             =head2 new()
533              
534             Creates a new Business::PayPal object, it can take the
535             following parameters:
536              
537             =over 2
538              
539             =item id
540              
541             The Business::PayPal object id, if not specified a new
542             id will be created using md5_hex(rand())
543              
544             =item address
545              
546             The address of PayPal's payment server, currently:
547             https://www.paypal.com/cgi-bin/webscr
548              
549             =item cert
550              
551             The x509 certificate for I
, see source for default.
552              
553             =item certcontent
554              
555             The contents of the x509 certificate I, see source for
556             default.
557              
558             =item addcert
559              
560             The x509 certificate for I
.
561             This is added to the default values.
562              
563             =item addcertcontent
564              
565             The contents of the x509 certificate I,
566             This is added to the default values.
567              
568             =back
569              
570             =head2 id()
571              
572             Returns the id for the Business::PayPal object.
573              
574             =head2 button()
575              
576             Returns the HTML for a PayPal button. It takes a large number of
577             parameters, which control the look and function of the button, some
578             of which are required and some of which have defaults. They are
579             as follows:
580              
581             =over 2
582              
583             =item cmd
584              
585             required, defaults to '_ext-enter'
586              
587             This allows the user information to be pre-filled in.
588             You should never need to specify this, as the default should
589             work fine.
590              
591             =item redirect_cmd
592              
593             required, defaults to '_xclick'
594              
595             This allows the user information to be pre-filled in.
596             You should never need to specify this, as the default should
597             work fine.
598              
599             =item button_image
600              
601             required, defaults to:
602              
603             CGI::image_button(-name => 'submit',
604             -src => 'http://images.paypal.com/x-click-but01.gif'
605             -alt => 'Make payments with PayPal',
606             )
607              
608             You may wish to change this if the button is on an https page
609             so as to avoid the browser warnings about insecure content on a
610             secure page.
611              
612             for example use a Bootstrap style button:
613              
614             button_image => '',
615              
616             =item form_id
617              
618             form_id => 'some_id',
619              
620             Adding id="some_id" to the form created. Adding and id will make it easier to locate
621             the form on the page by some JavaScript code.
622              
623             =item business
624              
625             required, no default
626              
627             This is the name of your PayPal account.
628              
629             =item item_name
630              
631             This is the name of the item you are selling.
632              
633             =item item_number
634              
635             This is a numerical id of the item you are selling.
636              
637             =item image_url
638              
639             A URL pointing to a 150 x 50 image which will be displayed
640             instead of the name of your PayPal account.
641              
642             =item no_shipping
643              
644             defaults to 1
645              
646             If set to 1, does not ask customer for shipping info, if
647             set to 0 the customer will be prompted for shipping information.
648              
649             =item return
650              
651             This is the URL to which the customer will return to after
652             they have finished paying.
653              
654             =item cancel_return
655              
656             This is the URL to which the customer will be sent if they cancel
657             before paying.
658              
659             =item no_note
660              
661             defaults to 1
662              
663             If set to 1, does not ask customer for a note with the payment,
664             if set to 0, the customer will be asked to include a note.
665              
666             =item currency_code
667              
668             Currency the payment should be taken in, e.g. EUR, GBP.
669             If not specified payments default to USD.
670              
671             =item address1
672              
673             =item undefined_quantity
674              
675             defaults to 0
676              
677             If set to 0 the quantity defaults to 1, if set to 1 the user
678             can edit the quantity.
679              
680             =item notify_url
681              
682             The URL to which PayPal Instant Payment Notification is sent.
683              
684             =item first_name
685              
686             First name of customer, used to pre-fill PayPal forms.
687              
688             =item last_name
689              
690             Last name of customer, used to pre-fill PayPal forms.
691              
692             =item shipping
693              
694             I don't know, something to do with shipping, please tell me if
695             you find out.
696              
697             =item shipping2
698              
699             I don't know, something to do with shipping, please tell me if you
700             find out.
701              
702             =item quantity
703              
704             defaults to 1
705              
706             Number of items being sold.
707              
708             =item amount
709              
710             Price of the item being sold.
711              
712             =item address1
713              
714             Address of customer, used to pre-fill PayPal forms.
715              
716             =item address2
717              
718             Address of customer, used to pre-fill PayPal forms.
719              
720             =item city
721              
722             City of customer, used to pre-fill PayPal forms.
723              
724             =item state
725              
726             State of customer, used to pre-fill PayPal forms.
727              
728             =item zip
729              
730             Zip of customer, used to pre-fill PayPal forms.
731              
732             =item night_phone_a
733              
734             Phone
735              
736             =item night_phone_b
737              
738             Phone
739              
740             =item night_phone_c
741              
742             Phone
743              
744             =item day_phone_a
745              
746             Phone
747              
748             =item day_phone_b
749              
750             Phone
751              
752             =item day_phone_c
753              
754             Phone
755              
756             =item receiver_email
757              
758             Email address of customer - I think
759              
760             =item invoice
761              
762             Invoice number - I think
763              
764             =item custom
765              
766             defaults to the Business::PayPal id
767              
768             Used by Business::PayPal to track which button is associated
769             with which Instant Payment Notification.
770              
771             =back
772              
773             =head2 ipnvalidate()
774              
775             Takes a reference to a hash of name value pairs, such as from a
776             CGI query object, which should contain all the name value pairs
777             which have been posted to the script by PayPal's Instant Payment
778             Notification posts that data back to PayPal, checking if the ssl
779             certificate matches, and returns success or failure, and the
780             reason.
781              
782             =head2 postpaypal()
783              
784             This method should not normally be used unless you need to test,
785             or if you are overriding the behaviour of ipnvalidate. It takes a
786             reference to a hash containing the query, posts to PayPal with
787             the data, and returns success or failure, as well as PayPal's
788             response.
789              
790             =head1 MAINTAINER
791              
792             Gabor Szabo, L, L
793              
794             phred, Efred@redhotpenguin.comE
795              
796             =head1 AUTHOR
797              
798             mock, Emock@obscurity.orgE
799              
800             =head1 SEE ALSO
801              
802             L, L, L.
803              
804             Explanation of the fields: L
805             See also in the pdf here: L
806              
807              
808             =head1 LICENSE
809              
810             Copyright (c) 2010, phred Efred@redhotpenguin.comE. All rights reserved.
811              
812             Copyright (c) 2002, mock Emock@obscurity.orgE. All rights reserved.
813              
814             This library is free software; you can redistribute it and/or modify
815             it under the same terms as Perl itself.
816              
817             =cut