Paypal IPN Error

62 views
Skip to first unread message

Jack Stewart

unread,
Jun 23, 2009, 3:27:45 AM6/23/09
to Satchmo users
When testing with the Paypal sandbox I've found the IPN is being
received but not processed by Satchmo. Using the Paypal IPN tester I
get the error below. There are a few references on the web to similar
erros being a python issue. Any clues?

2009-06-23 19:15:15,170 root : INFO Satchmo Started
2009-06-23 19:15:18,311 shop.listeners: DEBUG Added default shop
listeners
2009-06-23 19:15:18,508 sslurllib : DEBUG Installing SSLv2 HTTPS
Methods into urllib2
2009-06-23 19:15:27,746 recentlist.middleware: DEBUG Product url is
^/shop/product/(?P<slug>[-\w]+)/
2009-06-23 19:15:27,779 root : DEBUG Test IPN on PAYPAL
2009-06-23 19:15:27,800 root : DEBUG PayPal IPN data:
<QueryDict: {u'last_name': [u'Smith'], u'txn_id': [u'4623715'],
u'receiver_email': [u'sel...@paypalsandbox.com'], u'payment_status':
[u'Completed'], u'tax': [u'2.02'], u'payer_status': [u'unverified'],
u'residence_country': [u'US'], u'invoice': [u'abc1234'],
u'address_state': [u'CA'], u'item_name1': [u'something'], u'txn_type':
[u'cart'], u'address_street': [u'123, any street'], u'quantity1':
[u'1'], u'payment_date': [u'00:15:04 Jun. 23, 2009 PDT'],
u'first_name': [u'John'], u'mc_shipping': [u'3.02'], u'item_number1':
[u'AK-1234'], u'mc_gross1': [u'9.34'], u'custom': [u'xyz123'],
u'notify_version': [u'2.4'], u'address_name': [u'John Smith'],
u'test_ipn': [u'1'], u'receiver_id': [u'TESTSELLERID1'], u'payer_id':
[u'TESTBUYERID01'], u'mc_handling1': [u'1.67'], u'verify_sign':
[u'AbfT2FcWp5yf1KyrYCmBMo8Lg0oWA9gk106CIcorcKiQnw2svUCYvtGm'],
u'mc_handling': [u'2.06'], u'charset': [u'windows-1252'],
u'address_zip': [u'95131'], u'address_country_code': [u'US'],
u'address_city': [u'San Jose'], u'address_status': [u'confirmed'],
u'address_country': [u'United States'], u'mc_fee': [u'0.44'],
u'mc_currency': [u'USD'], u'payer_email':
[u'bu...@paypalsandbox.com'], u'payment_type': [u'instant'],
u'mc_shipping1': [u'1.02']}>
2009-06-23 19:15:27,843 root : ERROR Traceback (most recent
call last):
File "/usr/local/lib/python2.6/dist-packages/Satchmo-0.9_pre-
py2.6.egg/payment/modules/paypal/views.py", line 126, in ipn
if not confirm_ipn_data(data, PP_URL):
File "/usr/local/lib/python2.6/dist-packages/Satchmo-0.9_pre-
py2.6.egg/payment/modules/paypal/views.py", line 183, in
confirm_ipn_data
fo = urllib2.urlopen(req, params)
File "/usr/lib/python2.6/urllib2.py", line 124, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.6/urllib2.py", line 383, in open
response = self._open(req, data)
File "/usr/lib/python2.6/urllib2.py", line 401, in _open
'_open', req)
File "/usr/lib/python2.6/urllib2.py", line 361, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.6/dist-packages/Satchmo-0.9_pre-
py2.6.egg/satchmo_utils/sslurllib.py", line 45, in https_open
return self.do_open(HTTPSv2Connection, req)
File "/usr/lib/python2.6/urllib2.py", line 1087, in do_open
h = http_class(host, timeout=req.timeout) # will parse host:port
TypeError: __init__() got an unexpected keyword argument 'timeout'
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/Satchmo-0.9_pre-
py2.6.egg/payment/modules/paypal/views.py", line 126, in ipn
if not confirm_ipn_data(data, PP_URL):
File "/usr/local/lib/python2.6/dist-packages/Satchmo-0.9_pre-
py2.6.egg/payment/modules/paypal/views.py", line 183, in
confirm_ipn_data
fo = urllib2.urlopen(req, params)
File "/usr/lib/python2.6/urllib2.py", line 124, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.6/urllib2.py", line 383, in open
response = self._open(req, data)
File "/usr/lib/python2.6/urllib2.py", line 401, in _open
'_open', req)
File "/usr/lib/python2.6/urllib2.py", line 361, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.6/dist-packages/Satchmo-0.9_pre-
py2.6.egg/satchmo_utils/sslurllib.py", line 45, in https_open
return self.do_open(HTTPSv2Connection, req)
File "/usr/lib/python2.6/urllib2.py", line 1087, in do_open
h = http_class(host, timeout=req.timeout) # will parse host:port
TypeError: __init__() got an unexpected keyword argument 'timeout'
imeout'

Chris Moffitt

unread,
Jun 23, 2009, 10:46:17 AM6/23/09
to satchm...@googlegroups.com
Looks like it might be a python2.6 compatibility issue. Was there a change with the timeout parameter?

-Chris

Jack Stewart

unread,
Jun 25, 2009, 3:39:16 AM6/25/09
to Satchmo users

Here's the relevant bit of the paypal views.py:

req = urllib2.Request(PP_URL)
req.add_header("Content-type", "application/x-www-form-
urlencoded")
fo = urllib2.urlopen(req, params)

So far as I can tell the req object (and the associated timeout
parameter) come from urllib2 itself so it seems odd that it's
complaining when we pass it back to urllib2 in urlopen.

Chris Moffitt

unread,
Jun 25, 2009, 8:42:24 AM6/25/09
to satchm...@googlegroups.com

Jack Stewart

unread,
Jun 26, 2009, 4:10:15 AM6/26/09
to Satchmo users
Good spotting. The fix is stupidly simple:

--- sslurllib.py.old 2009-06-26 19:54:43.000000000 +1200
+++ sslurllib.py 2009-06-26 19:55:20.000000000 +1200
@@ -22,7 +22,7 @@
default_port = httplib.HTTPS_PORT

def __init__(self, host, port=None, key_file=None,
cert_file=None,
- strict=None):
+ strict=None, timeout=None):
httplib.HTTPConnection.__init__(self, host, port, strict)
self.key_file = key_file
self.cert_file = cert_file


Tested and it works for me.


On Jun 26, 12:42 am, Chris Moffitt <ch...@moffitts.net> wrote:
> I'm guessing it's somehow related to this ticket -http://hg.satchmoproject.com/satchmo/issue/826/python-26-compatibilit...
Reply all
Reply to author
Forward
0 new messages