Ejemplo n.º 1
0
        //1.7 退款状态查询 add 20181108
        public bool ApiRefundStatusQuery(string refund_order_id, string merchant_id, out Dictionary <string, string> result)
        {
            const string httpurl = "http://cashier.cdsoftware.cn/index.php/api/channel/query_refund";
            bool         ret     = false;

            //string key = "bf0ac37accfb6ed19d4676a54d6aaaf0";

            result = new Dictionary <string, string>();

            //1 json
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("refund_order_id", refund_order_id);
            dic.Add("timestamp", GetTimeStamp());
            string jsonData = JsonConvert.SerializeObject(dic);

            LogManager.WriteLogTran(LogType.Message, "ApiRefundStatusQuery jsonData= ", jsonData.ToString());

            //2 encrypt
            string encryptData = AESEncrypt(jsonData, Var.gkey);

            string httppara = string.Format("merchant_id={0}&data={1}", merchant_id, encryptData);

            LogManager.WriteLogTran(LogType.Message, "ApiRefundStatusQuery httppara= ", httppara.ToString());

            //3 send
            string inResult = HttpPost(httpurl, httppara, null);

            LogManager.WriteLogTran(LogType.Message, "ApiRefundStatusQuery Result= ", inResult.ToString());

            try
            {
                //4 get return json
                JObject result_json = JsonConvert.DeserializeObject(inResult) as JObject;
                if (result_json.Count == 0)
                {
                    return(false);
                }

                //5 judge
                if (result_json["code"].ToString() == "1")
                {
                    inResult = result_json["msg"].ToString();
                    LogManager.WriteLogTran(LogType.Message, "inResult= ", inResult.ToString());

                    string tmpdata = result_json["data"].ToString();

                    string tmpJson = AESDecrypt(tmpdata, Var.gkey);

                    result = JsonConvert.DeserializeObject <Dictionary <string, string> >(tmpJson);

                    ret = true;
                }
                else if (result_json["code"].ToString() == "0")
                {
                    result.Add("msg", "更新失败");
                    ret = false;
                }
                else
                {
                    //log
                    ret = false;
                }
            }
            catch (Exception)
            {
                ret = false;
            }
            return(ret);
        }
Ejemplo n.º 2
0
        //1.2下单
        public bool InterfaceAddOrder(string paychannel, string payment, string amount, string auth_code, string subject, string body, string merchant_id, string store_id, string operator_id, string device_id, string key, out string order_id, out Dictionary <string, string> result)
        {
            const string httpurl = "http://cashier.cdsoftware.cn/index.php/api/channel/add_order";
            bool         ret     = false;

            //key = "bf0ac37accfb6ed19d4676a54d6aaaf0";

            result   = new Dictionary <string, string>();
            order_id = string.Empty;

            //1 json
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("payment", payment);
            dic.Add("channel", paychannel);
            dic.Add("order_id", "");
            dic.Add("amount", amount);
            dic.Add("auth_code", auth_code);
            dic.Add("subject", subject);
            dic.Add("body", body);
            dic.Add("store_id", store_id);
            dic.Add("operator_id", operator_id);
            dic.Add("device_id", device_id);
            dic.Add("timestamp", GetTimeStamp());

            string jsonData = JsonConvert.SerializeObject(dic);

            LogManager.WriteLogTran(LogType.Message, "InterfaceAddOrder jsonData= ", jsonData.ToString());

            //2 encrypt
            string encryptData = AESEncrypt(jsonData, Var.gkey);

            string httppara = string.Format("merchant_id={0}&data={1}", merchant_id, encryptData);

            LogManager.WriteLogTran(LogType.Message, "InterfaceAddOrder httppara= ", httppara.ToString());

            //3 send
            string inResult = HttpPost(httpurl, httppara, null);

            LogManager.WriteLogTran(LogType.Message, "InterfaceAddOrder Result= ", inResult.ToString());

            try
            {
                //4 get return json
                JObject result_json = JsonConvert.DeserializeObject(inResult) as JObject;
                if (result_json.Count == 0)
                {
                    return(false);
                }

                //5 judge
                if (result_json["code"].ToString() == "1")
                {
                    inResult = result_json["msg"].ToString();
                    LogManager.WriteLogTran(LogType.Message, "inResult= ", inResult.ToString());

                    string tmpdata = result_json["data"].ToString();

                    string tmpJson = AESDecrypt(tmpdata, Var.gkey);

                    result = JsonConvert.DeserializeObject <Dictionary <string, string> >(tmpJson);

                    result.TryGetValue("order_id", out order_id);

                    ret = true;
                }
                else if (result_json["code"].ToString() == "0")
                {
                    ret = false;
                }
                else
                {
                    //log
                    ret = false;
                }
            }
            catch (Exception)
            {
                ret = false;
            }
            return(ret);
        }