从递归获取Django中的webhook

时间:2018-08-01 14:26:21

标签: python django django-rest-framework recurly

我想将webhook通知从递归发送到django项目。 我正在关注

https://dev.recurly.com/page/python

我的班级如下

class PushNotificationHandlerView(SimpleHTTPServer.SimpleHTTPRequestHandler, APIView):

 queryset = None


 def post(self,*args,**kwargs):
    bytes = int(self.headers["content-length"])
    data = self.rfile.read(bytes)
    notification = recurly.objects_for_push_notification(data)

    print notification
    #each webhook is defined by a type
    if notification['type'] == "successful_payment_notification":
        print "Payment Received"
    elif notification['type'] == "failed_payment_notification":
        print "The payment did not work"
    self.send_response(200)
    self.wfile.write("OK")
    self.wfile.flush()

事件再次发生时,会引发以下错误。

    Internal Server Error: /api/notifications/
    Traceback (most recent call last):
      File "site-packages/django/core/handlers/exception.py", line 41, in inner
        response = get_response(request)
      File "site-packages/django/core/handlers/base.py", line 187, in _get_response
        response = self.process_exception_by_middleware(e, request)
      File "site-packages/django/core/handlers/base.py", line 185, in _get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)
      File "site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
        return view_func(*args, **kwargs)
      File "site-packages/django/views/generic/base.py", line 62, in view
        self = cls(**initkwargs)
      TypeError: __init__() takes exactly 4 arguments (1 given)

0 个答案:

没有答案