def METHOD_NAME(request, response_d, **kwargs):
    from django.shortcuts import get_object_or_404
    paymentid = response_d.get('paymentid', 0)
    try:
        paymentid = int(paymentid)
    except:
        paymentid = 0
    with transaction.atomic():
        payment = get_object_or_404(Payment.objects.select_for_update(), pk=paymentid)
        if not payment.is_approved:  # if not already processed
            payment_update_firstdata(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