def METHOD_NAME(request, response_d, **kwargs):
    #from django.shortcuts import get_object_or_404
    x_invoice_num = response_d.get('x_invoice_num', 0)
    try:
        x_invoice_num = int(x_invoice_num)
    except:
        x_invoice_num = 0
    with transaction.atomic():
        #payment = get_object_or_404(Payment.objects.select_for_update(), pk=x_invoice_num)
        payment = get_object_or_404(Payment.objects.select_for_update(), pk=x_invoice_num)
        if not payment.is_approved:
            # authenticate with md5 hash to make sure the response is securely
            # received from firstdata.
            md5_hash = response_d.get('x_MD5_Hash', '')
            # calculate our md5_hash
            response_key = settings.FIRSTDATA_RESPONSE_KEY
            api_login_id = settings.MERCHANT_LOGIN
            t_id = response_d.get('x_trans_id', '')
            amount = response_d.get('x_amount', 0)
            s = '%s%s%s%s' % (response_key, api_login_id, t_id, amount)
            my_md5_hash = hashlib.md5(s.encode()).hexdigest()
            #if settings.FIRSTDATA_USE_RELAY_RESPONSE:
            if my_md5_hash.lower() != md5_hash.lower():
                raise Http404
            payment_update_firstdatae4(request, response_d, payment)
            payment_processing_object_updates(request, payment)
            # log an event
            log_payment(request, payment)
            # send payment recipients notification
            send_payment_notice(request, payment)
        return payment