using System;
using System.Collections;
//using System.Windows.Forms;

using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
using System.Text;
using System.Data;
using Cosmos.BaseFrame;

using System.Reflection;
/*-----------------------------------------------------------------------------------------------*/
// 설      명 : 해피기프트카드(코나머니)
// 작  성  자 : 
// 변경  이력 : 
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Service
{
    class HappyGiftCard : PaymentBase, IPaymentUs
    {
        #region Variable

        private SManager sManager = new SManager();                                 // 이 객체를 통해 업무 Service 호출
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)
        private PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조
        private TranStatus m_cTrnStatus = new TranStatus();                         // 거래정보 참조
        private IICReaderUs m_cICReader = null;                                     // IC리더기
        private ISignPadUs m_cSignPad = null;                                       // 싸인패드
        private IDataProcessUs m_cDataService = null;                               // 거래데이터 합계금액 계산 및 관리
        private IDataCommonUs m_cDataCommon = null;                                 // POS 공통함수 인터페이스

        private IMasterUs m_cMater = null;                                          // 마스터 Database

        private ISalePluItemUs m_cPluService = null;
        private DeviceStatus m_cDevStatus = new DeviceStatus();                     // 디바이스 관리

        //#20180329, 해피기프트(신) 신용카드 화면에서 승인 시 결제코드 선불카드로 저장되도록 수정 Start
        /// <summary>
        /// 해피기프트카드 프리픽스 구분자 ("N")
        /// </summary>
        //private const string HPGIFTCARD_DIV = "C"; // 기존        
        private const string HPGIFTCARD_DIV = "N"; // 변경
        //#20180329, 해피기프트(신) 신용카드 화면에서 승인 시 결제코드 선불카드로 저장되도록 수정 End

        //20171013 dkshin 해피기프트(신) IC/RF 충전 및 승인
        private Column.TR_ETC.DATA m_cPayEtc = null;

        #endregion

        #region 생성자
        public HappyGiftCard()
        {
            m_cPosStatus = (PosStatus)StateObject.POS;      // POS 기본정보
            m_cTrnStatus = (TranStatus)StateObject.TRAN;    // POS 거래정보
            m_cDataService = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE);
            m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
            m_cICReader = (IICReaderUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_ICREADER);
            m_cMater = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.PAY_DC_MASTER);
            m_cPluService = (ISalePluItemUs)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.SALE_PLU_ITEM);
            m_cSignPad = (ISignPadUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_SIGNPAD);

            m_cDevStatus = (DeviceStatus)StateObject.DEVICE;

        }
        #endregion

        #region 조회 관련 업무
        public string SearchPayment(string[] aParam, ref string[] aRet)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                switch (aParam[0])
                {
                    #region ### 해피기프트카드(코나머니) 카드프리픽스 조회
                    case PosConst.HPGIFTCARD_SEARCH_TYPE.PREFIX:
                        {
                            // 0:조회구분 
                            // 1:카드프리픽스 (해피기프트카드)
                            string cardBin = aParam[1].Substring(0, 6);

                            // 카드 프리픽스 마스터 조회 
                            IMasterUs cMater = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.PAY_DC_MASTER);

                            //#20180612 신용카드, 해피기프트(신) 화면에서 해피기프트(구) 카드번호 리딩되도록 수정 start
                            //기존
                            //DataTable dtData = cMater.Select(new string[] { PosMst.MST_CARD_PREFIX.TABLE_NAME, cardBin, HPGIFTCARD_DIV});
                            //변경
                            DataTable dtData = cMater.Select(new string[] { PosMst.MST_CARD_PREFIX.TABLE_NAME, cardBin });
                            //#20180612 신용카드, 해피기프트(신) 화면에서 해피기프트(구) 카드번호 리딩되도록 수정 end

                            if (dtData != null && dtData.Rows.Count > 0)
                            {
                                //#20180612 신용카드, 해피기프트(신) 화면에서 해피기프트(구) 카드번호 리딩되도록 수정 start
                                DataRow dr = dtData.Rows[0];

                                aRet[0] = CmUtil.GetDataRowStr(dr, PosMst.MST_CARD_PREFIX.DATA.CARD_DIV);
                                aRet[1] = CmUtil.GetDataRowStr(dr, PosMst.MST_CARD_PREFIX.DATA.PRFX_NM);
                                aRet[2] = CmUtil.GetDataRowStr(dr, PosMst.MST_CARD_PREFIX.DATA.CARD_CMP_CD);
                                aRet[3] = CmUtil.GetDataRowStr(dr, PosMst.MST_CARD_PREFIX.DATA.COOP_CARD_DIV);
                                //#20180612 신용카드, 해피기프트(신) 화면에서 해피기프트(구) 카드번호 리딩되도록 수정 end

                                sRet = UserCom.RST_OK;
                            }
                            else
                            {
                                sRet = UserCom.RST_IGNORE + MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0037);
                            }
                        }
                        break;  
                    #endregion

                    #region ### 해피기프트카드(코나머니) 잔액 조회
                    case PosConst.HPGIFTCARD_SEARCH_TYPE.HPGIFTCARD_SEARCH:
                        {
                            string sRecvdData = "";
                            string sSendData = string.Empty;

                            string sAppId = ""; //승인 구분자

                            string sReserved = "KMIQ";

                            string[] aIrtDTLRsp = null;


                            if (aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC || aParam[11] == "3" || aParam[9].Trim().Length > 0)  //IC정상 또는 FALLBACK
                            {
                                sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE;

                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start
                                // 기존
                                // sSendData = MakeCardICBody(sAppId, aParam, sReserved);
                                
                                //변경
                                if (m_cDevStatus.ICReader.UseYn != true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                                    sSendData = MakeCardMSRBody(sAppId, aParam, sReserved);
                                else
                                    sSendData = MakeCardICBody(sAppId, aParam, sReserved);
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End
                            }
                            else
                            {
                                sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_AGREE;
                                sSendData = MakeCardMSRBody(sAppId, aParam, sReserved);
                            }

                            //#20171018, 해피기프트(코나머니) 결제코드(신용->선불) 변경 Start, srlee
                            // 가맹점 정보 획득(회사승인ID,점포승인ID)
                            string sCmpApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.PPCARD_ITEM, ItemConst.TR_ITEM_ID.PPCARD.HPGIFT_CARD, PosMst.MST_VAN.DATA.CMP_APPR_ID);
                            string sApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.PPCARD_ITEM, ItemConst.TR_ITEM_ID.PPCARD.HPGIFT_CARD, PosMst.MST_VAN.DATA.APPR_ID);
                            //#20171018, 해피기프트(코나머니) 결제코드(신용->선불) 변경 End, srlee

                            // 신용카드 승인 전문 헤더 생성
                            sSendData = m_cDataCommon.MakeCreditCardHeader(sAppId, sSendData.Length, sCmpApprID, sApprID) + sSendData;

                            // 승인데이터 중 카드번호 마스킹 처리(2017.05.25) 

                            //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                            //기존
                            //string sWriteSendData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sSendData);
                            //변경
                            string sWriteSendData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sSendData);
                            //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                            UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                "[SEND:" + sWriteSendData);

                            //전문전송
                            string sIrtRet = m_cDataCommon.ExecuteCardIrt(sAppId, sSendData, ref sRecvdData, true, aParam[9], aParam[10], "", aParam[1]);
                            if (sIrtRet != UserCom.RST_OK)
                            {
                                return string.Format("|{0} - {1}", sIrtRet, sRecvdData);
                            }

                            byte[] bytes = Encoding.Default.GetBytes(sRecvdData);
                            int nNowPos = ItemColumn.LenMessage(Column.POS_VAN_HEADER.LEN);

                            if (sAppId != PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE)
                            {
                                nNowPos = 0;

                                aIrtDTLRsp = new string[Column.POS_RES_CREDITCARD_MSR.LEN.Length];
                                ItemColumn.ParseMessage(Column.POS_RES_CREDITCARD_MSR.LEN, Column.POS_RES_CREDITCARD_MSR.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                //기존
                                //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                //변경
                                string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end
                                
                                UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                    "[RECV:" + sWriteRecvData);

                                if (aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Status] != "O")
                                {
                                    return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message2]);
                                }
                                else
                                {
                                    //응답 구분자 리턴!
                                    aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Notice].ToString();

                                    aRet[0] = aRet[0].Replace("KNMC", "");      // M-Point인 경우 특정 문자 변경
                                }
                            }
                            else
                            {
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start                               
                                if (m_cDevStatus.ICReader.UseYn != true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF) // MS매장인데 해피기프트(신) IC 승인 할 경우
                                {
                                    //nNowPos = 0;

                                    aIrtDTLRsp = new string[Column.POS_RES_CREDITCARD_MSR.LEN.Length];
                                    ItemColumn.ParseMessage(Column.POS_RES_CREDITCARD_MSR.LEN, Column.POS_RES_CREDITCARD_MSR.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                    //기존
                                    //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                    //변경
                                    string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                    UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                        "[RECV:" + sWriteRecvData);

                                    if (aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Status] != "O")
                                    {
                                        return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message2]);
                                    }
                                    else
                                    {
                                        //응답 구분자 리턴!
                                        aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Notice].ToString();

                                        aRet[0] = aRet[0].Replace("KNMC", "");      // M-Point인 경우 특정 문자 변경
                                    }
                                }
                                else
                                {
                                    aIrtDTLRsp = new string[Column.POS_RES_CREDITCARDIC.LEN.Length];
                                    ItemColumn.ParseMessage(Column.POS_RES_CREDITCARDIC.LEN, Column.POS_RES_CREDITCARDIC.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                    //기존
                                    //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                    //변경
                                    string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                    UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                        "[RECV:" + sWriteRecvData);

                                    if (aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Status] != "O")
                                    {

                                        return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message2]);
                                    }
                                    else
                                    {
                                        aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Notice].ToString();

                                        aRet[0] = aRet[0].Replace("KNMC", "");
                                    }
                                }
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End
                            }

                            sRet = UserCom.RST_OK;
                        }
                        break;
                    #endregion

                    //20171013 dkshin 해피기프트(신) IC/RF 충전 및 승인
                    #region ### 해피기프트카드(코나머니) 충전
                    case PosConst.HPGIFTCARD_SEARCH_TYPE.HPGIFTCARD_RECHANGE:
                        {
                            string sRecvdData = "";
                            string sSendData = string.Empty;

                            string sAppId = ""; //승인 구분자

                            string sReserved = "KMCH";

                            string[] aIrtDTLRsp = null;

                            m_cPayEtc = new Column.TR_ETC.DATA();                                                            // 결과 저장 변수 생성
                            //20171019 dkshin 해피기프트(신) 충전 코드 변경
                            //m_cPayEtc.ETC_WAY_CD = ItemConst.TR_ITEM_ID.CREDITCARD_ITEM;                                        // 결제수단
                            //m_cPayEtc.ETC_DTL_CD_01 = ItemConst.TR_ITEM_ID.CREDITCARD.HPGIFT_CARD;                                 // 상세코드
                            m_cPayEtc.ETC_WAY_CD = ItemConst.TR_ITEM_ID.ETC_INFO_ITEM;
                            m_cPayEtc.ETC_DTL_CD_01 = ItemConst.TR_ITEM_ID.ETC_INFO.HAPPYGIFTNEW_CHARGE;                  


                            if (aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC || aParam[11] == "3" || aParam[9].Trim().Length > 0)  //IC정상 또는 FALLBACK
                            {
                                sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE;

                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start
                                // 기존
                                //sSendData = MakeCardICBody(sAppId, aParam, sReserved);
                                
                                if (m_cDevStatus.ICReader.UseYn != true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                                    sSendData = MakeCardMSRBody(sAppId, aParam, sReserved);
                                else
                                    sSendData = MakeCardICBody(sAppId, aParam, sReserved);
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End
                            }
                            else
                            {
                                sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_AGREE;
                                sSendData = MakeCardMSRBody(sAppId, aParam, sReserved);
                            }

                            // 가맹점 정보 획득(회사승인ID,점포승인ID)
                            //20171019 dkshin 해피기프트(신) 충전 코드 변경
                            //string sCmpApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.HPGIFT_CARD, PosMst.MST_VAN.DATA.CMP_APPR_ID);
                            //string sApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.HPGIFT_CARD, PosMst.MST_VAN.DATA.APPR_ID);                            
                            string sCmpApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.ETC_INFO_ITEM, ItemConst.TR_ITEM_ID.ETC_INFO.HAPPYGIFTNEW_CHARGE, PosMst.MST_VAN.DATA.CMP_APPR_ID);
                            string sApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.ETC_INFO_ITEM, ItemConst.TR_ITEM_ID.ETC_INFO.HAPPYGIFTNEW_CHARGE, PosMst.MST_VAN.DATA.APPR_ID);

                            // 신용카드 승인 전문 헤더 생성
                            sSendData = m_cDataCommon.MakeCreditCardHeader(sAppId, sSendData.Length, sCmpApprID, sApprID) + sSendData;

                            // 승인데이터 중 카드번호 마스킹 처리(2017.05.25)  
                            //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                            //기존
                            //string sWriteSendData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sSendData);
                            //변경
                            string sWriteSendData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sSendData);
                            //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                            UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                "[SEND:" + sWriteSendData);

                            //전문전송
                            string sIrtRet = m_cDataCommon.ExecuteCardIrt(sAppId, sSendData, ref sRecvdData, true, aParam[9], aParam[10], "", aParam[1]);
                            if (sIrtRet != UserCom.RST_OK)
                            {
                                return string.Format("|{0} - {1}", sIrtRet, sRecvdData);
                            }

                            byte[] bytes = Encoding.Default.GetBytes(sRecvdData);
                            int nNowPos = ItemColumn.LenMessage(Column.POS_VAN_HEADER.LEN);

                            if (sAppId != PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE)
                            {
                                nNowPos = 0;

                                aIrtDTLRsp = new string[Column.POS_RES_CREDITCARD_MSR.LEN.Length];
                                ItemColumn.ParseMessage(Column.POS_RES_CREDITCARD_MSR.LEN, Column.POS_RES_CREDITCARD_MSR.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                // 승인데이터 중 카드번호 마스킹 처리(2017.05.25)  
                                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                //기존
                                //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                //변경
                                string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                    "[RECV:" + sWriteRecvData);

                                if (aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Status] != "O")
                                {
                                    return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message2]);
                                }
                                else
                                {
                                    //응답 구분자 리턴!
                                    aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Notice].ToString();

                                    aRet[0] = aRet[0].Replace("KNMC", "");      // M-Point인 경우 특정 문자 변경
                                }

                                m_cPayEtc.OCCUR_ENTRY_02 = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppNo].Trim();                             // 승인번호
                                m_cPayEtc.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppDatatime], 0, 6);                                   // 승인일자
                                m_cPayEtc.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppDatatime], 6, 4);                                   // 승인시간

                                m_cPayEtc.AMT_ENTRY_04 = m_cDataService.DoubleParse(aRet[0]);                                                                              // 상품권잔액

                                m_cPayEtc.ETC_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY;                                                    // 할인결제구분 (1:결제, 2:할인)
                                m_cPayEtc.AMT_ENTRY_01 = m_cDataService.DoubleParse(aParam[4]);                                                                      // 받은돈
                                //20171019 dkshin 해피기프트(신) 충전 금액설정
                                m_cPayEtc.ETC_AMT = m_cDataService.DoubleParse(aParam[4]);

                                m_cPayEtc.OCCUR_ENTRY_01 = aParam[2];                                                                  // 카드번호
                                m_cPayEtc.OCCUR_ENTRY_05 = aParam[1];                                                                       // 입력 구분(방식)
                                
                                m_cPayEtc.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL;                                               // 승인구분

                                //m_cPayEtc.OCCUR_ENTRY_16 = CmUtil.GetDataRowStr(dr, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD);              // VAN 구분
                                m_cPayEtc.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayEtc.ETC_WAY_CD, m_cPayEtc.ETC_DTL_CD_01);   // 결제수단명

                                m_cPayEtc.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
                                m_cPayEtc.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;                                                  // 빌분리 번호
                            }
                            else
                            {                              
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start
                                if (m_cDevStatus.ICReader.UseYn != true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF) // MS매장인데 해피기프트(신) IC 승인 할 경우
                                {
                                    //nNowPos = 0;

                                    aIrtDTLRsp = new string[Column.POS_RES_CREDITCARD_MSR.LEN.Length];
                                    ItemColumn.ParseMessage(Column.POS_RES_CREDITCARD_MSR.LEN, Column.POS_RES_CREDITCARD_MSR.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                    // 승인데이터 중 카드번호 마스킹 처리(2017.05.25)  
                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                    //기존
                                    //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                    //변경
                                    string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                    UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                        "[RECV:" + sWriteRecvData);

                                    if (aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Status] != "O")
                                    {
                                        return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message2]);
                                    }
                                    else
                                    {
                                        //응답 구분자 리턴!
                                        aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Notice].ToString();

                                        aRet[0] = aRet[0].Replace("KNMC", "");      // M-Point인 경우 특정 문자 변경
                                    }

                                    m_cPayEtc.OCCUR_ENTRY_02 = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppNo].Trim();                             // 승인번호
                                    m_cPayEtc.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppDatatime], 0, 6);                                   // 승인일자
                                    m_cPayEtc.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppDatatime], 6, 4);                                   // 승인시간
                                }
                                else
                                {
                                    aIrtDTLRsp = new string[Column.POS_RES_CREDITCARDIC.LEN.Length];
                                    ItemColumn.ParseMessage(Column.POS_RES_CREDITCARDIC.LEN, Column.POS_RES_CREDITCARDIC.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                    //기존
                                    //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                    //변경
                                    string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                    UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                        "[RECV:" + sWriteRecvData);

                                    if (aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Status] != "O")
                                    {

                                        return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message2]);
                                    }
                                    else
                                    {
                                        aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Notice].ToString();

                                        aRet[0] = aRet[0].Replace("KNMC", "");
                                    }

                                    m_cPayEtc.OCCUR_ENTRY_02 = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.AppNo].Trim();                             // 승인번호
                                    m_cPayEtc.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.AppDatatime], 0, 6);                                   // 승인일자
                                    m_cPayEtc.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.AppDatatime], 6, 4);                                   // 승인시간
                                }
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End

                                m_cPayEtc.AMT_ENTRY_04 = m_cDataService.DoubleParse(aRet[0]);                                             // 상품권잔액

                                m_cPayEtc.ETC_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY;                                                       // 할인결제구분 (1:결제, 2:할인)
                                m_cPayEtc.AMT_ENTRY_01 = m_cDataService.DoubleParse(aParam[4]);                                           // 받은돈
                                //20171019 dkshin 해피기프트(신) 충전 금액설정
                                m_cPayEtc.ETC_AMT = m_cDataService.DoubleParse(aParam[4]);

                                m_cPayEtc.OCCUR_ENTRY_01 = aParam[22];                                                                    // 카드번호
                                m_cPayEtc.OCCUR_ENTRY_05 = aParam[1];                                                                     // 입력 구분(방식)

                                m_cPayEtc.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL;                                                  // 승인구분

                                //m_cPayEtc.OCCUR_ENTRY_16 = CmUtil.GetDataRowStr(dr, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD);               // VAN 구분
                                m_cPayEtc.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayEtc.ETC_WAY_CD, m_cPayEtc.ETC_DTL_CD_01);        // 결제수단명

                                m_cPayEtc.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
                                m_cPayEtc.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;                                                     // 빌분리 번호
                            }

                            sRet = UserCom.RST_OK;

                            // 결제 아이템 추가
                            ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);                     // 결제 내역 받아 오기
                            m_cPayEtc.SEQ = alEtcItem.Count + 1;
                            alEtcItem.Add(m_cPayEtc);

                            m_cDataService.UpdatePluAmount();       // 상품 합계금액 계산(거래해더)
                            m_cDataService.UpdatePayAmount();       // 결제 금액 재 계산 처리
                        }
                        break;
                    #endregion

                    //20171013 dkshin 해피기프트(신) IC/RF 충전 및 승인
                    #region ### 해피기프트카드(코나머니) 개시
                    case PosConst.HPGIFTCARD_SEARCH_TYPE.HPGIFTCARD_OPEN:
                        {
                            string sRecvdData = "";
                            string sSendData = string.Empty;

                            string sAppId = ""; //승인 구분자

                            string sReserved = "KMAC";

                            string[] aIrtDTLRsp = null;


                            if (aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC || aParam[11] == "3" || aParam[9].Trim().Length > 0)  //IC정상 또는 FALLBACK
                            {
                                sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE;
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start
                                // 기존
                                //sSendData = MakeCardICBody(sAppId, aParam, sReserved);

                                if (m_cDevStatus.ICReader.UseYn != true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                                    sSendData = MakeCardMSRBody(sAppId, aParam, sReserved);
                                else
                                    sSendData = MakeCardICBody(sAppId, aParam, sReserved);
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End

                            }
                            else
                            {
                                sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_AGREE;
                                sSendData = MakeCardMSRBody(sAppId, aParam, sReserved);
                            }

                            //#20171018, 해피기프트(코나머니) 결제코드(신용->선불) 변경 Start, srlee
                            // 가맹점 정보 획득(회사승인ID,점포승인ID)
                            string sCmpApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.ETC_INFO_ITEM, ItemConst.TR_ITEM_ID.ETC_INFO.HAPPYGIFTNEW_CHARGE, PosMst.MST_VAN.DATA.CMP_APPR_ID);
                            string sApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.ETC_INFO_ITEM, ItemConst.TR_ITEM_ID.ETC_INFO.HAPPYGIFTNEW_CHARGE, PosMst.MST_VAN.DATA.APPR_ID);
                            //#20171018, 해피기프트(코나머니) 결제코드(신용->선불) 변경 End, srlee

                            // 신용카드 승인 전문 헤더 생성
                            sSendData = m_cDataCommon.MakeCreditCardHeader(sAppId, sSendData.Length, sCmpApprID, sApprID) + sSendData;

                            // 승인데이터 중 카드번호 마스킹 처리(2017.05.25)  

                            //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                            //기존
                            //string sWriteSendData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sSendData);
                            //변경
                            string sWriteSendData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sSendData);
                            //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                            UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                "[SEND:" + sWriteSendData);

                            //전문전송
                            string sIrtRet = m_cDataCommon.ExecuteCardIrt(sAppId, sSendData, ref sRecvdData, true, aParam[9], aParam[10], "", aParam[1]);
                            if (sIrtRet != UserCom.RST_OK)
                            {
                                return string.Format("|{0} - {1}", sIrtRet, sRecvdData);
                            }

                            byte[] bytes = Encoding.Default.GetBytes(sRecvdData);
                            int nNowPos = ItemColumn.LenMessage(Column.POS_VAN_HEADER.LEN);

                            if (sAppId != PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE)
                            {
                                nNowPos = 0;

                                aIrtDTLRsp = new string[Column.POS_RES_CREDITCARD_MSR.LEN.Length];
                                ItemColumn.ParseMessage(Column.POS_RES_CREDITCARD_MSR.LEN, Column.POS_RES_CREDITCARD_MSR.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                //기존
                                //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                //변경
                                string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                    "[RECV:" + sWriteRecvData);

                                if (aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Status] != "O")
                                {
                                    return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message2]);
                                }
                                else
                                {
                                    //응답 구분자 리턴!
                                    aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Notice].ToString();

                                    aRet[0] = aRet[0].Replace("KNMC", "");      // M-Point인 경우 특정 문자 변경
                                }
                            }
                            else
                            {
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start                              
                                if (m_cDevStatus.ICReader.UseYn != true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF) // MS매장인데 해피기프트(신) IC 승인 할 경우
                                {
                                    //nNowPos = 0;

                                    aIrtDTLRsp = new string[Column.POS_RES_CREDITCARD_MSR.LEN.Length];
                                    ItemColumn.ParseMessage(Column.POS_RES_CREDITCARD_MSR.LEN, Column.POS_RES_CREDITCARD_MSR.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                    //기존
                                    //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                    //변경
                                    string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                    UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                        "[RECV:" + sWriteRecvData);

                                    if (aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Status] != "O")
                                    {
                                        return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message2]);
                                    }
                                    else
                                    {
                                        //응답 구분자 리턴!
                                        aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Notice].ToString();

                                        aRet[0] = aRet[0].Replace("KNMC", "");      // M-Point인 경우 특정 문자 변경
                                    }
                                }
                                else 
                                {
                                    aIrtDTLRsp = new string[Column.POS_RES_CREDITCARDIC.LEN.Length];
                                    ItemColumn.ParseMessage(Column.POS_RES_CREDITCARDIC.LEN, Column.POS_RES_CREDITCARDIC.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                    //기존
                                    //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                    //변경
                                    string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                    UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                        "[RECV:" + sWriteRecvData);

                                    if (aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Status] != "O")
                                    {

                                        return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message2]);
                                    }
                                    else
                                    {
                                        aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Notice].ToString();

                                        aRet[0] = aRet[0].Replace("KNMC", "");
                                    }
                                }
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End
                            }

                            sRet = UserCom.RST_OK;
                        }
                        break;
                    #endregion

                    //20171013 dkshin 해피기프트(신) IC/RF 충전 및 승인
                    #region ### 해피기프트카드(코나머니) 충전 취소
                    case PosConst.HPGIFTCARD_SEARCH_TYPE.HPGIFTCARD_RECHANGE_CANCEL:
                        {
                            string sRecvdData = "";
                            string sSendData = string.Empty;

                            string sAppId = ""; //승인 구분자

                            string sReserved = "KMCH";

                            string[] aIrtDTLRsp = null;

                            m_cPayEtc = new Column.TR_ETC.DATA();                                                            // 결과 저장 변수 생성
                            //20171019 dkshin 해피기프트(신) 충전 코드 변경
                            //m_cPayEtc.ETC_WAY_CD = ItemConst.TR_ITEM_ID.CREDITCARD_ITEM;                                        // 결제수단
                            //m_cPayEtc.ETC_DTL_CD_01 = ItemConst.TR_ITEM_ID.CREDITCARD.HPGIFT_CARD;                                 // 상세코드
                            m_cPayEtc.ETC_WAY_CD = ItemConst.TR_ITEM_ID.ETC_INFO_ITEM;
                            m_cPayEtc.ETC_DTL_CD_01 = ItemConst.TR_ITEM_ID.ETC_INFO.HAPPYGIFTNEW_CHARGE;


                            if (aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC || aParam[11] == "3" || aParam[9].Trim().Length > 0)  //IC정상 또는 FALLBACK
                            {
                                sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_CANCEL;
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start
                                // 기존
                                //sSendData = MakeCardICBody(sAppId, aParam, sReserved);

                                if (m_cDevStatus.ICReader.UseYn != true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                                    sSendData = MakeCardMSRBody(sAppId, aParam, sReserved);
                                else
                                    sSendData = MakeCardICBody(sAppId, aParam, sReserved);
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End

                            }
                            else
                            {
                                sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_CANCEL;
                                sSendData = MakeCardMSRBody(sAppId, aParam, sReserved);
                            }

                            // 가맹점 정보 획득(회사승인ID,점포승인ID)
                            //20171019 dkshin 해피기프트(신) 충전 코드 변경
                            //string sCmpApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.HPGIFT_CARD, PosMst.MST_VAN.DATA.CMP_APPR_ID);
                            //string sApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.HPGIFT_CARD, PosMst.MST_VAN.DATA.APPR_ID);
                            string sCmpApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.ETC_INFO_ITEM, ItemConst.TR_ITEM_ID.ETC_INFO.HAPPYGIFTNEW_CHARGE, PosMst.MST_VAN.DATA.CMP_APPR_ID);
                            string sApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.ETC_INFO_ITEM, ItemConst.TR_ITEM_ID.ETC_INFO.HAPPYGIFTNEW_CHARGE, PosMst.MST_VAN.DATA.APPR_ID);

                            // 신용카드 승인 전문 헤더 생성
                            sSendData = m_cDataCommon.MakeCreditCardHeader(sAppId, sSendData.Length, sCmpApprID, sApprID) + sSendData;

                            // 승인데이터 중 카드번호 마스킹 처리(2017.05.25)  
                            //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                            //기존
                            //string sWriteSendData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sSendData);
                            //변경
                            string sWriteSendData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sSendData);
                            //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                            UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                "[SEND:" + sWriteSendData);

                            //전문전송
                            string sIrtRet = m_cDataCommon.ExecuteCardIrt(sAppId, sSendData, ref sRecvdData, true, aParam[9], aParam[10], "", aParam[1]);
                            if (sIrtRet != UserCom.RST_OK)
                            {
                                return string.Format("|{0} - {1}", sIrtRet, sRecvdData);
                            }

                            byte[] bytes = Encoding.Default.GetBytes(sRecvdData);
                            int nNowPos = ItemColumn.LenMessage(Column.POS_VAN_HEADER.LEN);

                            if (sAppId == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_CANCEL)
                            {
                                nNowPos = 0;

                                aIrtDTLRsp = new string[Column.POS_RES_CREDITCARD_MSR.LEN.Length];
                                ItemColumn.ParseMessage(Column.POS_RES_CREDITCARD_MSR.LEN, Column.POS_RES_CREDITCARD_MSR.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                //기존
                                //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                //변경
                                string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                    "[RECV:" + sWriteRecvData);

                                if (aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Status] != "O")
                                {
                                    return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message2]);
                                }
                                else
                                {
                                    //응답 구분자 리턴!
                                    aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Notice].ToString();

                                    aRet[0] = aRet[0].Replace("KNMC", "");      // M-Point인 경우 특정 문자 변경
                                }

                                m_cPayEtc.OCCUR_ENTRY_02 = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppNo].Trim();                             // 승인번호
                                m_cPayEtc.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppDatatime], 0, 6);                                   // 승인일자
                                m_cPayEtc.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppDatatime], 6, 4);                                   // 승인시간

                                m_cPayEtc.AMT_ENTRY_04 = m_cDataService.DoubleParse(aRet[0]);                                                                              // 상품권잔액

                                m_cPayEtc.ETC_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY;                                                    // 할인결제구분 (1:결제, 2:할인)
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start
                                m_cPayEtc.AMT_ENTRY_01 = m_cDataService.DoubleParse(aParam[4]);                                                                      // 받은돈
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End
                                //20171019 dkshin 해피기프트(신) 충전 취소 금액설정
                                m_cPayEtc.ETC_AMT = m_cDataService.DoubleParse(aParam[4]);

                                m_cPayEtc.OCCUR_ENTRY_01 = aParam[2];                                                                  // 카드번호
                                m_cPayEtc.OCCUR_ENTRY_05 = aParam[1];                                                                  // 입력 구분(방식)

                                //#20171201, 해피기프트(신) 수정 Start
                                m_cPayEtc.OCCUR_ENTRY_06 = aParam[13];                                                                  // 원승인번호
                                m_cPayEtc.OCCUR_ENTRY_07 = aParam[14];                                                                  // 원승인일자
                                //#20171201, 해피기프트(신) 수정 End

                                m_cPayEtc.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL;                                               // 승인구분

                                //m_cPayEtc.OCCUR_ENTRY_16 = CmUtil.GetDataRowStr(dr, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD);              // VAN 구분
                                m_cPayEtc.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayEtc.ETC_WAY_CD, m_cPayEtc.ETC_DTL_CD_01);   // 결제수단명

                                m_cPayEtc.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
                                m_cPayEtc.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;                                                  // 빌분리 번호
                            }
                            else if (sAppId == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_CANCEL)
                            {
                                nNowPos = 0;

                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start                               
                                if (m_cDevStatus.ICReader.UseYn != true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                                {
                                    aIrtDTLRsp = new string[Column.POS_RES_CREDITCARD_MSR.LEN.Length];
                                    ItemColumn.ParseMessage(Column.POS_RES_CREDITCARD_MSR.LEN, Column.POS_RES_CREDITCARD_MSR.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                    //기존
                                    //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                    //변경
                                    string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                    UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                        "[RECV:" + sWriteRecvData);

                                    if (aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Status] != "O")
                                    {
                                        return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message2]);
                                    }
                                    else
                                    {
                                        //응답 구분자 리턴!
                                        aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Notice].ToString();

                                        aRet[0] = aRet[0].Replace("KNMC", "");      // M-Point인 경우 특정 문자 변경
                                    }

                                    m_cPayEtc.OCCUR_ENTRY_02 = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppNo].Trim();                             // 승인번호
                                    m_cPayEtc.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppDatatime], 0, 6);                                   // 승인일자
                                    m_cPayEtc.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppDatatime], 6, 4);                                   // 승인시간
                                }
                                else
                                {                             
                                    aIrtDTLRsp = new string[Column.POS_RES_CREDITCARDIC.LEN.Length];
                                    ItemColumn.ParseMessage(Column.POS_RES_CREDITCARDIC.LEN, Column.POS_RES_CREDITCARDIC.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                    //기존
                                    //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                    //변경
                                    string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                    //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                    UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                        "[RECV:" + sWriteRecvData);

                                    if (aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Status] != "O")
                                    {

                                        return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message2]);
                                    }
                                    else
                                    {
                                        aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Notice].ToString();

                                        aRet[0] = aRet[0].Replace("KNMC", "");
                                    }

                                    m_cPayEtc.OCCUR_ENTRY_02 = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.AppNo].Trim();                             // 승인번호
                                    m_cPayEtc.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.AppDatatime], 0, 6);                                   // 승인일자
                                    m_cPayEtc.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.AppDatatime], 6, 4);                                   // 승인시간
                                }
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End

                                m_cPayEtc.AMT_ENTRY_04 = m_cDataService.DoubleParse(aRet[0]);                                                                                               // 상품권잔액

                                m_cPayEtc.ETC_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY;                                                    // 할인결제구분 (1:결제, 2:할인)
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start
                                m_cPayEtc.AMT_ENTRY_01 = m_cDataService.DoubleParse(aParam[4]);                                                                      // 받은돈
                                //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End
                                //20171019 dkshin 해피기프트(신) 충전 취소 금액설정
                                m_cPayEtc.ETC_AMT = m_cDataService.DoubleParse(aParam[4]);

                                m_cPayEtc.OCCUR_ENTRY_01 = aParam[22];                                                                  // 카드번호
                                m_cPayEtc.OCCUR_ENTRY_05 = aParam[1];                                                                       // 입력 구분(방식)
                                
                                //#20171201, 해피기프트(신) 수정 Start
                                m_cPayEtc.OCCUR_ENTRY_06 = aParam[13];                                                                  // 원승인번호
                                m_cPayEtc.OCCUR_ENTRY_07 = aParam[14];                                                                  // 원승인일자
                                //#20171201, 해피기프트(신) 수정 End
                                
                                m_cPayEtc.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL;                                               // 승인구분

                                //m_cPayEtc.OCCUR_ENTRY_16 = CmUtil.GetDataRowStr(dr, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD);              // VAN 구분
                                m_cPayEtc.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayEtc.ETC_WAY_CD, m_cPayEtc.ETC_DTL_CD_01);   // 결제수단명

                                m_cPayEtc.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
                                m_cPayEtc.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;                                                  // 빌분리 번호
                            }
                            else
                            {
                                aIrtDTLRsp = new string[Column.POS_RES_CREDITCARDIC.LEN.Length];
                                ItemColumn.ParseMessage(Column.POS_RES_CREDITCARDIC.LEN, Column.POS_RES_CREDITCARDIC.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                                //기존
                                //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                                //변경
                                string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                                UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                                    "[RECV:" + sWriteRecvData);

                                if (aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Status] != "O")
                                {

                                    return string.Format("|{0} - {1}{2}", sRet, aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message1], aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message2]);
                                }
                                else
                                {
                                    aRet[0] = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Notice].ToString();

                                    aRet[0] = aRet[0].Replace("KNMC", "");
                                }

                                //20170920 dkshin 해피기프트카드 조회/충전
                                //aIrtDTLRsp = new string[Column.POS_RES_CREDITCARDIC.LEN.Length];
                                //ItemColumn.ParseMessage(Column.POS_RES_CREDITCARDIC.LEN, Column.POS_RES_CREDITCARDIC.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                                m_cPayEtc.OCCUR_ENTRY_02 = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.AppNo].Trim();                             // 승인번호
                                m_cPayEtc.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.AppDatatime], 0, 6);                                   // 승인일자
                                m_cPayEtc.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.AppDatatime], 6, 4);                                   // 승인시간

                                m_cPayEtc.AMT_ENTRY_04 = m_cDataService.DoubleParse(aRet[0]);                                                                                               // 상품권잔액

                                m_cPayEtc.ETC_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY;                                                    // 할인결제구분 (1:결제, 2:할인)
                                m_cPayEtc.AMT_ENTRY_01 = m_cDataService.DoubleParse(aParam[4]);                                                                      // 받은돈
                                //20171019 dkshin 해피기프트(신) 충전 취소 금액설정
                                m_cPayEtc.ETC_AMT = m_cDataService.DoubleParse(aParam[4]);

                                m_cPayEtc.OCCUR_ENTRY_01 = aParam[2];                                                                  // 카드번호
                                m_cPayEtc.OCCUR_ENTRY_05 = aParam[1];                                                                       // 입력 구분(방식)

                                m_cPayEtc.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL;                                               // 승인구분

                                //m_cPayEtc.OCCUR_ENTRY_16 = CmUtil.GetDataRowStr(dr, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD);              // VAN 구분
                                m_cPayEtc.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayEtc.ETC_WAY_CD, m_cPayEtc.ETC_DTL_CD_01);   // 결제수단명

                                m_cPayEtc.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
                                m_cPayEtc.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;                                                  // 빌분리 번호
                            }

                            sRet = UserCom.RST_OK;

                            // 결제 아이템 추가
                            ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);                     // 결제 내역 받아 오기
                            m_cPayEtc.SEQ = alEtcItem.Count + 1;
                            alEtcItem.Add(m_cPayEtc);

                            m_cDataService.UpdatePluAmount();       // 상품 합계금액 계산(거래해더)
                            m_cDataService.UpdatePayAmount();       // 결제 금액 재 계산 처리
                        }
                        break;
                    #endregion
                }

                return sRet;
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.ERROR, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
                return UserCom.RST_ERR + ex.Message;

            }
            finally
            {
                //여전법 대응!
                //////////////////////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref aParam);
                //////////////////////////////////////////////////////////////////////////////////
            }
        }
        #endregion 조회 관련 업무

        #region 결제 정보 획득
        /// <summary>
        /// 결제 정보 획득
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public object GetPayment(string[] aParam)
        {
            try
            {
                //20171013 dkshin 해피기프트(신) IC/RF 충전 및 승인
                //return null;
                return m_cPayEtc;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return null;
        }
        #endregion

        #region 결제 등록 처리
        /// <summary>
        /// 카드 결제 등록 처리
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string SetPayment(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                ArrayList aPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
                m_cPayItem = new Column.TR_PAYMENT.DATA();      // 결과 저장 변수 생성

                //#20171018, 해피기프트(코나머니) 결제코드(신용->선불) 변경 Start, srlee
                m_cPayItem.PAY_WAY_CD = ItemConst.TR_ITEM_ID.PPCARD_ITEM;
                m_cPayItem.PAY_DTL_CD_01 = ItemConst.TR_ITEM_ID.PPCARD.HPGIFT_CARD;
                //#20171018, 해피기프트(코나머니) 결제코드(신용->선불) 변경 End, srlee

                string sAppId = ""; //승인 구분자

                //0:마스킹 카드번호 1:입력구분 2:카드번호 3:할부개월 4:총금액 5:봉사료
                //6:세금 7:비밀번호 8:신용카드종류 9:칩데이터 10:사인
                //11:Fallback구분 12:제휴할인금액(캠페인) 13:원승인번호 14:원승인일자 15:아이템코드
                //16:매입사코드 17:매입사명 18:할인카드구분 19:할인금액 20:승인구분, 21:매체구분, 22:서비스코드

                if (aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF && aParam[9].Trim().Length > 0)  //RF고 칩데이터가 있으면 재정의
                {
                    aParam[9] = SetRfIcData(aParam[9]);
                }

                if (aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC || aParam[11] == "3" || aParam[9].Trim().Length > 0)  //IC정상 또는 FALLBACK
                {
                    sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE;
                }
                else
                {
                    sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_AGREE;
                }

                sRet = ExecuteIrt(sAppId, aParam);

                if (sRet == UserCom.RST_OK)
                {
                    // 결제 아이템 추가
                    ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);     // 결제 내역 받아 오기
                    m_cPayItem.SEQ = alPayItem.Count + 1;
                    alPayItem.Add(m_cPayItem);

                    m_cDataService.UpdatePluAmount();   // 상품 합계금액 계산(거래해더)
                    m_cDataService.UpdatePayAmount();   // 결제 금액 재 계산 처리

                    sRet = UserCom.RST_OK;
                }

            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.ERROR, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
                return UserCom.RST_ERR + ex.Message;
            }
            finally
            {
                //메세지 순번 증가
                m_cDataService.SetMsgNoInc(true, false, false);

                //여전법 대응!
                //////////////////////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref aParam);
                //////////////////////////////////////////////////////////////////////////////////
            }

            return sRet;

        }
        #endregion

        #region 결제 취소 처리
        /// <summary>
        /// 카드 결제 취소 처리
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string CancelPayment(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;

            string sCardInfo = "";

            string[] aStr = null;
             
            string m_sSign = "";

            try
            {

                string[] m_aParam = new string[23];

                //결과 저장
                ArrayList aPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
                m_cPayItem = (Column.TR_PAYMENT.DATA)aPayItem[CmUtil.IntParse(aParam[0])];

                string sAppId = ""; //승인 구분자

                // 정상 승인 거래만 전자서명 처리(2017.05.27)
                if (GetCancelReSign(m_cPayItem.PAY_AMT, ref m_sSign) == false)
                {
                    return sRet;
                }

                aStr = m_cPayItem.CanFiller1.Split(new string[] { "^!@" }, StringSplitOptions.None);
                sCardInfo = aStr[1];

                //#20171023, 해피기프트(신) 결제 수정 Start, srlee
                if (CmUtil.MidH(aStr[0], 2, 1) == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                {
                    /*m_aParam[2] = CmUtil.MidH(sCardInfo, 2, 512).Trim();
                    m_aParam[9] = SetRfIcData(CmUtil.MidH(sCardInfo, 1116, 512));
                    m_aParam[1] = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF;
                    m_aParam[21] = CmUtil.MidH(sCardInfo, 1, 1);
                    m_aParam[22] = m_cPayItem.OCCUR_ENTRY_23.ToString();

                    // 삼성 페이 체크!
                    if (CmUtil.MidH(sCardInfo, 1628, 2) == "02" && (m_aParam[21] == "D" || m_aParam[21] == "F"))
                    {
                        m_aParam[15] = "02";
                    }
                    else
                    {
                        m_aParam[15] = "";
                    }*/

                    string m_sInPutData = CmUtil.MidH(sCardInfo, 81, 512).Trim();//chip 데이터
                    string m_sInEncData = CmUtil.MidH(sCardInfo, 1, 40).Trim();// Track|| 데이터

                    //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start
                    if (m_cDevStatus.ICReader.UseYn == true)
                    {
                        string m_sInPutDataTemp = m_sInPutData;
                        EncryptedCardNo(m_sInEncData, ref m_sInPutData, ref m_sInEncData);
                        m_sInPutData = m_sInPutDataTemp;
                    }
                    //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End

                    m_aParam[2] = m_sInEncData;
                    m_aParam[9] = m_sInPutData;
                    m_aParam[1] = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF;
                    m_aParam[11] = "0";

                    m_aParam[21] = m_cPayItem.OCCUR_ENTRY_24.ToString();
                    m_aParam[22] = "";
                    m_aParam[15] = "";

                }
                else if (CmUtil.MidH(aStr[0], 2, 1) == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC)
                {
                    m_aParam[2] = CmUtil.MidH(sCardInfo, 6, 512).Trim();
                    m_aParam[9] = CmUtil.MidH(sCardInfo, 518, 512).Trim();

                    if (CmUtil.MidH(sCardInfo, 4, 2).Trim() == "02")
                    {
                        m_aParam[1] = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
                    }
                    else
                    {
                        m_aParam[1] = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC;
                    }
                    m_aParam[11] = CmUtil.MidH(sCardInfo, 3, 1); // == "3" ? "0" : "1";

                    m_aParam[21] = m_cPayItem.OCCUR_ENTRY_24.ToString();
                    m_aParam[22] = CmUtil.MidH(sCardInfo, 1067, 5).Trim();
                    m_aParam[15] = "";
                }
                else
                {
                    // MSR 버전이거나 IC이고 PosEntryMode가 'K'일 때
                    m_aParam[2] = CmUtil.MidH(sCardInfo, 0, 37).Trim();
                    m_aParam[9] = ""; // 칩데이터
                    m_aParam[1] = CmUtil.MidH(aStr[0], 2, 1);

                    m_aParam[21] = "";
                    m_aParam[22] = m_cPayItem.OCCUR_ENTRY_23.ToString();
                }
                //#20171023, 해피기프트(신) 결제 수정 End, srlee

                //0:마스킹 카드번호 1:입력구분 2:카드번호 3:할부개월 4:총금액 5:봉사료
                //6:세금 7:비밀번호 8:신용카드종류 9:칩데이터 10:사인
                //11:Fallback구분 12:제휴할인금액(캠페인) 13:원승인번호 14:원승인일자 15:아이템코드
                //16:매입사코드 17:매입사명 18:할인카드구분 19:할인금액 20:승인구분, 21:매체구분, 22:서비스코드

                m_aParam[3] = m_cPayItem.OCCUR_ENTRY_14.ToString().PadLeft(2, '0');
                m_aParam[4] = m_cPayItem.PAY_AMT.ToString();
                m_aParam[5] = m_cPayItem.AMT_ENTRY_04.ToString();
                m_aParam[6] = m_cPayItem.AMT_ENTRY_03.ToString();
                m_aParam[7] = "";    //비밀번호
                m_aParam[8] = "";    //신용카드종류

                m_aParam[10] = m_sSign;

                m_aParam[12] = m_cPayItem.AMT_ENTRY_07.ToString();
                m_aParam[13] = m_cPayItem.OCCUR_ENTRY_02.ToString();
                m_aParam[14] = m_cPayItem.OCCUR_ENTRY_03.ToString();


                m_aParam[16] = "";
                m_aParam[17] = "";
                m_aParam[18] = m_cPayItem.PAY_DTL_CD_02.ToString();
                m_aParam[19] = m_cPayItem.AMT_ENTRY_02.ToString();
                m_aParam[20] = "";

                if (m_aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC || m_aParam[11] == "3" || m_aParam[9].Trim().Length > 0)  //IC정상 또는 FALLBACK
                {
                    sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_CANCEL;
                }
                else
                {
                    sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_CANCEL;
                }

                sRet = ExecuteIrt(sAppId, m_aParam);
                if (sRet != UserCom.RST_OK)
                {
                    WinManager.ErrorMessage(sRet);
                    return UserCom.RST_ERR;
                }
                

                m_cPayItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.CANCEL;

                ICampaignUs cCampaingMain = (ICampaignUs)sManager.InitServiceInstance(ServiceLists.ASV_CAMPAIGN.DLL, ServiceLists.ASV_CAMPAIGN.CAMPAIGN_MAIN);
                // 캠페인 취소 처리
                cCampaingMain.CancelCampaignPayment(aParam[0], "");

                m_cDataService.UpdatePluAmount();       // 상품 합계금액 계산(거래해더)
                // 결제 금액 재 계산 처리
                m_cDataService.UpdatePayAmount();

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);

                sRet = UserCom.RST_ERR + ex.Message;
            }
            finally
            {
                //여전법 대응!
                //////////////////////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref sCardInfo);
                CmUtil.ZeroFillClear(ref m_cPayItem.CanFiller1);
                CmUtil.ZeroFillClear(ref aParam);
                CmUtil.ZeroFillClear(ref aStr);
                CmUtil.ZeroFillClear(ref m_sSign);
                //////////////////////////////////////////////////////////////////////////////////
            }
            return sRet;
        }
        #endregion

        #region 오타/반품시 처리
        /// <summary>
        /// 오타/반품시 처리
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string RefundPayment(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;

            string sCardInfo = "";
            string[] aStr = null;
            string m_sSign = "";

            try
            {
                string[] m_aParam = new string[23];

                //결과 저장
                ArrayList aPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
                m_cPayItem = (Column.TR_PAYMENT.DATA)aPayItem[CmUtil.IntParse(aParam[0])];

                string sAppId = ""; //승인 구분자

                //#20171023, 해피기프트(신) 결제 전화취소 수정 Start, srlee
                if (m_cPayItem.OCCUR_ENTRY_08.ToString() != ItemConst.PAY_APP_DIV.NORMAL)
                {
                    //임의 등록 이면 승인 없이 데이터 처리
                    //WinManager.ConfirmMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0240));

                    m_cPayItem.OCCUR_ENTRY_06 = m_cPayItem.OCCUR_ENTRY_02;
                    m_cPayItem.OCCUR_ENTRY_07 = m_cPayItem.OCCUR_ENTRY_03;
                }
                else
                {
                    // 정상 승인 거래만 전자서명 처리(2017.05.27)
                    if (GetCancelReSign(m_cPayItem.PAY_AMT, ref m_sSign) == false)
                    {
                        return sRet;
                    }

                    aStr = m_cPayItem.CanFiller1.Split(new string[] { "^!@" }, StringSplitOptions.None);

                    sCardInfo = aStr[1];

                    if (m_cDevStatus.ICReader.UseYn == true && CmUtil.MidH(aStr[0], 2, 1) != PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN)
                    {
                        //20171013 dkshin 해피기프트(신) IC/RF 충전 및 승인
                        /*m_aParam[2] = CmUtil.MidH(sCardInfo, 6, 512).Trim();
                        m_aParam[9] = CmUtil.MidH(sCardInfo, 518, 512).Trim();
                        if (CmUtil.MidH(sCardInfo, 4, 2).Trim() == "02")
                        {
                            m_aParam[1] = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
                        }
                        else
                        {
                            m_aParam[1] = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC;
                        }
                        m_aParam[11] = CmUtil.MidH(sCardInfo, 3, 1); // == "3" ? "0" : "1";

                        m_aParam[21] = m_cPayItem.OCCUR_ENTRY_24.ToString();
                        m_aParam[22] = CmUtil.MidH(sCardInfo, 1067, 5).Trim();
                        m_aParam[15] = "";
                        */
                        if (m_cPayItem.OCCUR_ENTRY_05 == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                        {
                            string m_sInPutData = CmUtil.MidH(sCardInfo, 81, 512).Trim();//chip 데이터
                            string m_sInEncData = CmUtil.MidH(sCardInfo, 1, 40).Trim();// Track|| 데이터

                            string m_sInPutDataTemp = m_sInPutData;
                            EncryptedCardNo(m_sInEncData, ref m_sInPutData, ref m_sInEncData);
                            m_sInPutData = m_sInPutDataTemp;

                            m_aParam[2] = m_sInEncData;
                            m_aParam[9] = m_sInPutData;
                            m_aParam[1] = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF;
                            m_aParam[11] = "0";

                            m_aParam[21] = m_cPayItem.OCCUR_ENTRY_24.ToString();
                            m_aParam[22] = "";
                            m_aParam[15] = "";
                        }
                        else
                        {
                            m_aParam[2] = CmUtil.MidH(sCardInfo, 6, 512).Trim();
                            m_aParam[9] = CmUtil.MidH(sCardInfo, 518, 512).Trim();
                            if (CmUtil.MidH(sCardInfo, 4, 2).Trim() == "02")
                            {
                                m_aParam[1] = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
                            }
                            else
                            {
                                m_aParam[1] = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC;
                            }
                            m_aParam[11] = CmUtil.MidH(sCardInfo, 3, 1); // == "3" ? "0" : "1";

                            m_aParam[21] = m_cPayItem.OCCUR_ENTRY_24.ToString();
                            m_aParam[22] = CmUtil.MidH(sCardInfo, 1067, 5).Trim();
                            m_aParam[15] = "";
                        }
                    }
                    else
                    {
                        //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start
                        // 기존
                        // MSR 버전이거나 IC이고 PosEntryMode가 'K'일 때
                        //m_aParam[2] = CmUtil.MidH(sCardInfo, 0, 37).Trim();
                        //m_aParam[9] = ""; // 칩데이터
                        //m_aParam[1] = CmUtil.MidH(aStr[0], 2, 1);

                        //m_aParam[21] = "";
                        //m_aParam[22] = m_cPayItem.OCCUR_ENTRY_23.ToString();

                        if (m_cPayItem.OCCUR_ENTRY_05 == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                        {
                            string m_sInPutData = CmUtil.MidH(sCardInfo, 81, 512).Trim();//chip 데이터
                            string m_sInEncData = CmUtil.MidH(sCardInfo, 1, 40).Trim();// Track|| 데이터

                            m_aParam[2] = m_sInEncData;
                            m_aParam[9] = m_sInPutData;
                            m_aParam[1] = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF;
                            m_aParam[11] = "0";

                            m_aParam[21] = m_cPayItem.OCCUR_ENTRY_24.ToString();
                            m_aParam[22] = "";
                            m_aParam[15] = "";
                        }
                        else
                        {
                            // MSR 버전이거나 IC이고 PosEntryMode가 'K'일 때
                            m_aParam[2] = CmUtil.MidH(sCardInfo, 0, 37).Trim();
                            m_aParam[9] = ""; // 칩데이터
                            m_aParam[1] = CmUtil.MidH(aStr[0], 2, 1);

                            m_aParam[21] = "";
                            m_aParam[22] = m_cPayItem.OCCUR_ENTRY_23.ToString();
                        }
                        //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End
                    }

                    m_aParam[3] = m_cPayItem.OCCUR_ENTRY_14.ToString().PadLeft(2, '0');
                    m_aParam[4] = m_cPayItem.PAY_AMT.ToString();
                    m_aParam[5] = m_cPayItem.AMT_ENTRY_04.ToString();
                    m_aParam[6] = m_cPayItem.AMT_ENTRY_03.ToString();
                    m_aParam[7] = "";    //비밀번호
                    m_aParam[8] = "";    //신용카드종류

                    m_aParam[10] = m_sSign;

                    m_aParam[12] = "";
                    m_aParam[13] = m_cPayItem.OCCUR_ENTRY_02.ToString();
                    m_aParam[14] = m_cPayItem.OCCUR_ENTRY_03.ToString();

                    if (m_aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC || m_aParam[11] == "3" || m_aParam[9].Trim().Length > 0)  //IC정상 또는 FALLBACK
                    {
                        sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_CANCEL;
                    }
                    else
                    {
                        sAppId = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_CANCEL;
                    }

                    sRet = ExecuteIrt(sAppId, m_aParam);

                    if (sRet != UserCom.RST_OK)
                    {
                        WinManager.ErrorMessage(sRet);
                        return UserCom.RST_ERR;
                    } 
                }
                //#20171023, 해피기프트(신) 결제 전화취소 수정 End, srlee

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);

                sRet = UserCom.RST_ERR + ex.Message;
            }
            finally
            {
                //여전법 대응!
                //////////////////////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref sCardInfo);
                CmUtil.ZeroFillClear(ref m_cPayItem.CanFiller1);
                CmUtil.ZeroFillClear(ref aParam);
                CmUtil.ZeroFillClear(ref aStr);
                CmUtil.ZeroFillClear(ref m_sSign);
                //////////////////////////////////////////////////////////////////////////////////
            }
            return sRet;
        }
        #endregion 오타/반품시 처리

        /// <summary>
        /// 조회 실행
        /// </summary>
        /// <param name="sAppType"></param>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string ExecuteIrt(string sAppType, string[] aParam)
        {

            string sRet = UserCom.RST_ERR;
            string sSendData = string.Empty;

            string[] aIrtDTLRsp = null;

            string sStatus = "";        // 거래일시 - 'O' : 승인 'X' : 거절
            string sAppNo = "";         // 승인번호 - 신용승인번호 또는 거절코드(4)
            string sAppDatatime = "";   // 거래일시 - YYMMDDhhmm
            string sMessage1 = "";      // Message1 - 승인시 : 카드종류명, 거절시 : 거절 MESSAGE
            string sMessage2 = "";      // Message2 - 승인시 : "OK : " 승인번호 8자리, 거절시 : 거절 MESSAGE
            string sNotice = "";        // Notice
            string sIssueCode = "";     // 발급사코드 - 발급사 코드 (카드사 코드 Table 참조)
            string sCardName = "";      // 카드종류명 - 발급사 카드종류명
            string sBuyCode = "";       // 매입사코드 - 매입사 코드 (카드사 코드 Table 참조)
            string sBuyName = "";       // 매입사명 - 전표 매입사명
            string sFranchiseNo = "";   // 가맹점번호
            string sReserved = "";      // Reserved
            string sCustomerInfo = "";  // 사용자정보(해피포인트 적립)

            try
            {
                // 연습모드이면 연습 데이터 설정
                if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1") return SetTrainingData(sAppType, aParam);

                string sRecvdData = "";

                if (aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC || aParam[11] == "3" || aParam[9].Trim().Length > 0)  //IC정상 또는 FALLBACK
                {
                    //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start
                    // 기존
                    //sSendData = MakeCardICBody(sAppType, aParam, "");
                    
                    // 변경
                    if (m_cDevStatus.ICReader.UseYn != true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                        sSendData = MakeCardMSRBody(sAppType, aParam, sReserved);
                    else
                        sSendData = MakeCardICBody(sAppType, aParam, sReserved);
                    //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End
                }
                else
                {
                    sSendData = MakeCardMSRBody(sAppType, aParam, "");
                }

                //#20171018, 해피기프트(코나머니) 결제코드(신용->선불) 변경 Start, srlee
                // 가맹점 정보 획득(회사승인ID,점포승인ID)
                string sCmpApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.PPCARD_ITEM, ItemConst.TR_ITEM_ID.PPCARD.HPGIFT_CARD, PosMst.MST_VAN.DATA.CMP_APPR_ID);
                string sApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.PPCARD_ITEM, ItemConst.TR_ITEM_ID.PPCARD.HPGIFT_CARD, PosMst.MST_VAN.DATA.APPR_ID);
                //#20171018, 해피기프트(코나머니) 결제코드(신용->선불) 변경 End, srlee

                // 신용카드 승인 전문 헤더 생성
                sSendData = m_cDataCommon.MakeCreditCardHeader(sAppType, sSendData.Length, sCmpApprID, sApprID) + sSendData;

                string sAppLogDiv = "";

                if (sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_AGREE || sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE)
                {
                    sAppLogDiv = PosConst.CANCEL_DIV.NORMAL;
                }
                else
                {
                    sAppLogDiv = PosConst.CANCEL_DIV.CANCEL;
                }

                // 승인데이터 중 카드번호 마스킹 처리(2017.05.25)

                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                //기존
                //string sWriteSendData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sSendData);
                //변경
                string sWriteSendData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sSendData);
                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                    "[SEND:" + sWriteSendData);
                // 요청 - 승인로그 저장   (판매구분, [0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문)
                m_cDataCommon.SetSaleApprLog(sAppLogDiv, new string[] { m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, sAppType, "S", aParam[0], CmUtil.DoubleParse(aParam[4]).ToString(), "", "", "", "", "", sWriteSendData });

                string sIrtRet = "";

                //전문전송
                sIrtRet = m_cDataCommon.ExecuteCardIrt(sAppType, sSendData, ref sRecvdData, true, aParam[9], aParam[10], "", aParam[1]);

                if (sIrtRet != UserCom.RST_OK)
                {
                    return string.Format("|{0} - {1}", sIrtRet, sRecvdData);
                }

                byte[] bytes = Encoding.Default.GetBytes(sRecvdData);

                int nNowPos = ItemColumn.LenMessage(Column.POS_VAN_HEADER.LEN);

                //20171013 dkshin 해피기프트(신) IC/RF 충전 및 승인
                //if (sAppType != PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE)
                //IC 승인이 아닐 경우 헤더
                if (sAppType != PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE)
                {
                    nNowPos = 0;
                } 

                if (sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_CANCEL || sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_AGREE)
                {
                    aIrtDTLRsp = new string[Column.POS_RES_CREDITCARD_MSR.LEN.Length];
                    ItemColumn.ParseMessage(Column.POS_RES_CREDITCARD_MSR.LEN, Column.POS_RES_CREDITCARD_MSR.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                    sStatus       = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Status];
                    sAppNo        = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppNo];
                    sAppDatatime  = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppDatatime];
                    sMessage1     = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message1];
                    sMessage2     = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message2];
                    sNotice       = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Notice];
                    sIssueCode    = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.IssueCode];
                    sCardName     = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.CardName];
                    sBuyCode      = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.BuyCode];
                    sBuyName      = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.BuyName];
                    sFranchiseNo  = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.FranchiseNo];
                    sReserved     = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Reserved];
                    sCustomerInfo = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.CustomerInfo];
                }
                else
                {
                    //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start
                    if (m_cDevStatus.ICReader.UseYn != true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF) //MS매장 해피기프트(신) RF 승인 시 IC전문
                    {
                        aIrtDTLRsp = new string[Column.POS_RES_CREDITCARD_MSR.LEN.Length];
                        ItemColumn.ParseMessage(Column.POS_RES_CREDITCARD_MSR.LEN, Column.POS_RES_CREDITCARD_MSR.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                        sStatus = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Status];
                        sAppNo = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppNo];
                        sAppDatatime = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.AppDatatime];
                        sMessage1 = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message1];
                        sMessage2 = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Message2];
                        sNotice = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Notice];
                        sIssueCode = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.IssueCode];
                        sCardName = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.CardName];
                        sBuyCode = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.BuyCode];
                        sBuyName = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.BuyName];
                        sFranchiseNo = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.FranchiseNo];
                        sReserved = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.Reserved];
                        sCustomerInfo = aIrtDTLRsp[Column.POS_RES_CREDITCARD_MSR.SEQ.CustomerInfo];
                    }
                    else
                    {
                        aIrtDTLRsp = new string[Column.POS_RES_CREDITCARDIC.LEN.Length];
                        ItemColumn.ParseMessage(Column.POS_RES_CREDITCARDIC.LEN, Column.POS_RES_CREDITCARDIC.TYPE, bytes, ref nNowPos, ref aIrtDTLRsp);

                        sStatus = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Status];
                        sAppNo = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.AppNo];
                        sAppDatatime = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.AppDatatime];
                        sMessage1 = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message1];
                        sMessage2 = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Message2];
                        sNotice = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Notice];
                        sIssueCode = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.IssueCode];
                        sCardName = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.CardName];
                        sBuyCode = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.BuyCode];
                        sBuyName = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.BuyName];
                        sFranchiseNo = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.FranchiseNo];
                        sReserved = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.Reserved];
                        sCustomerInfo = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.CustomerInfo];
                    }
                    //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End
                }

                // 승인데이터 중 카드번호 마스킹 처리(2017.05.25)
                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 start
                //기존
                //string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, "", sRecvdData);
                //변경
                string sWriteRecvData = CmUtil.MakeLogDataToMask(m_cDevStatus.ICReader.UseYn, aParam[2], sRecvdData);
                //#20171121 코나머니 승인로그 생성시 카드번호 마스킹 end

                UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                    "[RECV:" + sWriteRecvData);
                // 응답 - 승인로그 저장   (판매구분, [0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문)
                m_cDataCommon.SetSaleApprLog(sAppLogDiv, new string[] { m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, sAppType, "R"
                                                            , aParam[0], CmUtil.DoubleParse(aParam[4]).ToString()
                                                            , sAppNo, CmUtil.MidH(sAppDatatime, 0, 6), CmUtil.MidH(sAppDatatime, 6, 4)
                                                            , sStatus.Trim()
                                                            , sMessage1.Trim() + sMessage2.Trim()
                                                            , sWriteRecvData });

                if (sStatus != "O")
                {
                    return string.Format("|{0} - {1}{2}", sRet, sMessage1, sMessage2);
                }

                //결과 저장
                m_cPayItem.AMT_ENTRY_01 = CmUtil.DoubleParse(aParam[4]);                                                    //받은돈                                   
                m_cPayItem.AMT_ENTRY_02 = 0;                                                                                // 제휴 할인 금액
                m_cPayItem.AMT_ENTRY_03 = 0;

                double nAlterPayAmt = 0;

                //#15597 (코나머니)해피기프트 프로모션 영수증 출력 변경 Start
                //적용시 주석 해제
                //double nPayAmt = 0;
                //#15597 (코나머니)해피기프트 프로모션 영수증 출력 변경 End

                if (sBuyCode.Trim() == "58")
                {
                    nAlterPayAmt = CmUtil.DoubleParse(sNotice.Replace("KNMC", ""));                                         // 해피기프트카드(코나머니) 잔액
                }

                //#15597 (코나머니)해피기프트 프로모션 영수증 출력 변경 Start
                //적용시 주석 해제
                /*
                nPayAmt = CmUtil.DoubleParse(sMessage1.Replace("RAMT", ""));                                     // 해피기프트카드(코나머니) 실제 결제금액(할인 후 금액)

                if (nPayAmt == 0)
                {
                    nPayAmt = m_cPayItem.AMT_ENTRY_01;                                                          // 할인 프로모션 적용 안됐을 경우
                }
                */
                //#15597 (코나머니)해피기프트 프로모션 영수증 출력 변경 End

                if (sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_CANCEL || sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_CANCEL)
                {
                    //#15597 (코나머니)해피기프트 프로모션 영수증 출력 변경 Start
                    // 기존
                    m_cPayItem.AMT_ENTRY_04 = CmUtil.DoubleSubtraction(nAlterPayAmt, m_cPayItem.AMT_ENTRY_01);              // 사용전 잔액
                    //변경
                    //m_cPayItem.AMT_ENTRY_04 = CmUtil.DoubleSubtraction(nAlterPayAmt, nPayAmt);                       // 사용전 잔액
                    //#15597 (코나머니)해피기프트 프로모션 영수증 출력 변경 End

                    m_cPayItem.AMT_ENTRY_05 = nAlterPayAmt;                                                                 // 사용후 잔액

                    m_cPayItem.OCCUR_ENTRY_06 = m_cPayItem.OCCUR_ENTRY_02;                                                  // 원승인번호
                    m_cPayItem.OCCUR_ENTRY_07 = m_cPayItem.OCCUR_ENTRY_03;                                                  // 원승인일자
                }
                else
                {
                    //#15597 (코나머니)해피기프트 프로모션 영수증 출력 변경 Start
                    // 기존
                    m_cPayItem.AMT_ENTRY_04 = CmUtil.DoubleAdd(nAlterPayAmt, m_cPayItem.AMT_ENTRY_01);
                    // 변경
                    //m_cPayItem.AMT_ENTRY_04 = CmUtil.DoubleAdd(nAlterPayAmt, nPayAmt);
                    //#15597 (코나머니)해피기프트 프로모션 영수증 출력 변경 End

                    m_cPayItem.AMT_ENTRY_05 = nAlterPayAmt;

                    //#20171023, 해피기프트(신) 결제 수정 Start, srlee
                    //if (m_cDevStatus.ICReader.UseYn == true && aParam[1] != PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN)
                    if (m_cDevStatus.ICReader.UseYn == true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC)
                    {
                        m_cPayItem.OCCUR_ENTRY_01 = aParam[0];                                  //카드번호
                    }
                    else
                    {
                        m_cPayItem.OCCUR_ENTRY_01 = CmUtil.MidH(aParam[0], 0, 6) + "**********";  //카드번호
                    }
                    //#20171023, 해피기프트(신) 결제 수정 End, srlee

                    m_cPayItem.OCCUR_ENTRY_06 = "";                                                                          // 원승인번호
                    m_cPayItem.OCCUR_ENTRY_07 = "";                                                                          // 원승인일자

                    m_cPayItem.CanFiller1 = aParam[2];

                    //#20171023, 해피기프트(신) 결제 수정 Start, srlee
                    if (sReserved.Trim() == "H")
                    {
                        m_cPayItem.CanFiller2 = "823" + sCustomerInfo.Trim();                                                       // 해피포인트 적립
                    }
                    //#20171023, 해피기프트(신) 결제 수정 End, srlee
                }

                m_cPayItem.PAY_AMT = CmUtil.DoubleParse(aParam[4]);

                m_cPayItem.PAY_DTL_CD_02 = "";                                                                      // 캠페인코드
                m_cPayItem.PAY_DTL_CD_03 = "";
                m_cPayItem.PAY_DTL_CD_04 = "";
                m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY;                                                // 할인적립구분 (1:결제, 2:할인)

                m_cPayItem.AMT_ENTRY_06 = 0;
                m_cPayItem.AMT_ENTRY_07 = 0;
                m_cPayItem.AMT_ENTRY_08 = 0;
                m_cPayItem.AMT_ENTRY_09 = 0;
                m_cPayItem.AMT_ENTRY_10 = 0;

                m_cPayItem.OCCUR_ENTRY_02 = sAppNo;
                m_cPayItem.OCCUR_ENTRY_03 = CmUtil.MidH(sAppDatatime, 0, 6);
                m_cPayItem.OCCUR_ENTRY_04 = CmUtil.MidH(sAppDatatime, 6, 4);
                m_cPayItem.OCCUR_ENTRY_05 = aParam[1];                                      //입력구분

                m_cPayItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL;                   //승인구분
                m_cPayItem.OCCUR_ENTRY_09 = "";
                m_cPayItem.OCCUR_ENTRY_10 = "";                                             // 가맹점 정보
                m_cPayItem.OCCUR_ENTRY_11 = "";                                             // 유효기간
                m_cPayItem.OCCUR_ENTRY_12 = "";                                             // 결제 정보
                m_cPayItem.OCCUR_ENTRY_13 = "";

                m_cPayItem.OCCUR_ENTRY_16 = GetPayDtlCdToVanCode(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01);       // 승인업체 코드 조회
                m_cPayItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01);   // 결제수단명
                m_cPayItem.OCCUR_ENTRY_21 = GetPayDtlCdToCashBillYn(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01);   // 현금영수증 발행여부

                m_cPayItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
                m_cPayItem.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;              // 빌분리 번호

                // 키다운로드, 사인저장 안씀
                if (sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE)
                {
                    // KSN Download 체크
                    if (m_cPayItem.OCCUR_ENTRY_05 == "R")
                    {
                        // 서명패드(RF)
                        if (m_cPosStatus.Base.KSN_SignPad_Download.Trim() == "" && aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.DeviceFunc].ToUpper().Trim() == "K1")
                        {
                            m_cPosStatus.Base.KSN_SignPad_Download = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.DeviceFunc];

                            CmMessage m_PosSal = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosSaleInfo);
                            m_PosSal.GetMessage("POSOPEN").MakeMessageOverWrite("KSN_SignPad_Download", m_cPosStatus.Base.KSN_SignPad_Download);
                            m_PosSal.MakeFileFromMessage(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosSaleInfo);
                        }
                    }
                    else
                    {
                        // IC 리더기
                        if (m_cPosStatus.Base.KSN_IC_Download.Trim() == "" && aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.DeviceFunc].ToUpper().Trim() == "K1")
                        {
                            m_cPosStatus.Base.KSN_IC_Download = aIrtDTLRsp[Column.POS_RES_CREDITCARDIC.SEQ.DeviceFunc];

                            CmMessage m_PosSal = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosSaleInfo);
                            m_PosSal.GetMessage("POSOPEN").MakeMessageOverWrite("KSN_IC_Download", m_cPosStatus.Base.KSN_IC_Download);
                            m_PosSal.MakeFileFromMessage(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosSaleInfo);
                        }
                    }
                }

                //사인저장
                if (aParam[10].Trim().Length > 0)
                {
                    //싸인이미지명 변경
                    SetSignImgReName(sAppNo);

                    ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);     // 결제 내역 받아 오기
                    SetSignData(alPayItem.Count + 1, aParam[10]);
                }                

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            finally
            {
                CmUtil.ZeroFillClear(ref sSendData);
            }

            return sRet;
        }

        /// <summary>
        /// 연습 데이터 설정
        /// </summary>
        public string SetTrainingData(string sAppType, string[] aParam)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                double dPayAmt = 0;
                double dDcAmt = 0;
                double dtaxAmt = 0;
                double dDcCamp = 0;
                string sCardNo = "";
                string sDivMonth = "";
                string dDcCardCode = "";
                string sCancelFlag = "";
               
                //0:마스킹 카드번호 1:입력구분 2:카드번호 3:할부개월 4:총금액 5:봉사료
                //6:세금 7:비밀번호 8:신용카드종류 9:칩데이터 10:사인
                //11:Fallback구분 12:제휴할인금액(캠페인) 13:원승인번호 14:원승인일자 15:아이템코드
                //16:매입사코드 17:매입사명 18:할인카드구분 19:할인금액 20:승인구분

                dPayAmt = CmUtil.DoubleParse(aParam[4]);
                dDcAmt = CmUtil.DoubleParse(aParam[19]);
                dDcCamp = CmUtil.DoubleParse(aParam[12]);
                sCardNo = aParam[0];
                sDivMonth = aParam[3];
                dDcCardCode = aParam[18];
                dtaxAmt = CmUtil.DoubleParse(aParam[6]);

                if (sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE || sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_AGREE)
                {
                    sCancelFlag = ItemConst.PAY_CANCEL_DIV.NORMAL;
                }
                else
                {
                    sCancelFlag = ItemConst.PAY_CANCEL_DIV.CANCEL;
                }

                m_cPayItem.PAY_WAY_CD = ItemConst.TR_ITEM_ID.PPCARD_ITEM;
                m_cPayItem.PAY_AMT = dPayAmt;

                m_cPayItem.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;                                                  // 빌분리 번호

                m_cPayItem.PAY_DTL_CD_01 = ItemConst.TR_ITEM_ID.PPCARD.HPGIFT_CARD;
                m_cPayItem.PAY_DTL_CD_02 = "";
                m_cPayItem.PAY_DTL_CD_03 = "";
                m_cPayItem.PAY_DTL_CD_04 = "";
                m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY;

                m_cPayItem.QTY_ENTRY_01 = 0;
                m_cPayItem.QTY_ENTRY_02 = 0;
                m_cPayItem.QTY_ENTRY_03 = 0;
                m_cPayItem.QTY_ENTRY_04 = 0;
                m_cPayItem.QTY_ENTRY_05 = 0;

                m_cPayItem.AMT_ENTRY_01 = dPayAmt;
                m_cPayItem.AMT_ENTRY_02 = dDcAmt;   //제휴 할인 금액
                m_cPayItem.AMT_ENTRY_03 = dtaxAmt;  //세금
                m_cPayItem.AMT_ENTRY_04 = 0;
                m_cPayItem.AMT_ENTRY_05 = 0;
                m_cPayItem.AMT_ENTRY_06 = 0;
                m_cPayItem.AMT_ENTRY_07 = dDcCamp;
                m_cPayItem.AMT_ENTRY_08 = 0;
                m_cPayItem.AMT_ENTRY_09 = 0;
                m_cPayItem.AMT_ENTRY_10 = 0;

                m_cPayItem.OCCUR_ENTRY_01 = sCardNo;   //카드번호
                m_cPayItem.OCCUR_ENTRY_02 = "99999999";
                m_cPayItem.OCCUR_ENTRY_03 = DateTime.Now.ToString("yyMMdd");
                m_cPayItem.OCCUR_ENTRY_04 = DateTime.Now.ToString("HHmm");
                m_cPayItem.OCCUR_ENTRY_05 = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN;
                m_cPayItem.OCCUR_ENTRY_06 = "";   //원승인번호
                m_cPayItem.OCCUR_ENTRY_07 = "";   //원승인일자
                m_cPayItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.COMPULSION;
                m_cPayItem.OCCUR_ENTRY_09 = "";
                m_cPayItem.OCCUR_ENTRY_10 = "";
                m_cPayItem.OCCUR_ENTRY_11 = "99";
                m_cPayItem.OCCUR_ENTRY_12 = "";
                m_cPayItem.OCCUR_ENTRY_13 = "0";   //Fallback 구분
                m_cPayItem.OCCUR_ENTRY_14 = sDivMonth;    //할부개월
                m_cPayItem.OCCUR_ENTRY_15 = "0";   //은련구분
                m_cPayItem.OCCUR_ENTRY_16 = GetPayDtlCdToVanCode(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01);    // 승인업체 코드 조회
                m_cPayItem.OCCUR_ENTRY_17 = "1";   //사인유무
                m_cPayItem.OCCUR_ENTRY_18 = "";   //매체구분
                m_cPayItem.OCCUR_ENTRY_19 = "";    //비밀번호
                m_cPayItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01);   // 결제수단명
                m_cPayItem.OCCUR_ENTRY_21 = GetPayDtlCdToCashBillYn(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01);   // 현금영수증 발행여부
                m_cPayItem.OCCUR_ENTRY_22 = "";
                m_cPayItem.OCCUR_ENTRY_23 = "";
                m_cPayItem.OCCUR_ENTRY_24 = "";
                m_cPayItem.OCCUR_ENTRY_25 = "";

                m_cPayItem.CanFiller1 = "";
                m_cPayItem.CanFiller2 = "";
                m_cPayItem.CanFiller3 = "";

                m_cPayItem.CANCEL_DIV = sCancelFlag;

                sRet = UserCom.RST_OK;

            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;

        }

        /// <summary>
        /// 사인유무 체크
        /// </summary>
        /// <param name="sSignDiv"></param>
        /// <param name="dPayAmt"></param>
        /// <returns></returns>
        private string GetSignFlag(string sSignDiv, double dPayAmt)
        {
            string sRet = sSignDiv;

            try
            {
                if (sSignDiv != "1")
                {
                    if (dPayAmt > CmUtil.DoubleParse(CmUtil.IsNull(PosMstManager.GetPosOption(POS_OPTION.OPT007), "50000")))
                    {
                        sRet = "0";
                    }
                    else
                    {
                        sRet = "1";
                    }
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        #region 싸인 bitmap 이름 변경
        /// <summary>
        /// 싸인 bitmap 이름 변경
        /// </summary>
        /// <param name="sAppNo"></param>
        private void SetSignImgReName(string sAppNo)
        {
            try
            {
                string sSourcePath = BaseCom.NxDataPath + "SIGN\\SIGN.BMP";
                string sTagetPath = string.Format("{0}{1}{2}{3}{4}{5}.BMP", BaseCom.NxDataPath, "SIGN\\", m_cPosStatus.Base.SaleDate, m_cPosStatus.Base.PosNo, m_cPosStatus.Base.TradeNo, sAppNo);

                CmUtil.FileMove(sSourcePath, sTagetPath);
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }

        #endregion 싸인 bitmap 이름 변경

        #region 취소 거래 싸인 받기
        /// <summary>
        /// 취소거래 싸인 받기
        /// </summary>
        /// <returns></returns>
        private bool GetCancelReSign(double dPayAmt, ref string m_sSign)
        {

            //bool bRet = false;

            m_sSign = "";

            try
            {
                //싸인 받기
                if (m_cPayItem.PAY_AMT > CmUtil.DoubleParse(CmUtil.IsNull(PosMstManager.GetPosOption(POS_OPTION.OPT007), "50000")))
                {


                    if (m_cDevStatus.SignPad.UseYn == true)
                    {
                        string sPath = BaseCom.NxDataPath + "SIGN\\";

                        CmUtil.CreateDirectory(sPath);

                        //if (m_cSignPad.GetSign_SignPad((int)dPayAmt, sPath, "SIGN.BMP", ref m_sSign) == false)
                        if (m_cSignPad.GetSign_SignPadEx(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0557), m_cPosStatus.Global.NumericTOCurrency(dPayAmt) + " " + m_cPosStatus.Global.m_stCultureMaster.strCurrencyName
                            , "", "", sPath, "SIGN.BMP", ref m_sSign) == false)
                        {

                            if (WinManager.QuestionMessage(POS_MESSAGE.ERROR.MSG_0550) == false)
                            {
                                return false;
                            }

                            m_sSign = "";
                        }
                    }
                    else
                    {
                        UserLog.WriteLogFile(UserCom.LOG_DEBUG,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     "Not Use SingPad Skip!");
                    }
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return true;
        }
        #endregion 취소 거래 싸인 받기

        #region 신용카드 전문 바디 생성
        /// <summary>
        /// 신용 카드 바디 생성
        /// </summary>
        /// <param name="sAppType"></param>
        /// <param name="aParam"></param>
        /// <param name="Reserved"></param>
        /// <returns></returns>
        private string MakeCardICBody(string sAppType, string[] aParam, string Reserved)
        {

            string sSendData = string.Empty;
            string[] aIrtBody = null;
            try
            {

                if (sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE || sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_AGREE)
                {
                    aIrtBody = new string[Column.POS_REQ_CREDITCARDIC.LEN.Length];

                    if (m_cDevStatus.ICReader.UseYn == true)     // 여신전문금융업법 적용여부 체크
                         aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.DocVer] = PosConst.POS_VAN_MASTER.IRT_VERSION_02;

                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.EntryMode] = aParam[1];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.TrackII] = aParam[2];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.TrackIIFS] = PosConst.VAN_HEXA.FS;
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.DivMonth] = aParam[3];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.TotAmt] = aParam[4];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.ServiceAmt] = aParam[5];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.ServiceAmtGS] = PosConst.VAN_HEXA.GS;
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.Vat] = aParam[6];

                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.WKI] = "AA";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.PassWord] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.ECSLevel] = "";

                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.ItemCode] = aParam[15];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.CustmerInfo] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.Domain] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.ServerIP] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.MallBizNo] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.Reserved] = Reserved;
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.BizDiv] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.MediaDiv] = aParam[21];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.CorporationDiv] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.CardKind] = aParam[8];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.ETX] = PosConst.VAN_HEXA.ETX;
                    aIrtBody[Column.POS_REQ_CREDITCARDIC.SEQ.CR] = PosConst.VAN_HEXA.CR;

                    // 신용카드 승인 요청 전문 생성
                    sSendData = ItemColumn.MakeMessage(aIrtBody, Column.POS_REQ_CREDITCARDIC.LEN, Column.POS_REQ_CREDITCARDIC.TYPE);
                }
                else if (sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_CANCEL || sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_CANCEL)
                {
                    aIrtBody = new string[Column.POS_REQ_CREDITCARDIC_CANCEL.LEN.Length];

                    if (m_cDevStatus.ICReader.UseYn == true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC)     // 여신전문금융업법 적용여부 체크
                        aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.DocVer] = PosConst.POS_VAN_MASTER.IRT_VERSION_02;

                    //20171013 dkshin 해피기프트(신) IC/RF 충전 및 승인
                    if (m_cDevStatus.ICReader.UseYn == true && aParam[1] == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)     // 여신전문금융업법 적용여부 체크
                        aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.DocVer] = PosConst.POS_VAN_MASTER.IRT_VERSION_02;

                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.EntryMode] = aParam[1];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.TrackII] = aParam[2];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.TrackIIFS] = PosConst.VAN_HEXA.FS;
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.DivMonth] = aParam[3];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.TotAmt] = aParam[4];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.ServiceAmt] = aParam[5];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.ServiceAmtGS] = PosConst.VAN_HEXA.GS;
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.Vat] = aParam[6];

                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.WKI] = "AA";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.PassWord] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.ECSLevel] = "";

                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.OrgAppNo] = aParam[13];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.OrgAppDate] = aParam[14];

                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.ItemCode] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.CustmerInfo] = "";

                    //20171013 dkshin 해피기프트(신) IC/RF 충전 및 승인
                    //aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.Reserved] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.Reserved] = Reserved;

                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.BizDiv] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.MediaDiv] = aParam[21];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.CorporationDiv] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.CardKind] = aParam[8];
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.ETX] = PosConst.VAN_HEXA.ETX;
                    aIrtBody[Column.POS_REQ_CREDITCARDIC_CANCEL.SEQ.CR] = PosConst.VAN_HEXA.CR;

                    // 신용카드 승인 요청 전문 생성
                    sSendData = ItemColumn.MakeMessage(aIrtBody, Column.POS_REQ_CREDITCARDIC_CANCEL.LEN, Column.POS_REQ_CREDITCARDIC_CANCEL.TYPE);
                }

            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);

            }
            finally
            {
                CmUtil.ZeroFillClear(ref aIrtBody);
            }
            return sSendData;

        }
        #endregion
        #region 신용카드 전문 바디 생성
        /// <summary>
        /// 신용 카드 바디 생성
        /// </summary>
        /// <param name="sAppType"></param>
        /// <param name="aParam"></param>
        /// <param name="Reserved"></param>
        /// <returns></returns>
        private string MakeCardMSRBody(string sAppType, string[] aParam, string Reserved)
        {

            string sSendData = string.Empty;
            string[] aIrtBody = null;
            try
            {

                if (sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE || sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_AGREE)
                {
                    aIrtBody = new string[Column.POS_REQ_CREDITCARD_MSR.LEN.Length];

                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.EntryMode] = aParam[1];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.TrackII] = aParam[2];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.TrackIIFS] = PosConst.VAN_HEXA.FS;
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.DivMonth] = aParam[3];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.TotAmt] = aParam[4];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.ServiceAmt] = aParam[5];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.ServiceAmtGS] = PosConst.VAN_HEXA.GS;
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.Vat] = aParam[6];

                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.WKI] = "AA";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.PassWord] = "0000000000000000";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.ECSLevel] = "";

                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.ItemCode] = aParam[15];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.CustmerInfo] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.Domain] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.ServerIP] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.MallBizNo] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.Reserved] = Reserved;

                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.BizDiv] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.MediaDiv] = aParam[21];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.CorporationDiv] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.CardKind] = aParam[8];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.ICChipData] = aParam[9];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.ICChipData_GS] = PosConst.VAN_HEXA.GS;
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.SignData] = aParam[10];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.SignData_GS] = PosConst.VAN_HEXA.GS;
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.ETX] = PosConst.VAN_HEXA.ETX;
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR.SEQ.CR] = PosConst.VAN_HEXA.CR;

                    // 신용카드 승인 요청 전문 생성
                    sSendData = ItemColumn.MakeMessage(aIrtBody, Column.POS_REQ_CREDITCARD_MSR.LEN, Column.POS_REQ_CREDITCARD_MSR.TYPE);
                }
                else if (sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_CANCEL || sAppType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_CANCEL)
                {
                    aIrtBody = new string[Column.POS_REQ_CREDITCARD_MSR_CANCEL.LEN.Length];

                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.EntryMode] = aParam[1];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.TrackII] = aParam[2];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.TrackIIFS] = PosConst.VAN_HEXA.FS;
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.DivMonth] = aParam[3];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.TotAmt] = aParam[4];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.ServiceAmt] = aParam[5];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.ServiceAmtGS] = PosConst.VAN_HEXA.GS;
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.Vat] = aParam[6];

                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.WKI] = "AA";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.PassWord] = "0000000000000000";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.ECSLevel] = "";

                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.OrgAppNo] = aParam[13];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.OrgAppDate] = aParam[14];

                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.ItemCode] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.CustmerInfo] = "";

                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.Reserved] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.BizDiv] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.MediaDiv] = aParam[21];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.CorporationDiv] = "";
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.CardKind] = aParam[8];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.ICChipData] = aParam[9];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.ICChipData_GS] = PosConst.VAN_HEXA.GS;
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.SignData] = aParam[10];
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.SignData_GS] = PosConst.VAN_HEXA.GS;
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.ETX] = PosConst.VAN_HEXA.ETX;
                    aIrtBody[Column.POS_REQ_CREDITCARD_MSR_CANCEL.SEQ.CR] = PosConst.VAN_HEXA.CR;

                    // 신용카드 승인 요청 전문 생성
                    sSendData = ItemColumn.MakeMessage(aIrtBody, Column.POS_REQ_CREDITCARD_MSR_CANCEL.LEN, Column.POS_REQ_CREDITCARD_MSR_CANCEL.TYPE);
                }

            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);

            }
            finally
            {
                CmUtil.ZeroFillClear(ref aIrtBody);
            }
            return sSendData;

        }
        #endregion

        #region 카드 발급사 인증 요청
        /// <summary>
        /// 발급사 인증 요청
        /// </summary>
        /// <param name="sIcChipData"></param>
        /// <returns></returns>
        private bool SetCardCardIssuer(string sIcChipData, string AppGbn)
        {

            string sRecvEmv = string.Empty;
            bool bRet = false;

            try
            {

                int nFs = sIcChipData.IndexOf(PosConst.VAN_HEXA.FS) + 1;
                sIcChipData = CmUtil.MidH(sIcChipData, nFs, sIcChipData.Length).Trim();

                if (AppGbn == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_CANCEL)
                    sIcChipData += PosConst.VAN_HEXA.FS + PosConst.VAN_HEXA.FS + PosConst.VAN_HEXA.FS;

                if (m_cICReader.CardIssuer_ICReader(sIcChipData, ref sRecvEmv) == true)
                {
                    bRet = true;
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return bRet;
        }
        #endregion

        #region 사인데이터 저장
        /// <summary>
        /// 사인데이터 저장
        /// </summary>
        /// <param name="iSeq"></param>
        /// <param name="sSignData"></param>
        private void SetSignData(int iSeq, string sSignData)
        {
            try
            {
                ArrayList aSignItem = (ArrayList)StateObject.GetItemObject(Column.TR_SIGN.ITEM);
                Column.TR_SIGN.DATA cSignItem = new Column.TR_SIGN.DATA();

                cSignItem.SEQ = aSignItem.Count + 1;
                cSignItem.PAY_SEQ = iSeq;
                cSignItem.SIGN_TIME = DateTime.Now.ToString("HHmmss");
                cSignItem.SIGN_DATA = sSignData;

                aSignItem.Add(cSignItem);

            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

        }
        #endregion

        #region RF IC DATA 전문 생성
        /// <summary>
        /// RF IC DATA 전문 생성
        /// </summary>
        /// <param name="sInIcData"></param>
        /// <returns></returns>
        private string SetRfIcData(string sInIcData)
        {

            string sOutIcdata = "";

            try
            {
                if (sInIcData != "")
                {
                    sOutIcdata += CmUtil.MidH(sInIcData, 0, 12).Trim();		//DeviceSeqNum
                    sOutIcdata += CmUtil.MidH(sInIcData, 12, 2).Trim();		//PanSeqNum
                    sOutIcdata += CmUtil.MidH(sInIcData, 14, 16).Trim();	//AddPosInfo
                    sOutIcdata += CmUtil.MidH(sInIcData, 30, 64).Trim();	//Iad
                    sOutIcdata += CmUtil.MidH(sInIcData, 94, 32).Trim();	//DFN
                    sOutIcdata += CmUtil.MidH(sInIcData, 126, 16).Trim();	//ARQC
                    sOutIcdata += CmUtil.MidH(sInIcData, 142, 2).Trim();	//CID
                    sOutIcdata += CmUtil.MidH(sInIcData, 144, 8).Trim();	//UTN
                    sOutIcdata += CmUtil.MidH(sInIcData, 152, 4).Trim();	//ATC
                    sOutIcdata += CmUtil.MidH(sInIcData, 156, 10).Trim();	//TVR
                    sOutIcdata += CmUtil.MidH(sInIcData, 166, 6).Trim();	//TTD
                    sOutIcdata += CmUtil.MidH(sInIcData, 172, 2).Trim();	//TST
                    sOutIcdata += CmUtil.MidH(sInIcData, 174, 4).Trim();	//AIP
                    sOutIcdata += CmUtil.MidH(sInIcData, 178, 6).Trim();	//CVMR
                    sOutIcdata += CmUtil.MidH(sInIcData, 184, 6).Trim();	//TC
                    sOutIcdata += CmUtil.MidH(sInIcData, 190, 2).Trim();	//TT
                    sOutIcdata += CmUtil.MidH(sInIcData, 192, 8).Trim();	//IFDSN
                    sOutIcdata += CmUtil.MidH(sInIcData, 200, 2).Trim();	//TSCC
                    sOutIcdata += CmUtil.MidH(sInIcData, 202, 4).Trim();	//AVN
                    sOutIcdata += CmUtil.MidH(sInIcData, 206, 4).Trim();	//TSC
                    sOutIcdata += CmUtil.MidH(sInIcData, 210, 4).Trim();	//PEM
                }

            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sOutIcdata;
        }
        #endregion

         #region 결제 수기 등록(임의등록)
        /// <summary>
        /// 결제 수기 등록(임의등록)
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string SetMenualPayment(string[] aParam)
        {
            return UserCom.RST_ERR;
          
        }
        #endregion 결제 수기 등록(임의등록)
    }
}
