spookylukey / django-paypal

A pluggable Django application for integrating PayPal Payments Standard or Payments Pro
MIT License
729 stars 208 forks source link

TypeError in models.py line 330 #175

Closed jack-guo closed 7 years ago

jack-guo commented 7 years ago
ERROR 2017-04-26 09:36:44,270 exception 5116 25813979760 Internal Server Error: /paypal/paypal/
Traceback (most recent call last):
  File "/home/User1/env/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/User1/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/User1/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/User1/env/lib/python2.7/site-packages/django/views/decorators/http.py", line 40, in inner
    return func(request, *args, **kwargs)
  File "/home/User1/env/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/User1/env/lib/python2.7/site-packages/paypal/standard/ipn/views.py", line 104, in ipn
    ipn_obj.send_signals()
  File "/home/User1/env/lib/python2.7/site-packages/paypal/standard/ipn/models.py", line 39, in send_signals
    valid_ipn_received.send(sender=self)
  File "/home/User1/env/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 193, in send
    for receiver in self._live_receivers(sender)
  File "with_subscription/signals.py", line 29, in paypal_subscription_signals
    'is_billing_agreement': ipn_obj.is_billing_agreement(),
  File "/home/User1/env/lib/python2.7/site-packages/paypal/standard/models.py", line 330, in is_billing_agreement
    return len(self.mp_id) > 0
TypeError: object of type 'NoneType' has no len()

proposed fix: use a try catch to return False on TypeError

def is_billing_agreement(self): `

    warn_untested()
    try:
        return len(self.mp_id) > 0
    except TypeError, err:
        return False

`

jack-guo commented 7 years ago

https://pastebin.com/MvLU1Pxg

here are the correction for the whole models.py

spookylukey commented 7 years ago

Closing - see PR