private void load()
 {
     try
     {
         lblAmount.Visibility = Visibility.Hidden;
         if (SysBLL.payCostType == 5)
         {
             lblAmount.Visibility = Visibility.Visible;
             lblAmount.Content    = "应缴金额:" + Payment.GasPayParam.GasCard.price + " 元";;
         }
         if (SysBLL.payCostType == 11)
         {
             lblAmount.Visibility = Visibility.Visible;
             lblAmount.Content    = "应缴金额:" + Payment.propPayTempParam.RechageAmount + " 元";;
         }
         if (SysBLL.payCostType == 12)
         {
             lblAmount.Visibility = Visibility.Visible;
             lblAmount.Content    = "应缴金额:" + Payment.propSecPayParam.RechageAmount + " 元";;
         }
         txtPassword.Text = "";
         if (SysBLL.PasswordErrorInfo.Contains("错误"))
         {
             SysBLL.Player("密码错误.wav");
         }
         else
         {
             SysBLL.Player("输入密码.wav");
         }
         showinfoLbl.Text = SysBLL.PasswordErrorInfo;
         isCloseForm      = false;
         if (SysBLL.payCardType == 1)
         {
             //万通支付
             //pwdBLL.SetCryptMode(1);//万通卡加密方式
             pwdBLL.OpenKeyboard(SysConfigHelper.readerNode("ZT598Port"), "9600", SysBLL.payCardNo);
         }
         else
         {
             //pwdBLL.SetCryptMode(0);//银行卡加密方式
             pwdBLL.OpenKeyboard(SysConfigHelper.readerNode("ZT598Port"), "9600", SysBLL.payCardNo);
         }
         //扫描键盘
         keyThread = new Thread(delegate()
         {
             key();
         });
         keyThread.Start();
         new Thread(delegate() { SysBLL.Player("输入密码.wav"); }).Start();
     }
     catch (ThreadAbortException ae) { log.Write("error:" + ae.Message); }
     catch (WtException we) { log.Write("error:输入密码页面异常"); }
     catch (Exception ex) {
         log.Write("error:输入密码页面异常:" + ex.Message);
     }
 }
Example #2
0
        /// <summary>
        /// 支付
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public PayResultInfo payStart(PayParam p)
        {
            //密码键盘工具类
            PasswordBLL pwdBLL = new PasswordBLL();
            //交易数据访问类
            PayAccess payAccess = new PayAccess();
            //支付结果
            PayResultInfo payResultInfo = null;

            try
            {
                Dictionary <string, string> parameters = new Dictionary <string, string>();
                //缴费类型
                parameters.Add("serviceType", p.serviceType);
                //交易金额
                parameters.Add("realAmout", p.rechageAmount);
                //交易类型,纸币,银行卡,万通卡
                parameters.Add("tr.shop_type", isWtLkl(p.icParams));
                if (PayStaticParam.payType == -1)
                {//电子现金支付相关参数
                    //获取批次号
                    p.batchNo = LKLProcedure.GetBatchNo();
                    //获取支付报文
                    parameters.Add("tr.data", PayBLL.PayMessage(ref p));
                    //批次流水号
                    parameters.Add("dzls", p.batchNo + p.WtLklorderNo);
                }
                //云平台交易流水号
                parameters.Add("tr.cloud_no", p.orderNo);
                if ("4".Equals(p.serviceType))
                {
                    //万通卡支付相关参数
                    if (SysBLL.IsTest.Equals("正式"))
                    {
                        parameters.Add("terminalno", "XNJ00002");
                        parameters.Add("terminal", ConfigurationManager.AppSettings["MechineNo"]);
                    }
                    else
                    {
                        parameters.Add("terminalno", "UU000002");
                        parameters.Add("terminal", ConfigurationManager.AppSettings["MechineNo"]);
                    }
                }
                else
                {
                    parameters.Add("terminalNo", p.terminalNo);
                }
                //设置其余参数
                initParam(parameters, p);
                //发起支付
                payResultInfo = payAccess.PayResNewAcc(parameters);
                //纸币交易到此为止
                if (PayStaticParam.payType == 0)
                {
                    if ("0000".Equals(payResultInfo.code))
                    {
                        //支付成功
                        log.Write("--------------------交易结束--------------------");
                        return(payResultInfo);
                    }
                    else
                    {
                        payResultInfo.code = "9999";
                        log.Write("--------------------交易结束--------------------");
                        return(payResultInfo);
                    }
                }
                if (isNull(payResultInfo) || ("9991".Equals(payResultInfo.code)))
                {
                    //冲正
                    CorrectParam correctParam = new CorrectParam();
                    //缴费类型
                    correctParam.serviceType = p.serviceType;
                    //支付类型
                    correctParam.shop_type = isWtLkl(p.icParams);
                    //云平台交易流水
                    correctParam.cloud_no = p.orderNo;
                    for (int i = 1; i <= 3; i++)
                    {
                        //获取冲正报文
                        correctParam.data = Util.JumpUtil.CorrectJump(p);
                        //发起冲正
                        PayResultInfo payResultInfoacc = payAccess.CorrectAcc(correctParam);
                        if ("0000".Equals(payResultInfoacc.code))
                        {
                            break;
                        }
                    }
                    payResultInfo.code = "9991";
                    return(payResultInfo);
                }
                else if ("9955".Equals(payResultInfo.code))
                {
                    //密码错误
                    SysBLL.PasswordErrorInfo = "密码错误,请重新输入!";
                    log.Write("密码错误");
                    log.Write("--------------------交易结束--------------------");
                    if (p.icParams == null)
                    {
                        //打开键盘,同时交易页面跳转到输入密码页面,万通
                        pwdBLL.OpenKeyboard(SysConfigHelper.readerNode("ZT598Port"), "9600", p.WtNo);
                        return(payResultInfo);
                    }
                    else
                    {
                        //打开键盘,同时交易页面跳转到输入密码页面,银行卡
                        pwdBLL.OpenKeyboard(SysConfigHelper.readerNode("ZT598Port"), "9600", p.icParams["cardNo"]);
                        return(payResultInfo);
                    }
                }
                else if ("9951".Equals(payResultInfo.code))
                {
                    //余额不足
                    log.Write("余额不足");
                    return(payResultInfo);
                }
                else if ("9900".Equals(payResultInfo.code))
                {
                    //发起退款
                    refund(ref payResultInfo, p);
                    return(payResultInfo);
                }
                else if ("0000".Equals(payResultInfo.code))
                {
                    //支付成功
                    log.Write("--------------------交易结束--------------------");
                    //银行卡给万通卡充值成功后,测试环境下会在其他服务页面中显示银行卡退款按钮,可进行退款操作
                    if (SysBLL.IsTest.Equals("测试"))
                    {
                        if (p.serviceType.Equals("4"))
                        {
                            //发起退款
                            RefundTest refundTest = new RefundTest();
                            refundTest.refundPayResultInfo = payResultInfo;
                            refundTest.refundPayParam      = p;
                            PayStaticParam.refundTest.Add(refundTest);
                        }
                    }
                    return(payResultInfo);
                }
                else
                {
                    return(payResultInfo);
                }
            }
            catch (Exception ex)
            {
                log.Write("error:99:支付失败:" + ex.Message + ex.InnerException);
                return(payResultInfo);
            }
        }
Example #3
0
        private void pay()
        {
            log.Write("--------------------交易开始--------------------");
            log.Write("----------缴费类型:公交");
            try
            {
                WantongBLL wt           = new WantongBLL();
                string     wtCard       = "";
                string     icParamsJson = "";

                string order        = "";
                string orderparam   = "";
                string serialStr    = "";
                string reconcStr    = "";
                string result       = "";
                string jsonPayParam = "";

                string busCard = "";

                string batchNo  = "";
                string payMoney = "";

                //交易日志,订单编号
                string orderNo = "";
                //交易日志,商户类型
                string shopType = "";

                string shopNo = "";

                string trandNo = "";

                PasswordBLL pwdBLL = new PasswordBLL();
                Dictionary <string, string> map = null;
                string payCode = "Z000000003";//payCode = "Z000000005";

                string ClientNo = "";

                string terminalNo = SysConfigHelper.readerNode("ClientNo");

                if (icParams != null)
                {
                    payCode    = "Z000000005";
                    terminalNo = SysConfigHelper.readerNode("LklClientNo");
                }

                WintopPayParam witonPay = new WintopPayParam();

                witonPay.price = payParam.UserInputMoney;
                witonPay.pwd   = payParam.Pwd;
                busCard        = Payment.BusPayParam.BusNo;
                BusReChangeParam busReChangeParam = new BusReChangeParam();
                busReChangeParam.appsid       = payParam.Output.APPSID;
                busReChangeParam.paymentAmout = payParam.UserInputMoney;
                busReChangeParam.paymentno    = busCard;
                busReChangeParam.wmoney       = payParam.Output.WMONEY;
                busReChangeParam.trandeNo     = SysBLL.getHHMMSSITime10();
                //busReChangeParam.orderno = orderNo;
                log.Write("发起公交充值");

                BusCpuCardParam param          = new BusCpuCardParam();
                BusCpuCardInfo  busCpuCardInfo = BusAccess.GetOrder(busReChangeParam, param, payCode);
                Payment.BusPayParam.BusCpuCardInfo = busCpuCardInfo;
                string cloudNo = busCpuCardInfo.msgrsp.orderno;

                //向后台发送订单记录
                if (icParams == null)
                {
                    orderNo = Wanton.GetOrderNo();
                    //tradeRecord.branch_termail_no = SysConfigHelper.readerNode("ClientNo");
                    ClientNo = BusPayParam.busShopNo + "|" + SysConfigHelper.readerNode("ClientNo");
                }
                else
                {
                    orderNo  = LKLProcedure.GetOrderNo();
                    ClientNo = BusPayParam.busShopNo + "|" + BusPayParam.busClient;
                }
                //支付
                try
                {
                    if (icParams == null)
                    {
                        log.Write("交易类型:万通交易");
                        //万通卡号
                        //orderNo = SysBLL.GetRnd(6, true, false, false, false, "");
                        shopNo            = orderNo + "|" + SysConfigHelper.readerNode("ClientNo") + "|" + SysConfigHelper.readerNode("ShopNo");
                        witonPay.orderNo  = orderNo;
                        witonPay.price    = payParam.UserInputMoney;
                        wtCard            = wt.GetCardNo();
                        witonPay.wintopNo = wtCard;
                        pwdBLL.SetCryptMode(1);//万通卡加密方式
                        log.Write("万通卡号:" + witonPay.wintopNo);
                        log.Write("交易金额:" + witonPay.price);
                        log.Write("终端交易流水号" + orderNo);
                        log.Write("开始支付");
                        witonPay.pwd = payParam.Pwd;
                        map          = Wanton.pay(witonPay, BusPayParam.busShopNo);
                        shopType     = "1";
                        jsonPayParam = JsonConvert.SerializeObject(witonPay);
                        map.Add("payParam", jsonPayParam);
                    }
                    else
                    {
                        log.Write("交易类型:拉卡拉交易");
                        //银行卡
                        //orderNo = SysBLL.GetOrderNo();
                        shopNo  = orderNo + "|" + SysConfigHelper.readerNode("ClientNo") + "|" + SysConfigHelper.readerNode("ShopNo");
                        batchNo = SysBLL.GetBatchNo();
                        pwdBLL.SetCryptMode(0);//银行卡加密方式
                        payMoney = payParam.UserInputMoney;
                        log.Write("银行卡号:" + icParams["cardNo"]);
                        log.Write("交易金额:" + payMoney);
                        log.Write("终端交易流水号" + orderNo);
                        log.Write("开始支付");
                        map          = wtPayBLL.LKLProcedure.PayOrder(payParam.Pwd, payMoney, icParams, orderNo, batchNo, BusPayParam.busShopNo, BusPayParam.busClient);
                        shopType     = "0";
                        icParamsJson = JsonConvert.SerializeObject(icParams);
                        map.Add("bankParam", icParamsJson);
                    }
                    map.Add("orderType", "5");    //1、广电 2、水务3、燃气4、电力5、公交6、万通卡7、热力
                    map.Add("payType", shopType); //拉卡拉是0,万通是1
                    map.Add("payOrderNo", orderNo);
                    map.Add("busCardNo", busCard);

                    //如果万通支付成功
                    if (!map["recode"].Equals("00"))
                    {
                        if ("55".Equals(map["recode"]))
                        {
                            SysBLL.PasswordErrorInfo = "密码错误,请重新输入!";
                            log.Write("密码错误");
                            log.Write("--------------------交易结束--------------------");
                            if (icParams == null)
                            {
                                pwdBLL.OpenKeyboard(SysConfigHelper.readerNode("ZT598Port"), "9600", wtCard);
                                this.Dispatcher.Invoke(new Action(() => { Util.JumpUtil.jumpCommonPage("FormInputPassword"); }));
                                return;
                            }
                            else
                            {
                                pwdBLL.OpenKeyboard(SysConfigHelper.readerNode("ZT598Port"), "9600", icParams["cardNo"]);
                                this.Dispatcher.Invoke(new Action(() => { Util.JumpUtil.jumpCommonPage("FormInputPassword"); }));
                                return;
                            }
                        }
                        else if ("51".Equals(map["recode"]))
                        {
                            log.Write("余额不足");
                            exit("余额不足");
                            return;
                        }
                        else
                        {
                            log.Write("支付失败:返回码:" + map["recode"]);
                            exit("充值失败,请重新缴费,或退卡");
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.Write("支付异常,发起冲正:" + ex.Message);
                    //冲正
                    if (icParams == null)
                    {
                        //万通冲正
                        for (int i = 1; i <= 3; i++)
                        {
                            try
                            {
                                Dictionary <string, string> mapCor = Wanton.correct(witonPay, BusPayParam.busShopNo);
                                if (mapCor == null)
                                {
                                    mapCor = new Dictionary <string, string>();
                                }
                                mapCor.Add("payParam", jsonPayParam);
                                mapCor.Add("orderType", "5");    //1、广电 2、水务3、燃气4、电力5、公交6、万通卡7、热力
                                mapCor.Add("payType", shopType); //拉卡拉是0,万通是1
                                mapCor.Add("payOrderNo", orderNo);
                                mapCor.Add("busCardNo", busCard);


                                if (mapCor["recode"].Equals("00"))
                                {
                                    log.Write("冲正成功");
                                    break;
                                }
                                else
                                {
                                    log.Write("冲正失败,返回码:" + mapCor["recode"]);
                                }
                            }
                            catch (Exception)
                            {
                                log.Write("冲正失败");
                            }
                            finally { Thread.Sleep(wtPayUtils.Fibonacci(i) * 1000); }
                        }
                        exit("充值失败,请重新缴费,或退卡");
                        return;
                    }
                    else
                    {
                        for (int i = 1; i <= 3; i++)
                        {
                            try
                            {
                                //拉卡拉冲正
                                Dictionary <string, string> ret = LKLProcedure.correct(icParams, payMoney, orderNo, batchNo);
                                if (ret == null)
                                {
                                    ret = new Dictionary <string, string>();
                                }
                                ret.Add("payParam", jsonPayParam);
                                ret.Add("orderType", "5");    //1、广电 2、水务3、燃气4、电力5、公交6、万通卡7、热力
                                ret.Add("payType", shopType); //拉卡拉是0,万通是1
                                ret.Add("payOrderNo", orderNo);
                                ret.Add("busCardNo", busCard);

                                if (ret["recode"].Equals("00"))
                                {
                                    log.Write("冲正成功");
                                    break;
                                }
                                else
                                {
                                    log.Write("冲正失败,返回码:" + ret["recode"]);
                                }
                            }
                            catch (Exception ex8) { log.Write("冲正失败"); }
                            finally { Thread.Sleep(wtPayUtils.Fibonacci(i) * 1000); }
                        }
                        exit("充值失败,请重新缴费,或退卡");
                        return;
                    }
                }
                string busOrderNo = "";
                string recode     = "";
                //发送订单,充值
                try
                {
                    trandNo        = map["cloudOrderNo"];
                    busCpuCardInfo = BusAccess.ReCharge(busCpuCardInfo, param);


                    if (busCpuCardInfo.cpumsg.OUTPUT != null)
                    {
                        try
                        {
                            order = JsonConvert.SerializeObject(busCpuCardInfo);
                            map.Add("payres", order);
                            orderparam = JsonConvert.SerializeObject(busReChangeParam);
                            map.Add("payresparam", orderparam);
                            map.Add("state", "消费成功");
                            map.Add("type", "1");//1消费,2冲正,3消费撤销
                            serialStr = JsonConvert.SerializeObject(map);
                            reconcStr = busCpuCardInfo.msgrsp.orderno + "|" + busCard + "|" + busCpuCardInfo.msghead.reqsn + "|" + orderNo + "|" + busCpuCardInfo.msgrsp.paymentAmout + "|" + SysBLL.getYYYYMMDDHHMMSSTime() + "|" + busCpuCardInfo.msgrsp.Tac + "|" + busCpuCardInfo.msghead.reqsn + "|" + payParam.Output.WMONEY + "";


                            result = HttpHelper.sendPaymentLog(serialStr, reconcStr, shopNo, shopType, "1");
                        }
                        catch (Exception ex) { log.Write("发送对账信息异常:" + ex.Message); }
                        finally
                        {
                            log.Write("交易成功,交易信息:" + reconcStr);
                            log.Write("--------------------交易结束--------------------");
                            //支付成功
                            this.Dispatcher.Invoke(new Action(() => { Util.JumpUtil.jumpCommonPage("FormBusStep08_success"); }));
                        }
                        return;
                    }
                    throw new Exception();
                }
                catch (Exception ex3)
                {
                    log.Write("支付通知交易异常:" + ex3.Message);
                    //string refund = map["_2"] + "|" + map["_4"] + "|" + map["_59"] + "|" + "";
                    //退款
                    string conName = "公交卡退费申请";
                    //string payOrderNo = busCpuCardInfo.msgrsp.orderno;
                    //tring payOrderNo = busOrderNo.ToString();
                    string payOrderNo  = cloudNo;
                    string transType   = "02";
                    string serviceName = "TK001";

                    try
                    {
                        if (icParams == null)
                        {
                            //string sendPaymentLogResult = HttpHelper.sendPaymentLog(serialStr, reconcStr, shopNo, shopType);
                            //JObject paymentLogObject = JObject.Parse(sendPaymentLogResult);//用于获取后台生成的ID
                            string refundRequestState = "0";//是否需要向云平台发起退款申请
                        }
                        else
                        {
                            //string sendPaymentLogResult = HttpHelper.sendPaymentLog(serialStr, reconcStr, shopNo, shopType);
                            //JObject paymentLogObject = JObject.Parse(sendPaymentLogResult);//用于获取后台生成的ID
                            string refundRequestState = "1";//是否需要向云平台发起退款申请
                        }
                    }
                    catch (Exception ex) { log.Write("退款异常:" + ex.Message); }
                    finally
                    {
                        payFail("充值失败,请重新缴费,或退卡");
                    }
                    return;
                }
            }
            catch (Exception ex5)
            {
                log.Write("交易异常:" + ex5.Message);
                exit("充值失败,请重新缴费,或退卡");
                return;
            }
        }