using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Data;
using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
namespace Cosmos.Service
{
///
/// TPay Service
///
class TPay : PaymentBase, IPaymentUs
{
///
/// T페이 동글
///
private ITPaygleUs m_cDeviceTPaygle = null;
///
/// T페이 통합결제 일때 SKT 할인 ITEM
///
private Column.TR_PAYMENT.DATA m_cSktItem = null;
///
/// T페이 카드 기본 프리픽스
///
private readonly string[] TPAY_CARD_PREFIX = new string[] { "292", "294", "297" };
///
/// T페이 카드 프리픽스 구분자 ("T")
///
private const string TPAY_CARD_DIV = "T";
///
/// 생성자
///
public TPay()
{
m_cDeviceTPaygle = (ITPaygleUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_TPAYGLE);
}
///
/// 결제조회
///
///
/// 0:조회구분 (PosConst.TPAY_SEARCH_TYPE)
///
///
///
public string SearchPayment(string[] aParam, ref string[] aRet)
{
string ret = UserCom.RST_ERR;
try
{
switch (aParam[0])
{
#region ### T페이 카드프리픽스 조회
case PosConst.TPAY_SEARCH_TYPE.PREFIX:
{
// 0:조회구분
// 1:카드프리픽스 (T페이)
string cardBin = aParam[1].Substring(0, 6);
// 카드 프리픽스 마스터 조회
IMasterUs cMater = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.PAY_DC_MASTER);
DataTable dtData = cMater.Select(new string[] { PosMst.MST_CARD_PREFIX.TABLE_NAME, cardBin, TPAY_CARD_DIV });
if (dtData != null && dtData.Rows.Count > 0)
{
aRet[0] = CmUtil.GetDataRowStr(dtData.Rows[0], PosMst.MST_CARD_PREFIX.DATA.CARD_DIV);
aRet[1] = CmUtil.GetDataRowStr(dtData.Rows[0], PosMst.MST_CARD_PREFIX.DATA.PRFX_NM);
return UserCom.RST_OK;
}
else if (TPAY_CARD_PREFIX.Contains(cardBin.Substring(0,3)))
{
aRet[0] = TPAY_CARD_DIV;
aRet[1] = "T-PAY";
ret = UserCom.RST_OK;
}
else
{
ret = UserCom.RST_IGNORE + MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0546);
}
}
break;
#endregion
#region ### 통합결제 SKT할인 ITEM 조회/설정
case PosConst.TPAY_SEARCH_TYPE.SKTDC_ITEM:
{
// 0:조회구분
// 1:T페이 거래일련번호
string payWayCd = GetMenuKeyToPayWayCd(PosKey.MENU_KEY.SKT);
string payDtlCd = GetMenuKeyToPayDtlCd(PosKey.MENU_KEY.SKT);
string tradeSeqNo = aParam[1].Trim();
int selectRow = -1;
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
for (var i = 0; i < alPayItem.Count; i++)
{
Column.TR_PAYMENT.DATA cPayItem = (Column.TR_PAYMENT.DATA)alPayItem[i];
if (cPayItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;
if (cPayItem.PAY_WAY_CD != payWayCd) continue;
if (cPayItem.PAY_DTL_CD_01 != payDtlCd) continue;
if (cPayItem.OCCUR_ENTRY_15.Trim() != tradeSeqNo) continue;
selectRow = i;
break;
}
aRet[0] = selectRow.ToString();
ret = selectRow >= 0 ? UserCom.RST_OK : UserCom.RST_ERR;
}
break;
#endregion
#region ### 통합결제 T페이 결제 아이템
case PosConst.TPAY_SEARCH_TYPE.TPAY_ITEM:
{
// 0:조회구분
// 1:T페이 거래일련번호
string payWayCd = GetMenuKeyToPayWayCd(PosKey.MENU_KEY.T_PAY);
string payDtlCd = GetMenuKeyToPayDtlCd(PosKey.MENU_KEY.T_PAY);
string tradeSeqNo = aParam[1].Trim();
int selectRow = -1;
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
for (var i = 0; i < alPayItem.Count; i++)
{
Column.TR_PAYMENT.DATA cPayItem = (Column.TR_PAYMENT.DATA)alPayItem[i];
if (cPayItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;
if (cPayItem.PAY_WAY_CD != payWayCd) continue;
if (cPayItem.PAY_DTL_CD_01 != payDtlCd) continue;
if (cPayItem.OCCUR_ENTRY_15.Trim() != tradeSeqNo) continue;
selectRow = i;
break;
}
aRet[0] = selectRow.ToString();
ret = selectRow >= 0 ? UserCom.RST_OK : UserCom.RST_ERR;
}
break;
#endregion
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 (함수명))
"Exception." + ex.Message);
ret = UserCom.RST_ERR + ex.Message;
}
return ret;
}
///
/// 결제 정보 획득
///
///
/// 0:결제세부코드 (ItemConst.TR_ITEM_ID)
///
///
public object GetPayment(string[] aParam)
{
object retValue = null;
try
{
if (aParam[0] == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_SKT)
{
retValue = base.m_cPayItem;
}
else if (aParam[0] == ItemConst.TR_ITEM_ID.PAY.T_PAY)
{
retValue = this.m_cSktItem;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 (함수명))
"Exception." + ex.Message);
}
return retValue;
}
///
/// 결제등록
///
///
/// 0:메뉴키 (PosKey.MENU_KEY.T_PAY)
/// 1:T페이 결제구분 (PosConst.TPAY_TRADE_TYPE, 0:통합결제, 1:일반결제)
/// 2:입력구분 (PosConst.POS_VAN_MASTER.INPUT_TYPE)
/// 3:입력모드 (PosConst.POS_VAN_MASTER.TPAY_ENTRY_MODE)
/// 4:카드데이터
/// 5:암호화카드번호
/// 6:암호화비밀번호
/// 7:할인대상금액
/// 8:T페이결제금액
///
///
public string SetPayment(string[] aParam)
{
string posMenuKey = string.Empty; // 0:메뉴키
string tpayTradeType = string.Empty; // 1:T페이 결제구분 (PosConst.TPAY_TRADE_TYPE, 0:통합결제, 1:일반결제)
string inputType = string.Empty; // 2:입력구분 (PosConst.POS_VAN_MASTER.INPUT_TYPE)
string entryMode = string.Empty; // 3:입력모드 (PosConst.POS_VAN_MASTER.TPAY_ENTRY_MODE)
string inputData = string.Empty; // 4:카드데이터
string encData = string.Empty; // 5:암호화카드번호
string encPass = string.Empty; // 6:암호화비밀번호
double destAmt = 0; // 7:할인대상금액
double payAmt = 0; // 8:T페이결제금액
try
{
string ret = UserCom.RST_ERR;
posMenuKey = aParam[0].Trim();
tpayTradeType = aParam[1].Trim();
inputType = aParam[2].Trim();
entryMode = aParam[3].Trim();
inputData = aParam[4].Trim();
encData = aParam[5].Trim();
encPass = aParam[6].Trim();
destAmt = CmUtil.DoubleParse(aParam[7]);
payAmt = CmUtil.DoubleParse(aParam[8]);
string productCode = "1001";
string pointType = base.GetMenuKeyToPointType(posMenuKey);
// 통신사(SKT)할인 ITEM
this.m_cSktItem = null;
// T페이 결제 ITEM
base.m_cPayItem = new Column.TR_PAYMENT.DATA();
base.m_cPayItem.PAY_WAY_CD = GetMenuKeyToPayWayCd(posMenuKey);
base.m_cPayItem.PAY_DTL_CD_01 = GetMenuKeyToPayDtlCd(posMenuKey);
// T페이 결제 승인
ret = this.ExecuteIrt(PosConst.CANCEL_DIV.NORMAL, PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_DIS_A
, tpayTradeType, pointType, inputType, entryMode, inputData, encData, encPass, destAmt, payAmt, productCode);
if (ret != UserCom.RST_OK) return ret;
// 결제 아이템 추가
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
// SKT할인 아이템 추가
if (tpayTradeType == PosConst.TPAY_TRADE_TYPE.COMPLEX && this.m_cSktItem != null)
{
this.m_cSktItem.SEQ = alPayItem.Count + 1;
alPayItem.Add(this.m_cSktItem);
if (this.m_cSktItem.PAY_DTL_CD_05 == PosConst.PAY_DC_TYPE.DC)
{
// 상품아이템에 할인금액 설정
SetPluDiscountAmount(-1, m_cSktItem.PAY_WAY_CD + m_cSktItem.PAY_DTL_CD_01, "", m_cSktItem.PAY_AMT);
}
}
// T페이 아이템 추가
base.m_cPayItem.SEQ = alPayItem.Count + 1;
alPayItem.Add(base.m_cPayItem);
base.m_cDataService.UpdatePluAmount(); // 상품 합계금액 계산(거래해더)
base.m_cDataService.UpdatePayAmount(); // 결제 금액 재 계산 처리
return UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 (함수명))
"Exception." + ex.Message);
return UserCom.RST_ERR + ex.Message;
}
finally
{
CmUtil.ZeroFillClear(ref aParam);
CmUtil.ZeroFillClear(ref inputData);
}
}
///
/// 결제취소
///
///
/// 0:취소행번호
///
///
public string CancelPayment(string[] aParam)
{
string inputType = string.Empty; // 입력구분 (PosConst.POS_VAN_MASTER.INPUT_TYPE)
string entryMode = string.Empty; // 입력모드 (PosConst.POS_VAN_MASTER.TPAY_ENTRY_MODE)
string inputData = string.Empty; // 카드데이터
string encData = string.Empty; // 암호화카드번호
string encPass = string.Empty; // 암호화비밀번호
try
{
string ret = UserCom.RST_ERR;
if (m_cTrnStatus.Head.TradeDiv != ItemConst.TRAN_DIV.NORMAL) return UserCom.RST_ERR;
// 결제목록
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
// 결제내역 (T페이)
int payRow = CmUtil.IntParse(aParam[0]);
base.m_cPayItem = (Column.TR_PAYMENT.DATA)alPayItem[payRow];
// 결제내역 (SKT할인)
this.m_cSktItem = null;
string[] aRet = new string[5];
ret = this.SearchPayment(new string[] { PosConst.TPAY_SEARCH_TYPE.SKTDC_ITEM, base.m_cPayItem.OCCUR_ENTRY_15 }, ref aRet);
if (ret == UserCom.RST_OK)
{
int sktRow = CmUtil.IntParse(aRet[0]);
if (sktRow >= 0 && sktRow < alPayItem.Count)
{
this.m_cSktItem = (Column.TR_PAYMENT.DATA)alPayItem[sktRow];
this.m_cSktItem.OCCUR_ENTRY_05 = m_cPayItem.OCCUR_ENTRY_05;
}
}
string tpayTradeType = this.m_cSktItem != null ? PosConst.TPAY_TRADE_TYPE.COMPLEX
: PosConst.TPAY_TRADE_TYPE.NORMAL; // T페이 결제구분 (PosConst.TPAY_TRADE_TYPE, 0:통합결제, 1:일반결제)
//#20170906 T페이 고도화 작업 phj, start
//292 : t멤버십, 294 통합결제, 297 : 일반결제
if ((this.m_cSktItem != null) && ((this.m_cSktItem.OCCUR_ENTRY_01.Substring(0, 3) == "294") || (this.m_cSktItem.OCCUR_ENTRY_01.Substring(0, 3) == "292")))
{
tpayTradeType = PosConst.TPAY_TRADE_TYPE.COMPLEX;
}
else
{
tpayTradeType = PosConst.TPAY_TRADE_TYPE.NORMAL;
}
//#20170906 T페이 고도화 작업 phj, end
string pointType = base.GetPayDtlCdToPointType(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01); // 포인트구분
string apprNo = base.m_cPayItem.OCCUR_ENTRY_02;
string apprDate = base.m_cPayItem.OCCUR_ENTRY_03;
double destAmt = base.m_cPayItem.AMT_ENTRY_10; // 할인대상금액
double payAmt = base.m_cPayItem.AMT_ENTRY_01 + base.m_cPayItem.AMT_ENTRY_02; // T페이결제금액 + SKT할인금액
inputType = base.m_cPayItem.OCCUR_ENTRY_05;
inputData = base.m_cPayItem.OCCUR_ENTRY_01;
entryMode = PosConst.POS_VAN_MASTER.TPAY_ENTRY_MODE.KEYIN;
encData = base.m_cPayItem.CanFiller1;
encPass = this.m_cDeviceTPaygle.GetHashPassword(base.m_cPayItem.CanFiller2.Trim());
if (string.IsNullOrWhiteSpace(encPass))
{
return UserCom.RST_ERR + POS_MESSAGE.ERROR.MSG_0545;
}
// T페이 결제 승인
ret = this.ExecuteIrt(PosConst.CANCEL_DIV.CANCEL, PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_DIS_C
, tpayTradeType, pointType, inputType, entryMode, inputData, encData, encPass, destAmt, payAmt, "", m_cPayItem.OCCUR_ENTRY_03, m_cPayItem.OCCUR_ENTRY_02);
if (ret != UserCom.RST_OK) return ret;
// SKT할인 아이템 후 처리
if (tpayTradeType == PosConst.TPAY_TRADE_TYPE.COMPLEX && this.m_cSktItem != null)
{
if (this.m_cSktItem.PAY_DTL_CD_05 == PosConst.PAY_DC_TYPE.DC)
ClearPluDiscountAmount(this.m_cSktItem.PAY_WAY_CD + this.m_cSktItem.PAY_DTL_CD_01, "");
this.m_cSktItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
}
// T페이 결제 취소 처리
base.m_cPayItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
base.m_cDataService.UpdatePluAmount(); // 상품 합계금액 계산(거래해더)
base.m_cDataService.UpdatePayAmount(); // 결제 금액 재 계산 처리
return UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 (함수명))
"Exception." + ex.Message);
return UserCom.RST_ERR + ex.Message;
}
finally
{
CmUtil.ZeroFillClear(ref inputData);
CmUtil.ZeroFillClear(ref encData);
CmUtil.ZeroFillClear(ref encPass);
CmUtil.ZeroFillClear(ref aParam);
if (base.m_cPayItem != null)
{
CmUtil.ZeroFillClear(ref base.m_cPayItem.CanFiller1);
CmUtil.ZeroFillClear(ref base.m_cPayItem.CanFiller2);
CmUtil.ZeroFillClear(ref base.m_cPayItem.CanFiller3);
}
}
}
///
/// 결제반품(자동반품)
///
///
/// 0:취소행번호
///
///
public string RefundPayment(string[] aParam)
{
string inputType = string.Empty; // 입력구분 (PosConst.POS_VAN_MASTER.INPUT_TYPE)
string entryMode = string.Empty; // 입력모드 (PosConst.POS_VAN_MASTER.TPAY_ENTRY_MODE)
string inputData = string.Empty; // 카드데이터
string encData = string.Empty; // 암호화카드번호
string encPass = string.Empty; // 암호화비밀번호
try
{
string ret = UserCom.RST_ERR;
// 결제목록
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
// 결제내역 (T페이)
int payRow = CmUtil.IntParse(aParam[0]);
base.m_cPayItem = (Column.TR_PAYMENT.DATA)alPayItem[payRow];
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;
ret = UserCom.RST_OK;
}
else
{
// 결제내역 (SKT할인)
this.m_cSktItem = null;
string[] aRet = new string[5];
ret = this.SearchPayment(new string[] { PosConst.TPAY_SEARCH_TYPE.SKTDC_ITEM, base.m_cPayItem.OCCUR_ENTRY_15 }, ref aRet);
if (ret == UserCom.RST_OK)
{
int sktRow = CmUtil.IntParse(aRet[0]);
if (sktRow >= 0 && sktRow < alPayItem.Count)
{
this.m_cSktItem = (Column.TR_PAYMENT.DATA)alPayItem[sktRow];
this.m_cSktItem.OCCUR_ENTRY_05 = base.m_cPayItem.OCCUR_ENTRY_05;
}
}
string tpayTradeType = this.m_cSktItem != null ? PosConst.TPAY_TRADE_TYPE.COMPLEX
: PosConst.TPAY_TRADE_TYPE.NORMAL; // T페이 결제구분 (PosConst.TPAY_TRADE_TYPE, 0:통합결제, 1:일반결제)
//#20170906 T페이 고도화 작업 phj, start
//292 : t멤버십, 294 통합결제, 297 : 일반결제
if ((this.m_cSktItem != null) && ((this.m_cSktItem.OCCUR_ENTRY_01.Substring(0, 3) == "294") || (this.m_cSktItem.OCCUR_ENTRY_01.Substring(0, 3) == "292")))
{
tpayTradeType = PosConst.TPAY_TRADE_TYPE.COMPLEX;
}
else
{
tpayTradeType = PosConst.TPAY_TRADE_TYPE.NORMAL;
}
//#20170906 T페이 고도화 작업 phj, end
string pointType = base.GetPayDtlCdToPointType(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01); // 포인트구분
string apprNo = base.m_cPayItem.OCCUR_ENTRY_02;
string apprDate = base.m_cPayItem.OCCUR_ENTRY_03;
double destAmt = base.m_cPayItem.AMT_ENTRY_10; // 할인대상금액
double payAmt = base.m_cPayItem.AMT_ENTRY_01 + base.m_cPayItem.AMT_ENTRY_02; // T페이결제금액 + SKT할인금액
inputType = base.m_cPayItem.OCCUR_ENTRY_05;
inputData = base.m_cPayItem.OCCUR_ENTRY_01;
entryMode = PosConst.POS_VAN_MASTER.TPAY_ENTRY_MODE.KEYIN;
encData = base.m_cPayItem.CanFiller1;
encPass = this.m_cDeviceTPaygle.GetHashPassword(base.m_cPayItem.CanFiller2.Trim());
if (string.IsNullOrWhiteSpace(encPass))
{
return UserCom.RST_ERR + POS_MESSAGE.ERROR.MSG_0545;
}
// T페이 결제 승인
ret = this.ExecuteIrt(PosConst.CANCEL_DIV.CANCEL, PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_DIS_C
, tpayTradeType, pointType, inputType, entryMode, inputData, encData, encPass, destAmt, payAmt, "", m_cPayItem.OCCUR_ENTRY_03, m_cPayItem.OCCUR_ENTRY_02);
}
return ret;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 (함수명))
"Exception." + ex.Message);
return UserCom.RST_ERR + ex.Message;
}
finally
{
CmUtil.ZeroFillClear(ref inputData);
CmUtil.ZeroFillClear(ref encData);
CmUtil.ZeroFillClear(ref encPass);
CmUtil.ZeroFillClear(ref aParam);
if (base.m_cPayItem != null)
{
CmUtil.ZeroFillClear(ref base.m_cPayItem.CanFiller1);
CmUtil.ZeroFillClear(ref base.m_cPayItem.CanFiller2);
CmUtil.ZeroFillClear(ref base.m_cPayItem.CanFiller3);
}
}
}
///
/// 결제 수기 등록(임의등록)
///
///
///
public string SetMenualPayment(string[] aParam)
{
throw new NotImplementedException();
}
///
/// T페이 결제 IRT
///
/// 취소구분 (PosConst.CANCEL_DIV)
/// 거래구분 (PosConst.POS_VAN_MASTER.TRADE_ID)
/// T페이 결제구분 (PosConst.TPAY_TRADE_TYPE, 0:통합결제, 1:일반결제)
/// 포인트구분 ("TPAY")
/// 입력모드 (PosConst.POS_VAN_MASTER.INPUT_TYPE)
/// 입력모드 (PosConst.POS_VAN_MASTER.TPAY_ENTRY_MODE)
/// 카드번호
/// 암호화카드번호
/// 암호화비밀번호
/// 할인대상금액
/// 결제금액
/// SKT상품코드("1001")
/// 원승인일자
/// 원승인번호
///
private string ExecuteIrt(string trandeDiv, string tranType, string tpayTradeType, string pointType, string inputType, string entryMode, string inputData, string encData, string encPass, double destAmt, double payAmt, string productCode
, string orgApprDate = "", string orgApprNo = "")
{
string[] aIrtRsp = null;
try
{
string ret = UserCom.RST_ERR;
// Van Code
string vanCd = base.GetPayDtlCdToVanCode(base.m_cPayItem.PAY_WAY_CD, base.m_cPayItem.PAY_DTL_CD_01);
if (vanCd == "")
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0563);
return UserCom.RST_ERR;
}
// 통합결제 시 T페이 거래일련번호 (SKT할인 매칭키)
string tradeSeqNo = tpayTradeType == PosConst.TPAY_TRADE_TYPE.COMPLEX ? DateTime.Now.ToString("yyyyMMddHHmmssfff") : string.Empty;
// 추가정보
string[] aAddInfoReq = new string[Column.TPAY_ADDINFO_REQ.LEN.Length];
aAddInfoReq[Column.TPAY_ADDINFO_REQ.SEQ.TrTypeCode] = tpayTradeType == PosConst.TPAY_TRADE_TYPE.COMPLEX ? "000040" : "000050";
aAddInfoReq[Column.TPAY_ADDINFO_REQ.SEQ.DisDestAmt] = destAmt.ToString();
aAddInfoReq[Column.TPAY_ADDINFO_REQ.SEQ.TotAmount] = payAmt.ToString();
aAddInfoReq[Column.TPAY_ADDINFO_REQ.SEQ.PosEntryMode] = entryMode;
aAddInfoReq[Column.TPAY_ADDINFO_REQ.SEQ.EncPassword] = encPass;
aAddInfoReq[Column.TPAY_ADDINFO_REQ.SEQ.VReserved] = "";
string addInfoReq = ItemColumn.MakeMessage(aAddInfoReq, Column.TPAY_ADDINFO_REQ.LEN, Column.TPAY_ADDINFO_REQ.TYPE);
aIrtRsp = new string[Column.POS_RES_POINT.LEN.Length];
if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1")
{
// 연습모드
ret = SetTrainingData(base.m_cPayItem.PAY_WAY_CD, base.m_cPayItem.PAY_DTL_CD_01, vanCd, tranType, pointType, inputType, inputData, encData, payAmt, destAmt, ref aIrtRsp);
}
else
{
ret = ExecutePointIrt(trandeDiv, base.m_cPayItem.PAY_WAY_CD, base.m_cPayItem.PAY_DTL_CD_01
, vanCd, tranType, pointType, inputType, inputData, encData, destAmt, orgApprDate, orgApprNo, "", productCode, "", "", addInfoReq, ref aIrtRsp, "", "");
}
if (ret != UserCom.RST_OK) return ret;
// 추가응답정보 분해
string[] aAddInfoRes = new string[Column.TPAY_ADDINFO_RES.LEN.Length];
ItemColumn.ParseMessage(Column.TPAY_ADDINFO_RES.LEN, Column.TPAY_ADDINFO_RES.TYPE, aIrtRsp[Column.POS_RES_POINT.SEQ.ResAddRespon], 0, ref aAddInfoRes);
#region T-페이 결제 ITEM 생성
if (trandeDiv == PosConst.CANCEL_DIV.NORMAL)
{
base.m_cPayItem.PAY_AMT = CmUtil.DoubleParse(aAddInfoRes[Column.TPAY_ADDINFO_RES.SEQ.AppAmt]); // 받은금액 (T페이 결제금액)
base.m_cPayItem.PAY_DTL_CD_02 = string.Empty;
base.m_cPayItem.PAY_DTL_CD_03 = string.Empty;
base.m_cPayItem.PAY_DTL_CD_04 = string.Empty;
base.m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY;
base.m_cPayItem.QTY_ENTRY_01 = 0;
base.m_cPayItem.QTY_ENTRY_02 = 0;
base.m_cPayItem.QTY_ENTRY_03 = 0;
base.m_cPayItem.QTY_ENTRY_04 = 0;
base.m_cPayItem.QTY_ENTRY_05 = 0;
base.m_cPayItem.AMT_ENTRY_01 = CmUtil.DoubleParse(aAddInfoRes[Column.TPAY_ADDINFO_RES.SEQ.AppAmt]); // 받은금액 (T페이 결제금액)
base.m_cPayItem.AMT_ENTRY_02 = CmUtil.DoubleParse(aAddInfoRes[Column.TPAY_ADDINFO_RES.SEQ.DisAmt]); // 할인금액 (SKT 멤버십 할인금액)
base.m_cPayItem.AMT_ENTRY_03 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResSavePoint]); // 총포인트
base.m_cPayItem.AMT_ENTRY_04 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResUsesPoint]); // 가용포인트 (할인후결제금액)
base.m_cPayItem.AMT_ENTRY_05 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResSavePoint]); // 잔여포인트
base.m_cPayItem.AMT_ENTRY_06 = 0;
base.m_cPayItem.AMT_ENTRY_07 = 0;
base.m_cPayItem.AMT_ENTRY_08 = 0;
base.m_cPayItem.AMT_ENTRY_09 = 0;
base.m_cPayItem.AMT_ENTRY_10 = destAmt; // SKT 할인대상금액
// TPAY 실바코드번호 설정 오류 수정(2017.07.17)
base.m_cPayItem.OCCUR_ENTRY_01 = inputData; // 바코드번호
//base.m_cPayItem.OCCUR_ENTRY_01 = encData; //inputData; // 바코드번호 => T페이 실바코드번호(2017.06.20)
base.m_cPayItem.OCCUR_ENTRY_02 = aIrtRsp[Column.POS_RES_POINT.SEQ.ResApprNo].Trim(); // 승인번호
base.m_cPayItem.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrDate], 0, 6); // 승인일자
base.m_cPayItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrDate], 6, 4); // 승인시간
base.m_cPayItem.OCCUR_ENTRY_05 = inputType; // 입력구분
base.m_cPayItem.OCCUR_ENTRY_06 = string.Empty; // 원승인번호
base.m_cPayItem.OCCUR_ENTRY_07 = string.Empty; // 원승인일자
base.m_cPayItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL; // 승인구분
base.m_cPayItem.OCCUR_ENTRY_09 = string.Empty;
base.m_cPayItem.OCCUR_ENTRY_10 = string.Empty; // 가맹점구분
base.m_cPayItem.OCCUR_ENTRY_11 = string.Empty; // 가맹점추가사용
base.m_cPayItem.OCCUR_ENTRY_12 = string.Empty; //
base.m_cPayItem.OCCUR_ENTRY_13 = string.Empty;
base.m_cPayItem.OCCUR_ENTRY_14 = entryMode; // T페이 입력구분 (010:KEYIN,020:SWIPE,031:BARCODE,032:BLE,033:NFC)
base.m_cPayItem.OCCUR_ENTRY_15 = tradeSeqNo; // T페이 거래일련번호(통합결제 시 SKT할인 매칭키)
base.m_cPayItem.OCCUR_ENTRY_16 = vanCd; // VAN 구분
base.m_cPayItem.OCCUR_ENTRY_17 = string.Empty;
base.m_cPayItem.OCCUR_ENTRY_18 = aIrtRsp[Column.POS_RES_POINT.SEQ.ResStoreNo]; // 가맹점번호
base.m_cPayItem.OCCUR_ENTRY_19 = string.Empty;
base.m_cPayItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01); // 결제수단명
base.m_cPayItem.OCCUR_ENTRY_21 = ItemConst.PAY_CASHBILL_DIV.NO; // 현금영수증발행여부
base.m_cPayItem.OCCUR_ENTRY_22 = string.Empty;
base.m_cPayItem.OCCUR_ENTRY_23 = string.Empty;
base.m_cPayItem.OCCUR_ENTRY_24 = string.Empty;
base.m_cPayItem.OCCUR_ENTRY_25 = string.Empty;
base.m_cPayItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
base.m_cPayItem.BILLSPR_NO = base.m_cTrnStatus.Sale.BillSplitNo; // 빌분리 번호
}
else
{
// TPAY 실바코드번호 설정 오류 수정(2017.07.17) => 반품시 카드번호 재설정 안함.
//base.m_cPayItem.OCCUR_ENTRY_01 = encData; //inputData; // 바코드번호 => T페이 실바코드번호(2017.06.20)
base.m_cPayItem.OCCUR_ENTRY_02 = aIrtRsp[Column.POS_RES_POINT.SEQ.ResApprNo].Trim(); // 승인번호
base.m_cPayItem.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrDate], 0, 6); // 승인일자
base.m_cPayItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrDate], 6, 4); // 승인시간
//base.m_cPayItem.OCCUR_ENTRY_05 = inputType; // 입력구분
base.m_cPayItem.OCCUR_ENTRY_06 = orgApprNo; // 원승인번호
base.m_cPayItem.OCCUR_ENTRY_07 = orgApprDate; // 원승인일자
base.m_cPayItem.OCCUR_ENTRY_13 = entryMode; // T페이 입력구분 (010:KEYIN,020:SWIPE,031:BARCODE,032:BLE,03:NFC)
}
#endregion
#region SKT 할인 ITEM 생성 (T페이 통합결제 일때)
if (tpayTradeType == PosConst.TPAY_TRADE_TYPE.COMPLEX && base.m_cPayItem.AMT_ENTRY_02 != 0)
{
if (trandeDiv == PosConst.CANCEL_DIV.NORMAL)
{
this.m_cSktItem = new Column.TR_PAYMENT.DATA();
m_cSktItem.PAY_WAY_CD = GetMenuKeyToPayWayCd(PosKey.MENU_KEY.SKT); // 결제수단코드
m_cSktItem.PAY_AMT = base.m_cPayItem.AMT_ENTRY_02; // 사용포인트 (할인금액)
m_cSktItem.PAY_DTL_CD_01 = GetMenuKeyToPayDtlCd(PosKey.MENU_KEY.SKT); // 결제세부코드1
m_cSktItem.PAY_DTL_CD_02 = string.Empty;
// SKT할인 할인결제구분 마스터 조회
string payDcType = PosMstManager.GetMstPayDc(m_cSktItem.PAY_WAY_CD, m_cSktItem.PAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.PAY_DC_TYPE);
m_cSktItem.PAY_DTL_CD_03 = payDcType == PosConst.PAY_DC_TYPE.PAY ? "0" : "1"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
m_cSktItem.PAY_DTL_CD_04 = string.Empty;
m_cSktItem.PAY_DTL_CD_05 = payDcType; // 할인결제구분 (1:결제, 2:할인)
m_cSktItem.QTY_ENTRY_01 = 0;
m_cSktItem.QTY_ENTRY_02 = 0;
m_cSktItem.QTY_ENTRY_03 = 0;
m_cSktItem.QTY_ENTRY_04 = 0;
m_cSktItem.QTY_ENTRY_05 = 0;
m_cSktItem.AMT_ENTRY_01 = base.m_cPayItem.AMT_ENTRY_02; // 사용포인트 (할인금액)
m_cSktItem.AMT_ENTRY_02 = 0; // 캠페인할인금액
m_cSktItem.AMT_ENTRY_03 = base.m_cPayItem.AMT_ENTRY_03; // 총포인트
m_cSktItem.AMT_ENTRY_04 = base.m_cPayItem.AMT_ENTRY_04; // 가용포인트 (할인후결제금액)
m_cSktItem.AMT_ENTRY_05 = base.m_cPayItem.AMT_ENTRY_05; // 잔여포인트
m_cSktItem.AMT_ENTRY_06 = 0;
m_cSktItem.AMT_ENTRY_07 = 0;
m_cSktItem.AMT_ENTRY_08 = 0;
m_cSktItem.AMT_ENTRY_09 = 0;
m_cSktItem.AMT_ENTRY_10 = base.m_cPayItem.AMT_ENTRY_10; // SKT 할인대상금액
m_cSktItem.OCCUR_ENTRY_01 = base.m_cPayItem.OCCUR_ENTRY_01; // 바코드번호
m_cSktItem.OCCUR_ENTRY_02 = base.m_cPayItem.OCCUR_ENTRY_02; // 승인번호
m_cSktItem.OCCUR_ENTRY_03 = base.m_cPayItem.OCCUR_ENTRY_03; // 승인일자
m_cSktItem.OCCUR_ENTRY_04 = base.m_cPayItem.OCCUR_ENTRY_04; // 승인시간
m_cSktItem.OCCUR_ENTRY_05 = base.m_cPayItem.OCCUR_ENTRY_05; // 입력구분
m_cSktItem.OCCUR_ENTRY_06 = string.Empty; // 원승인번호
m_cSktItem.OCCUR_ENTRY_07 = string.Empty; // 원승인일자
m_cSktItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL; // 승인구분
m_cSktItem.OCCUR_ENTRY_09 = string.Empty;
m_cSktItem.OCCUR_ENTRY_10 = string.Empty; //
m_cSktItem.OCCUR_ENTRY_11 = string.Empty; //
m_cSktItem.OCCUR_ENTRY_12 = string.Empty; //
m_cSktItem.OCCUR_ENTRY_13 = string.Empty; //
m_cSktItem.OCCUR_ENTRY_14 = string.Empty; //
m_cSktItem.OCCUR_ENTRY_15 = base.m_cPayItem.OCCUR_ENTRY_15; // T페이 거래일련번호 (통합결제시 매칭키)
m_cSktItem.OCCUR_ENTRY_16 = base.m_cPayItem.OCCUR_ENTRY_16; // VAN 구분
m_cSktItem.OCCUR_ENTRY_17 = string.Empty;
m_cSktItem.OCCUR_ENTRY_18 = base.m_cPayItem.OCCUR_ENTRY_18; // 가맹점번호
m_cSktItem.OCCUR_ENTRY_19 = string.Empty;
m_cSktItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cSktItem.PAY_WAY_CD, m_cSktItem.PAY_DTL_CD_01); // 결제수단명
m_cSktItem.OCCUR_ENTRY_21 = GetPayDtlCdToCashBillYn(m_cSktItem.PAY_WAY_CD, m_cSktItem.PAY_DTL_CD_01); // 현금영수증 발행여부
m_cSktItem.OCCUR_ENTRY_22 = string.Empty;
m_cSktItem.OCCUR_ENTRY_23 = string.Empty;
m_cSktItem.OCCUR_ENTRY_24 = string.Empty;
m_cSktItem.OCCUR_ENTRY_25 = string.Empty;
m_cSktItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
m_cSktItem.BILLSPR_NO = base.m_cPayItem.BILLSPR_NO; // 빌분리 번호
}
else
{
m_cSktItem.OCCUR_ENTRY_01 = base.m_cPayItem.OCCUR_ENTRY_01; // 바코드번호
m_cSktItem.OCCUR_ENTRY_02 = base.m_cPayItem.OCCUR_ENTRY_02; // 승인번호
m_cSktItem.OCCUR_ENTRY_03 = base.m_cPayItem.OCCUR_ENTRY_03; // 승인일자
m_cSktItem.OCCUR_ENTRY_04 = base.m_cPayItem.OCCUR_ENTRY_04; // 승인시간
m_cSktItem.OCCUR_ENTRY_05 = base.m_cPayItem.OCCUR_ENTRY_05; // 입력구분
m_cSktItem.OCCUR_ENTRY_06 = orgApprNo; // 원승인번호
m_cSktItem.OCCUR_ENTRY_07 = orgApprDate; // 원승인일자
}
}
#endregion
return UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 (함수명))
"Exception." + ex.Message);
return UserCom.RST_ERR + ex.Message;
}
finally
{
CmUtil.ZeroFillClear(ref inputData);
CmUtil.ZeroFillClear(ref encData);
CmUtil.ZeroFillClear(ref encPass);
CmUtil.ZeroFillClear(ref aIrtRsp);
}
}
///
/// 연습 데이터 설정
///
///
///
private string SetTrainingData(string payWayCd, string payDtlCd, string vanCd, string tranType, string pointType, string inputType, string inputData, string encData, double payAmt, double destAmt, ref string[] aIrtRsp)
{
try
{
// 제휴사 결제 할인 금액 계산
double disAmt = m_cDataCommon.ExecTermCoopCmpPayDc(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, "", destAmt);
if (disAmt == 0)
{
disAmt = (int)((destAmt * 0.1) / 10) * 10 ;
}
string[] aAddInfoRes = new string[Column.TPAY_ADDINFO_RES.LEN.Length];
aAddInfoRes[Column.TPAY_ADDINFO_RES.SEQ.MemberLevel] = "MV";
aAddInfoRes[Column.TPAY_ADDINFO_RES.SEQ.DisAmt] = disAmt.ToString();
aAddInfoRes[Column.TPAY_ADDINFO_RES.SEQ.AppAmt] = (payAmt - disAmt).ToString();
aAddInfoRes[Column.TPAY_ADDINFO_RES.SEQ.BillAmt] = "0";
aAddInfoRes[Column.TPAY_ADDINFO_RES.SEQ.RemainLimit1] = "0";
aAddInfoRes[Column.TPAY_ADDINFO_RES.SEQ.RemainLimit2] = "0";
string addInfoRes = ItemColumn.MakeMessage(aAddInfoRes, Column.TPAY_ADDINFO_RES.LEN, Column.TPAY_ADDINFO_RES.TYPE);
aIrtRsp[Column.POS_RES_POINT.SEQ.ResDocVer] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResStatus] = "O";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrDate] = DateTime.Now.ToString("yyMMddhhmm");
aIrtRsp[Column.POS_RES_POINT.SEQ.ResMessage1] = "T페이".PadRight(16);
aIrtRsp[Column.POS_RES_POINT.SEQ.ResMessage2] = "OK:99999999".PadRight(16);
aIrtRsp[Column.POS_RES_POINT.SEQ.ResApprNo] = "99999999".PadRight(12);
aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrPoint] = disAmt.ToString().PadLeft(9, '0');
aIrtRsp[Column.POS_RES_POINT.SEQ.ResUsesPoint] = "0".PadRight(9, '0');
aIrtRsp[Column.POS_RES_POINT.SEQ.ResSavePoint] = "0".PadRight(9, '0');
aIrtRsp[Column.POS_RES_POINT.SEQ.ResSparePoint] = "0".PadRight(9, '0');
aIrtRsp[Column.POS_RES_POINT.SEQ.ResStoreNo] = "TEST".PadRight(15);
aIrtRsp[Column.POS_RES_POINT.SEQ.ResNotice1] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResNotice2] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResNotice3] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.Resnotice4] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResReserved] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResCampaign] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResRS] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResAddRespon] = addInfoRes;
aIrtRsp[Column.POS_RES_POINT.SEQ.ResGS] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResKeyDownLoad] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResFsLen] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResFsField] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResETX] = "";
aIrtRsp[Column.POS_RES_POINT.SEQ.ResCR] = "";
return UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 (함수명))
"Exception." + ex.Message);
return UserCom.RST_ERR + ex.Message;
}
}
}
}