code: def pay_sign_dict(
      appid,
      pay_sign_key,
      add_noncestr=True,
      add_timestamp=True,
      add_appid=True,
      **kwargs
  ):
      
      assert pay_sign_key, "PAY SIGN KEY IS EMPTY"
  
      if add_appid:
          kwargs.update({'appid': appid})
  
      if add_noncestr:
          kwargs.update({'noncestr': generate_token()})
  
      if add_timestamp:
          kwargs.update({'timestamp': int(time.time())})
  
      params = kwargs.items()
  
      _params = [
          (k.lower(), v) for k, v in kwargs.items() if k.lower() != "appid"
      ]
      _params += [('appid', appid), ('appkey', pay_sign_key)]
      _params.sort()
  
      sign = '&'.join(["%s=%s" % (str(p[0]), str(p[1]))
                       for p in _params]).encode("utf-8")
      sign = sha1(sign).hexdigest()
      sign_type = 'SHA1'
  
      return dict(params), sign, sign_type
docs: 支付参数签名