/// <summary> /// 获取app唤起客户端参数 /// </summary> /// <param name="prepayId">预支付交易Id</param> /// <returns></returns> public WxGetAppClientParaResp GetAppClientParaResp(string prepayId) { var appPara = new WxGetAppClientParaResp { app_id = ApiConfig.AppId, mch_id = ApiConfig.MchId, time_stamp = DateTime.Now.ToLocalSeconds().ToString(), nonce = SysUtil.GenerateNonceStr(), prepay_id = prepayId, package = "Sign=WXPay" }; var dics = new SortedDictionary <string, object> { ["appid"] = appPara.app_id, ["partnerid"] = appPara.mch_id, ["timestamp"] = appPara.time_stamp, ["noncestr"] = appPara.nonce, ["package"] = appPara.package, ["prepayid"] = appPara.prepay_id }; appPara.sign = GetSign(GetSignContent(dics)); return(appPara); }
/// <summary> /// 授权码查询OPENID接口 /// </summary> /// <param name="auth_code"></param> /// <returns></returns> public async Task <WxPayAuthCodeOpenIdResp> GetAuthCodeOpenIdAsync(string auth_code) { var url = string.Concat(m_ApiUrl, "/tools/authcodetoopenid"); var dics = new SortedDictionary <string, object> { ["nonce_str"] = SysUtil.GenerateNonceStr(), ["auth_code"] = auth_code }; return(await PostApiAsync <WxPayAuthCodeOpenIdResp>(url, dics)); }
/// <summary> /// 获取企业付款信息 /// </summary> /// <param name="partner_trade_no"></param> /// <returns></returns> public async Task <WxPayGetTransferCashResp> GetTransferCashAsync(string partner_trade_no) { var urlStr = string.Concat(m_ApiUrl, "/mmpaymkttransfers/gettransferinfo"); var dics = new SortedDictionary <string, object> { ["nonce_str"] = SysUtil.GenerateNonceStr(), ["partner_trade_no"] = partner_trade_no }; return(await PostApiAsync <WxPayGetTransferCashResp>(urlStr, dics, null, GetCertHttpClient())); }
/// <summary> /// 转换短链api /// </summary> /// <param name="long_url"></param> /// <returns></returns> public async Task <WxPayGetShortUrlResp> GetShortUrlAsync(string long_url) { var url = string.Concat(m_ApiUrl, "/tools/shorturl"); var dics = new SortedDictionary <string, object> { ["nonce_str"] = SysUtil.GenerateNonceStr(), ["long_url"] = long_url }; return(await PostApiAsync <WxPayGetShortUrlResp>(url, dics, null, false, true, d => d["long_url"] = d["long_url"].UrlEncode())); }
/// <summary> /// 查询红包 /// </summary> /// <param name="mch_billno">商户订单号</param> /// <param name="bill_type">订单类型</param> /// <returns></returns> public async Task <WxPayQueryRedResp> QueryRedAsync(string mch_billno, string bill_type = "MCHT") { var urlStr = string.Concat(m_ApiUrl, "/mmpaymkttransfers/gethbinfo"); var dics = new SortedDictionary <string, object> { ["nonce_str"] = SysUtil.GenerateNonceStr(), ["mch_billno"] = mch_billno, ["bill_type"] = bill_type }; return(await PostApiAsync <WxPayQueryRedResp>(urlStr, dics, null, GetCertHttpClient())); }
/// <summary> /// 生成二维码地址(扫码支付模式一) /// </summary> /// <param name="product_id"></param> /// <returns></returns> public string CreateScanCode(string product_id) { var dics = new SortedDictionary <string, object> { ["time_stamp"] = DateTime.Now.ToLocalSeconds().ToString(), ["nonce_str"] = SysUtil.GenerateNonceStr(), ["product_id"] = product_id, ["appid"] = ApiConfig.AppId, ["mch_id"] = ApiConfig.MchId }; var encStr = GetSignContent(dics); var sign = GetSign(encStr); return(string.Concat("weixin://wxpay/bizpayurl?", encStr, "&sign=", sign)); }
/// <summary> /// 获取js和小程序唤起客户端参数 /// </summary> /// <param name="prepayId">预支付交易Id</param> /// <returns></returns> public WxGetJsClientParaResp GetJsClientParaResp(string prepayId) { var jsPara = new WxGetJsClientParaResp { app_id = ApiConfig.AppId, time_stamp = DateTime.Now.ToLocalSeconds().ToString(), nonce = SysUtil.GenerateNonceStr(), package = string.Concat("prepay_id=", prepayId) }; var dics = new SortedDictionary <string, object> { ["appId"] = jsPara.app_id, ["timeStamp"] = jsPara.time_stamp, ["nonceStr"] = jsPara.nonce, ["package"] = jsPara.package, ["signType"] = jsPara.sign_type }; jsPara.sign = GetSign(GetSignContent(dics)); return(jsPara); }
public WxPayBaseReq() { var nonceStr = SysUtil.GenerateNonceStr(); _dics["nonce_str"] = nonceStr; }