spc-kiosk-pb/Agent/OLEDevice/OCBDirect.cs

624 lines
40 KiB
C#
Raw Normal View History

2019-06-16 05:12:09 +00:00
using Cosmos.Common;
using Cosmos.CommonManager;
using Cosmos.ServiceProvider;
using Cosmos.UserFrame;
using System;
using System.Runtime.InteropServices;
using System.Text;
/*-----------------------------------------------------------------------------------------------*/
// 설 명 : OCB 직통신
// 작 성 자 :
// 변경 이력 :
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.OLEDevice
{
/// <summary>
/// OCB 직통신
/// </summary>
public class OCBDirect : IOCBDirect
{
#region MPS.DLL
/// <summary>
/// 가맹점등록
/// </summary>
[DllImport("MPS.dll")]
public static extern int RegisterMcht(string A, string B, string C, string D, string E, string F, string G, string H, string I, string J, byte[] K);
/// <summary>
/// 가맹점등록
/// </summary>
[DllImport("MPS.dll")]
public static extern int AuthMcht(string A, string B, string C, string D, string E, string F, string G, string H, string I, string J, byte[] K);
/// <summary>
/// 포인트조회
/// </summary>
[DllImport("MPS.dll")]
public static extern int InquiryPoint(string A, string B, string C, string D, string E, string F, string G, string H, string I, string J, string K, string L, byte[] M);
/// <summary>
/// 포인트적립
/// </summary>
[DllImport("MPS.dll")]
public static extern int SavePoint(string A, string B, string C, string D, string E, string F, string G, string H,
string I, string J, string K, string L, string M, string N, string O, string P,
string Q, string R, string S, string T, string U, string V, string W, string X,
string Y, int Z, byte[] AA, int BB, byte[] CC, byte[] DD);
/// <summary>
/// 포인트적립취소
/// </summary>
[DllImport("MPS.dll")]
public static extern int CancelSavePoint(string A, string B, string C, string D, string E, string F, string G, string H,
string I, string J, string K, string L, string M, string N, string O, string P,
string Q, string R, string S, string T, string U, string V, byte[] W);
/// <summary>
/// 포인트사용
/// </summary>
[DllImport("MPS.dll")]
public static extern int UsePoint ( string A, string B, string C, string D, string E, string F, string G, string H,
string I, string J, string K, string L, string M, string N, string O, string P,
string Q, string R, string S, string T, byte[] U );
/// <summary>
/// 포인트사용취소
/// </summary>
[DllImport("MPS.dll")]
public static extern int CancelUsePoint(string A, string B, string C, string D, string E, string F, string G, string H,
string I, string J, string K, string L, string M, string N, string O, string P,
string Q, string R, string S, byte[] T);
/// <summary>
/// 포인트할인
/// </summary>
[DllImport("MPS.dll")]
public static extern int DiscountService(string A, string B, string C, string D, string E, string F, string G, string H, string I,
string J, string K, string L, string M, string N, string O, string P, string Q, string R,
string S, string T, byte[] U);
/// <summary>
/// 포인트할인취소
/// </summary>
[DllImport("MPS.dll")]
public static extern int CancelDiscountService ( string A, string B, string C, string D, string E, string F, string G, string H, string I,
string J, string K, string L, string M, string N, string O, string P, string Q, string R,
string S, byte[] T );
/// <summary>
/// 망취소
/// </summary>
[DllImport("MPS.dll")]
public static extern int ForcedCancelUsePoint(string A, string B, string C, string D, string E, string F, string G, string H,
string I, string J, string K, string L, string M, string N, string O, string P,
string Q, string R, string S, byte[] T);
private IDataCommonUs m_cDataCommon = null;
protected SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출
#endregion
#region
/// <summary>
/// StateServer Object (StateServer 객체)
/// </summary>
public StateServer StateObject = (StateServer)StateServer.GetInstance();
/// <summary>
/// Pos 상태 정보 객체
/// </summary>
public PosStatus m_cPosStatus = null;
/// <summary>
/// 생성자
/// </summary>
public OCBDirect()
{
try
{
m_cPosStatus = (PosStatus)StateObject.POS;
m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_IOS,
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 (함수명))
ex.Message);
}
}
#endregion
#region OCB
/// <summary>
/// OCB 직통신
/// </summary>
/// <param name="sTradeDiv"></param>
/// <param name="sPayWayCD"></param>
/// <param name="sPayWayDtlCD"></param>
/// <param name="sTranType"></param>
/// <param name="sCardNo"></param>
/// <param name="sCardPwd"></param>
/// <param name="sPayAmt"></param>
/// <param name="sApprDt"></param>
/// <param name="sApprNo"></param>
/// <param name="sUniqueID"></param>
/// <param name="sResMsg"></param>
/// <param name="aIrtRspDTL"></param>
/// <returns></returns>
public string OCB_Direct_Point(string sTradeDiv, string sPayWayCD, string sPayWayDtlCD, string sTranType, string sCardNo, string sCardPwd, string sPayAmt, string sApprDt, string sApprNo, string sUniqueID, ref string sResMsg, ref string[] aIrtRspDTL)
{
int nRet = -1;
string sRet = UserCom.RST_ERR;
byte[] bRecvData = new byte[4096];
int nNowPos = 0;
string sResCD = "0";
string sApprTm = "";
try
{
#region 0.
// 응답메시지
sResMsg = "";
// VAN 정보 조회
//string sCMPApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.OKCASHBACK_POINT, PosMst.MST_VAN.DATA.CMP_APPR_ID);
//string sApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.OKCASHBACK_POINT, PosMst.MST_VAN.DATA.APPR_ID);
//string sApprPWD = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.OKCASHBACK_POINT, PosMst.MST_VAN.DATA.APPR_PWD);
string sCMPApprID = PosMstManager.GetMstVan(PosMstManager.GetPosOption(POS_OPTION.OPT326), PosMst.MST_VAN.DATA.CMP_APPR_ID);
string sApprID = PosMstManager.GetMstVan(PosMstManager.GetPosOption(POS_OPTION.OPT326), PosMst.MST_VAN.DATA.APPR_ID);
string sApprPWD = PosMstManager.GetMstVan(PosMstManager.GetPosOption(POS_OPTION.OPT326), PosMst.MST_VAN.DATA.APPR_PWD);
// 입력구분
string sInputType = "2";
if (sCardNo.IndexOf("=") > 0) sInputType = "0";
// 추적번호 = POS번호(2) + 일자(DD) + 시간(SSFFF)
if (sTranType != PosConst.POS_OCB_DIRECT.NET_CAN_POINT)
sUniqueID = m_cPosStatus.Base.PosNo.PadLeft(2, '0') + DateTime.Now.ToString("dd") + string.Format("{0:00000}", DateTime.Now.ToString("ssfff")) + "0";
#endregion
// 요청 - 승인로그 저장 (판매구분, [0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문)
string sSendData = sTranType + CmUtil.MidH(sCMPApprID, 0, 4) + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss") + CmUtil.MidH(sUniqueID, 0, 10) + "A" + "A1" + CmUtil.MidH(sApprID, 0, 15) + CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10) + CmUtil.MidH(sApprPWD, 0, 16) + CmUtil.MidH(sCardNo, 0, 16) + CmUtil.MidH(sCardPwd, 0, 16) + CmUtil.MidH(sPayAmt, 0, 16) + CmUtil.MidH(sApprDt, 0, 8) + CmUtil.MidH(sApprNo, 0, 16) + CmUtil.MidH(sUniqueID, 0, 10);
// 승인데이터 중 카드번호 마스킹 처리(2017.05.25)
string sWriteSendData = CmUtil.MakeLogDataToMask(false, sCardNo, sSendData);
UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
"[SEND:" + sWriteSendData);
m_cDataCommon.SetSaleApprLog(sTradeDiv, new string[] { sPayWayCD, sPayWayDtlCD, sTranType, "S", sCardNo, sPayAmt, "", "", "", "", "", sWriteSendData });
#region 1.
// 1.요청전문
switch (sTranType)
{
case PosConst.POS_OCB_DIRECT.STOR_REGISTER:
{
#region
/*
A CHAR 4 2A10
B CHAR 4
C CHAR 8 :20030924(YYYYMMDD)
D CHAR 6 :130201(HHMMSS)
E CHAR 10 Sequence number( Unique)
F CHAR 1 ID 'A' : OKCashbag
G CHAR 2 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' :
H CHAR 15 (8)+SPACE 7
I CHAR 10 :1111111111
J CHAR 16 :1111
*/
nRet = RegisterMcht(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1"
, CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10), CmUtil.MidH(sApprPWD, 0, 16), bRecvData);
break;
#endregion
}
case PosConst.POS_OCB_DIRECT.STOR_AUTH:
{
#region
/*
A CHAR 4 2A20
B CHAR 4
C CHAR 8 :20030924(YYYYMMDD)
D CHAR 6 :130201(HHMMSS)
E CHAR 10 Sequence number( Unique)
F CHAR 1 ID 'A' : OKCashbag
G CHAR 2 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' :
H CHAR 15 (8)+SPACE 7
I CHAR 10 :1111111111
J CHAR 16 :1111
*/
nRet = AuthMcht(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1"
, CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10), CmUtil.MidH(sApprPWD, 0, 16), bRecvData);
break;
#endregion
}
case PosConst.POS_OCB_DIRECT.INQ_POINT:
{
#region
/*
A CHAR 4 2M30
B CHAR 4
C CHAR 8 :20030924(YYYYMMDD)
D CHAR 6 :130201(HHMMSS)
E CHAR 10 Sequence number( Unique)
F CHAR 1 ID 'A' : OKCashbag
G CHAR 2 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' :
H CHAR 15 (8)+SPACE 7
I CHAR 10 :1111111111
J CHAR 19 :1234123412341234 ('-')
K CHAR 19 :1234123412341234 ('-')
L CHAR 2 : 'R1' , :'R2'
*/
nRet = InquiryPoint(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1"
, CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), "R1", bRecvData);
break;
#endregion
}
case PosConst.POS_OCB_DIRECT.SAVE_POINT:
{
#region
/*
A CHAR 4 2100
B CHAR 4
C CHAR 8 :20030924(YYYYMMDD)
D CHAR 6 :130201(HHMMSS)
E CHAR 10 Sequence number( Unique)
F CHAR 1 ID 'A' : OKCashbag
G CHAR 2 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' :
H CHAR 15 (8)+SPACE 7
I CHAR 10 :1111111111
J CHAR 8 :20030924(YYYYMMDD)
K CHAR 6 :130201(HHMMSS)
L CHAR 1 KEY-IN '0':Swapping, '2':Key-in, 'F': mart only
M CHAR 19 :1234123412341234 ('-')
N CHAR 19 :1234123412341234 ('-')
O CHAR 2 '01' :
P CHAR 2 '11' : , '12' : , '21' : , '22' :
Q CHAR 2 :01, :02
R CHAR 10 :10000
S CHAR 9 :12000 ((T) + (U) + (V) )
T CHAR 9 :10000( )
U CHAR 9 :1000( )
V CHAR 9 :1000( )
W CHAR 1 (0:), (1)
X CHAR 1 +(0), Only(1)
Y CHAR 30 :123456789( Space처리)
Z INT 4 :2 (50 ) ( 0(Zero))
AA STRUCT (18) :8823456789123 ()( )
( CHAR형) (5) :2 ( Space로처리)( )
(6) :123456 ( )
(1)
BB INT 4 :2 (50 ) ( 0(Zero))
CC STRUCT (18) :8823456789123 ()( )
( CHAR형) (6) :2 ( Space로처리) ( )
(6) :123456 ( )
(9) :10000 ( Space로처리)( )
(6) :F10000 ( )
(CHAR *) Type Casting해서 .
*/
nRet = SavePoint(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1", CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10)
, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss")
, CmUtil.MidH(sInputType, 0, 1), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), "01", "11", "01"
, CmUtil.MidH(sPayAmt, 0, 10), CmUtil.MidH("", 0, 9), CmUtil.MidH("", 0, 9), CmUtil.MidH("", 0, 9), CmUtil.MidH("", 0, 9)
, CmUtil.MidH("0", 0, 1), "1", CmUtil.MidH("", 0, 30), 0, null, 0, null, bRecvData);
break;
#endregion
}
case PosConst.POS_OCB_DIRECT.SAVE_CAN_POINT:
{
#region
/*
A CHAR 4 2110
B CHAR 4
C CHAR 8 :20030924(YYYYMMDD)
D CHAR 6 :130201(HHMMSS)
E CHAR 10 Sequence number( Unique)
F CHAR 1 ID 'A' : OKCashbag
G CHAR 2 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' :
H CHAR 15 (8)+SPACE 7
I CHAR 10 :1111111111
J CHAR 8 :20030924(YYYYMMDD)
K CHAR 6 :130201(HHMMSS)
L CHAR 1 KEY-IN 0':Swapping, '2':Key-in
M CHAR 19 :1234123412341234 ('-')
N CHAR 19 :1234123412341234 ('-')
O CHAR 8 :20030924(YYYYMMDD)
P CHAR 9 :123456789( Space로처리)
Q CHAR 2 '21' :
R CHAR 2 '41' :
S CHAR 10 :10000( Space로처리)
T CHAR 1 +(0), Only(1)
U CHAR 30 :123456789( Space처리)
V CHAR 1 '1' : /, '2' : , '3' : ( )
*/
nRet = CancelSavePoint(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1", CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10)
, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss")
, CmUtil.MidH(sInputType, 0, 1), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), CmUtil.MidH(sApprDt, 0, 8), CmUtil.MidH(sApprNo, 0, 9), "21", "41"
, CmUtil.MidH(sPayAmt, 0, 10), "1", CmUtil.MidH("", 0, 30), "1", bRecvData);
break;
#endregion
}
case PosConst.POS_OCB_DIRECT.USE_POINT:
{
#region
/*
A CHAR 4 2400
B CHAR 4
C CHAR 8 :20030924(YYYYMMDD)
D CHAR 6 :130201(HHMMSS)
E CHAR 10 Sequence number( Unique)
F CHAR 1 ID 'A' : OKCashbag
G CHAR 2 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' :
H CHAR 15 (8)+SPACE 7
I CHAR 10 :1111111111
J CHAR 8 :20030924(YYYYMMDD)
K CHAR 6 :130201(HHMMSS)
L CHAR 1 KEY-IN 0':Swapping, '2':Key-in
M CHAR 19 :1234123412341234 ('-')
N CHAR 19 :1234123412341234 ('-')
O CHAR 16 :1111
P CHAR 2 '11' :
Q CHAR 2 '40' :
R CHAR 2 '08' :
S CHAR 10 :10000
T CHAR 10 :10000
*/
nRet = UsePoint(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1", CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10)
, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss")
, CmUtil.MidH(sInputType, 0, 1), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), CmUtil.MidH(sCardPwd, 0, 16), "11", "40", "08"
, CmUtil.MidH(sPayAmt, 0, 10), CmUtil.MidH("", 0, 10), bRecvData);
break;
#endregion
}
case PosConst.POS_OCB_DIRECT.USE_CAN_POINT:
{
#region
/*
A CHAR 4 2410
B CHAR 4
C CHAR 8 :20030924(YYYYMMDD)
D CHAR 6 :130201(HHMMSS)
E CHAR 10 Sequence number( Unique)
F CHAR 1 ID 'A' : OKCashbag
G CHAR 2 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' :
H CHAR 15 (8)+SPACE 7
I CHAR 10 :1111111111
J CHAR 8 :20030924(YYYYMMDD)
K CHAR 6 :130201(HHMMSS)
L CHAR 1 KEY-IN 0':Swapping, '2':Key-in
M CHAR 19 :1234123412341234 ('-')
N CHAR 19 :1234123412341234 ('-')
O CHAR 8 :20030924(YYYYMMDD)
P CHAR 9 :123456789( Space로처리)
Q CHAR 2 '22' :
R CHAR 2 '42' :
S CHAR 10 :10000( Space로처리)
*/
nRet = CancelUsePoint(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1", CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10)
, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss")
, CmUtil.MidH(sInputType, 0, 1), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), CmUtil.MidH(sApprDt, 0, 8), CmUtil.MidH(sApprNo, 0, 9), "22", "42"
, CmUtil.MidH(sPayAmt, 0, 10), bRecvData);
break;
#endregion
}
case PosConst.POS_OCB_DIRECT.NET_CAN_POINT:
{
#region
/*
A CHAR 4 2410
B CHAR 4
C CHAR 8 :20030924(YYYYMMDD)
D CHAR 6 :130201(HHMMSS)
E CHAR 10
F CHAR 1 ID 'A' : OKCashbag
G CHAR 2 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' :
H CHAR 15 (8)+SPACE 7
I CHAR 10 :1111111111
J CHAR 8 :20030924(YYYYMMDD)
K CHAR 6 :130201(HHMMSS)
L CHAR 1 KEY-IN 0':Swapping, '2':Key-in
M CHAR 19 :1234123412341234 ('-')
N CHAR 19 :1234123412341234 ('-')
O CHAR 8 :20030924(YYYYMMDD)
P CHAR 9 :123456789( Space로처리)
Q CHAR 2 '21' : '22' :
R CHAR 2 '41' : '42' :
S CHAR 10 :10000( Space로처리)
*/
nRet = ForcedCancelUsePoint(PosConst.POS_OCB_DIRECT.NET_CAN_POINT, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1", CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10)
, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss")
, CmUtil.MidH(sInputType, 0, 1), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), CmUtil.MidH(sApprDt, 0, 8), CmUtil.MidH(sApprNo, 0, 9), (sTranType == PosConst.POS_OCB_DIRECT.SAVE_CAN_POINT ? "21" : "22"), (sTranType == PosConst.POS_OCB_DIRECT.SAVE_CAN_POINT ? "41" : "42")
, CmUtil.MidH(sPayAmt, 0, 10), bRecvData);
break;
#endregion
}
}
#endregion
#region 2.
// 2.처리결과
if (nRet != 1)
{
sResMsg = ErrCodeToMsg(nRet); // 오류
sResCD = "1";
}
#endregion
#region 3.()
else
{
// 정상응답
switch (sTranType)
{
case PosConst.POS_OCB_DIRECT.STOR_REGISTER: // 가맹점 등록
case PosConst.POS_OCB_DIRECT.STOR_AUTH: // 가맹점 인증
{
nNowPos = 0;
aIrtRspDTL = new string[Column.POS_REQ_OCB_AUTHMCHT.LEN.Length];
ItemColumn.ParseMessage(Column.POS_REQ_OCB_AUTHMCHT.LEN, Column.POS_REQ_OCB_AUTHMCHT.TYPE, bRecvData, ref nNowPos, ref aIrtRspDTL);
if (aIrtRspDTL[Column.POS_REQ_OCB_AUTHMCHT.SEQ.RES_CD].Trim() != "1")
{
// 응답오류
sResMsg = aIrtRspDTL[Column.POS_REQ_OCB_AUTHMCHT.SEQ.RES_MSG].Trim();
sResCD = "1";
}
else
{
// 정상
sResMsg = "OK";
sResCD = "0";
sRet = UserCom.RST_OK;
}
break;
}
case PosConst.POS_OCB_DIRECT.INQ_POINT: // 포인트 조회
{
nNowPos = 0;
aIrtRspDTL = new string[Column.POS_REQ_OCB_INQPOINT.LEN.Length];
ItemColumn.ParseMessage(Column.POS_REQ_OCB_INQPOINT.LEN, Column.POS_REQ_OCB_INQPOINT.TYPE, bRecvData, ref nNowPos, ref aIrtRspDTL);
if (aIrtRspDTL[Column.POS_REQ_OCB_INQPOINT.SEQ.RES_CD].Trim() != "1")
{
// 응답오류
sResMsg = aIrtRspDTL[Column.POS_REQ_OCB_INQPOINT.SEQ.RES_MSG1].Trim();
sResCD = "1";
}
else
{
// 정상
sResMsg = "OK";
sResCD = "0";
sRet = UserCom.RST_OK;
}
break;
}
case PosConst.POS_OCB_DIRECT.SAVE_POINT: // 포인트 적립
case PosConst.POS_OCB_DIRECT.USE_POINT: // 포인트 사용
{
nNowPos = 0;
aIrtRspDTL = new string[Column.POS_REQ_OCB_POINT.LEN.Length];
ItemColumn.ParseMessage(Column.POS_REQ_OCB_POINT.LEN, Column.POS_REQ_OCB_POINT.TYPE, bRecvData, ref nNowPos, ref aIrtRspDTL);
if (aIrtRspDTL[Column.POS_REQ_OCB_POINT.SEQ.RES_CD].Trim() != "1")
{
// 응답오류
sResMsg = aIrtRspDTL[Column.POS_REQ_OCB_POINT.SEQ.RES_MSG1].Trim();
sResCD = "1";
}
else
{
// 정상
sResMsg = "OK";
sResCD = "0";
sApprDt = aIrtRspDTL[Column.POS_REQ_OCB_POINT.SEQ.APPR_DATE].Trim();
sApprTm = aIrtRspDTL[Column.POS_REQ_OCB_POINT.SEQ.APPR_TIME].Trim();
sApprNo = aIrtRspDTL[Column.POS_REQ_OCB_POINT.SEQ.APPR_NO].Trim();
sRet = UserCom.RST_OK;
}
break;
}
case PosConst.POS_OCB_DIRECT.SAVE_CAN_POINT: // 포인트 적립 취소
case PosConst.POS_OCB_DIRECT.USE_CAN_POINT: // 포인트 사용 취소
case PosConst.POS_OCB_DIRECT.NET_CAN_POINT: // 포인트 망 취소
{
nNowPos = 0;
aIrtRspDTL = new string[Column.POS_REQ_OCB_CANPOINT.LEN.Length];
ItemColumn.ParseMessage(Column.POS_REQ_OCB_CANPOINT.LEN, Column.POS_REQ_OCB_CANPOINT.TYPE, bRecvData, ref nNowPos, ref aIrtRspDTL);
if (aIrtRspDTL[Column.POS_REQ_OCB_CANPOINT.SEQ.RES_CD].Trim() != "1")
{
// 응답오류
sResMsg = aIrtRspDTL[Column.POS_REQ_OCB_CANPOINT.SEQ.RES_MSG1].Trim();
sResCD = "1";
}
else
{
// 정상
sResMsg = "OK";
sResCD = "0";
sApprDt = aIrtRspDTL[Column.POS_REQ_OCB_CANPOINT.SEQ.APPR_DATE].Trim();
sApprTm = aIrtRspDTL[Column.POS_REQ_OCB_CANPOINT.SEQ.APPR_TIME].Trim();
sApprNo = aIrtRspDTL[Column.POS_REQ_OCB_CANPOINT.SEQ.APPR_NO].Trim();
sRet = UserCom.RST_OK;
}
break;
}
}
}
// 응답 - 승인로그 저장 (판매구분, [0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문)
string sRecvData = ByteToString(bRecvData);
// 승인데이터 중 카드번호 마스킹 처리(2017.05.25)
string sWriteRecvData = CmUtil.MakeLogDataToMask(false, sCardNo, sRecvData.Trim());
UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
"[RECV:" + sWriteRecvData);
m_cDataCommon.SetSaleApprLog(sTradeDiv, new string[] { sPayWayCD, sPayWayDtlCD, sTranType, "R"
, sCardNo, sPayAmt
, sApprNo, (sApprDt == "" ? DateTime.Now.ToString("yyyyMMdd") : sApprDt), (sApprTm == "" ? DateTime.Now.ToString("HHmmss") : sApprTm)
, sResCD
, sResMsg
, sWriteRecvData });
#endregion
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_IOS,
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 (함수명))
ex.Message);
sResMsg = ex.Message;
}
return sRet;
}
#endregion
#region
/// <summary>
/// 응답코드
/// </summary>
/// <param name="nErrCode"></param>
/// <returns></returns>
private string ErrCodeToMsg(int nErrCode)
{
string sMsg = string.Empty;
try
{
switch (nErrCode)
{
case -1 : sMsg = "실패 - 함수Parameter값 이상"; break;
case 2 : sMsg = "암호화 실패 - 암호화, 복호화오류"; break;
case 3 : sMsg = "소켓 초기화 실패 - 네트워크 단절에 의한 소켓 초기화 실패"; break;
case 4 : sMsg = "소켓 Send 실패"; break;
case 5 : sMsg = "소켓 Receive 실패"; break;
case 6 : sMsg = "소켓 타임아웃"; break;
case 7 : sMsg = "인터넷 연결 실패"; break;
default: sMsg = "알 수 없는 에러"; break;
}
}
catch { }
return sMsg;
}
#endregion
#region Byte
/// <summary>
/// Byte배열을 string으로 변환 (Byte배열의 null(0x00)값 제거)
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
private string ByteToString(byte[] data)
{
int inx = Array.FindIndex(data, 0, (x) => x == 0x0);
if (inx >= 0)
{
return Encoding.Default.GetString(data, 0, inx);
}
else
{
return Encoding.Default.GetString(data);
}
}
#endregion
}
}