code: def _payload(fields, values):
      
      for field_name, field in fields.items():
          if field_name in values:
              if isinstance(field, OneToOneField):
                  values[field_name + '_id'] = (
                      getattr(values.pop(field_name), 'id', None)
                  )
              elif isinstance(field, OneToManyField):
                  values[field_name + '_ids'] = [
                      entity.id for entity in values.pop(field_name)
                  ]
              elif isinstance(field, ListField):
                  def parse(obj):
                      """parse obj payload if it is an Entity"""
                      if isinstance(obj, Entity):
                          return _payload(obj.get_fields(), obj.get_values())
                      return obj
  
                  values[field_name] = [
                      parse(obj) for obj in values[field_name]]
      return values
docs: Implement the ``*_payload`` methods.
  
      It's frequently useful to create a dict of values that can be encoded to
      JSON and sent to the server. Unfortunately, there are mismatches between
      the field names used by NailGun and the field names the server expects.
      This method provides a default translation that works in many cases. For
      example:
  
      >>> from nailgun.entities import Product
      >>> product = Product(name='foo', organization=1)
      >>> set(product.get_fields())
      {
          'description',
          'gpg_key',
          'id',
          'label',
          'name',
          'organization',
          'sync_plan',
      }
      >>> set(product.get_values())
      {'name', 'organization'}
      >>> product.create_payload()
      {'organization_id': 1, 'name': 'foo'}
  
      :param fields: A value like what is returned by
          :meth:`nailgun.entity_mixins.Entity.get_fields`.
      :param values: A value like what is returned by
          :meth:`nailgun.entity_mixins.Entity.get_values`.
      :returns: A dict mapping field names to field values.