1

I am trying to make an api request to Paypal in Sandbox mode but getting a urlopen SSL error.

api_url = 'https://api-3t.sandbox.paypal.com/nvp'
data = 

{'CANCELURL': 'http://localhost:8000/paypal/canceled/',
 'L_PAYMENTREQUEST_0_AMT0': '2749.00',
 'L_PAYMENTREQUEST_0_DESC0': 'Like Christmas in a cup',
 'L_PAYMENTREQUEST_0_NAME0': 'Apple ',
 'L_PAYMENTREQUEST_0_QTY0': '1',
 'METHOD': 'SetExpressCheckout',
 'PAYMENTREQUEST_0_AMT': '2749.00',
 'PAYMENTREQUEST_0_CURRENCYCODE': 'USD',
 'PAYMENTREQUEST_0_DESC': 'Your payment to Foobar Inc.',
 'PAYMENTREQUEST_0_ITEMAMT': '2749.00',
 'PAYMENTREQUEST_0_PAYMENTACTION': 'Sale',
 'PWD': '****',
 'RETURNURL': 'http://localhost:8000/paypal/confirm/',
 'SIGNATURE': '****',
 'USER': '****',
 'VERSION': '91.0'}
response = urllib2.urlopen(api_url, data=urlencode(data))

Response Im getting is

Traceback (most recent call last): File "", line 1, in File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 431, in open response = self._open(req, data) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 449, in _open '_open', req) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain result = func(*args) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1240, in https_open context=self._context) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1197, in do_open raise URLError(err) URLError:

Is it because I am sending the request from non-https client(localhost)? I tried this few months back it was working fine. Are there any settings I have to change ? Is this a recent change in API ?

Coderaemon
  • 3,619
  • 6
  • 27
  • 50
  • 1
    You need to make sure your system can send HTTP requests to PayPal using the TLS 1.2 protocol. Your server software stack must not be compatible with that right now. Look up info about POODLE for more details. – Drew Angell Feb 04 '16 at 15:04
  • can you guide me to some link how to check what you mentioned ? – Coderaemon Feb 04 '16 at 21:53
  • 1
    Here is some info I put together about it, but it's specific to PHP server stacks: https://www.angelleye.com/paypal-ssl-error-poodle-vunerability/ The basic point is the same, though. – Drew Angell Feb 04 '16 at 22:42
  • 1
    I uninstalled `requests` than installed `pip install requests[security]` . Using `requests` I am able to make a post request to paypal but the response status is success with warning. `ACK=SuccessWithWarning&VERSION=91%2e0&BUILD=18308778&L_ERRORCODE0=11812`. Error 11812 means data invalid; don't know what data is invalid. – Coderaemon Feb 04 '16 at 22:42
  • 1
    For API errors [this page](https://developer.paypal.com/docs/classic/api/errorcodes/) provides additional detail. In the case of 11812 it looks like you must be passing too many characters in the description parameter so it's getting truncated. – Drew Angell Feb 04 '16 at 23:19
  • This seems to be the same issue described and solved [here](http://stackoverflow.com/a/35666924/2035869). – Codiak Feb 27 '16 at 07:18

0 Answers0