Beispiel #1
0
    /// <summary>
    /// 显示账单明细
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnPayDetail_Click(object sender, EventArgs e)
    {
        try
        {
            string sqlWhere = " OrderId='" + txtOldOrder.Text.Trim() + "' ";
            PbProject.Logic.ControlBase.BaseDataManage baseDataManage = new PbProject.Logic.ControlBase.BaseDataManage();
            List <Tb_Ticket_Order>     mOrderList    = baseDataManage.CallMethod("Tb_Ticket_Order", "GetList", null, new Object[] { sqlWhere }) as List <Tb_Ticket_Order>;
            List <Tb_Ticket_Passenger> PassengerList = baseDataManage.CallMethod("Tb_Ticket_Passenger", "GetList", null, new Object[] { sqlWhere }) as List <Tb_Ticket_Passenger>;


            List <string> strList = new PbProject.Logic.Pay.Bill().CreateOrderAndTicketPayDetailNew(mOrderList[0], PassengerList); //计算订单金额生成订单

            if (strList != null && strList.Count > 0)
            {
                foreach (string item in strList)
                {
                    txtReturnValue.Text += item + "\r\r\n";
                }

                txtReturnValue.Text += "PayMoney = " + mOrderList[0].PayMoney + "\r\r\n";
                txtReturnValue.Text += "OrderMoney = " + mOrderList[0].OrderMoney + "\r\r\n";
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), DateTime.Now.Ticks.ToString(), "alert('生成数据失败');", true);
            }
        }
        catch (Exception ex)
        {
        }
    }
Beispiel #2
0
    /// <summary>
    /// 计算订单金额
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnPayMoney_Click(object sender, EventArgs e)
    {
        try
        {
            string sqlWhere = " OrderId='" + txtOldOrder.Text.Trim() + "' ";
            PbProject.Logic.ControlBase.BaseDataManage baseDataManage = new PbProject.Logic.ControlBase.BaseDataManage();
            List <Tb_Ticket_Order>     mOrderList    = baseDataManage.CallMethod("Tb_Ticket_Order", "GetList", null, new Object[] { sqlWhere }) as List <Tb_Ticket_Order>;
            List <Tb_Ticket_Passenger> PassengerList = baseDataManage.CallMethod("Tb_Ticket_Passenger", "GetList", null, new Object[] { sqlWhere }) as List <Tb_Ticket_Passenger>;


            // PbProject.Logic.Pay.Data d = new PbProject.Logic.Pay.Data();
            //string PayMoney = d.CreateOrderPayMoney(mOrderList[0], PassengerList).ToString();
            //string OrderMoney = d.CreateOrderOrderMoney(mOrderList[0], PassengerList).ToString();

            PbProject.Logic.Pay.Bill bill = new PbProject.Logic.Pay.Bill();
            bill.CreateOrderAndTicketPayDetailNew(mOrderList[0], PassengerList);
            decimal PayMoney   = mOrderList[0].PayMoney;
            decimal OrderMoney = mOrderList[0].OrderMoney;


            txtReturnValue.Text += "PayMoney=" + PayMoney + ",OrderMoney=" + OrderMoney;
        }
        catch (Exception ex)
        {
        }
    }
    /// <summary>
    /// SetData
    /// </summary>
    private void SetData()
    {
        #region 参数

        //head
        string Version       = "";
        string ServiceCode   = "";
        string TransactionID = "";
        string SrcSysID      = "";
        string DstSysID      = "";
        string Result_code   = "";
        string Result_msg    = "";
        string order_no      = "";
        string HMAC          = "";
        //body
        string Employee_ID   = "";
        string PosSn         = "";
        string PosRequestID  = "";
        string ReferNo       = "";
        string OrderNo       = "";
        string Amount        = "";
        string Split         = "";
        string ReqTime       = "";
        string PayTypeCode   = "";
        string PayMethod     = "";
        string ChequeNo      = "";
        string BankCardName  = "";
        string BankCardNo    = "";
        string BankOrderNo   = "";
        string YeepayOrderNo = "";

        #endregion

        try
        {
            if (Request.RequestType == "POST")
            {
                //接收并读取POST过来的XML文件流
                StreamReader reader  = new StreamReader(Request.InputStream);
                String       xmlData = reader.ReadToEnd();
                XElement     root    = XElement.Parse(xmlData);

                //测试数据
                //String xmlData = "<?xml version='1.0' encoding='UTF-8'?><COD-MS><SessionHead><Version>1.0</Version><ServiceCode>COD403</ServiceCode><TransactionID>loyoyoCOD403201206133852742769</TransactionID><SrcSysID>yeepay</SrcSysID><DstSysID>loyoyo</DstSysID><ReqTime>20120613185635</ReqTime><HMAC>46a2796241d09cef6e2d7a47d66b58f3</HMAC></SessionHead><SessionBody><EmployeeID>123456</EmployeeID><PosSn>0373NL230526</PosSn><OrderNo></OrderNo><Amount>0.02</Amount><PosRequestID>100045</PosRequestID><ReferNo>295220459300</ReferNo><PayTypeCode>1</PayTypeCode><PayMethod>1</PayMethod><ChequeNo></ChequeNo><BankCardNo>532458******8327</BankCardNo><BankCardName>中国建设银行</BankCardName><BankOrderNo>06061311064879185607216579479811</BankOrderNo><YeepayOrderNo>817769940727510I</YeepayOrderNo></SessionBody></COD-MS>";
                //XElement root = XElement.Parse(xmlData);

                #region 解析参数

                //第一段
                foreach (XElement xe in root.Elements("SessionHead"))
                {
                    if (xe.Element("Version") != null)
                    {
                        Version = xe.Element("Version").Value;
                    }
                    if (xe.Element("ServiceCode") != null)
                    {
                        ServiceCode = xe.Element("ServiceCode").Value;
                    }
                    if (xe.Element("TransactionID") != null)
                    {
                        TransactionID = xe.Element("TransactionID").Value;
                    }
                    if (xe.Element("SrcSysID") != null)
                    {
                        SrcSysID = xe.Element("SrcSysID").Value;
                    }
                    if (xe.Element("DstSysID") != null)
                    {
                        DstSysID = xe.Element("DstSysID").Value;
                    }
                    if (xe.Element("ReqTime") != null)
                    {
                        ReqTime = xe.Element("ReqTime").Value;
                    }
                    if (xe.Element("HMAC") != null)
                    {
                        HMAC = xe.Element("HMAC").Value;
                    }
                }
                //第二段
                foreach (XElement xe in root.Elements("SessionBody"))
                {
                    if (xe.Element("EmployeeID") != null)
                    {
                        Employee_ID = xe.Element("EmployeeID").Value;
                    }
                    if (xe.Element("PosSn") != null)
                    {
                        PosSn = xe.Element("PosSn").Value;
                    }
                    if (xe.Element("PosRequestID") != null)
                    {
                        PosRequestID = xe.Element("PosRequestID").Value;
                    }
                    if (xe.Element("ReferNo") != null)
                    {
                        ReferNo = xe.Element("ReferNo").Value;
                    }
                    if (xe.Element("OrderNo") != null)
                    {
                        order_no = xe.Element("OrderNo").Value;
                    }
                    if (xe.Element("Amount") != null)
                    {
                        Amount = xe.Element("Amount").Value;
                    }
                    if (xe.Element("Split") != null)
                    {
                        Split = xe.Element("Split").Value;
                    }
                    if (xe.Element("ReqTime") != null)
                    {
                        ReqTime = xe.Element("ReqTime").Value;
                    }
                    if (xe.Element("PayTypeCode") != null)
                    {
                        PayTypeCode = xe.Element("PayTypeCode").Value;
                    }
                    if (xe.Element("PayMethod") != null)
                    {
                        PayMethod = xe.Element("PayMethod").Value;
                    }
                    if (xe.Element("ChequeNo") != null)
                    {
                        ChequeNo = xe.Element("ChequeNo").Value;
                    }
                    if (xe.Element("BankCardName") != null)
                    {
                        BankCardName = xe.Element("BankCardName").Value;
                    }
                    if (xe.Element("BankCardNo") != null)
                    {
                        BankCardNo = xe.Element("BankCardNo").Value;
                    }
                    if (xe.Element("BankOrderNo") != null)
                    {
                        BankOrderNo = xe.Element("BankOrderNo").Value;
                    }
                    if (xe.Element("YeepayOrderNo") != null)
                    {
                        YeepayOrderNo = xe.Element("YeepayOrderNo").Value;
                    }
                }

                #endregion

                #region 处理

                string strOnError = "";
                bool   result     = false;

                try
                {
                    strOnError += "/开始记录账单";

                    if (ServiceCode == "COD403")
                    {
                        result = new PbProject.Logic.Pay.Bill().CreateLogMoneyDetail("", YeepayOrderNo, Amount, 13, PosSn, "POS充值", "POS充值");
                    }
                    else if (ServiceCode == "COD406")
                    {
                        result = new PbProject.Logic.Pay.Bill().CreateCancelLogMoneyDetail("", YeepayOrderNo, Amount, 13, PosSn, "POS充值失败,已经撤销充值", "POS充值失败,已经撤销充值");
                    }
                    else
                    {
                        strOnError += "/ServiceCode:" + ServiceCode;
                    }

                    if (result == true)
                    {
                        strOnError += "/记录账单成功";
                    }
                    else
                    {
                        strOnError += "/记录账单失败";
                    }

                    Result_code = "2";
                    Result_msg  = "成功";
                }
                catch (Exception ex)
                {
                    Result_code = "3";
                    Result_msg  = "失败";

                    strOnError += "/失败(catch):" + ex;
                }

                OnErrorNew(strOnError, false);

                //构造返回字符串
                StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                sb.Append("<COD-MS>");
                sb.Append("<SessionHead>");
                sb.Append("<Result_code>" + Result_code + "</Result_code>");
                sb.Append("<Result_msg>" + Result_msg + "</Result_msg>");
                sb.Append("<Version>" + Version + "</Version>");
                sb.Append("<ServiceCode>" + ServiceCode + "</ServiceCode>");
                sb.Append("<TransactionID>" + TransactionID + "</TransactionID>");
                sb.Append("<SrcSysID>" + SrcSysID + "</SrcSysID>");
                sb.Append("<DstSysID>" + DstSysID + "</DstSysID>");
                sb.Append("<RespTime>" + ReqTime + "</RespTime>");
                sb.Append("<HMAC>" + HMAC + "</HMAC>");
                sb.Append("</SessionHead>");
                sb.Append("<SessionBody>");
                sb.Append("<OrderNo>" + OrderNo + "</OrderNo>");
                sb.Append("</SessionBody>");
                sb.Append("</COD-MS>");

                OnErrorNew(xmlData + "\r\n" + sb.ToString() + "\r\n end", false);

                Response.Write(sb.ToString());

                #endregion
            }
            else
            {
                OnErrorNew("提交方式不是 POST: Request.RequestType=" + Request.RequestType, false);
            }
        }
        catch (Exception ex)
        {
            OnErrorNew("SetData_catch:" + ex.ToString(), false);
        }
    }
    /// <summary>
    /// 执行方法
    /// </summary>
    private string IsValidationNew()
    {
        string rtnOk = "06";

        if (Request["merchantId"] == null)
        {
            return("");
        }

        try
        {
            PbProject.Logic.Pay._99Bill _99bill = new PbProject.Logic.Pay._99Bill();

            string processFlag        = Request["processFlag"].ToString().Trim();
            string txnType            = Request["txnType"].ToString().Trim();
            string orgTxnType         = Request["orgTxnType"].ToString().Trim();
            string amt                = Request["amt"].ToString().Trim();
            string orgExternalTraceNo = Request["orgExternalTraceNo"].ToString().Trim();
            string terminalOperId     = Request["terminalOperId"].ToString().Trim();
            string terminalId         = Request["terminalId"].ToString().Trim();//
            string authCode           = Request["authCode"].ToString().Trim();
            string RRN                = Request["RRN"].ToString().Trim();
            string shortPAN           = Request["shortPAN"].ToString().Trim();
            string responseCode       = Request["responseCode"].ToString().Trim();
            string responseMessage    = Request["responseMessage"].ToString().Trim();//
            string cardType           = Request["cardType"].ToString().Trim();
            string issuerId           = Request["issuerId"].ToString().Trim();
            string issuerIdView       = Request["issuerIdView"].ToString().Trim();    //
            string signature          = Request["signature"].ToString().Trim();       //
            string externalTraceNo    = Request["externalTraceNo"].ToString().Trim(); // 订单号
            string merchantId         = Request["merchantId"].ToString().Trim();      //
            string txnTime            = Request["txnTime"].ToString().Trim();

            responseMessage = HttpUtility.UrlDecode(responseMessage, Encoding.GetEncoding("utf-8"));
            issuerIdView    = HttpUtility.UrlDecode(issuerIdView, Encoding.GetEncoding("utf-8"));


            string val = "";
            val = appendParam(val, processFlag);
            val = appendParam(val, txnType);
            val = appendParam(val, orgTxnType);
            val = appendParam(val, amt);
            val = appendParam(val, externalTraceNo);
            val = appendParam(val, orgExternalTraceNo);
            val = appendParam(val, terminalOperId);
            val = appendParam(val, authCode);
            val = appendParam(val, RRN);
            val = appendParam(val, txnTime);
            val = appendParam(val, shortPAN);
            val = appendParam(val, responseCode);
            val = appendParam(val, cardType);
            val = appendParam(val, issuerId);

            if (CerRSAVerifySignature(val, signature, HttpContext.Current.Server.MapPath("~/Pay/Key/mgw.cer")))
            {
                OnErrorNew("支付失败: " + externalTraceNo, false);

                rtnOk = "1";

                #region 验签成功

                //消费交易
                if (txnType == "PUR")
                {
                    //成功
                    if (processFlag == "0")
                    {
                        //PiaoBao.BLLLogic.Pay.YeePay yeepay = new PiaoBao.BLLLogic.Pay.YeePay();
                        //OnErrorNew("开始记录");
                        ////默认支持银行卡
                        //string pay_type = "1";
                        //yeepay.Charge(terminalId, amt, pay_type, RRN, txnTime.Replace(" ", ""));
                        //OnErrorNew("结束记录");



                        ///// <summary>
                        ///// 充值成功,生成充值账单
                        ///// </summary>
                        ///// <param name="orderId">订单编号</param>
                        ///// <param name="payNo">交易号</param>
                        ///// <param name="price">交易金额</param>
                        ///// <param name="payWay"> //payWay支付方式:1支付宝/2快钱/3汇付/4/财付通/5支付宝网银/6快钱网银/7汇付网银/8财付通网银/
                        ///// 9支付宝pos/10快钱pos/11汇付pos/12财付通/13易宝pos/14账户支付</param>
                        ///// <param name="useId">付款人id 或者 POS机编号</param>
                        ///// <param name="operReason">原因或操作描述</param>
                        ///// <param name="remark">备注</param>

                        PbProject.Logic.Pay.Bill bill = new PbProject.Logic.Pay.Bill();
                        bill.CreateLogMoneyDetail(externalTraceNo, externalTraceNo, amt, 10, terminalId, "在线支付", "在线充值");  // 在线充值

                        //报告给快钱处理结果,并提供将要重定向的地址。
                        OnErrorNew("支付成功:" + externalTraceNo, false);

                        rtnOk = "0";
                    }
                }

                #endregion
            }
            else
            {
                OnErrorNew("验签失败:" + externalTraceNo, false);
                rtnOk = "IG";
            }
        }
        catch (Exception ex)
        {
            OnErrorNew("处理异常:", true);
        }
        return(rtnOk);
    }
Beispiel #5
0
    /// <summary>
    /// 支付
    /// </summary>
    /// <param name="root"></param>
    /// <param name="xmlData"></param>
    private void Pay(XElement root, string xmlData)
    {
        #region
        //Transaction_Header
        string transaction_id   = "";
        string requester        = "";
        string version          = "";
        string target           = "";
        string request_time     = "";
        string delivery_dept_no = "";
        string delivery_dept    = "";
        string delivery_man     = "";
        string delivery_name    = "";
        string logistics_alias  = "";
        string MAC = "";
        //Transaction_Body
        string order_no          = "";
        string order_payable_amt = "";
        string pay_type          = "";
        string terminal_id       = "";
        string trace_no          = "";
        string resp_code         = "";
        string resp_msg          = "";

        //第一段
        foreach (XElement xe in root.Elements("Transaction_Header"))
        {
            transaction_id = xe.Element("transaction_id").Value;
            requester      = xe.Element("requester").Value;
            version        = xe.Element("version").Value;
            target         = xe.Element("target").Value;
            request_time   = xe.Element("request_time").Value;
            MAC            = xe.Element("MAC").Value;
            foreach (XElement xe2 in root.Elements("ext_attributes"))
            {
                delivery_dept_no = xe.Element("delivery_dept_no").Value;
                delivery_dept    = xe.Element("delivery_dept").Value;
                delivery_man     = xe.Element("delivery_man").Value;
                delivery_name    = xe.Element("delivery_name").Value;
                logistics_alias  = xe.Element("logistics_alias").Value;
            }
        }
        //第二段
        foreach (XElement xe in root.Elements("Transaction_Body"))
        {
            order_no          = xe.Element("order_no").Value;          //订单号
            order_payable_amt = xe.Element("order_payable_amt").Value; //应付金额
            pay_type          = xe.Element("pay_type").Value;
            terminal_id       = xe.Element("terminal_id").Value;       // pos机号
            trace_no          = xe.Element("trace_no").Value;          //凭证号
        }

        //获取报文字符串
        string content = removeXMLNodeByName(xmlData, "MAC");
        content = content.Contains("<?xml version=") ? content.Substring(content.IndexOf(">") + 1) : content;
        //开始验签
        string result = sign(content, _Private_key);
        if (verify(content, result, _Public_key))
        {
            try
            {
                //PiaoBao.BLLLogic.Pay.YeePay yeepay = new PiaoBao.BLLLogic.Pay.YeePay();

                //OnErrorNew("开始记录");
                ////支付宝支持银行卡
                //pay_type = "1";
                //yeepay.Charge(terminal_id, order_payable_amt, pay_type, order_no, request_time);
                //OnErrorNew("结束记录");

                ///// <summary>
                ///// 充值成功,生成充值账单
                ///// </summary>
                ///// <param name="orderId">订单编号</param>
                ///// <param name="payNo">交易号</param>
                ///// <param name="price">交易金额</param>
                ///// <param name="payWay"> //payWay支付方式:1支付宝/2快钱/3汇付/4/财付通/5支付宝网银/6快钱网银/7汇付网银/8财付通网银/
                ///// 9支付宝pos/10快钱pos/11汇付pos/12财付通/13易宝pos/14账户支付</param>
                ///// <param name="useId">付款人id 或者 POS机编号</param>
                ///// <param name="operReason">原因或操作描述</param>
                ///// <param name="remark">备注</param>

                PbProject.Logic.Pay.Bill bill = new PbProject.Logic.Pay.Bill();
                bill.CreateLogMoneyDetail("", order_no, order_payable_amt, 9, terminal_id, "POS充值", "POS充值");  // 在线充值

                resp_code = "00";
                resp_msg  = "成功";
            }
            catch
            {
                resp_code = "01";
                resp_msg  = "失败";
            }
        }
        else
        {
            resp_code = "01";
            resp_msg  = "失败";
        }

        #endregion

        //构造返回字符串
        StringBuilder sb  = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        StringBuilder sb2 = new StringBuilder();
        StringBuilder sb3 = new StringBuilder();
        sb.Append("<Transaction>");
        sb.Append("<Transaction_Header>");
        sb.Append("<transaction_id>" + transaction_id + "</transaction_id>"); //MI0005
        sb.Append("<requester>" + requester + "</requester>");                // //请求方,支付宝作为发送方时,采用1111111111 为标识码
        sb.Append("<target>" + target + "</target>");                         //应答方,需填写航旅商户英文名称
        sb.Append("<resp_time>" + request_time + "</resp_time>");             //响应时间,格式为 yyyyMMddHHmmss
        sb.Append("<resp_code>" + resp_code + "</resp_code>");                //正常 00
        sb.Append("<resp_msg>" + resp_msg + "</resp_msg>");                   //成功

        sb3.Append("</Transaction_Header>");
        sb3.Append("<Transaction_Body>");
        sb3.Append("<order_no>" + order_no + "</order_no>");//订单号
        sb3.Append("</Transaction_Body>");
        sb3.Append("</Transaction>");

        content = sb.ToString() + sb3.ToString();
        content = content.Replace("<Transaction>", "");
        content = content.Replace("</Transaction>", "");

        MAC = sign(content.Substring(content.IndexOf(">") + 1), _Private_key);

        sb2.Append("<MAC>" + MAC + "</MAC>");

        Response.Write(sb.ToString() + sb2.ToString() + sb3.ToString());

        string dir = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Log\\" + Page + "\\";
        if (!Directory.Exists(dir))
        {
            Directory.CreateDirectory(dir);
        }
        StreamWriter fs = new StreamWriter(dir + System.DateTime.Now.ToString("yyyy-MM-dd") + ".txt", true, System.Text.Encoding.Default);
        fs.WriteLine(xmlData + "\r\n\r\n" + sb.ToString() + sb2.ToString() + sb3.ToString());
        fs.Close();
    }
Beispiel #6
0
        /// <summary>
        /// 分账退款接口
        /// </summary>
        /// <returns></returns>
        public bool ClientSplitRollback(TenPayParam tenPayParam)
        {
            PbProject.Logic.Pay.Bill bill = new PbProject.Logic.Pay.Bill();
            bool result = true;

            if (tenPayParam.BackState == 1)
            {
                #region 平台退款
                string details = string.Format("分账参数:{0}", tenPayParam.Bus_Args);
                //平台退款
                int returnresult = ClientPlatformRefund(tenPayParam);

                OnErrorNew("订单号:" + tenPayParam.Orderid + ",平台退款状态:" + returnresult + ",details: " + details);

                switch (returnresult)
                {
                case 0:
                    bill.CreateBillRefundFailedLog(null, tenPayParam.Orderid, "财付通平台退款通信失败:" + details);
                    result = false;
                    break;

                case 1:
                    bill.CreateBillRefund(tenPayParam.Orderid, tenPayParam.PayNo, 4, "在线退款", "财付通退款", details);
                    result = true;
                    break;

                case 2:
                    bill.CreateBillRefundFailedLog(null, tenPayParam.Orderid, "财付通平台退款业务错误信息或签名错误:" + details);
                    result = false;
                    break;

                default:
                    break;
                }
                #endregion
            }
            else
            {
                //创建请求对象
                BaseSplitRequestHandler reqHandler = new BaseSplitRequestHandler(HttpContext.Current);
                //通信对象
                TenpayHttpClient httpClient = new TenpayHttpClient();
                //应答对象
                ScriptClientResponseHandler resHandler = new ScriptClientResponseHandler();
                //请求参数设置

                reqHandler.init();
                reqHandler.setKey(key);
                reqHandler.setGateUrl("https://mch.tenpay.com/cgi-bin/split_rollback.cgi");

                reqHandler.setParameter("cmdno", "95");
                reqHandler.setParameter("version", "4");
                reqHandler.setParameter("fee_type", "1");
                reqHandler.setParameter("bargainor_id", bargainor_id);          //商户号
                reqHandler.setParameter("sp_billno", tenPayParam.OldOrderid);   //商家订单号
                reqHandler.setParameter("transaction_id", tenPayParam.PayNo);   //财付通交易单号[外部订单号]
                reqHandler.setParameter("return_url", "http://127.0.0.1/");     //后台系统调用,必现填写为http://127.0.0.1/
                reqHandler.setParameter("total_fee", tenPayParam.Total_Tee);
                //退款ID,同个ID财付通认为是同一个退款,格式为109+10位商户号+8位日期+7位序列号
                string refund_id = string.Format("109{0}{1}{2}", bargainor_id, DateTime.Now.ToString("yyyyMMdd"), TenpayUtil.BuildRandomStr(7));
                reqHandler.setParameter("refund_id", refund_id);
                reqHandler.setParameter("bus_type", "97");
                //格式:退款总额| (账户^退款金额)[|(账户^退款金额)]*
                reqHandler.setParameter("bus_args", tenPayParam.Bus_Args);

                //-----------------------------
                //设置通信参数
                //-----------------------------
                //证书必须放在用户下载不到的目录,避免证书被盗取
                httpClient.setCertInfo(pfxPath, bargainor_id);

                string requestUrl = reqHandler.getRequestURL();
                //设置请求内容
                httpClient.setReqContent(requestUrl);
                //设置超时
                httpClient.setTimeOut(10);

                string rescontent = "";
                //后台调用

                if (httpClient.call())
                {
                    //获取结果
                    rescontent = httpClient.getResContent();

                    resHandler.setKey(key);
                    //设置结果参数
                    resHandler.setContent(rescontent);

                    //判断签名及结果
                    if (resHandler.isTenpaySign() && resHandler.getParameter("pay_result") == "0")
                    {
                        //分账回退成功
                        bill.UpdateBackState(tenPayParam.OldOrderid, 1);
                        //取结果参数做业务处理
                        // resultMsg = "OK,transaction_id=" + resHandler.getParameter("transaction_id");

                        string details = string.Format("财付通交易号:{0} || {1}", resHandler.getParameter("transaction_id"), tenPayParam.Bus_Args);
                        //平台退款
                        int returnresult = ClientPlatformRefund(tenPayParam);
                        switch (returnresult)
                        {
                        case 0:
                            bill.CreateBillRefundFailedLog(null, tenPayParam.Orderid, "财付通平台退款通信失败:" + details);
                            result = false;
                            break;

                        case 1:
                            bill.CreateBillRefund(tenPayParam.Orderid, tenPayParam.PayNo, 4, "在线退款", "财付通退款", details);
                            result = true;
                            break;

                        case 2:
                            bill.CreateBillRefundFailedLog(null, tenPayParam.Orderid, "财付通平台退款业务错误信息或签名错误:" + details);
                            result = false;
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        result = false;
                        string details = string.Format("财付通分账退款业务错误信息或签名错误:{0},{1}--{2}", resHandler.getParameter("pay_result"), resHandler.getParameter("pay_info"), tenPayParam.Bus_Args);
                        bill.CreateBillRefundFailedLog(null, tenPayParam.Orderid, details); //分账退款失败
                        //错误时,返回结果未签名。
                        //如包格式错误或未确认结果的,请使用原来订单号重新发起,确认结果,避免多次操作
                    }
                }
                else
                {
                    result = false;
                    //后台调用通信失败
                    string details = string.Format("财付通分账退款通信失败:{0}{1}=={2}", httpClient.getErrInfo(), httpClient.getResponseCode(), tenPayParam.Bus_Args);
                    bill.CreateBillRefundFailedLog(null, tenPayParam.Orderid, details); //退款失败
                    //有可能因为网络原因,请求已经处理,但未收到应答。
                }
            }
            return(result);
        }
Beispiel #7
0
        /// <summary>
        /// 支付查询
        /// </summary>
        /// <param name="payType">支付方式</param>
        /// <param name="oldOrderId">订单号</param>
        ///  <param name="IsOperOrder">true:更新订单等信息 、false:不跟新订单等信息</param>
        /// <param name="oldOrderId">out:提示消息</param>
        /// <returns></returns>
        public string PaySel(string payType, string oldOrderId, bool IsOperOrder, out string msgShow)
        {
            string strValue = "";

            msgShow = "";

            try
            {
                string  PayNo    = ""; //交易号
                decimal PayMoney = 0;  //交易金额

                PbProject.Logic.Pay.Bill payBill = new PbProject.Logic.Pay.Bill();

                if (payType == "1")
                {
                    msgShow += "支付宝:";

                    #region 支付宝

                    PbProject.Logic.Pay.AliPay aliPay = new PbProject.Logic.Pay.AliPay();

                    strValue = aliPay.TradeQuery(oldOrderId);

                    if (strValue.Contains("<error>TRADE_NOT_EXIST</error>"))
                    {
                        msgShow += "查询失败";
                    }
                    else if (strValue.Contains("<trade_status>TRADE_SUCCESS</trade_status>"))
                    {
                        msgShow += "交易成功";

                        XElement root = XElement.Parse(strValue);

                        if (root.Element("response") != null)
                        {
                            XElement xe = root.Element("response");

                            if (xe.Element("trade") != null)
                            {
                                XElement xe1 = xe.Element("trade");

                                //交易号
                                if (xe1.Element("trade_no") != null)
                                {
                                    PayNo    = xe1.Element("trade_no").Value;
                                    msgShow += " , 交易号:" + PayNo;
                                }

                                //交易金额
                                if (xe1.Element("total_fee") != null)
                                {
                                    PayMoney = decimal.Parse(xe1.Element("total_fee").Value);
                                    msgShow += " , 订单支付金额:" + PayMoney.ToString("f2");
                                }
                            }
                        }


                        if (IsOperOrder && msgShow.Contains("交易成功"))
                        {
                            payBill.CreateBillPayBill(oldOrderId, PayNo, 1, "", "在线支付", "支付宝支付", ""); // 支付
                        }
                    }
                    else
                    {
                        msgShow += "支付宝 未付";
                    }



                    #endregion

                    strValue = "支付宝查询结果:" + strValue;
                }
                else if (payType == "2")
                {
                    msgShow += "快钱:";

                    #region 快钱

                    PbProject.Logic.Pay._99Bill bill = new PbProject.Logic.Pay._99Bill();
                    strValue = bill.GetPayReturn(oldOrderId);

                    if (strValue.Contains("<payResult>10</payResult>"))
                    {
                        msgShow += "交易成功";
                        XElement root = XElement.Parse(strValue);
                        //交易号
                        if (root.Element("dealId") != null)
                        {
                            PayNo    = root.Element("dealId").Value;
                            msgShow += " , 交易号:" + PayNo;
                        }
                        //支付金额
                        if (root.Element("payAmount") != null)
                        {
                            PayMoney = decimal.Parse(root.Element("payAmount").Value);
                            PayMoney = PayMoney / 100;
                            msgShow += " , 订单支付金额:" + PayMoney.ToString("f2");
                        }
                        if (IsOperOrder && msgShow.Contains("交易成功"))
                        {
                            payBill.CreateBillPayBill(oldOrderId, PayNo, 2, "", "在线支付", "快钱支付", ""); // 支付
                        }
                        if (strValue.Contains("<sharingStatus>10</sharingStatus>"))
                        {
                            msgShow += ",分账成功";
                        }
                        else
                        {
                            msgShow += ",分账失败";
                        }
                    }
                    else
                    {
                        msgShow += "快钱 未付";
                    }
                    #endregion

                    strValue = "快钱查询结果:" + strValue;
                }
                else if (payType == "3")
                {
                    msgShow += "汇付:";

                    #region 汇付

                    PbProject.Logic.Pay.ChinaPnr chinaPnr = new PbProject.Logic.Pay.ChinaPnr();
                    strValue = chinaPnr.QueryStatus(oldOrderId);
                    if (strValue.Contains("CmdId=QueryStatus") && strValue.Contains("RespCode=000000") && strValue.Contains("已支付"))
                    {
                        msgShow += "交易成功";
                        msgShow += " , 交易号:" + DateTime.Now.ToString("yyyyMMddHHmmss");
                        msgShow += " , 订单支付金额:见订单";

                        if (IsOperOrder && msgShow.Contains("交易成功"))
                        {
                            payBill.CreateBillPayBill(oldOrderId, PayNo, 3, "", "在线支付", "汇付支付", ""); // 支付
                        }
                    }
                    else
                    {
                        msgShow += "汇付 未付";
                    }

                    #endregion

                    strValue = "汇付查询结果:" + strValue;
                }
                else if (payType == "4")
                {
                    msgShow += "财付通:";

                    #region 财付通
                    msgShow += "财付通暂时不支付查询";
                    #endregion

                    strValue = "汇付查询结果:" + msgShow;
                }
                else
                {
                    msgShow = "请选择支付方式";
                }
            }
            catch (Exception)
            {
            }
            return(strValue);
        }