2Checkout IPN -Validierungsantwort Python

import hmac
import hashlib
import datetime

from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt


def hmac_md5(key, value):
    message = value.encode('utf-8')
    return hmac.new(key.encode('utf-8'), message, digestmod=hashlib.md5).hexdigest()

@csrf_exempt
def subscription_listener(request):
    if request.method == "GET":
        return HttpResponse("Hello")

    if request.method == "POST":
        pass_str = "SECRET_KEY_HERE"
        DATE = datetime.datetime.now().strftime("%Y%m%d%H%M%S")

        original_dict = dict(request.POST)
        base_string_for_return_hash = str(len(original_dict['IPN_PID[]'][0])) + str(
            original_dict['IPN_PID[]'][0]) + str(
            len(original_dict['IPN_PNAME[]'][0])) + str(original_dict['IPN_PNAME[]'][0]) + str(
            len(original_dict['IPN_DATE'][0])) + str(original_dict['IPN_DATE'][0]) + str(len(DATE)) + str(DATE)

        hashed = hmac_md5(pass_str, base_string_for_return_hash)
        
        response = "<EPAYMENT>{}|{}</EPAYMENT>".format(DATE, hashed)

        return HttpResponse(response)
Open Oystercatcher