Get subscription ID with new Paypal Webhooks

26 Views Asked by At

I use the following endpoint for receiving the Paypal webhooks:

@method_decorator(csrf_exempt, name='dispatch')
class ProcessWebHookView(View):
    def post(self, request):
        if "HTTP_PAYPAL_TRANSMISSION_ID" not in request.META:
            return HttpResponse(status=400)
        
        auth_algo = request.META['HTTP_PAYPAL_AUTH_ALGO']
        cert_url = request.META['HTTP_PAYPAL_CERT_URL']
        transmission_id = request.META['HTTP_PAYPAL_TRANSMISSION_ID']
        transmission_sig = request.META['HTTP_PAYPAL_TRANSMISSION_SIG']
        transmission_time = request.META['HTTP_PAYPAL_TRANSMISSION_TIME']
        webhook_id = settings.PAYPAL_WEBHOOK_ID
        event_body = request.body.decode(request.encoding or "utf-8")

        valid = notifications.WebhookEvent.verify(
            transmission_id=transmission_id,
            timestamp=transmission_time,
            webhook_id=webhook_id,
            event_body=event_body,
            cert_url=cert_url,
            actual_sig=transmission_sig,
            auth_algo=auth_algo,
        )

        if not valid:
            return HttpResponse(status=400)

        webhook_event = json.loads(event_body)

        event_type = webhook_event["event_type"]

        print(event_type)

        return HttpResponse()

Well in the metadata no information about the subscription id can be found. Does anyone have experience how to get this information from the request?

0

There are 0 best solutions below