Exemple #1
0
        //微信统一下单获取prepay_id & 再次签名返回数据
        private static string Getprepay_id(string appid, string attach, string body, string mch_id, string nonce_str, string notify_url, string openid, string bookingNo, int total_fee)
        {
            var    url    = "https://api.mch.weixin.qq.com/pay/unifiedorder"; //微信统一下单请求地址
            string strA   = "appid=" + appid + "&attach=" + attach + "&body=" + body + "&mch_id=" + mch_id + "&nonce_str=" + nonce_str + "&notify_url=" + notify_url + "&openid=" + openid + "&out_trade_no=" + bookingNo + "&spbill_create_ip=61.50.221.43&total_fee=" + total_fee + "&trade_type=JSAPI";
            string strk   = strA + "&key=" + _key;                            //key为商户平台设置的密钥key(假)
            string strMD5 = Md5Helper.Md5(strk).ToUpper();                    //MD5签名

            //签名
            var formData = "<xml>";

            formData += "<appid>" + appid + "</appid>";                      //appid
            formData += "<attach>" + attach + "</attach>";                   //附加数据(描述)
            formData += "<body>" + body + "</body>";                         //商品描述
            formData += "<mch_id>" + mch_id + "</mch_id>";                   //商户号
            formData += "<nonce_str>" + nonce_str + "</nonce_str>";          //随机字符串,不长于32位。
            formData += "<notify_url>" + notify_url + "</notify_url>";       //通知地址
            formData += "<openid>" + openid + "</openid>";                   //openid
            formData += "<out_trade_no>" + bookingNo + "</out_trade_no>";    //商户订单号
            formData += "<spbill_create_ip>61.50.221.43</spbill_create_ip>"; //终端IP
            formData += "<total_fee>" + total_fee + "</total_fee>";          //支付金额单位为(分)
            formData += "<trade_type>JSAPI</trade_type>";                    //交易类型(JSAPI--公众号支付)
            formData += "<sign>" + strMD5 + "</sign>";                       //签名
            formData += "</xml>";

            //请求数据
            var getdata = AjaxRequest.HttpPost(url, formData);

            //获取xml数据
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(getdata);
            //xml格式转json
            string json = doc.ToJsonStr();

            JObject jo        = json.ToJsonObject <JObject>();
            string  prepay_id = jo["xml"]["prepay_id"]["#cdata-section"].ToString();

            //时间戳
            string _time = getTime().ToString();

            //再次签名返回数据至小程序
            string strB = "appId=" + appid + "&nonceStr=" + nonce_str + "&package=prepay_id=" + prepay_id + "&signType=MD5&timeStamp=" + _time + "&key=" + _key;

            //wx自己写的一个类
            PaymentEntity payment = new PaymentEntity();

            payment.timeStamp = _time;
            payment.nonceStr  = nonce_str;
            payment.package   = "prepay_id=" + prepay_id;
            payment.paySign   = Md5Helper.Md5(strB).ToUpper();
            payment.signType  = "MD5";

            //向小程序返回json数据
            return(payment.ToJsonStr());
        }
        /*----------------------end--------------------------*/

        #region 接口统一请求接口
        string GetRequestResult(Dictionary <string, string> dicParam, string apiType)
        {
            string resultContent = "";

            try
            {
                string param = this.GetParam(dicParam, apiType);
                resultContent = AjaxRequest.HttpPost(CommonCacheConfig.pdd_api_host + "?" + param, "", null, "", "application/json;charset=UTF-8");
            }
            catch (Exception)
            {
                throw;
            }
            return(resultContent);
        }
Exemple #3
0
        string GetRequestResult(string param_json, string api_name)
        {
            string resultContent = "";

            try
            {
                resultContent = AjaxRequest.HttpPost(CommonCacheConfig.haodanku_api_host + "get_orienteeringitems" + "?" + param_json, null, "", "application/json;charset=UTF-8");
            }
            catch (Exception)
            {
                throw;
            }

            return(resultContent);
        }
        /// <summary>
        /// 拼多多商品转链
        /// </summary>
        /// <param name="goods_Zs_UnitGenerateRequest"></param>
        /// <returns></returns>
        public Goods_Zs_UnitGenerateResponse Good_Convert_Link(Goods_Zs_UnitGenerateRequest goods_Zs_UnitGenerateRequest)
        {
            Goods_Zs_UnitGenerateResponse goods_Zs_UnitGenerateResponse = null;

            try
            {
                string param         = this.GetParam(goods_Zs_UnitGenerateRequest.ModelToUriParamByDic(), "pdd.ddk.goods.zs.unit.url.gen");
                string resultContent = AjaxRequest.HttpPost(CommonCacheConfig.pdd_api_host + "?" + param, "", null, "", "application/json;charset=UTF-8");

                goods_Zs_UnitGenerateResponse = resultContent.ToJsonObject <Goods_Zs_UnitGenerateResponse>();
            }
            catch (Exception ex)
            {
                LogHelper.WriteException("Good_Convert_Link", ex);
            }
            return(goods_Zs_UnitGenerateResponse);
        }
        /// <summary>
        /// 生成营销工具推广链接
        /// </summary>
        /// <param name="rp_Prom_Url_GenerateRequest"></param>
        /// <returns></returns>
        public Rp_Prom_Url_GenerateResponse Get_Rp_Prom_Url_Generate(Rp_Prom_Url_GenerateRequest rp_Prom_Url_GenerateRequest)
        {
            Rp_Prom_Url_GenerateResponse rp_Prom_Url_GenerateResponse = null;

            try
            {
                string param         = this.GetParam(rp_Prom_Url_GenerateRequest.ModelToUriParamByDic(), "pdd.ddk.rp.prom.url.generate");
                string resultContent = AjaxRequest.HttpPost(CommonCacheConfig.pdd_api_host + "?" + param, "", null, "", "application/json;charset=UTF-8");

                rp_Prom_Url_GenerateResponse = resultContent.ToJsonObject <Rp_Prom_Url_GenerateResponse>();
            }
            catch (Exception ex)
            {
                LogHelper.WriteException("Get_Rp_Prom_Url_Generate", ex);
            }
            return(rp_Prom_Url_GenerateResponse);
        }
        /// <summary>
        /// 查询是否绑定备案
        /// </summary>
        /// <param name="member_Authority_QueryRequest"></param>
        /// <returns></returns>
        public Member_Authority_QueryResponse GetMemberAuthorityQuery(Member_Authority_QueryRequest member_Authority_QueryRequest)
        {
            Member_Authority_QueryResponse member_Authority_QueryResponse = null;

            try
            {
                string param         = this.GetParam(member_Authority_QueryRequest.ModelToUriParamByDic(), "pdd.ddk.member.authority.query");
                string resultContent = AjaxRequest.HttpPost(CommonCacheConfig.pdd_api_host + "?" + param, "", null, "", "application/json;charset=UTF-8");

                member_Authority_QueryResponse = resultContent.ToJsonObject <Member_Authority_QueryResponse>();
            }
            catch (Exception ex)
            {
                LogHelper.WriteException("GetMemberAuthorityQuery", ex);
            }
            return(member_Authority_QueryResponse);
        }
        /// <summary>
        /// 获取拼多多订单详情
        /// </summary>
        /// <param name="order_Detail_GetRequest"></param>
        /// <returns></returns>
        public Order_Detail_GetResponse GetOrderDetailInfo(Order_Detail_GetRequest order_Detail_GetRequest)
        {
            Order_Detail_GetResponse order_Detail_GetResponse = null;

            try
            {
                string param         = this.GetParam(order_Detail_GetRequest.ModelToUriParamByDic(), "pdd.ddk.order.detail.get");
                string resultContent = AjaxRequest.HttpPost(CommonCacheConfig.pdd_api_host + "?" + param, "", null, "", "application/json;charset=UTF-8");

                order_Detail_GetResponse = resultContent.ToJsonObject <Order_Detail_GetResponse>();
            }
            catch (Exception ex)
            {
                LogHelper.WriteException("GetOrderDetailInfo", ex);
            }
            return(order_Detail_GetResponse);
        }
        /// <summary>
        /// 获取拼多多增量订单数据
        /// </summary>
        /// <param name="incrementOrderListRequest"></param>
        /// <returns></returns>
        public IncrementOrder_List_GetResponse GetIncrementOrderList(IncrementOrderListRequest incrementOrderListRequest)
        {
            IncrementOrder_List_GetResponse incrementOrder_List_GetResponse = null;

            try
            {
                string param         = this.GetParam(incrementOrderListRequest.ModelToUriParamByDic(), "pdd.ddk.order.list.increment.get");
                string resultContent = AjaxRequest.HttpPost(CommonCacheConfig.pdd_api_host + "?" + param, "", null, "", "application/json;charset=UTF-8");

                incrementOrder_List_GetResponse = resultContent.ToJsonObject <IncrementOrder_List_GetResponse>();
            }
            catch (Exception ex)
            {
                LogHelper.WriteException("GetIncrementOrderList", ex);
            }

            return(incrementOrder_List_GetResponse);
        }
Exemple #9
0
        string GetApiResponse(string api_type, string paramJson, bool is_post = true)
        {
            string returnContent = "";
            Dictionary <string, string> header = new Dictionary <string, string>();

            //header.Add("Connection", "Upgrade ");
            header.Add("Upgrade", "HTTP/3.0 ");
            if (is_post)
            {
                returnContent = AjaxRequest.HttpPost(api_host + makeRequestParam(api_type, paramJson), paramJson, header, "", "application/json");
            }
            else
            {
                returnContent = AjaxRequest.HttpGet(api_host + makeRequestParam(api_type, paramJson), paramJson);
            }

            return(returnContent);
        }
        string GetRequestResult(string param_json, string api_name)
        {
            string resultContent = "";
            try
            {
                Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>();
                dic.Add("param_json", param_json);

                string param = this.GetParam(dic, api_name);
                resultContent = AjaxRequest.HttpPost(CommonCacheConfig.jd_api_host + "?" + param, null, "", "application/json;charset=UTF-8");
            }
            catch (Exception)
            {
                throw;
            }

            return resultContent;
        }
        public Pdd_TokenInfoEntity Refersh_pdd_Token(string refresh_token)
        {
            Pdd_TokenInfoEntity pdd_TokenInfoEntity = null;

            try
            {
                Dictionary <string, string> paramDic = new Dictionary <string, string>();
                paramDic.Add("refresh_token", refresh_token);
                string param         = this.GetParam(paramDic, "pdd.pop.auth.token.refresh");
                string resultContent = AjaxRequest.HttpPost(CommonCacheConfig.pdd_api_host + "?" + param, "", null, "", "application/json;charset=UTF-8");

                pdd_TokenInfoEntity = resultContent.ToJsonObject <Pdd_TokenInfoResponse>().pop_auth_token_refresh_response;

                LogHelper.WriteLog("Refersh_pdd_Token", resultContent);
            }
            catch (Exception ex)
            {
                LogHelper.WriteException("Refersh_pdd_Token", ex);
            }

            return(pdd_TokenInfoEntity);
        }