예제 #1
0
        /// <summary>
        /// 从统一下单成功返回的数据中获取微信浏览器调起jsapi支付所需的参数,
        /// 更详细的说明请参考网页端调起支付API:http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7
        /// </summary>
        private string GetJsApiParameters(string prepayId, bool forJsSdk = false)
        {
            var jsApiParam = new WxPayData(WxPayConfig);

            jsApiParam.SetValue("appId", PayConfig.AppId);
            jsApiParam.SetValue("timeStamp", WxPayApi.GenerateTimeStamp());
            jsApiParam.SetValue("nonceStr", WxPayApi.GenerateNonceStr());
            jsApiParam.SetValue("package", "prepay_id=" + prepayId);
            jsApiParam.SetValue("signType", "MD5");
            jsApiParam.SetValue("paySign", jsApiParam.MakeSign());

            if (!forJsSdk)
            {
                return(jsApiParam.ToJson());
            }

            //JsSdk方式调用时,参数有差别
            return(SerializeUtil.ToJson(new Dictionary <string, string>
            {
                { "timestamp", jsApiParam.GetValueStr("timeStamp") },
                { "nonceStr", jsApiParam.GetValueStr("nonceStr") },
                { "package", jsApiParam.GetValueStr("package") },
                { "signType", jsApiParam.GetValueStr("signType") },
                { "paySign", jsApiParam.GetValueStr("paySign") }
            }));
        }
예제 #2
0
 /// <summary>
 /// 判断调用结果是否成功
 /// </summary>
 internal bool IsResultSuccess(WxPayData result)
 {
     return(result.GetValueStr("return_code") == "SUCCESS" && result.GetValueStr("result_code") == "SUCCESS");
 }