Пример #1
0
        /// <summary>
        /// 中信银行扣款方法,使用posinf.dll动态链接库
        /// </summary>
        /// <returns></returns>
        public string Bank_Pos_Deduct()
        {
            string          Lrc    = new Random().Next(100, 999).ToString();
            ZIBOPOSResolver handle = new ZIBOPOSResolver();

            handle.AddListInParas(handle.GetMac(), 8, new char[] { (' ') }, "L");                 //POS机号
            handle.AddListInParas(PayAPIConfig.Operator.UserSysId, 8, new char[] { (' ') }, "L"); //POS员工号
            handle.AddListInParas("00", 2, new char[] { (' ') }, "L");                            //交易类型
            handle.AddListInParas(ZHAmount, 12, new char[] { ('0') }, "R");                       //交易金额
            handle.AddListInParas("", 8, new char[] { (' ') }, "R");                              //原交易日期:退货时用,其他交易空格
            handle.AddListInParas("", 12, new char[] { (' ') }, "R");                             //原交易参考号:退货时用,其他交易空格
            handle.AddListInParas("", 6, new char[] { (' ') }, "R");                              //原交易凭证号:撤销时用,其他交易空格
            handle.AddListInParas(Lrc, 3, new char[] { (' ') }, "R");                             //LRC校验:3位随机数字
            handle.AddListInParas("", 100, new char[] { (' ') }, "R");                            //全民付(行业信息)

            StringBuilder Baninput = handle.CommInput();

            result = handle.CardTrans(Baninput);
            if (result.ReCode == "00")
            {
                string strresult = result.BankCode + "," + result.BankCardNo + "," + result.CertificateNo + "," + result.Amount + "," +
                                   result.ErrMsg + "," + result.MerchantNo + "," + result.TerminalNo + "," + result.BatchNo + "," + result.TransDate + "," +
                                   result.TransTime + "," + result.TransNo + "," + result.LicenseNo + "," + result.TallyDate + result.LRC + "," + Lrc;
                return(strresult);
            }
            else
            {
                throw new Exception(result.ErrMsg);
            }
        }
Пример #2
0
        /// <summary>
        /// 中信银行扣款方法,使用posinf.dll
        /// </summary>
        /// <param name="isCancelAll">是否全部撤销</param>
        /// <returns></returns>
        public string Bank_Pos_back(bool isCancelAll)
        {
            string Lrc = new Random().Next(100, 999).ToString();
            /************************************************************************/

            /* 通过CREATE_TIME与当前的日期进行对比,判断是当日撤销还是隔日退货,因为
             * 不同的日期需调用银行不同的方法来进行撤销银行交易*/
            /************************************************************************/
            string Insert_time = Convert.ToDateTime(tradePayPara.SettleInfo.CreateTime).ToString("yyyyMMdd");
            //新增的银联POS功能
            string bank_amount = "0";

            if (isCancelAll)
            {
                bank_amount = Convert.ToString(Convert.ToInt32(Convert.ToDecimal(tradePayPara.SettleInfo.AmountPos) * 100));
            }
            else
            {
                bank_amount = Convert.ToString(Convert.ToInt32(Math.Abs(Convert.ToDecimal(tradePayPara.CommPara.RefundAmount)) * 100));
            }

            /************************************************************************/
            /* 将本地存放的SETTLE_BACK_NO的字符串进行分割成数组,为撤销交易提供参数                                                                     */
            /************************************************************************/
            string[]        arrResult = tradePayPara.SettleInfo.SettleBackNo.ToString().Split(',');
            ZIBOPOSResolver handle    = new ZIBOPOSResolver();

            //交易参数
            if (Insert_time != DateTime.Now.ToString("yyyyMMdd") || !isCancelAll)
            {
                //如果交易时间与当前日期不一致,使用银行隔日退货
                handle.AddListInParas(handle.GetMac(), 8, new char[] { (' ') }, "L");                 //POS机号
                handle.AddListInParas(PayAPIConfig.Operator.UserSysId, 8, new char[] { (' ') }, "L"); //POS员工号
                handle.AddListInParas("02", 2, new char[] { (' ') }, "L");                            //交易类型
                handle.AddListInParas(bank_amount, 12, new char[] { ('0') }, "R");                    //交易金额
                handle.AddListInParas(arrResult[8], 8, new char[] { (' ') }, "R");                    //原交易日期:退货时用,其他交易空格
                handle.AddListInParas(arrResult[10], 12, new char[] { (' ') }, "R");                  //原交易参考号:退货时用,其他交易空格
                handle.AddListInParas("", 6, new char[] { (' ') }, "R");                              //原交易凭证号:撤销时用,其他交易空格
                handle.AddListInParas(Lrc, 3, new char[] { (' ') }, "R");                             //LRC校验:3位随机数字
                handle.AddListInParas("", 100, new char[] { (' ') }, "R");                            //全民付(行业信息)
            }
            else
            {
                //交易日期与当前日期一致,就直接使用银行撤销
                handle.AddListInParas(handle.GetMac(), 8, new char[] { (' ') }, "L");                 //POS机号
                handle.AddListInParas(PayAPIConfig.Operator.UserSysId, 8, new char[] { (' ') }, "L"); //POS员工号
                handle.AddListInParas("01", 2, new char[] { (' ') }, "L");                            //交易类型
                handle.AddListInParas(bank_amount, 12, new char[] { ('0') }, "R");                    //交易金额
                handle.AddListInParas("", 8, new char[] { (' ') }, "R");                              //原交易日期:退货时用,其他交易空格
                handle.AddListInParas("", 12, new char[] { (' ') }, "R");                             //原交易参考号:退货时用,其他交易空格
                handle.AddListInParas(arrResult[2], 6, new char[] { (' ') }, "R");                    //原交易凭证号:撤销时用,其他交易空格
                handle.AddListInParas(Lrc, 3, new char[] { (' ') }, "R");                             //LRC校验:3位随机数字
                handle.AddListInParas("", 100, new char[] { (' ') }, "R");                            //全民付(行业信息)
            }


            StringBuilder Baninput = handle.CommInput();

            //调用银行撤销方法
            result = handle.CardTrans(Baninput);
            if (result.ReCode == "00")
            {
                string strresult = result.BankCode + "," + result.BankCardNo + "," + result.CertificateNo + "," + result.Amount + "," +
                                   result.ErrMsg + "," + result.MerchantNo + "," + result.TerminalNo + "," + result.BatchNo + "," + result.TransDate + "," +
                                   result.TransTime + "," + result.TransNo + "," + result.LicenseNo + "," + result.TallyDate + result.LRC + "," + Lrc;
                return(strresult);
            }
            else
            {
                throw new Exception(result.ErrMsg);
            }
        }