Esempio n. 1
0
 public JsonResult JsapiPay(GetBrandWCPayRequestParams getBrandWCPayRequestParams)
 {
     return(MyJson(new JsapiPayResult
     {
         err_msg = getBrandWCPayRequestParams.paySign == PayService.GetBrandWCPayRequestParamsSign(getBrandWCPayRequestParams, "key")? "get_brand_wcpay_request:ok" : "签名错误。"
     }));
 }
Esempio n. 2
0
 public void CheckGetBrandWCPayRequestParamsSign(GetBrandWCPayRequestParams getBrandWCPayRequestParams)
 {
     if (getBrandWCPayRequestParams == null)
     {
         JsapiPayRet("参数不能为空!");
     }
     if (string.IsNullOrEmpty(getBrandWCPayRequestParams.nonceStr))
     {
         JsapiPayRet("随机字符串nonceStr不能为空!");
     }
     else
     {
         if (getBrandWCPayRequestParams.nonceStr.Length > 32)
         {
             JsapiPayRet("随机字符串nonceStr长度不能大于32个字符!");
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 对jsapi支付的参数进行签名加密
        /// </summary>
        /// <param name="getBrandWCPayRequestParams">jsapi参数</param>
        /// <param name="key">加密用的key</param>
        /// <returns></returns>
        public string GetBrandWCPayRequestParamsSign(GetBrandWCPayRequestParams getBrandWCPayRequestParams, string key)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("appId=").Append(getBrandWCPayRequestParams.appId)
            .Append("&nonceStr=").Append(getBrandWCPayRequestParams.nonceStr)
            .Append("&package=").Append(getBrandWCPayRequestParams.package)
            .Append("&signType=").Append(getBrandWCPayRequestParams.signType)
            .Append("&timeStamp=").Append(getBrandWCPayRequestParams.timeStamp)
            .Append("&key=").Append(key);
            if (getBrandWCPayRequestParams.signType == "MD5")
            {
                return(EncryptHelper.GetMD5FromStr(sb.ToString()));
            }
            else if (getBrandWCPayRequestParams.signType == "HMAC-SHA256")
            {
                return(EncryptHelper.HmacSha256(sb.ToString()));
            }
            else
            {
                JsapiPayRet("signType错误,目前只支持MD5或HMAC-SHA256加密。");
                return(null);
            }
        }