Ejemplo n.º 1
0
        /// <summary>
        /// 查询支付业务是否存在
        /// </summary>
        /// <param name="payBUS"></param>
        /// <param name="cbsRespAction">cbs返回参数回调函数,主要用于记录日志</param>
        /// <param name="payParamAction">查询参数回调函数,主要用于记录日志,返回失败才会执行,第一个参数是请求参数,第二个参数是错误信息</param>
        /// <returns></returns>
        public string SearchPayBUS(PayBUSInfo payBUS, Action <string> cbsRespAction = null, Action <string, string> payParamAction = null)
        {
            string error = "";
            //生成支付请求信息参数
            string param   = this.PayBUSInfoXMLStr(payBUS);
            string respStr = HttpHelper.Post(Url, param);

            cbsRespAction?.Invoke(respStr);

            respStr = this.GetXMLInnerData(respStr);
            CBSERPPGK respObj = XMLHelper.DeserializeToObject <CBSERPPGK>(respStr);

            if (!respObj.IsSucess)
            {
                bool flag1 = false;
                bool flag3 = false;

                if (respObj.INFO != null)
                {
                    respObj.INFO.ERRMSG = respObj.INFO.ERRMSG.Replace("\n", "");
                    if (!string.IsNullOrEmpty(respObj.INFO.ERRMSG))
                    {
                        error += "\n" + respObj.INFO.ERRMSG;
                    }
                    else
                    {
                        flag1 = !flag1;
                    }
                }
                if (respObj.SYCOMRETZ != null)
                {
                    respObj.SYCOMRETZ.ERRMSG = respObj.SYCOMRETZ.ERRMSG.Replace("\n", "");
                    if (!string.IsNullOrEmpty(respObj.SYCOMRETZ.ERRMSG))
                    {
                        error += "\n" + respObj.SYCOMRETZ.ERRMSG;
                    }
                    else
                    {
                        flag3 = !flag3;
                    }
                }

                payParamAction?.Invoke(param, error);
                return("");
            }
            else
            {
                return(respObj.ERPAYBUSZ.BUSNBR);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 生成查询支付业务是否存在请求信息xml字符串
        /// </summary>
        /// <param name="payInfo"></param>
        /// <returns></returns>
        private string PayBUSInfoXMLStr(PayBUSInfo payInfo)
        {
            string        head = "<?xml version='1.0' encoding='GBK'?><PGK><DATA><![CDATA[";
            StringBuilder sb   = new StringBuilder();

            sb.Append("<?xml version='1.0' encoding='GBK'?>");
            sb.Append("<CBSERPPGK>");
            sb.Append("<INFO><FUNNAM>ERPAYBUS</FUNNAM></INFO>");
            sb.Append("<ERPAYBUSX>");
            sb.Append($"<CLTACC>{payInfo.CLTACC}</CLTACC>");
            sb.Append($"<REVACC>{payInfo.REVACC}</REVACC>");
            sb.Append($"<TRSAMT>{payInfo.TRSAMT}</TRSAMT>");
            sb.Append($"<REFNBR>{payInfo.REFNBR}</REFNBR>");
            sb.Append("</ERPAYBUSX>");
            sb.Append("</CBSERPPGK>");
            string body      = sb.ToString();
            string mbody     = body.Replace("\n", "").Replace("\r", "");
            string checkCode = this.CheckCode(CRC32_PASSWORD + Key + mbody);
            string end       = $"]]></DATA><CHECKCODE>{checkCode}</CHECKCODE></PGK>";

            return(head + body + end);
        }