public WXConfigInfo(string app_id, string url, string js_api_ticket) { appId = app_id; nonceStr = WXUtil.getNonceStr(); timestamp = DateTime.Now.toIntervalSince1970(); signature = WXUtil.wxConfigSignature(nonceStr, timestamp, url, js_api_ticket); }
public string getJSApiTicket() { if (!_jsapi_ticket.isNull() && _jsapi_tikcket_expire > DateTime.Now.AddSeconds(30)) { return(_jsapi_ticket); } WXUtil.fetchJSApiTicket(getAccessToken(), out _jsapi_ticket, out _jsapi_tikcket_expire); return(_jsapi_ticket); }
public string getAccessToken() { if (!_access_token.isNull() && _access_token_expire > DateTime.Now.AddSeconds(30)) { return(_access_token); } WXUtil.fetchAccessToken(APP_ID, APP_SECRET, out _access_token, out _access_token_expire); return(_access_token); }
/// <summary> /// 获取当前提交的body内容 /// </summary> /// <returns></returns> public string getContent(string app_id, string mch_id, string mch_secret) { var sd = new SortedDictionary <string, string>(); sd["appid"] = app_id; sd["mch_id"] = mch_id; sd["nonce_str"] = WXUtil.getNonceStr(); var fields = this.GetType().GetFields(); foreach (FieldInfo fi in fields) { string value = fi.GetValue(this).ToString(); if (value.isNull()) { continue; } sd[fi.Name] = value; } sd["sign"] = WXUtil.wxTradeSignature(sd, mch_secret); return(WXUtil.toXml(sd)); }
public void setContentString(string content_string) { content = WXUtil.fromXml(content_string); initProperties(); }
/// <summary> /// 查询订单信息, sheet_no和transaction_id二选一填写, 另一个填空字符串 /// </summary> /// <param name="sheet_no"></param> /// <param name="transaction_id"></param> /// <returns></returns> public WXTradeResQueryOrder queryOrder(string sheet_no, string transaction_id) { return(WXUtil.queryOrder(sheet_no, transaction_id, APP_ID, MCH_ID, MCH_SECRET)); }
/// <summary> /// 统一下单, 获取预付单号 /// </summary> /// <param name="trade_sheet">交易订单</param> /// <returns></returns> public WXTradeResUnifiedOrder unifiedOrder(TradeSheetBase trade_sheet) { return(WXUtil.unifiedOrder(trade_sheet, PAY_NOTIFY_URL, APP_ID, MCH_ID, MCH_SECRET)); }
/// <summary> /// 根据二维码接口返回的ticket获取二维码图片 /// </summary> /// <param name="ticket"></param> /// <returns></returns> public Image getQRCodeImage(string ticket) { return(WXUtil.getQRCodeImage(ticket)); }
/// <summary> /// 获取临时二维码, 有效时间自定义 /// </summary> /// <param name="parameter">场景参数</param> /// <param name="expire_seconds">过期时间(最大不超过2592000(30天)</param> public WXResQRCode requestTemporaryQRCode(string parameter, int expire_seconds) { return(WXUtil.requestTemporaryQRCode(parameter, expire_seconds, getAccessToken())); }
/// <summary> /// 获取永久二维码(带参数, 有个数限制) /// </summary> /// <param name="parameter">场景参数</param> /// <returns></returns> public WXResQRCode requestLimitedQRCode(string parameter) { return(WXUtil.requestLimitedQRCode(parameter, getAccessToken())); }
/// <summary> /// 发送模板消息 /// </summary> /// <param name="message"></param> /// <returns></returns> public string sendTemplateMessage(WXTemplateMessageBase message) { return(WXUtil.sendTemplateMessage(message, getAccessToken())); }
/// <summary> /// 创建自定义菜单(指定路径) /// </summary> /// <param name="path"></param> /// <returns></returns> public string refreshCustomMenu(string path) { return(WXUtil.refreshCustomMenuByPath(path, getAccessToken())); }
/// <summary> /// 删除自定义菜单 /// </summary> /// <returns></returns> public string deleteCustomMenu() { return(WXUtil.deleteCustomMenu(getAccessToken())); }
/// <summary> /// 根据用户openid获取微信信息 /// </summary> /// <param name="open_id"></param> /// <returns></returns> public WXUserInfo userInfoByOpenId(string open_id) { return(WXUtil.userInfoByOpenId(open_id, getAccessToken())); }
/// <summary> /// 根据微信授权code获取微信信息 /// </summary> /// <param name="code"></param> /// <returns></returns> public WXUserInfo userInfoByCode(string code) { return(WXUtil.userInfoByCode(code, APP_ID, APP_SECRET)); }
public WXConfigInfo(string app_id) { appId = app_id; nonceStr = WXUtil.getNonceStr(); timestamp = DateTime.Now.toIntervalSince1970(); }