Exemplo n.º 1
0
        /// <summary>
        /// 下载对账单
        /// </summary>
        /// <param name="orderParams">发送或者接收到的数据集合M按照ASCII码字典序集合</param>
        /// <returns></returns>
        public static SortedDictionary <string, object> DownloadBill(SortedDictionary <string, object> orderParams)
        {
            // 注意:
            //      1、微信侧未成功下单的交易不会出现在对账单中。支付成功后撤销的交易会出现在对账单中,跟原支付单订单号一致,bill_type为REVOKED。
            //      2、微信在次日9点启动生成前一天的对账单,建议商户10点后再获取。
            //      3、对账单中涉及金额的字段单位为“元”。
            //
            // 返回结果:
            //      成功时:
            //          数据以文本表格的方式返回,第一行为表头,后面各行为对应的字段内容,字段内容跟查询订单或退款结果一致,具体字段说明可查阅相应接口。
            //      失败时:
            //          <xml>
            //              <return_code><![CDATA[FAIL]]></return_code>
            //              <return_msg><![CDATA[签名失败]]></return_msg>
            //          </xml>

            var resultXml = WechatWebClient.Post("https://api.mch.weixin.qq.com/pay/downloadbill", Common.SortedDictionaryToXml(orderParams));

            if (resultXml.Substring(0, 5) == "<xml>") //若接口调用失败会返回xml格式的结果
            {
                return(Common.XmlToSortedDictionary(resultXml));
            }
            else  //接口调用成功则返回非xml格式的数据
            {
                var result = new SortedDictionary <string, object>();
                result.Add("result", resultXml);
                return(result);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 查询订单
        /// </summary>
        /// <param name="orderParams"> 发送或者接收到的数据集合M按照ASCII码字典序集合</param>
        /// <returns></returns>
        public static SortedDictionary <string, object> QueryOrder(SortedDictionary <string, object> orderParams)
        {
            // 返回结果: xml转换成的SortedDictionary
            //     <xml>
            //          <return_code><![CDATA[SUCCESS]]></return_code>
            //          <return_msg><![CDATA[OK]]></return_msg>
            //          <appid><![CDATA[wx2421b1c4370ec43b]]></appid>
            //          <mch_id><![CDATA[10000100]]></mch_id>
            //          <device_info><![CDATA[1000]]></device_info>
            //          <nonce_str><![CDATA[TN55wO9Pba5yENl8]]></nonce_str>
            //          <sign><![CDATA[BDF0099C15FF7BC6B1585FBB110AB635]]></sign>
            //          <result_code><![CDATA[SUCCESS]]></result_code>
            //          <openid><![CDATA[oUpF8uN95-Ptaags6E_roPHg7AG0]]></openid>
            //          <is_subscribe><![CDATA[Y]]></is_subscribe>
            //          <trade_type><![CDATA[MICROPAY]]></trade_type>
            //          <bank_type><![CDATA[CCB_DEBIT]]></bank_type>
            //          <total_fee>1</total_fee>
            //          <fee_type><![CDATA[CNY]]></fee_type>
            //          <transaction_id><![CDATA[1008450740201411110005820873]]></transaction_id>
            //          <out_trade_no><![CDATA[1415757673]]></out_trade_no>
            //          <attach><![CDATA[订单额外描述]]></attach>
            //          <time_end><![CDATA[20141111170043]]></time_end>
            //          <trade_state><![CDATA[SUCCESS]]></trade_state>
            //     </xml>

            var resultXml = WechatWebClient.Post("https://api.mch.weixin.qq.com/pay/orderquery", Common.SortedDictionaryToXml(orderParams));

            return(Common.XmlToSortedDictionary(resultXml));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 删除个性化菜单
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="menuId">post数据(个性菜单id)</param>
        /// <returns>ResultModels.WechatResult</returns>
        public static ResultModels.WechatResult DeletePersonaliseMenu(string appId, string appSecret, string menuId)
        {
            string url = string.Format("https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new { menuid = menuId };

            return(WechatWebClient.Post <ResultModels.WechatResult>(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 测试个性化菜单匹配结果
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="userId">post数据(user_id可以是粉丝的OpenID,也可以是粉丝的微信号。)</param>
        /// <returns>string</returns>
        public static string TryMatchPersonaliseMenu(string appId, string appSecret, string userId)
        {
            string url = string.Format("https://api.weixin.qq.com/cgi-bin/menu/trymatch?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new { user_id = userId };

            return(WechatWebClient.Post(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 第一种方式:创建卡券二维码图片进行投放
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="cardId">卡券id</param>
        /// <param name="openId">指定领取者的openid,只有该用户能领取。bind_openid字段为true的卡券必须填写,非指定openid不必填写</param>
        /// <param name="code">卡券Code码,use_custom_code字段为true的卡券必须填写,非自定义code不必填写</param>
        /// <param name="isNeverExpires">是否绝不过期,True:是;False:会过期</param>
        /// <param name="validTime">当isNeverExpires为False时需要指定有效时间</param>
        /// <returns>二维码图片</returns>
        public static string ShowCardQrcode(string appId, string appSecret, string cardId, string openId = "", string code = "", bool isNeverExpires = true, int validTime = 1800)
        {
            if (validTime < 60 || validTime > 1800)
            {
                validTime = 1800;
            }

            string url = string.Format("https://api.weixin.qq.com/card/qrcode/create?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var result = new ResultModels.CardQrcodeResult();

            if (isNeverExpires)
            {
                var obj = new
                {
                    action_name = "QR_CARD",
                    action_info = new
                    {
                        card = new
                        {
                            card_id        = cardId,
                            code           = code,
                            openid         = openId,
                            is_unique_code = false,
                            outer_id       = 1
                        }
                    }
                };

                result = WechatWebClient.Post <ResultModels.CardQrcodeResult>(url, JsonConvert.SerializeObject(obj));
            }
            else
            {
                var obj = new
                {
                    action_name    = "QR_CARD",
                    expire_seconds = validTime,
                    action_info    = new
                    {
                        card = new
                        {
                            card_id        = cardId,
                            code           = code,
                            openid         = openId,
                            is_unique_code = false,
                            outer_id       = 1
                        }
                    }
                };

                result = WechatWebClient.Post <ResultModels.CardQrcodeResult>(url, JsonConvert.SerializeObject(obj));
            }

            return(string.Format("https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={0}", Uri.EscapeDataString(result.ticket)));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 查询卡券详情
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="cardId">卡券id</param>
        /// <returns></returns>
        public static string GetCardDetail(string appId, string appSecret, string cardId)
        {
            string url = string.Format("https://api.weixin.qq.com/card/get?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new
            {
                card_id = cardId,
            };

            return(WechatWebClient.Post(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 删除卡券
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="cardId">卡券id</param>
        /// <returns>ResultModels.WechatResult</returns>
        public static ResultModels.WechatResult DeleteCard(string appId, string appSecret, string cardId)
        {
            string url = string.Format("https://api.weixin.qq.com/card/delete?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new
            {
                card_id = cardId
            };

            return(WechatWebClient.Post <ResultModels.WechatResult>(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 查询该用户卡包里属于该appid下的卡券
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="model">Models.GetUserCardListModel</param>
        /// <returns>ResultModels.GetUserCardListResult</returns>
        public static ResultModels.GetUserCardListResult GetUserCardList(string appId, string appSecret, Models.GetUserCardListModel model)
        {
            string url = string.Format("https://api.weixin.qq.com/card/user/getcardlist?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new
            {
                openid  = model.OpenID,
                card_id = model.CardId
            };

            return(WechatWebClient.Post <ResultModels.GetUserCardListResult>(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 设置卡券失效接口
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="code">设置失效的Code码</param>
        /// <param name="cardId">卡券id,非自定义卡券不需要输入</param>
        /// <returns>ResultModels.WechatResult</returns>
        public static ResultModels.WechatResult SetCardInvalid(string appId, string appSecret, Models.SetCardInvalidModel model)
        {
            string url = string.Format("https://api.weixin.qq.com/card/code/unavailable?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new
            {
                code    = model.Code,
                card_id = model.CardId
            };

            return(WechatWebClient.Post <ResultModels.WechatResult>(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 查询状态卡券的列表
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="model">Models.GetCardModel</param>
        /// <returns>ResultModels.GetCardListResult</returns>
        public static ResultModels.GetCardListResult GetCardList(string appId, string appSecret, Models.GetCardListModel model)
        {
            string url = string.Format("https://api.weixin.qq.com/card/batchget?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new
            {
                offset      = model.Offset < 0 ? 0 : model.Offset,
                count       = model.Count > 50 ? 50 : model.Count,
                status_list = model.StatusList
            };

            return(WechatWebClient.Post <ResultModels.GetCardListResult>(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 修改库存接口
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="model">Models.UpdateCardStockModel</param>
        /// <returns>ResultModels.WechatResult</returns>
        public static ResultModels.WechatResult UpdateCardStock(string appId, string appSecret, Models.UpdateCardStockModel model)
        {
            string url = string.Format("https://api.weixin.qq.com/card/modifystock?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new
            {
                card_id = model.CardId,
                increase_stock_value = model.IncreaseStockValue,
                reduce_stock_value   = model.ReduceStockValue,
            };

            return(WechatWebClient.Post <ResultModels.WechatResult>(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 12
0
        /// 第三种:通过群发卡券投放卡券
        #endregion

        #region 核销卡券
        #endregion

        #region 管理卡券
        /// <summary>
        /// 查询卡券信息
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="model">model</param>
        /// <returns>ResultModels.GetCodeResult</returns>
        public static ResultModels.GetCodeResult GetCode(string appId, string appSecret, Models.GetCodeModel model)
        {
            string url = string.Format("https://api.weixin.qq.com/card/code/get?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new
            {
                card_id       = model.CardId,
                code          = model.Code,
                check_consume = model.CheckConsume
            };

            return(WechatWebClient.Post <ResultModels.GetCodeResult>(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 13
0
        /// 第二种:添加卡券JS-SDK进行投放

        /// <summary>
        /// 第三种:通过创建货架接口投放卡券
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="model">Models.CardShelvesModel</param>
        /// <returns>ResultModels.CardShelvesResult</returns>
        public static ResultModels.CardShelvesResult CreateShelves(string appId, string appSecret, Models.CardShelvesModel model)
        {
            string url = string.Format("https://api.weixin.qq.com/card/landingpage/create?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new
            {
                banner     = model.Banner,
                page_title = model.PageTitle,
                can_share  = model.CanShare,
                scene      = model.Scene,
                card_list  = model.CardList
            };

            return(WechatWebClient.Post <ResultModels.CardShelvesResult>(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 14
0
        /// <summary>
        /// 测速上报
        /// </summary>
        /// <param name="orderParams">发送或者接收到的数据集合M按照ASCII码字典序集合</param>
        /// <returns></returns>
        public static SortedDictionary <string, object> Report(SortedDictionary <string, object> orderParams)
        {
            // 注意:
            //      商户在调用微信支付提供的相关接口时,会得到微信支付返回的相关信息以及获得整个接口的响应时间。为提高整体的服务水平,协助商户一起提高服务质量,微信支付提供了相关接口调用耗时和返回信息的主动上报接口,微信支付可以根据商户侧上报的数据进一步优化网络部署,完善服务监控,和商户更好的协作为用户提供更好的业务体验。
            //
            // 返回结果:
            //      <xml>
            //          <return_code><![CDATA[SUCCESS/FAIL]]></return_code>
            //          <return_msg><![CDATA[返回信息,如非空,为错误原因(签名失败/参数格式校验错误)]]></return_msg>
            //      </xml>

            var resultXml = WechatWebClient.Post("https://api.mch.weixin.qq.com/payitil/report", Common.SortedDictionaryToXml(orderParams));

            return(Common.XmlToSortedDictionary(resultXml));
        }
Exemplo n.º 15
0
        /// <summary>
        /// 发送模板消息
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="openId">openid</param>
        /// <param name="templateId">模板id</param>
        /// <param name="url">跳转地址</param>
        /// <param name="color">消息颜色</param>
        /// <param name="data">消息内容</param>
        /// <returns>响应内容</returns>
        public static string SendTempleteMessage(string appId, string appSecret, string openId, string templateId, string url, string color, string data)
        {
            string address = string.Format("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}", AccessToken.GetToken(appId, appSecret));

            object obj = new
            {
                touser      = openId,
                template_id = templateId,
                url         = url,
                topcolor    = color,
                data        = data
            };

            return(WechatWebClient.Post(address, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 16
0
        /// <summary>
        /// 申请开通摇一摇周边功能接口
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="model">model(摇一摇周边申请model)</param>
        /// <returns></returns>
        public static string Apply(string appId, string appSecret, Models.ShakeAroundApplyModel model)
        {
            string url = string.Format("https://api.weixin.qq.com/shakearound/account/register?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new
            {
                name                    = model.Name,
                phone_number            = model.PhoneNumber,
                email                   = model.Email,
                industry_id             = model.IndustryId,
                qualification_cert_urls = model.QualificationCertUrls,
                apply_reason            = model.ApplyReason
            };

            return(WechatWebClient.Post(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 17
0
        /// <summary>
        /// 拉取特殊卡券概况数据接口
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="model">Models.GetCardStatisticalModel</param>
        /// <returns>ResultModels.GetCardStatisticalResult</returns>
        public static ResultModels.GetCardStatisticalResult GetSpecialCardStatistical(string appId, string appSecret, Models.GetCardStatisticalModel model)
        {
            int interval = (model.EndDate - model.BeginDate).Days;

            model.EndDate = interval > 62 ? model.BeginDate.AddDays(62) : model.EndDate;

            string url = string.Format("https://api.weixin.qq.com/datacube/getcardmembercardinfo?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new
            {
                begin_date  = model.BeginDate.ToString("yyyy-MM-dd"),
                end_date    = model.EndDate.ToString("yyyy-MM-dd"),
                cond_source = model.CondSource
            };

            return(WechatWebClient.Post <ResultModels.GetCardStatisticalResult>(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 18
0
        /// <summary>
        /// 统一下单
        /// </summary>
        /// <param name="orderParams">发送或者接收到的数据集合M按照ASCII码字典序集合</param>
        /// <returns></returns>
        public static SortedDictionary <string, object> UnifiedOrder(SortedDictionary <string, object> orderParams)
        {
            // 返回结果: xml转换成的SortedDictionary
            //     <xml>
            //          <return_code><![CDATA[SUCCESS]]></return_code>
            //          <return_msg><![CDATA[OK]]></return_msg>
            //          <appid><![CDATA[wx2421b1c4370ec43b]]></appid>
            //          <mch_id><![CDATA[10000100]]></mch_id>
            //          <nonce_str><![CDATA[IITRi8Iabbblz1Jc]]></nonce_str>
            //          <sign><![CDATA[7921E432F65EB8ED0CE9755F0E86D72F]]></sign>
            //          <result_code><![CDATA[SUCCESS]]></result_code>
            //          <prepay_id><![CDATA[wx201411101639507cbf6ffd8b0779950874]]></prepay_id>
            //          <trade_type><![CDATA[JSAPI]]></trade_type>
            //      </xml>
            //

            var resultXml = WechatWebClient.Post("https://api.mch.weixin.qq.com/pay/unifiedorder", Common.SortedDictionaryToXml(orderParams));

            return(Common.XmlToSortedDictionary(resultXml));
        }
Exemplo n.º 19
0
        /// <summary>
        /// 关闭订单
        /// </summary>
        /// <param name="orderParams">发送或者接收到的数据集合M按照ASCII码字典序集合</param>
        /// <returns></returns>
        public static SortedDictionary <string, object> CloseOrder(SortedDictionary <string, object> orderParams)
        {
            //商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口
            //订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟。

            // 返回结果: xml转换成的SortedDictionary
            //      <xml>
            //          <return_code><![CDATA[SUCCESS]]></return_code>
            //          <return_msg><![CDATA[OK]]></return_msg>
            //          <appid><![CDATA[wx2421b1c4370ec43b]]></appid>
            //          <mch_id><![CDATA[10000100]]></mch_id>
            //          <nonce_str><![CDATA[BFK89FC6rxKCOjLX]]></nonce_str>
            //          <sign><![CDATA[72B321D92A7BFA0B2509F3D13C7B1631]]></sign>
            //          <result_code><![CDATA[SUCCESS]]></result_code>
            //      </xml>

            var resultXml = WechatWebClient.Post("https://api.mch.weixin.qq.com/pay/closeorder", Common.SortedDictionaryToXml(orderParams));

            return(Common.XmlToSortedDictionary(resultXml));
        }
Exemplo n.º 20
0
        /// <summary>
        /// 设置卡券买单接口
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="cardId">卡券id</param>
        /// <param name="isOpen">是否开启买单功能,填true/false</param>
        /// <returns>ResultModels.WechatResult</returns>
        public static ResultModels.WechatResult SetCardCanPay(string appId, string appSecret, string cardId, bool isOpen = true)
        {
            var card = GetCardDetail(appId, appSecret, cardId);

            var result = JsonConvert.DeserializeObject <dynamic>(card);

            var card_type = result["card"]["card_type"].ToString().ToLower();

            JArray ja = (JArray)result["card"][card_type]["base_info"]["location_id_list"];

            string url = string.Format("https://api.weixin.qq.com/card/paycell/set?access_token={0}", AccessToken.GetToken(appId, appSecret));

            var obj = new
            {
                card_id = cardId,
                is_open = isOpen
            };

            return(WechatWebClient.Post <ResultModels.WechatResult>(url, JsonConvert.SerializeObject(obj)));
        }
Exemplo n.º 21
0
        /// <summary>
        /// 创建永久二维码图片URL。
        /// 注释:这里返回的直接是一张图片,可以直接展示和下载
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="scene_id">场景值ID,临时二维码时为32位非0整型,永久二维码时最大值为100000(目前参数只支持1--100000)。</param>
        /// <returns>二维码图片URL</returns>
        public static string ShowPermanentQrcode(string appId, string appSecret, int scene_id)
        {
            string url = string.Format("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={0}", AccessToken.GetToken(appId, appSecret));
            var    obj = new
            {
                action_name = "QR_LIMIT_SCENE",
                action_info = new
                {
                    scene = new
                    {
                        scene_id = scene_id
                    }
                }
            };

            var result = WechatWebClient.Post(url, JsonConvert.SerializeObject(obj));

            var ticket = JsonConvert.DeserializeObject <dynamic>(result)["ticket"].ToString();

            return(string.Format("https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={0}", Uri.EscapeDataString(ticket)));
        }
Exemplo n.º 22
0
        /// <summary>
        /// 查询退款单
        /// </summary>
        /// <param name="orderParams">发送或者接收到的数据集合M按照ASCII码字典序集合</param>
        /// <returns></returns>
        public static SortedDictionary <string, object> QueryRefundOrder(SortedDictionary <string, object> orderParams)
        {
            //提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。
            // 返回结果: xml转换成的SortedDictionary
            //      <xml>
            //          <appid><![CDATA[wx2421b1c4370ec43b]]></appid>
            //          <mch_id><![CDATA[10000100]]></mch_id>
            //          <nonce_str><![CDATA[TeqClE3i0mvn3DrK]]></nonce_str>
            //          <out_refund_no_0><![CDATA[1415701182]]></out_refund_no_0>
            //          <out_trade_no><![CDATA[1415757673]]></out_trade_no>
            //          <refund_count>1</refund_count>
            //          <refund_fee_0>1</refund_fee_0>
            //          <refund_id_0><![CDATA[2008450740201411110000174436]]></refund_id_0>
            //          <refund_status_0><![CDATA[PROCESSING]]></refund_status_0>
            //          <result_code><![CDATA[SUCCESS]]></result_code>
            //          <return_code><![CDATA[SUCCESS]]></return_code>
            //          <return_msg><![CDATA[OK]]></return_msg>
            //          <sign><![CDATA[1F2841558E233C33ABA71A961D27561C]]></sign>
            //          <transaction_id><![CDATA[1008450740201411110005820873]]></transaction_id>
            //      </xml>
            var resultXml = WechatWebClient.Post("https://api.mch.weixin.qq.com/pay/refundquery", Common.SortedDictionaryToXml(orderParams));

            return(Common.XmlToSortedDictionary(resultXml));
        }
Exemplo n.º 23
0
        /// <summary>
        /// 申请退款
        /// </summary>
        /// <param name="orderParams">发送或者接收到的数据集合M按照ASCII码字典序集合</param>
        /// <returns></returns>
        public static SortedDictionary <string, object> RefundOrder(SortedDictionary <string, object> orderParams)
        {
            // 返回结果: xml转换成的SortedDictionary
            //      <xml>
            //          <return_code><![CDATA[SUCCESS]]></return_code>
            //          <return_msg><![CDATA[OK]]></return_msg>
            //          <appid><![CDATA[wx2421b1c4370ec43b]]></appid>
            //          <mch_id><![CDATA[10000100]]></mch_id>
            //          <nonce_str><![CDATA[NfsMFbUFpdbEhPXP]]></nonce_str>
            //          <sign><![CDATA[B7274EB9F8925EB93100DD2085FA56C0]]></sign>
            //          <result_code><![CDATA[SUCCESS]]></result_code>
            //          <transaction_id><![CDATA[1008450740201411110005820873]]></transaction_id>
            //          <out_trade_no><![CDATA[1415757673]]></out_trade_no>
            //          <out_refund_no><![CDATA[1415701182]]></out_refund_no>
            //          <refund_id><![CDATA[2008450740201411110000174436]]></refund_id>
            //          <refund_channel><![CDATA[]]></refund_channel>
            //          <refund_fee>1</refund_fee>
            //          <coupon_refund_fee>0</coupon_refund_fee>
            //      </xml>
            //
            var resultXml = WechatWebClient.Post("https://api.mch.weixin.qq.com/secapi/pay/refund", Common.SortedDictionaryToXml(orderParams));

            return(Common.XmlToSortedDictionary(resultXml));
        }
Exemplo n.º 24
0
        /// <summary>
        /// 更新卡券
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="data">post内容(json格式的字符串)</param>
        /// <returns>ResultModels.UpdateCardResult</returns>
        public static ResultModels.UpdateCardResult UpdateCard(string appId, string appSecret, string data)
        {
            string url = string.Format("https://api.weixin.qq.com/card/update?access_token={0}", AccessToken.GetToken(appId, appSecret));

            return(WechatWebClient.Post <ResultModels.UpdateCardResult>(url, data));
        }
Exemplo n.º 25
0
        /// <summary>
        /// 上传卡券Logo
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="data">post数据(json格式)</param>
        /// <returns>成功:{"url":"http://mmbiz.qpic.cn/mmbiz/iaL1LJM1mF9aRKPZJkmG8xXhiaHqkKSVMMWeN3hLut7X7hicFNjakmxibMLGWpXrEXB33367o7zHN0CwngnQY7zb7g/0"};失败:{"errcode":40009,"errmsg":"invalid image size"}</returns>
        public static string UploadLogo(string appId, string appSecret, string data)
        {
            string url = string.Format("https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token={0}", AccessToken.GetToken(appId, appSecret));

            return(WechatWebClient.Post(url, data));
        }
Exemplo n.º 26
0
        /// <summary>
        /// 创建卡券
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="data">post数据(json格式)</param>
        /// <returns>ResultModels.CardResult</returns>
        public static ResultModels.CardResult CreateCard(string appId, string appSecret, string data)
        {
            string url = string.Format("https://api.weixin.qq.com/card/create?access_token={0}", AccessToken.GetToken(appId, appSecret));

            return(WechatWebClient.Post <ResultModels.CardResult>(url, data.ToString().Replace("\\", "").Replace("\"{", "{").Replace("}\"", "}")));
        }
Exemplo n.º 27
0
        /// <summary>
        /// 创建个性化菜单
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="model">ButtonGroupModel</param>
        /// <returns>ResultModels.GetPersonaliseMenuResult</returns>
        public static ResultModels.GetPersonaliseMenuResult CreatePersonaliseMenu(string appId, string appSecret, ButtonGroupModel model)
        {
            string url = string.Format("https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token={0}", AccessToken.GetToken(appId, appSecret));

            return(WechatWebClient.Post <ResultModels.GetPersonaliseMenuResult>(url, JsonConvert.SerializeObject(model)));
        }