def METHOD_NAME(request, response_d, payment, **kwargs):
    name = response_d.get('name', '')
    if name:
        name_list = name.split(' ')
        if len(name_list) >= 2:
            payment.first_name = name_list[0]
            payment.last_name = ' '.join(name_list[1:])
    payment.address = response_d.get('address', '')
    payment.city = response_d.get('city', '')
    payment.state = response_d.get('state', '')
    payment.country = response_d.get('country', '')
    payment.phone = response_d.get('phone', '')
    sname = response_d.get('nametoship', '')
    if sname:
        name_list = sname.split(' ')
        if len(name_list) >= 2:
            payment.ship_to_first_name = name_list[0]
            payment.ship_to_last_name = ' '.join(name_list[1:])
    payment.ship_to_address = response_d.get('addresstoship', '')
    payment.ship_to_city = response_d.get('citytoship', '')
    payment.ship_to_state = response_d.get('statetoship', '')
    payment.ship_to_zip = response_d.get('ziptoship', '')
    payment.ship_to_country = response_d.get('countrytoship', '')
    result = response_d.get('result', '')
    respmsg = (response_d.get('respmsg', '')).lower()
    payment.response_reason_text = respmsg
    if result=='0' and  respmsg == 'approved':
        payment.response_code = '1'
        payment.response_subcode = '1'
        payment.response_reason_code = '1'
        payment.status_detail = 'approved'
        # http://www.firstdata.com/downloads/marketing-merchant/fd_globalgatewayconnect_usermanualnorthamerica.pdf
        payment.trans_id = response_d.get('pnref', '')
    else:
        payment.response_code = 0
        payment.response_reason_code = 0
    if payment.is_approved:
        payment.mark_as_paid()
        payment.save()
        payment.invoice.make_payment(request.user, payment.amount)
    else:
        if not payment.status_detail:
            payment.status_detail = 'not approved'
        payment.save()