Ejemplo n.º 1
0
        public void Test()
        {
            var tx_info = new RefundRequest_TX_INFO()
            {
                MONEY = "0.01",
                ORDER = "105000148164313190228144018226"
            };
            var refundRequest = new RefundRequest()
            {
                REQUEST_SN = QRModel.CreateREQUEST_SN(),
                CUST_ID    = QRModel.MERCHANTID,
                USER_ID    = "105000148164313-001",
                PASSWORD   = "******",
                LANGUAGE   = "CN",
                TX_CODE    = "5W1004",
                SIGNCERT   = "1111",
                SIGN_INFO  = "1111",
                TX_INFO    = tx_info
            };
            string request  = XmlHelper.SerializeToXmlStr(refundRequest, false);
            string returstr = HttpClientUtil.HttpPost("http://localhost:2582/pay/ccb/notice", request, "text/xml");


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

            dic.Add("ORDERID", "123123");
            dic.Add("POSID", "456456");
            string data = string.Empty;

            foreach (string key in dic.Keys)
            {
                data += key + "=" + dic[key] + "&";
            }
            string payStr = HttpClientUtil.HttpPost("http://localhost:2582/pay/ccb/notice", data.Trim('&')); //提交网银网关地址
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 退款申请
        /// </summary>
        public string Refund(string OrderId)
        {
            var tx_info = new RefundRequest_TX_INFO()
            {
                MONEY = "0.01",
                ORDER = OrderId
            };
            var refundRequest = new RefundRequest()
            {
                REQUEST_SN = QRModel.CreateREQUEST_SN(),
                CUST_ID    = QRModel.MERCHANTID,
                USER_ID    = "001",
                PASSWORD   = "******",
                LANGUAGE   = "CN",
                TX_CODE    = "5W1004",
                TX_INFO    = tx_info
            };
            string request = "<?xml version=\"1.0\" encoding=\"GB2312\" standalone=\"yes\" ?>" + XmlHelper.SerializeToXmlStr(refundRequest, true);



            int        port         = 9010;
            string     host         = "192.168.30.168";//服务器端ip地址
            IPAddress  ip           = IPAddress.Parse(host);
            IPEndPoint ipe          = new IPEndPoint(ip, port);
            Socket     clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            clientSocket.Connect(ipe);
            //send message<?xml version='1.0' encoding='GB2312' standalone='yes' ?>
            //string sendStr = "<TX><REQUEST_SN>19022818202467701</REQUEST_SN><CUST_ID>105000148164313</CUST_ID><USER_ID>105000148164313-001</USER_ID><PASSWORD>jlkj2019</PASSWORD><TX_CODE>5W1004</TX_CODE><LANGUAGE>CN</LANGUAGE><TX_INFO><MONEY>0.01</MONEY><ORDER>105000148164313190228121021514</ORDER></TX_INFO><SIGN_INFO></SIGN_INFO><SIGNCERT></SIGNCERT></TX>";
            byte[] sendBytes = Encoding.Default.GetBytes(request);
            clientSocket.Send(sendBytes);

            //receive message
            string recStr = "";

            byte[] recBytes = new byte[4096];
            int    bytes    = clientSocket.Receive(recBytes, recBytes.Length, 0);

            recStr += Encoding.Default.GetString(recBytes, 0, bytes);
            Console.WriteLine(recStr);

            clientSocket.Close();



            //    string returstr = HttpClientUtil.HttpPost("https://192.168.30.168:9010", request, "text/xml");
            //退款返回数据
            //var RETURN_CODE = XmlHelper.GetNodeValue(returstr, XmlHelper.XmlType.String, "RETURN_CODE");
            // if (RETURN_CODE.RETURN_CODE.Equals("000000"))
            //{
            //    //交易成功todo
            //}
            //var refundResponse = XmlHelper.XmlDeserialize<RefundResponse>(returstr);
            //if (refundResponse.RETURN_CODE.Equals("000000"))
            //{
            //    //交易成功todo
            //}
            return("");
        }