Handle payment received and respond with a dictionary

def process_lipisha_payment(request):
    """Handle payment received and respond with a dictionary"""
    log.debug(request.POST)
    schema = LipishaInitiateSchema
    api_type = request.POST.get('api_type')
    if api_type == TYPE_ACKNOWLEDGE:
        schema = LipishaAcknowledgeSchema
    form = Form(request, schema())
    transaction_status_code = STATUS_SUCCESS
    transaction_status = 'Processed'
    transaction_status_description = 'Processed'
    if form.validate():
        if api_type == TYPE_INITIATE:
            # Process new payment
            pass
        elif api_type == TYPE_ACKNOWLEDGE:
            if form.data.get('transaction_status_code') == STATUS_SUCCESS:
                # Process successful accknowledgement
                pass
            else:
                log.error('Invalid payment acknowledgement')
                log.error(request.POST)
    else:
        log.error("Error while processing payment")
        for error in form.all_errors():
            log.error(error)
        transaction_status_code = STATUS_INITIATE_FAILURE
        transaction_status = 'Error'
        transaction_status_description = 'Error while processing'
    if api_type == TYPE_INITIATE:
        data = request.POST
        return dict(
            api_key=LIPISHA_API_KEY,
            api_signature=LIPISHA_API_SIGNATURE,
            api_version=data.get('api_version'),
            api_type=TYPE_RECEIPT,
            transaction_reference=data.get('transaction_reference'),
            transaction_status_code=transaction_status_code,
            transaction_status=transaction_status,
            transaction_status_description=transaction_status_description,
        )
    return {}