Пример #1
0
 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);
 }
Пример #2
0
 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);
 }
Пример #3
0
 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);
 }
Пример #4
0
        /// <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));
        }
Пример #5
0
 public void setContentString(string content_string)
 {
     content = WXUtil.fromXml(content_string);
     initProperties();
 }
Пример #6
0
 /// <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));
 }
Пример #7
0
 /// <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));
 }
Пример #8
0
 /// <summary>
 /// 根据二维码接口返回的ticket获取二维码图片
 /// </summary>
 /// <param name="ticket"></param>
 /// <returns></returns>
 public Image getQRCodeImage(string ticket)
 {
     return(WXUtil.getQRCodeImage(ticket));
 }
Пример #9
0
 /// <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()));
 }
Пример #10
0
 /// <summary>
 /// 获取永久二维码(带参数, 有个数限制)
 /// </summary>
 /// <param name="parameter">场景参数</param>
 /// <returns></returns>
 public WXResQRCode requestLimitedQRCode(string parameter)
 {
     return(WXUtil.requestLimitedQRCode(parameter, getAccessToken()));
 }
Пример #11
0
 /// <summary>
 /// 发送模板消息
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 public string sendTemplateMessage(WXTemplateMessageBase message)
 {
     return(WXUtil.sendTemplateMessage(message, getAccessToken()));
 }
Пример #12
0
 /// <summary>
 /// 创建自定义菜单(指定路径)
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 public string refreshCustomMenu(string path)
 {
     return(WXUtil.refreshCustomMenuByPath(path, getAccessToken()));
 }
Пример #13
0
 /// <summary>
 /// 删除自定义菜单
 /// </summary>
 /// <returns></returns>
 public string deleteCustomMenu()
 {
     return(WXUtil.deleteCustomMenu(getAccessToken()));
 }
Пример #14
0
 /// <summary>
 /// 根据用户openid获取微信信息
 /// </summary>
 /// <param name="open_id"></param>
 /// <returns></returns>
 public WXUserInfo userInfoByOpenId(string open_id)
 {
     return(WXUtil.userInfoByOpenId(open_id, getAccessToken()));
 }
Пример #15
0
 /// <summary>
 /// 根据微信授权code获取微信信息
 /// </summary>
 /// <param name="code"></param>
 /// <returns></returns>
 public WXUserInfo userInfoByCode(string code)
 {
     return(WXUtil.userInfoByCode(code, APP_ID, APP_SECRET));
 }
Пример #16
0
 public WXConfigInfo(string app_id)
 {
     appId     = app_id;
     nonceStr  = WXUtil.getNonceStr();
     timestamp = DateTime.Now.toIntervalSince1970();
 }