diff --git a/DLL_HK.sln b/DLL_HK_EPS.sln
similarity index 100%
rename from DLL_HK.sln
rename to DLL_HK_EPS.sln
diff --git a/ECR_N5_DLL_TestUI/ECR_N5_DLL_TestUI.csproj b/ECR_N5_DLL_TestUI/ECR_N5_DLL_TestUI.csproj
index 8389570..21b04f8 100644
--- a/ECR_N5_DLL_TestUI/ECR_N5_DLL_TestUI.csproj
+++ b/ECR_N5_DLL_TestUI/ECR_N5_DLL_TestUI.csproj
@@ -51,6 +51,9 @@
4
+
+ ..\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll
+
@@ -102,6 +105,7 @@
ResXFileCodeGenerator
Resources.Designer.cs
+
SettingsSingleFileGenerator
Settings.Designer.cs
diff --git a/ECR_N5_DLL_TestUI/MainWindow.xaml b/ECR_N5_DLL_TestUI/MainWindow.xaml
index 4fb6ca6..4a28360 100644
--- a/ECR_N5_DLL_TestUI/MainWindow.xaml
+++ b/ECR_N5_DLL_TestUI/MainWindow.xaml
@@ -5,51 +5,34 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ECR_N5_DLL_TestUI"
mc:Ignorable="d"
- Title="ECR N5 DLL TEST" Height="881" Width="810">
-
+ Title="ECR N5 DLL TEST" Height="1062" Width="1174">
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -71,31 +54,47 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ECR_N5_DLL_TestUI/MainWindow.xaml.cs b/ECR_N5_DLL_TestUI/MainWindow.xaml.cs
index 369ef04..2121a6a 100644
--- a/ECR_N5_DLL_TestUI/MainWindow.xaml.cs
+++ b/ECR_N5_DLL_TestUI/MainWindow.xaml.cs
@@ -17,6 +17,7 @@ using System.Threading;
using System.Security.Cryptography;
using System.Windows.Threading;
using n5coredll;
+using Newtonsoft.Json.Linq;
namespace ECR_N5_DLL_TestUI
{
@@ -27,7 +28,7 @@ namespace ECR_N5_DLL_TestUI
private string dataBits = "8";
private string stopBits = "One";
private string parity = "None";
- private string timeOut = "180000";
+ private string timeOut = "300000";
private string thisEvent;
@@ -38,9 +39,13 @@ namespace ECR_N5_DLL_TestUI
public string requestStrByThead = null;
public string showResultStr = null;
public string txnAmtTextBoxValue = null;
+ public string cashbackAmtTextBoxValue = null;
public string paymentAppIdComboBoxValue = null;
+ public string currencyComboBoxValue = null;
+ public string ecrRefNoTextBoxValue = null;
public string qrValueTextBoxValue = null;
public string ecrTxnIdTextBoxValue = null;
+ public string traceNoTextBoxValue = null;
public string panTextBoxValue = null;
public string authCodeTextBoxValue = null;
public string batchIdTextBoxValue = null;
@@ -78,28 +83,17 @@ namespace ECR_N5_DLL_TestUI
{
InitializeComponent();
}
+ private string timeout = "300000";
private void requestSaleThead()
{
if (panTextBoxValue!=null && panTextBoxValue!= "" && expDateTextBoxValue!=null && expDateTextBoxValue!="")
- jsonResultByThead = n5Core.requestSale(txnIdForSale, txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
+ jsonResultByThead = n5Core.requestSaleWithTimeout(txnIdForSale, txnAmtTextBoxValue, "0", cashbackAmtTextBoxValue , ecrRefNoTextBoxValue, currencyComboBoxValue, paymentAppIdComboBoxValue, qrValueTextBoxValue, timeout);
else
- jsonResultByThead = n5Core.requestSale(txnIdForSale, txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
+ jsonResultByThead = n5Core.requestSaleWithTimeout(txnIdForSale, txnAmtTextBoxValue, "0", cashbackAmtTextBoxValue, ecrRefNoTextBoxValue, currencyComboBoxValue, paymentAppIdComboBoxValue, qrValueTextBoxValue, timeout);
this.requestStrByThead = this.saleRequestMsg;
showResult();
}
- private void requestPreauthThead()
- {
- jsonResultByThead = n5Core.processPreauth(txnIdForPreAuth, txnAmtTextBoxValue, paymentAppIdComboBoxValue, panTextBoxValue, expDateTextBoxValue);
- this.requestStrByThead = this.preAuthRequestMsg;
- showResult();
- }
- private void requestOfflineThead()
- {
-
- jsonResultByThead = n5Core.processOffline(txnIdForOffline, txnAmtTextBoxValue, paymentAppIdComboBoxValue, authCodeTextBoxValue, panTextBoxValue, expDateTextBoxValue);
- this.requestStrByThead = this.offlineRequestMsg;
- showResult();
- }
+
private void requestAdjustThead()
{
@@ -107,49 +101,18 @@ namespace ECR_N5_DLL_TestUI
// this.requestStrByThead = this.offlineRequestMsg;
// showResult();
}
- private void requestRefundThead()
- {
- jsonResultByThead = n5Core.requestRefund(txnIdForRefund, txnAmtTextBoxValue, paymentAppIdComboBoxValue, qrValueTextBoxValue);
- this.requestStrByThead = this.refundRequestMsg;
- showResult();
- }
private void requestRetrievalThead()
{
- jsonResultByThead = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, 180000);
+ jsonResultByThead = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, traceNoTextBoxValue ,180000);
this.requestStrByThead = this.retrievalRequestMsg;
showResult();
}
- private void requestRepeatRetrievalThead()
- {
- while (isRepeatSubmit)
- {
- String result = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, 10000);
- addRepeatLog("=============================count" + repeatCount + "=============================");
- addRepeatLog("ecrTxnId = " + ecrTxnIdTextBoxValue);
-
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(result);
- if (retrievalResult != null && retrievalResult.Status.Equals("00"))
- {
- addRepeatLog("Retrieval Success!");
- }
- else
- addRepeatLog("Retrieval Failed!");
-
- }
-
- }
- private void requestVoidThead()
- {
- jsonResultByThead = n5Core.requestVoid(ecrTxnIdTextBoxValue, qrValueTextBoxValue);
- this.requestStrByThead = this.voidRequestMsg;
- showResult();
- }
private void requestSettlementThead()
{
jsonResultByThead = n5Core.sendSettlementtRequest();
this.requestStrByThead = this.settlementRequestMsg;
- showResult();
+ showSettleResult();
}
private void requestLinkRequestThead()
@@ -161,7 +124,7 @@ namespace ECR_N5_DLL_TestUI
private void requestReprintThead()
{
- jsonResultByThead = n5Core.sendReprintRequest();
+ jsonResultByThead = n5Core.sendReprintRequest(ecrTxnIdTextBoxValue, traceNoTextBoxValue,true);
this.requestStrByThead = this.reprintRequestMsg;
showResult();
}
@@ -208,46 +171,151 @@ namespace ECR_N5_DLL_TestUI
showResult();
}
- private int repeatCount = 1;
- public void sendRepeatSubmit()
- {
- if (n5Core == null || !n5CoreInitSuccess)
- {
- n5Core = n5coredll.N5Core.getInstance();
- int initResult = n5Core.initN5Core(portName, baudRate, dataBits, stopBits, parity, timeOut);
- if (initResult == 0)
- {
- n5CoreInitSuccess = true;
- }
+ public void showInput(string func)
+ {
+ settle_valuedate_combox.Visibility = Visibility.Hidden;
+ settle_valuedate_lbl.Visibility = Visibility.Hidden;
+ if (func.Equals("SALE"))
+ {
+ retrieval_lbl_isnTextBox.Visibility = Visibility.Hidden;
+ retrieval_traceNoTextBox.Visibility = Visibility.Hidden;
+ retrieval_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ retrieval_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+ print_lbl_isnTextBox.Visibility = Visibility.Hidden;
+ print_traceNoTextBox.Visibility = Visibility.Hidden;
+ print_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ print_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+
+ sale_lbl_txnAmtTextBox.Visibility = Visibility.Visible;
+ sale_txnAmtTextBox.Visibility = Visibility.Visible;
+ sale_lbl_paymentAppId.Visibility = Visibility.Visible;
+ sale_paymentAppIdComboBox.Visibility = Visibility.Visible;
+ sale_lbl_currency.Visibility = Visibility.Visible;
+ sale_currencyComboBox.Visibility = Visibility.Visible;
+ sale_lbl_cashbackAmtTextBox.Visibility = Visibility.Visible;
+ sale_cashbackAmtTextBox.Visibility = Visibility.Visible;
+ sale_lbl_ecrRefNoTextBox.Visibility = Visibility.Visible;
+ sale_ecrRefNoTextBox.Visibility = Visibility.Visible;
+ sale_lbl_ecrRefNoTextBox.Visibility = Visibility.Visible;
+ sale_ecrRefNoTextBox.Visibility = Visibility.Visible;
+ sale_lbl_txnId.Visibility = Visibility.Visible;
+ sale_ecrTxnIdTextBox.Visibility = Visibility.Visible;
+
}
- /*
- if (!n5CoreInitSuccess)
- {
- this.requestStrByThead = "n5coredll init fail.";
- this.jsonResultByThead = string.Empty;
- showResult();
- return;
- }*/
- if (this.ecrTxnIdTextBox.Text == null || "".Equals(this.ecrTxnIdTextBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.ecrTxnIdTextBox.Focus();
- return;
+ else if (func.Equals("RETRIEVAL"))
+ {
+ sale_lbl_txnAmtTextBox.Visibility = Visibility.Hidden;
+ sale_txnAmtTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ sale_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+ sale_lbl_currency.Visibility = Visibility.Hidden;
+ sale_currencyComboBox.Visibility = Visibility.Hidden;
+ sale_lbl_cashbackAmtTextBox.Visibility = Visibility.Hidden;
+ sale_cashbackAmtTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_txnId.Visibility = Visibility.Hidden;
+ sale_ecrTxnIdTextBox.Visibility = Visibility.Hidden;
+ print_lbl_isnTextBox.Visibility = Visibility.Hidden;
+ print_traceNoTextBox.Visibility = Visibility.Hidden;
+ print_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ print_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+ settle_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ settle_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+
+ retrieval_lbl_isnTextBox.Visibility = Visibility.Visible;
+ retrieval_traceNoTextBox.Visibility = Visibility.Visible;
+ retrieval_lbl_paymentAppId.Visibility = Visibility.Visible;
+ retrieval_paymentAppIdComboBox.Visibility = Visibility.Visible;
+ }
+ else if (func.Equals("PRINT"))
+ {
+ sale_lbl_txnAmtTextBox.Visibility = Visibility.Hidden;
+ sale_txnAmtTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ sale_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+ sale_lbl_currency.Visibility = Visibility.Hidden;
+ sale_currencyComboBox.Visibility = Visibility.Hidden;
+ sale_lbl_cashbackAmtTextBox.Visibility = Visibility.Hidden;
+ sale_cashbackAmtTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_txnId.Visibility = Visibility.Hidden;
+ sale_ecrTxnIdTextBox.Visibility = Visibility.Hidden;
+ retrieval_lbl_isnTextBox.Visibility = Visibility.Hidden;
+ retrieval_traceNoTextBox.Visibility = Visibility.Hidden;
+ retrieval_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ retrieval_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+ settle_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ settle_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+
+ print_lbl_isnTextBox.Visibility = Visibility.Visible;
+ print_traceNoTextBox.Visibility = Visibility.Visible;
+ print_lbl_paymentAppId.Visibility = Visibility.Visible;
+ print_paymentAppIdComboBox.Visibility = Visibility.Visible;
+ }
+ else if (func.Equals("SETTLE"))
+ {
+ sale_lbl_txnAmtTextBox.Visibility = Visibility.Hidden;
+ sale_txnAmtTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ sale_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+ sale_lbl_currency.Visibility = Visibility.Hidden;
+ sale_currencyComboBox.Visibility = Visibility.Hidden;
+ sale_lbl_cashbackAmtTextBox.Visibility = Visibility.Hidden;
+ sale_cashbackAmtTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_txnId.Visibility = Visibility.Hidden;
+ sale_ecrTxnIdTextBox.Visibility = Visibility.Hidden;
+ retrieval_lbl_isnTextBox.Visibility = Visibility.Hidden;
+ retrieval_traceNoTextBox.Visibility = Visibility.Hidden;
+ retrieval_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ retrieval_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+
+ print_lbl_isnTextBox.Visibility = Visibility.Hidden;
+ print_traceNoTextBox.Visibility = Visibility.Hidden;
+ print_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ print_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+
+ settle_lbl_paymentAppId.Visibility = Visibility.Visible;
+ settle_paymentAppIdComboBox.Visibility = Visibility.Visible;
}
else
{
- ecrTxnIdTextBoxValue = ecrTxnIdTextBox.Text;
- Thread th = new Thread(requestRepeatRetrievalThead);
- th.Start();
+ sale_lbl_txnAmtTextBox.Visibility = Visibility.Hidden;
+ sale_txnAmtTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ sale_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+ sale_lbl_currency.Visibility = Visibility.Hidden;
+ sale_currencyComboBox.Visibility = Visibility.Hidden;
+ sale_lbl_cashbackAmtTextBox.Visibility = Visibility.Hidden;
+ sale_cashbackAmtTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_ecrRefNoTextBox.Visibility = Visibility.Hidden;
+ sale_lbl_txnId.Visibility = Visibility.Hidden;
+ sale_ecrTxnIdTextBox.Visibility = Visibility.Hidden;
+ retrieval_lbl_isnTextBox.Visibility = Visibility.Hidden;
+ retrieval_traceNoTextBox.Visibility = Visibility.Hidden;
+ retrieval_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ retrieval_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+
+ print_lbl_isnTextBox.Visibility = Visibility.Hidden;
+ print_traceNoTextBox.Visibility = Visibility.Hidden;
+ print_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ print_paymentAppIdComboBox.Visibility = Visibility.Hidden;
+
+ settle_lbl_paymentAppId.Visibility = Visibility.Hidden;
+ settle_paymentAppIdComboBox.Visibility = Visibility.Hidden;
}
-
- }
-
- public void stopRepeatSubmit()
- {
- repeatCount = 1;
}
public void sendSubmit()
@@ -284,36 +352,40 @@ namespace ECR_N5_DLL_TestUI
return;
}
- if ("Sale".Equals(this.thisEvent))
+ if ("SALE".Equals(this.thisEvent))
{
- if (this.txnAmtTextBox.Text == null || "".Equals(this.txnAmtTextBox.Text.Trim()))
+ if (this.sale_txnAmtTextBox.Text == null || "".Equals(this.sale_txnAmtTextBox.Text.Trim()))
{
this.requestStrByThead = "Please input parameter.";
this.jsonResultByThead = "Please input parameter.";
showResult();
- this.txnAmtTextBox.Focus();
+ this.sale_txnAmtTextBox.Focus();
return;
}
- else if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text.Trim()))
+ else if (this.sale_paymentAppIdComboBox.Text == null || "".Equals(this.sale_paymentAppIdComboBox.Text.Trim()))
{
this.requestStrByThead = "Please input parameter.";
this.jsonResultByThead = "Please input parameter.";
showResult();
- this.paymentAppIdComboBox.Focus();
+ this.sale_paymentAppIdComboBox.Focus();
return;
}
else
{
- txnAmtTextBoxValue = this.txnAmtTextBox.Text;
- paymentAppIdComboBoxValue = this.paymentAppIdComboBox.Text;
- qrValueTextBoxValue = this.qrValueTextBox.Text;
- panTextBoxValue = this.panTextBox.Text;
- expDateTextBoxValue = this.expDateTextBox.Text;
-
+ txnAmtTextBoxValue = this.sale_txnAmtTextBox.Text;
+ cashbackAmtTextBoxValue = this.sale_cashbackAmtTextBox.Text;
+ paymentAppIdComboBoxValue = this.sale_paymentAppIdComboBox.Text;
+ currencyComboBoxValue = this.sale_currencyComboBox.Text;
+ ecrRefNoTextBoxValue = this.sale_ecrRefNoTextBox.Text;
txnIdForSale = this.getTxnId();
- this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForSale + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue + "\n qrValue = " + qrValueTextBoxValue;
+ if (ecrRefNoTextBoxValue == "" && cashbackAmtTextBoxValue != "")
+ this.requestStrByThead = " EVENT_NAME : " + currEventName + "\n TXN_ID = " + txnIdForSale + "\n TXN_AMT = " + txnAmtTextBoxValue + "\n CASHBACK_AMT = " + cashbackAmtTextBoxValue + "\n PAYMENT_APP_ID = " + paymentAppIdComboBoxValue + "\n CURRENCY = " + currencyComboBoxValue;
+ else if (ecrRefNoTextBoxValue != "" && cashbackAmtTextBoxValue != "")
+ this.requestStrByThead = " EVENT_NAME : " + currEventName + "\n TXN_ID = " + txnIdForSale + "\n TXN_AMT = " + txnAmtTextBoxValue + "\n CASHBACK_AMT = " + cashbackAmtTextBoxValue + "\n PAYMENT_APP_ID = " + paymentAppIdComboBoxValue + "\n CURRENCY = " + currencyComboBoxValue + "\n ECR_REF_NO = " + ecrRefNoTextBoxValue;
+ else
+ this.requestStrByThead = " EVENT_NAME : " + currEventName + "\n TXN_ID = " + txnIdForSale + "\n TXN_AMT = " + txnAmtTextBoxValue + "\n PAYMENT_APP_ID = " + paymentAppIdComboBoxValue + "\n CURRENCY = " + currencyComboBoxValue + "\n ECR_REF_NO = " + ecrRefNoTextBoxValue;
showResult();
- addLog("txnId = " + txnIdForSale + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue + ",qrValue = " + qrValueTextBoxValue);
+ addLog("txnId = " + txnIdForSale + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue + ",currency = " + currencyComboBoxValue);
//jsonResultByThead = n5Core.requestSale(this.getTxnId(), txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
this.saleRequestMsg = this.requestStrByThead;
@@ -322,170 +394,22 @@ namespace ECR_N5_DLL_TestUI
}
}
- else if("Adjust".Equals(this.thisEvent))
- {
- if (this.txnAmtTextBox.Text == null || "".Equals(this.txnAmtTextBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.txnAmtTextBox.Focus();
- return;
- }
- else if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.paymentAppIdComboBox.Focus();
- return;
- }
- else
- {
- txnAmtTextBoxValue = this.txnAmtTextBox.Text;
- paymentAppIdComboBoxValue = this.paymentAppIdComboBox.Text;
- qrValueTextBoxValue = this.qrValueTextBox.Text;
- panTextBoxValue = this.panTextBox.Text;
- expDateTextBoxValue = this.expDateTextBox.Text;
-
- txnIdForSale = this.getTxnId();
- this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForPreAuth + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue + "\n qrValue = " + qrValueTextBoxValue;
- showResult();
- addLog("txnId = " + txnIdForPreAuth + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue + ",qrValue = " + qrValueTextBoxValue);
- //jsonResultByThead = n5Core.requestSale(this.getTxnId(), txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
- this.preAuthRequestMsg = this.requestStrByThead;
-
- Thread th = new Thread(requestPreauthThead);
- th.Start();
- }
-
- }
- else if ("PreAuth".Equals(this.thisEvent))
- {
- if (this.txnAmtTextBox.Text == null || "".Equals(this.txnAmtTextBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.txnAmtTextBox.Focus();
- return;
- }
- else if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.paymentAppIdComboBox.Focus();
- return;
- }
- else
- {
- txnAmtTextBoxValue = this.txnAmtTextBox.Text;
- paymentAppIdComboBoxValue = this.paymentAppIdComboBox.Text;
- panTextBoxValue = this.panTextBox.Text;
- expDateTextBoxValue = this.expDateTextBox.Text;
-
- txnIdForPreAuth = this.getTxnId();
- this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForPreAuth + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue;
- showResult();
- addLog("txnId = " + txnIdForPreAuth + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue);
- //jsonResultByThead = n5Core.requestSale(this.getTxnId(), txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
- this.preAuthRequestMsg = this.requestStrByThead;
-
- Thread th = new Thread(requestPreauthThead);
- th.Start();
- }
-
- }
- else if ("Offline".Equals(this.thisEvent))
- {
- if (this.txnAmtTextBox.Text == null || "".Equals(this.txnAmtTextBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.txnAmtTextBox.Focus();
- return;
- }
- else if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.paymentAppIdComboBox.Focus();
- return;
- }
- else
- {
- txnAmtTextBoxValue = this.txnAmtTextBox.Text;
- paymentAppIdComboBoxValue = this.paymentAppIdComboBox.Text;
- qrValueTextBoxValue = this.qrValueTextBox.Text;
- panTextBoxValue = this.panTextBox.Text;
- authCodeTextBoxValue = this.authCodeTextBox.Text;
- expDateTextBoxValue = this.expDateTextBox.Text;
-
- txnIdForOffline = this.getTxnId();
- this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForOffline + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue;
- showResult();
- addLog("txnId = " + txnIdForOffline + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue );
- //jsonResultByThead = n5Core.requestSale(this.getTxnId(), txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
- this.offlineRequestMsg = this.requestStrByThead;
-
- Thread th = new Thread(requestOfflineThead);
- th.Start();
- }
-
- }
- else if ("Refund".Equals(this.thisEvent))
- {
- if (this.txnAmtTextBox.Text == null || "".Equals(this.txnAmtTextBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.txnAmtTextBox.Focus();
- }
- else if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.paymentAppIdComboBox.Focus();
- return;
- }
- else
- {
- txnAmtTextBoxValue = this.txnAmtTextBox.Text;
- paymentAppIdComboBoxValue = this.paymentAppIdComboBox.Text;
- qrValueTextBoxValue = this.qrValueTextBox.Text;
-
- txnIdForRefund = this.getTxnId();
- this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForRefund + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue + "\n qrValue = " + qrValueTextBoxValue;
- showResult();
- addLog("txnId = " + txnIdForRefund + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue + ",qrValue = " + qrValueTextBoxValue);
-
- //jsonResultByThead = n5Core.requestRefund(txnId, txnAmtTextBoxValue, paymentAppIdComboBoxValue, qrValueTextBoxValue);
- this.refundRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestRefundThead);
- th.Start();
- }
- }
- else if ("Retrieval".Equals(this.thisEvent))
+ else if ("RETRIEVAL".Equals(this.thisEvent))
{
- if (this.ecrTxnIdTextBox.Text == null || "".Equals(this.ecrTxnIdTextBox.Text.Trim()))
+ if (this.retrieval_traceNoTextBox.Text == null || "".Equals(this.retrieval_traceNoTextBox.Text.Trim()))
{
this.requestStrByThead = "Please input parameter.";
this.jsonResultByThead = "Please input parameter.";
showResult();
- this.ecrTxnIdTextBox.Focus();
+ this.retrieval_traceNoTextBox.Focus();
return;
}
else
{
- ecrTxnIdTextBoxValue = this.ecrTxnIdTextBox.Text;
- this.requestStrByThead = "Test Function : " + currEventName + "\n ecrTxnId = " + ecrTxnIdTextBoxValue;
+ ecrTxnIdTextBoxValue = "";
+ traceNoTextBoxValue = this.retrieval_traceNoTextBox.Text;
+ this.requestStrByThead = " EVENT_NAME : " + currEventName + "\n PAYMENT_APP_ID = " + "EPS" + "\n TRACE_NO = " + traceNoTextBoxValue;
showResult();
- addLog("ecrTxnId = " + ecrTxnIdTextBoxValue);
//jsonResultByThead = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, 180000);
this.retrievalRequestMsg = this.requestStrByThead;
@@ -493,31 +417,7 @@ namespace ECR_N5_DLL_TestUI
th.Start();
}
}
- else if ("Void".Equals(this.thisEvent))
- {
- if (this.ecrTxnIdTextBox.Text == null || "".Equals(this.ecrTxnIdTextBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.ecrTxnIdTextBox.Focus();
- return;
- }
- else
- {
- qrValueTextBoxValue = this.qrValueTextBox.Text;
- ecrTxnIdTextBoxValue = this.ecrTxnIdTextBox.Text;
-
- this.requestStrByThead = "Test Function : " + currEventName + "\n ecrTxnId = " + ecrTxnIdTextBoxValue + "\n qrValue = " + qrValueTextBoxValue;
- showResult();
- addLog("ecrTxnId = " + ecrTxnIdTextBoxValue + ", qrValue = " + qrValueTextBoxValue);
- // jsonResultByThead = n5Core.requestVoid(ecrTxnIdTextBoxValue, qrValueTextBoxValue);
- this.voidRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestVoidThead);
- th.Start();
- }
- }
- else if ("Settlement".Equals(this.thisEvent))
+ else if ("SETTLE".Equals(this.thisEvent))
{
this.requestStrByThead = "Test Function : " + currEventName;
showResult();
@@ -527,7 +427,7 @@ namespace ECR_N5_DLL_TestUI
Thread th = new Thread(requestSettlementThead);
th.Start();
}
- else if ("Link Request".Equals(this.thisEvent))
+ else if ("Link Test".Equals(this.thisEvent))
{
this.requestStrByThead = "Test Function : " + currEventName;
showResult();
@@ -536,90 +436,24 @@ namespace ECR_N5_DLL_TestUI
Thread th = new Thread(requestLinkRequestThead);
th.Start();
}
- else if ("Reprint".Equals(this.thisEvent))
+ else if ("PRINT".Equals(this.thisEvent))
{
- this.requestStrByThead = "Test Function : " + currEventName;
- showResult();
- //jsonResultByThead = n5Core.sendReprintRequest();
- this.reprintRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestReprintThead);
- th.Start();
- }
- else if ("Terminaion".Equals(this.thisEvent))
- {
- this.requestStrByThead = "Test Function : " + currEventName;
- showResult();
- //jsonResultByThead = n5Core.sendAbortRequest();
- this.terminaionRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestTerminaionThead);
- th.Start();
- }
- else if ("Scan".Equals(this.thisEvent))
- {
- this.requestStrByThead = "Test Function : " + currEventName;
- showResult();
- //jsonResultByThead = n5Core.sendAbortRequest();
- this.scanRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestScanThread);
- th.Start();
- }
- else if ("ReadCard".Equals(this.thisEvent))
- {
- this.requestStrByThead = "Test Function : " + currEventName;
- showResult();
- //jsonResultByThead = n5Core.sendAbortRequest();
- this.readCardRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestReadCardNFCThead);
- th.Start();
- }
- else if ("AddPoint".Equals(this.thisEvent))
- {
- this.requestStrByThead = "Test Function : " + currEventName;
- ecrTxnIdTextBoxValue = this.ecrTxnIdTextBox.Text;
- txnAmtTextBoxValue = this.txnAmtTextBox.Text;
- showResult();
- //jsonResultByThead = n5Core.sendAbortRequest();
- this.addPointRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestAddPointThead);
- th.Start();
- }
- else if ("BatchEnquiry".Equals(this.thisEvent))
- {
- if (this.settleDateTextBox.Text == null || "".Equals(this.settleDateTextBox.Text.Trim()))
+ if (this.print_traceNoTextBox.Text == null || "".Equals(this.print_traceNoTextBox.Text.Trim()))
{
this.requestStrByThead = "Please input parameter.";
this.jsonResultByThead = "Please input parameter.";
showResult();
- this.settleDateTextBox.Focus();
+ this.print_traceNoTextBox.Focus();
return;
}
else
{
- this.settleDateTextBoxValue = this.settleDateTextBox.Text;
- this.requestStrByThead = "Test Function : " + currEventName;
+ traceNoTextBoxValue = this.retrieval_traceNoTextBox.Text;
+ this.requestStrByThead = " EVENT_NAME : " + currEventName + "\n PAYMENT_APP_ID = " + "EPS" + "\n TRACE_NO = " + traceNoTextBoxValue;
showResult();
- this.batchEnquiryRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestBatchEnquiryThead);
- th.Start();
- }
- }
- else if ("SettleEnquiry".Equals(this.thisEvent))
- {
- if (this.batchIdTextBox.Text == null || "".Equals(this.batchIdTextBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.batchIdTextBox.Focus();
- return;
- }
- else
- {
- this.batchIdTextBoxValue = this.batchIdTextBox.Text;
- this.requestStrByThead = "Test Function : " + currEventName;
- showResult();
- this.settleEnquiryRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestSettleEnquiryThead);
+ //jsonResultByThead = n5Core.sendReprintRequest();
+ this.reprintRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestReprintThead);
th.Start();
}
}
@@ -648,269 +482,38 @@ namespace ECR_N5_DLL_TestUI
{
this.logPathTextBox.Text = "Log Path : " + System.IO.Path.GetTempPath() + "\\myN5TestWin.log";
}
-
- if ("Sale".Equals(this.thisEvent))
- {
- this.ecrTxnIdTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = true;
- if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
- {
- this.paymentAppIdComboBox.Text = "CC";
- }
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.paymentAppIdComboBox.IsEnabled = true;
- this.qrValueTextBox.IsEnabled = true;
- this.panTextBox.IsEnabled = true;
- this.expDateTextBox.IsEnabled = true;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
- }
- else if("PreAuth".Equals(this.thisEvent))
- {
- this.ecrTxnIdTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = true;
- if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
- {
- this.paymentAppIdComboBox.Text = "CC";
- }
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.paymentAppIdComboBox.IsEnabled = true;
- this.panTextBox.IsEnabled = true;
- this.expDateTextBox.IsEnabled = true;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
- }
- else if ("Offline".Equals(this.thisEvent))
+ showInput(this.thisEvent);
+ if ("SALE".Equals(this.thisEvent))
{
- this.ecrTxnIdTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = true;
- if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
+ this.sale_ecrTxnIdTextBox.Text = "";
+ this.sale_ecrRefNoTextBox.Text = "";
+ this.sale_txnAmtTextBox.Text = "";
+ this.sale_cashbackAmtTextBox.Text = "";
+ if (this.sale_paymentAppIdComboBox.Text == null || "".Equals(this.sale_paymentAppIdComboBox.Text))
{
- this.paymentAppIdComboBox.Text = "CC";
+ this.sale_paymentAppIdComboBox.Text = "EPS";
}
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.paymentAppIdComboBox.IsEnabled = true;
- this.panTextBox.IsEnabled = true;
- this.authCodeTextBox.IsEnabled = true;
- this.expDateTextBox.IsEnabled = true;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
- }
- else if ("Adjust".Equals(this.thisEvent))
- {
- this.ecrTxnIdTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = true;
- if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
- {
- this.paymentAppIdComboBox.Text = "CC";
- }
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.paymentAppIdComboBox.IsEnabled = true;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
- }
- else if ("Refund".Equals(this.thisEvent))
- {
- this.ecrTxnIdTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = true;
- if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
- {
- this.paymentAppIdComboBox.Text = "CC";
- }
- this.batchIdTextBox.Text = "";
- this.paymentAppIdComboBox.IsEnabled = true;
- this.qrValueTextBox.IsEnabled = true;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
- }
- else if ("Retrieval".Equals(this.thisEvent))
- {
- this.txnAmtTextBox.Text = "";
- this.paymentAppIdComboBox.Text = "";
- this.qrValueTextBox.Text = "";
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = false;
- this.paymentAppIdComboBox.IsEnabled = false;
- this.qrValueTextBox.IsEnabled = false;
- this.ecrTxnIdTextBox.IsEnabled = true;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
}
- else if ("Void".Equals(this.thisEvent))
+ else if ("RETRIEVAL".Equals(this.thisEvent))
{
- this.txnAmtTextBox.Text = "";
- this.paymentAppIdComboBox.Text = "";
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = false;
- this.paymentAppIdComboBox.IsEnabled = false;
- this.qrValueTextBox.IsEnabled = true;
- this.ecrTxnIdTextBox.IsEnabled = true;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
+ this.retrieval_traceNoTextBox.Text = "";
}
- else if ("Settlement".Equals(this.thisEvent))
+ else if ("PRINT".Equals(this.thisEvent))
{
- this.txnAmtTextBox.Text = "";
- this.paymentAppIdComboBox.Text = "";
- this.qrValueTextBox.Text = "";
- this.ecrTxnIdTextBox.Text = "";
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = false;
- this.paymentAppIdComboBox.IsEnabled = false;
- this.qrValueTextBox.IsEnabled = false;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
+ this.print_traceNoTextBox.Text = "";
}
- else if ("Link Request".Equals(this.thisEvent))
+ else if ("SETTLE".Equals(this.thisEvent))
{
- this.txnAmtTextBox.Text = "";
- this.paymentAppIdComboBox.Text = "";
- this.qrValueTextBox.Text = "";
- this.ecrTxnIdTextBox.Text = "";
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = false;
- this.paymentAppIdComboBox.IsEnabled = false;
- this.qrValueTextBox.IsEnabled = false;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
+ settle_valuedate_combox.Items.Clear();
}
- else if ("Terminaion".Equals(this.thisEvent))
+ else if ("Link Test".Equals(this.thisEvent))
{
- this.txnAmtTextBox.Text = "";
- this.paymentAppIdComboBox.Text = "";
- this.qrValueTextBox.Text = "";
- this.ecrTxnIdTextBox.Text = "";
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = false;
- this.paymentAppIdComboBox.IsEnabled = false;
- this.qrValueTextBox.IsEnabled = false;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
- }
- else if ("Scan".Equals(this.thisEvent))
- {
- this.txnAmtTextBox.Text = "";
- this.paymentAppIdComboBox.Text = "";
- this.qrValueTextBox.Text = "";
- this.ecrTxnIdTextBox.Text = "";
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = false;
- this.paymentAppIdComboBox.IsEnabled = false;
- this.qrValueTextBox.IsEnabled = false;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
- }
- else if ("ReadCard".Equals(this.thisEvent))
- {
- this.txnAmtTextBox.Text = "";
- this.paymentAppIdComboBox.Text = "";
- this.qrValueTextBox.Text = "";
- this.ecrTxnIdTextBox.Text = "";
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = false;
- this.paymentAppIdComboBox.IsEnabled = false;
- this.qrValueTextBox.IsEnabled = false;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
- }
- else if ("AddPoint".Equals(this.thisEvent))
- {
- this.txnAmtTextBox.Text = "";
- this.paymentAppIdComboBox.Text = "";
- this.qrValueTextBox.Text = "";
- this.ecrTxnIdTextBox.Text = "";
- this.batchIdTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = true;
- this.paymentAppIdComboBox.IsEnabled = false;
- this.qrValueTextBox.IsEnabled = false;
- this.ecrTxnIdTextBox.IsEnabled = true;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = false;
- }
- else if ("BatchEnquiry".Equals(this.thisEvent))
- {
- this.txnAmtTextBox.Text = "";
- this.paymentAppIdComboBox.Text = "";
- this.qrValueTextBox.Text = "";
- this.ecrTxnIdTextBox.Text = "";
- this.panTextBox.Text = "";
- this.authCodeTextBox.Text = "";
- this.expDateTextBox.Text = "";
- this.batchIdTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = false;
- this.paymentAppIdComboBox.IsEnabled = false;
- this.qrValueTextBox.IsEnabled = false;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.panTextBox.IsEnabled = false;
- this.authCodeTextBox.IsEnabled = false;
- this.expDateTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = false;
- this.settleDateTextBox.IsEnabled = true;
- }
- else if ("SettleEnquiry".Equals(this.thisEvent))
- {
- this.txnAmtTextBox.Text = "";
- this.paymentAppIdComboBox.Text = "";
- this.qrValueTextBox.Text = "";
- this.ecrTxnIdTextBox.Text = "";
- this.panTextBox.Text = "";
- this.authCodeTextBox.Text = "";
- this.expDateTextBox.Text = "";
- this.settleDateTextBox.Text = "";
- this.txnAmtTextBox.IsEnabled = false;
- this.paymentAppIdComboBox.IsEnabled = false;
- this.qrValueTextBox.IsEnabled = false;
- this.ecrTxnIdTextBox.IsEnabled = false;
- this.panTextBox.IsEnabled = false;
- this.authCodeTextBox.IsEnabled = false;
- this.expDateTextBox.IsEnabled = false;
- this.batchIdTextBox.IsEnabled = true;
- this.settleDateTextBox.IsEnabled = false;
+
}
}
- private void Submit_Repeat_Button_Click(object sender, RoutedEventArgs e)
- {
- this.requestTextBox.Text = string.Empty;
- this.result1TextBox.Text = string.Empty;
- if (!isRepeatSubmit)
- {
- this.submit_repeat_Button.Content = "Stop Repeat";
- isRepeatSubmit = true;
- addRepeatLog("==========Repeat start========== ");
- this.sendRepeatSubmit();
- }
- else
- {
- this.submit_repeat_Button.Content = "Start Repeat";
- isRepeatSubmit = false;
- this.stopRepeatSubmit();
- addRepeatLog("==========Repeat end========== ");
- }
- }
+
private void Submit_1_Button_Click(object sender, RoutedEventArgs e)
{
@@ -1032,6 +635,36 @@ namespace ECR_N5_DLL_TestUI
return 0;
}
+ private string batchResult = "";
+ private string selectedBatchStr = "";
+ private int showSettleResult()
+ {
+ //this.requestTextBox.Text = this.requestStrByThead;
+ requestTextBox.Dispatcher.Invoke(
+ DispatcherPriority.Normal, TimeSpan.FromSeconds(1), new Action(showRequestTxtBox));
+
+ showResultStr = this.jsonResultByThead.Replace("{", "").Replace("}", "").Replace(",", "\n");
+ //this.result1TextBox.Text = showResultStr;
+
+ result1TextBox.Dispatcher.Invoke(
+ DispatcherPriority.Normal, TimeSpan.FromSeconds(1), new Action(showResultTxtBox));
+ JObject jsonObj = null;
+ try
+ {
+ jsonObj = JObject.Parse(jsonResultByThead);
+ if (jsonObj.GetValue("STATUS").ToString().Equals("00"))
+ {
+ batchResult = (String)jsonObj.GetValue("BATCH");
+ settle_valuedate_combox.Dispatcher.Invoke(DispatcherPriority.Normal, TimeSpan.FromSeconds(1), new Action(showSettleComboBox));
+ showSettleComboBox();
+ }
+ else
+ batchResult = "";
+ }
+ catch (Exception ex) { }
+ return 0;
+ }
+
private void showRequestTxtBox()
{
this.requestTextBox.Text = requestStrByThead;
@@ -1042,6 +675,57 @@ namespace ECR_N5_DLL_TestUI
this.result1TextBox.Text = showResultStr;
}
+ private void showBatchResult()
+ {
+ this.result1TextBox.Text = selectedBatchStr;
+ }
+
+ private void showSettleComboBox()
+ {
+ sale_currencyComboBox.Visibility = Visibility.Hidden;
+ settle_valuedate_combox.Visibility = Visibility.Visible;
+ settle_valuedate_lbl.Visibility = Visibility.Visible;
+ if (batchResult != null)
+ {
+ JArray jlist = JArray.Parse(batchResult);
+ for (int i = 0; i < jlist.Count; ++i) //遍历JArray
+ {
+ JObject tempo = JObject.Parse(jlist[i].ToString());
+ settle_valuedate_combox.Items.Add(tempo.GetValue("BANKIN_VALUE_DATE"));
+ }
+ settle_valuedate_combox.Items.Add("show all");
+ settle_valuedate_combox.SelectedIndex = settle_valuedate_combox.Items.Count - 1;
+ }
+ }
+
+ private void ValueDayComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ try
+ {
+ if (this.settle_valuedate_combox.SelectedItem.ToString().Equals("show all"))
+ {
+ showResultTxtBox();
+ }
+ else
+ {
+ if (batchResult != null)
+ {
+ JArray jlist = JArray.Parse(batchResult);
+ for (int i = 0; i < jlist.Count; ++i) //遍历JArray
+ {
+ JObject tempo = JObject.Parse(jlist[i].ToString());
+ if (tempo.GetValue("BANKIN_VALUE_DATE").ToString().Equals(this.settle_valuedate_combox.SelectedItem.ToString()))
+ {
+ selectedBatchStr = tempo.ToString();
+ showBatchResult();
+ }
+ }
+ }
+ }
+ }
+ catch (Exception ex) { }
+ }
+
private void PortNameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
this.n5CoreInitSuccess = false;
diff --git a/ECR_N5_DLL_TestUI/packages.config b/ECR_N5_DLL_TestUI/packages.config
new file mode 100644
index 0000000..0fa4e01
--- /dev/null
+++ b/ECR_N5_DLL_TestUI/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/n5coredll/LogUtil.cs b/n5coredll/LogUtil.cs
new file mode 100644
index 0000000..b4726dd
--- /dev/null
+++ b/n5coredll/LogUtil.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace n5coredll
+{
+ public class LogUtil
+ {
+ private static String mLogPath;
+ private static LogUtil mInstance;
+ public static LogUtil getInstance()
+ {
+ if (mInstance == null)
+ mInstance = new LogUtil();
+
+ return mInstance;
+ }
+
+ public void setLogPath(String logPath)
+ {
+ if (logPath.EndsWith(@"\"))
+ mLogPath = logPath;
+ else
+ mLogPath = logPath + @"\";
+ }
+
+ private String getCurLogFile()
+ {
+
+ StringBuilder txnIdSb = new StringBuilder();
+ DateTime dt = DateTime.Now;
+ return ("n5dll" + "_" + dt.ToString("yyyyMMdd") +".log");
+ }
+
+ public void addRepeatLog(string logInfo)
+ {
+ try
+ {
+ String path = mLogPath + getCurLogFile();
+ //path = @"C:\Users\rexli\AppData\Local\Temp\test.log";
+ if (!File.Exists(path))
+ {
+ using (StreamWriter sw = File.CreateText(path))
+ {
+ sw.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss:ffff") + " [LOGGER] " + logInfo);
+ sw.Flush();
+ sw.Close();
+ }
+
+ }
+ else
+ {
+ using (StreamWriter sw = File.AppendText(path))
+ {
+ sw.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss:ffff") + " [LOGGER] " + logInfo);
+ sw.Flush();
+ sw.Close();
+ }
+
+ }
+ // Console.WriteLine(logInfo);
+
+ }
+ catch (Exception err)
+ {
+ Console.WriteLine("Exception = " + err);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/n5coredll/N5Core.cs b/n5coredll/N5Core.cs
index 2d910cc..498255e 100644
--- a/n5coredll/N5Core.cs
+++ b/n5coredll/N5Core.cs
@@ -97,11 +97,7 @@ namespace n5coredll
bool result = openSerialPort();
if (result)
{
- String echoResult = sendLinkTestRequest();
- if (RequestResult.toReqResultFromJsonMsg(echoResult).Status == STATUS_SUCC)
- return 0;
- else
- return - 1;
+ return 0;
}
else
return -1;
@@ -157,187 +153,15 @@ namespace n5coredll
}*/
//For Pacific Coffee only
- public string requestManualSale(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue, string pan, string expDate)
- {
- return processSale(dtxnId, dtxnAmt, dtipAmt, appId, qrcValue, pan, expDate);
- }
-
- public string requestSale(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue)
- {
- return processSale(dtxnId, dtxnAmt, dtipAmt, appId, qrcValue, "","");
- }
-
- public string requestSale(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue, string pTimeout)
- {
- return processSale(dtxnId, dtxnAmt, dtipAmt, appId, qrcValue, "", "", pTimeout);
- }
- public string requestSaleWithTimeout(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue, string pTimeout)
+ public string requestSaleWithTimeout(string dtxnId, string dtxnAmt, string dtipAmt, string dCashbackAmt, string ecrRefNo, string currency, string appId, string qrcValue, string pTimeout)
{
- return processSale(dtxnId, dtxnAmt, dtipAmt, appId, qrcValue, "", "", pTimeout);
+ return processEPSSale(dtxnId, dtxnAmt, dtipAmt, dCashbackAmt, ecrRefNo, currency, appId, qrcValue, "", "", pTimeout);
}
- public string requestRefund(string dtxnId, string dtxnAmt, string appId, string qrcValue)
- {
- return processRefund(dtxnId, dtxnAmt, appId, qrcValue);
- }
- private string processSale(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue, string pan, string expDate)
- {
- if (ifBusy)
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_BUSY);
- ifBusy = true;
- SaleResult saleResult = null;
- decimal txnAmt = decimal.Parse(dtxnAmt);
- decimal tipAmt = decimal.Parse(dtipAmt);
- if (txnAmt.CompareTo(decimal.Parse("0")) < 1 || tipAmt.CompareTo(decimal.Parse("0")) < 0)
- {
- Console.WriteLine("dtxnAmt or dtipAmt parameter error");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_PARAM);
- }
-
- sendTime = 0;
- isSending = false;
- mRecvTimes = 0;
- isReadyBack = false;
- currReqByteArr = null;
- currResultJsonStr = null;
- isGetACK = false;
- if (openSerialPort())
- {
- PaymentApp tmpAppId = ObjectUtil.getPaymentApp(appId);
- /*
- if (appId == "CC")
- tmpAppId = PaymentApp.CC;
- else if (appId == "QRC")
- tmpAppId = PaymentApp.QRC;
- else if (appId == "AMEX")
- tmpAppId = PaymentApp.AMEX;
- else if (appId == "CPN")
- tmpAppId = PaymentApp.CPN;
- else if (appId == "DC")
- tmpAppId = PaymentApp.DC;
- else if (appId == "NONE")
- tmpAppId = PaymentApp.NONE;
- else
- tmpAppId = PaymentApp.NONE;
- */
- if (dtxnId == null)
- dtxnId = getTxnId();
-
- string reqSaleStr = SaleResult.toJsonForSale(dtxnId, txnAmt, tipAmt, tmpAppId, qrcValue,pan,expDate);
- Console.WriteLine("reqSaleStr = " + reqSaleStr);
- if (reqSaleStr == null || "".Equals(reqSaleStr))
- {
- Console.WriteLine("reqSaleStr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_PARAM);
- }
- currReqByteArr = packReqMsg(reqSaleStr);
- if (currReqByteArr == null || currReqByteArr.Length == 0)
- {
- Console.WriteLine("currReqByteArr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_PARAM);
- }
-
- Console.WriteLine("currReqByteArr = " + currReqByteArr);
- Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
- saleResult = null;
- this.sendReqMsg();
- }
- else
- {
- Console.WriteLine("serialPort no open. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_OPENCOM);
- }
-
- int sleepTime = timeOut / 1000;
- DateTime startTime = DateTime.Now;
-
- Boolean ifEnd = false;
- int inqCount = 0;
- DateTime lastInqTime = DateTime.Now;
- while (!ifEnd)
- {
- DateTime nowTime = DateTime.Now;
- TimeSpan sp = nowTime - startTime;
- if (sp.TotalSeconds > sleepTime)
- ifEnd = true;
- else if (sp.TotalSeconds < 30)
- {
- if (!isSending && !isGetACK)
- this.resendReqMsg();
- if (isReadyBack)
- {
- closeSerialPort();
- if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
- {
- ifBusy = false;
- return currResultJsonStr;
- }
- }
- }
- else
- {
- closeSerialPort();
- TimeSpan txnInqSp = nowTime - lastInqTime;
- if (inqCount >= 12)
- ifEnd = true;
- else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
- {
- string retrivReusltStr = requestRetrieval(dtxnId, 10000);
- inqCount++;
- lastInqTime = DateTime.Now;
- if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
- {
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- ifBusy = false;
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string saleResultStr = "{\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
-
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
- ifBusy = false;
- return saleResultStr;
- }
-
- }
- }
- isReadyBack = false;
- }
- }
-
-
- Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_TIMEOUT);
- }
-
- private string processSale(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue, string pan, string expDate, string pTimeout)
+
+ private string processEPSSale(string dtxnId, string dtxnAmt, string dtipAmt, string dCashbackAmt, string ecrRefNo, string currency, string appId, string qrcValue, string pan, string expDate, string pTimeout)
{
if (ifBusy)
return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_BUSY);
@@ -345,6 +169,9 @@ namespace n5coredll
SaleResult saleResult = null;
decimal txnAmt = decimal.Parse(dtxnAmt);
decimal tipAmt = decimal.Parse(dtipAmt);
+ decimal cashbackAmt = 0;
+ if (dCashbackAmt != "")
+ cashbackAmt = decimal.Parse(dCashbackAmt);
if (txnAmt.CompareTo(decimal.Parse("0")) < 1 || tipAmt.CompareTo(decimal.Parse("0")) < 0)
{
Console.WriteLine("dtxnAmt or dtipAmt parameter error");
@@ -382,7 +209,7 @@ namespace n5coredll
if (dtxnId == null)
dtxnId = getTxnId();
- string reqSaleStr = SaleResult.toJsonForSale(dtxnId, txnAmt, tipAmt, tmpAppId, qrcValue, pan, expDate);
+ string reqSaleStr = SaleResult.toJsonForSale(dtxnId, txnAmt, tipAmt, cashbackAmt, ecrRefNo, currency, tmpAppId, qrcValue, pan, expDate);
Console.WriteLine("reqSaleStr = " + reqSaleStr);
if (reqSaleStr == null || "".Equals(reqSaleStr))
{
@@ -430,7 +257,7 @@ namespace n5coredll
TimeSpan sp = nowTime - startTime;
if (sp.TotalSeconds > sleepTime)
ifEnd = true;
- else if (sp.TotalSeconds < 30)
+ else
{
if (!isSending && !isGetACK)
this.resendReqMsg();
@@ -440,840 +267,15 @@ namespace n5coredll
if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
{
ifBusy = false;
+ currResultJsonStr = SaleResult.rebuildSaleRespMsg(currResultJsonStr);
return currResultJsonStr;
}
}
}
- else
- {
- closeSerialPort();
- TimeSpan txnInqSp = nowTime - lastInqTime;
- //if (inqCount >= 12)
- // ifEnd = true;
- if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
- {
- retrivReusltStr = requestRetrieval(dtxnId, 10000);
- inqCount++;
- lastInqTime = DateTime.Now;
- if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
- {
- retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- ifBusy = false;
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string saleResultStr = "{\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
-
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
- ifBusy = false;
- return saleResultStr;
- }
-
- }
- }
- isReadyBack = false;
- }
- }
-
- //Do last txn inquiry
- retrivReusltStr = requestRetrieval(dtxnId, 10000);
- retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- ifBusy = false;
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string saleResultStr = "{\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
-
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
- ifBusy = false;
- return saleResultStr;
}
-
-
+ ifBusy = false;
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_TIMEOUT);
- }
-
- public string processPreauth(string dtxnId, string dtxnAmt, string appId, string pan, string expDate)
- {
- if (ifBusy)
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_BUSY);
- ifBusy = true;
- SaleResult saleResult = null;
- decimal txnAmt = decimal.Parse(dtxnAmt);
- if (txnAmt.CompareTo(decimal.Parse("0")) < 1)
- {
- Console.WriteLine("dtxnAmt or dtipAmt parameter error");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_PARAM);
- }
-
- sendTime = 0;
- isSending = false;
- mRecvTimes = 0;
- isReadyBack = false;
- currReqByteArr = null;
- currResultJsonStr = null;
- isGetACK = false;
- if (openSerialPort())
- {
- PaymentApp tmpAppId = ObjectUtil.getPaymentApp(appId);
- /*
- if (appId == "CC")
- tmpAppId = PaymentApp.CC;
- else if (appId == "QRC")
- tmpAppId = PaymentApp.QRC;
- else if (appId == "AMEX")
- tmpAppId = PaymentApp.AMEX;
- else if (appId == "CPN")
- tmpAppId = PaymentApp.CPN;
- else if (appId == "DC")
- tmpAppId = PaymentApp.DC;
- else if (appId == "NONE")
- tmpAppId = PaymentApp.NONE;
- else
- tmpAppId = PaymentApp.NONE;
- */
- if (dtxnId == null)
- dtxnId = getTxnId();
-
- string reqPreauthStr = SaleResult.toJsonForPreauth(dtxnId, txnAmt, tmpAppId, pan, expDate);
- Console.WriteLine("reqPreauthStr = " + reqPreauthStr);
- if (reqPreauthStr == null || "".Equals(reqPreauthStr))
- {
- Console.WriteLine("reqPreauthStr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_PARAM);
- }
- currReqByteArr = packReqMsg(reqPreauthStr);
- if (currReqByteArr == null || currReqByteArr.Length == 0)
- {
- Console.WriteLine("currReqByteArr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_PARAM);
- }
-
- Console.WriteLine("currReqByteArr = " + currReqByteArr);
- Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
- saleResult = null;
- this.sendReqMsg();
- }
- else
- {
- Console.WriteLine("serialPort no open. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_OPENCOM);
- }
-
- int sleepTime = timeOut / 1000;
- DateTime startTime = DateTime.Now;
-
- Boolean ifEnd = false;
- int inqCount = 0;
- DateTime lastInqTime = DateTime.Now;
- while (!ifEnd)
- {
- DateTime nowTime = DateTime.Now;
- TimeSpan sp = nowTime - startTime;
- if (sp.TotalSeconds > sleepTime)
- ifEnd = true;
- else if (sp.TotalSeconds < 30)
- {
- if (!isSending && !isGetACK)
- this.resendReqMsg();
- if (isReadyBack)
- {
- closeSerialPort();
- if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
- {
- ifBusy = false;
- return currResultJsonStr;
- }
- }
- }
- else
- {
- closeSerialPort();
- TimeSpan txnInqSp = nowTime - lastInqTime;
- if (inqCount >= 12)
- ifEnd = true;
- else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
- {
- string retrivReusltStr = requestRetrieval(dtxnId, 10000);
- inqCount++;
- lastInqTime = DateTime.Now;
- if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
- {
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "PREAUTH_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- ifBusy = false;
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string saleResultStr = "{\"EVENT_NAME\":\"PREAUTH_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + "}";
-
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
- ifBusy = false;
- return saleResultStr;
- }
-
- }
- }
- isReadyBack = false;
- }
- }
-
-
- Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_TIMEOUT);
- }
-
-
-
- public string processOffline(string dtxnId, string dtxnAmt, string appId, string authCode, string pan, string expDate)
- {
- if (ifBusy)
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_BUSY);
- ifBusy = true;
- SaleResult saleResult = null;
- decimal txnAmt = decimal.Parse(dtxnAmt);
- if (txnAmt.CompareTo(decimal.Parse("0")) < 1 )
- {
- Console.WriteLine("dtxnAmt or dtipAmt parameter error");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_PARAM);
- }
-
- sendTime = 0;
- isSending = false;
- mRecvTimes = 0;
- isReadyBack = false;
- currReqByteArr = null;
- currResultJsonStr = null;
- isGetACK = false;
- if (openSerialPort())
- {
- PaymentApp tmpAppId = ObjectUtil.getPaymentApp(appId);
- /*
- if (appId == "CC")
- tmpAppId = PaymentApp.CC;
- else if (appId == "QRC")
- tmpAppId = PaymentApp.QRC;
- else if (appId == "AMEX")
- tmpAppId = PaymentApp.AMEX;
- else if (appId == "CPN")
- tmpAppId = PaymentApp.CPN;
- else if (appId == "DC")
- tmpAppId = PaymentApp.DC;
- else if (appId == "NONE")
- tmpAppId = PaymentApp.NONE;
- else
- tmpAppId = PaymentApp.NONE;
- */
- if (dtxnId == null)
- dtxnId = getTxnId();
-
- string reqOfflineStr = SaleResult.toJsonForOffline(dtxnId, txnAmt, tmpAppId, authCode, pan, expDate);
- Console.WriteLine("reqOfflineStr = " + reqOfflineStr);
- if (reqOfflineStr == null || "".Equals(reqOfflineStr))
- {
- Console.WriteLine("reqOfflineStr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_PARAM);
- }
- currReqByteArr = packReqMsg(reqOfflineStr);
- if (currReqByteArr == null || currReqByteArr.Length == 0)
- {
- Console.WriteLine("currReqByteArr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_PARAM);
- }
-
- Console.WriteLine("currReqByteArr = " + currReqByteArr);
- Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
- saleResult = null;
- this.sendReqMsg();
- }
- else
- {
- Console.WriteLine("serialPort no open. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_OPENCOM);
- }
-
- int sleepTime = timeOut / 1000;
- DateTime startTime = DateTime.Now;
-
- Boolean ifEnd = false;
- int inqCount = 0;
- DateTime lastInqTime = DateTime.Now;
- while (!ifEnd)
- {
- DateTime nowTime = DateTime.Now;
- TimeSpan sp = nowTime - startTime;
- if (sp.TotalSeconds > sleepTime)
- ifEnd = true;
- else if (sp.TotalSeconds < 30)
- {
- if (!isSending && !isGetACK)
- this.resendReqMsg();
- if (isReadyBack)
- {
- closeSerialPort();
- if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
- {
- ifBusy = false;
- return currResultJsonStr;
- }
- }
- }
- else
- {
- closeSerialPort();
- TimeSpan txnInqSp = nowTime - lastInqTime;
- if (inqCount >= 12)
- ifEnd = true;
- else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
- {
- string retrivReusltStr = requestRetrieval(dtxnId, 10000);
- inqCount++;
- lastInqTime = DateTime.Now;
- if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
- {
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "OFFLINE_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- ifBusy = false;
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string saleResultStr = "{\"EVENT_NAME\":\"OFFLINE_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + "}";
-
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
- ifBusy = false;
- return saleResultStr;
- }
-
- }
- }
- isReadyBack = false;
- }
- }
-
-
- Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_TIMEOUT);
- }
-
- public string processAdjust(string dtxnId, string dtotalTxnAmt, string dtotalForeignAmt, string appId)
- {
- if (ifBusy)
- return RequestResult.createRespErrJson("ADJUST_RESP", ERR_STATUS_BUSY);
- ifBusy = true;
- SaleResult saleResult = null;
- decimal totalTxnAmt = decimal.Parse(dtotalTxnAmt);
- decimal totalForeignAmt = decimal.Parse(dtotalForeignAmt);
- if (totalTxnAmt.CompareTo(decimal.Parse("0")) < 0 || totalForeignAmt.CompareTo(decimal.Parse("0")) < 0)
- {
- Console.WriteLine("dtxnAmt or dtipAmt parameter error");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("ADJUST_RESP", ERR_STATUS_PARAM);
- }
-
- sendTime = 0;
- isSending = false;
- mRecvTimes = 0;
- isReadyBack = false;
- currReqByteArr = null;
- currResultJsonStr = null;
- isGetACK = false;
- if (openSerialPort())
- {
- PaymentApp tmpAppId = ObjectUtil.getPaymentApp(appId);
- /*
- if (appId == "CC")
- tmpAppId = PaymentApp.CC;
- else if (appId == "QRC")
- tmpAppId = PaymentApp.QRC;
- else if (appId == "AMEX")
- tmpAppId = PaymentApp.AMEX;
- else if (appId == "CPN")
- tmpAppId = PaymentApp.CPN;
- else if (appId == "DC")
- tmpAppId = PaymentApp.DC;
- else if (appId == "NONE")
- tmpAppId = PaymentApp.NONE;
- else
- tmpAppId = PaymentApp.NONE;
- */
- if (dtxnId == null)
- dtxnId = getTxnId();
-
- string reqAdjustStr = SaleResult.toJsonForAdjust(dtxnId, totalTxnAmt, totalForeignAmt, tmpAppId);
- Console.WriteLine("reqAdjustStr = " + reqAdjustStr);
- if (reqAdjustStr == null || "".Equals(reqAdjustStr))
- {
- Console.WriteLine("reqSaleStr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("ADJUST_RESP", ERR_STATUS_PARAM);
- }
- currReqByteArr = packReqMsg(reqAdjustStr);
- if (currReqByteArr == null || currReqByteArr.Length == 0)
- {
- Console.WriteLine("currReqByteArr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson(";", ERR_STATUS_PARAM);
- }
-
- Console.WriteLine("currReqByteArr = " + currReqByteArr);
- Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
- saleResult = null;
- this.sendReqMsg();
- }
- else
- {
- Console.WriteLine("serialPort no open. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("ADJUST_RESP", ERR_STATUS_OPENCOM);
- }
-
- int sleepTime = timeOut / 1000;
- DateTime startTime = DateTime.Now;
-
- Boolean ifEnd = false;
- int inqCount = 0;
- DateTime lastInqTime = DateTime.Now;
- while (!ifEnd)
- {
- DateTime nowTime = DateTime.Now;
- TimeSpan sp = nowTime - startTime;
- if (sp.TotalSeconds > sleepTime)
- ifEnd = true;
- else if (sp.TotalSeconds < 30)
- {
- if (!isSending && !isGetACK)
- this.resendReqMsg();
- if (isReadyBack)
- {
- closeSerialPort();
- if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
- {
- ifBusy = false;
- return currResultJsonStr;
- }
- }
- }
- else
- {
- closeSerialPort();
- TimeSpan txnInqSp = nowTime - lastInqTime;
- if (inqCount >= 12)
- ifEnd = true;
- else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
- {
- string retrivReusltStr = requestRetrieval(dtxnId, 10000);
- inqCount++;
- lastInqTime = DateTime.Now;
- if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
- {
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- ifBusy = false;
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string saleResultStr = "{\"EVENT_NAME\":\"ADJUST_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "}";
-
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
- ifBusy = false;
- return saleResultStr;
- }
-
- }
- }
- isReadyBack = false;
- }
- }
-
-
- Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("ADJUST_RESP", ERR_STATUS_TIMEOUT);
- }
-
- public string requestVoid(string originalEcrRefTxnId, string qrcValue)
- {
- if (ifBusy)
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_BUSY);
- ifBusy = true;
- if (originalEcrRefTxnId == null || "".Equals(originalEcrRefTxnId.Trim()))
- {
- Console.WriteLine("parameter error");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_PARAM);
- }
-
- sendTime = 0;
- isSending = false;
- mRecvTimes = 0;
- isReadyBack = false;
- currReqByteArr = null;
- currResultJsonStr = null;
- isGetACK = false;
-
- if (openSerialPort())
- {
- string reqVoidStr = VoidResult.toJsonForVoid(originalEcrRefTxnId, qrcValue);
- Console.WriteLine("reqVoidStr = " + reqVoidStr);
- if (reqVoidStr == null || "".Equals(reqVoidStr))
- {
- Console.WriteLine("reqVoidStr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_PARAM);
- }
- currReqByteArr = packReqMsg(reqVoidStr);
- if (currReqByteArr == null || currReqByteArr.Length == 0)
- {
- Console.WriteLine("currReqByteArr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_PARAM);
- }
-
- Console.WriteLine("currReqByteArr = " + currReqByteArr);
- Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
- this.sendReqMsg();
- }
- else
- {
- Console.WriteLine("serialPort no open. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_OPENCOM);
- }
-
- int sleepTime = timeOut / 1000;
- DateTime startTime = DateTime.Now;
-
- Boolean ifEnd = false;
- int inqCount = 0;
- DateTime lastInqTime = DateTime.Now;
- while (!ifEnd)
- {
- DateTime nowTime = DateTime.Now;
- TimeSpan sp = nowTime - startTime;
- if (sp.TotalSeconds > sleepTime)
- ifEnd = true;
- else if (sp.TotalSeconds < 30)
- {
- if (!isSending && !isGetACK)
- this.resendReqMsg();
- if (isReadyBack)
- {
- closeSerialPort();
- if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
- {
- ifBusy = false;
- return currResultJsonStr;
- }
- }
- }
- else
- {
- closeSerialPort();
- TimeSpan txnInqSp = nowTime - lastInqTime;
- if (inqCount >= 12)
- ifEnd = true;
- else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
- {
- string retrivReusltStr = requestRetrieval(originalEcrRefTxnId, 10000);
- inqCount++;
- lastInqTime = DateTime.Now;
- if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
- {
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "VOID_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Voided || retrievalResult.TxnStatus == TxnStatus.Failed)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string voidResultStr = "{\"EVENT_NAME\":\"VOID_RESP\",\"STATUS\":\"13\",\"TXN_ID\":\"" + originalEcrRefTxnId + "\"}";
-
- //retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "VOID_RESP");
- ifBusy = false;
- return voidResultStr;
- }
-
- }
- }
- isReadyBack = false;
- }
- }
-
- Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_TIMEOUT);
- }
-
- private string processRefund(string dtxnId, string dtxnAmt, string appId, string qrcValue)
- {
- if (ifBusy)
- return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_BUSY);
- ifBusy = true;
- RefundResult refundResult;
- decimal txnAmt = decimal.Parse(dtxnAmt);
- if (txnAmt.CompareTo(decimal.Parse("0")) < 1)
- {
- Console.WriteLine("parameter error");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_PARAM);
- }
-
- sendTime = 0;
- isSending = false;
- mRecvTimes = 0;
- isReadyBack = false;
- currReqByteArr = null;
- currResultJsonStr = null;
- isGetACK = false;
-
- if (openSerialPort())
- {
- PaymentApp tmpAppId = ObjectUtil.getPaymentApp(appId);
- /*
- if (appId == "CC")
- tmpAppId = PaymentApp.CC;
- else if (appId == "QRC")
- tmpAppId = PaymentApp.QRC;
- else if (appId == "AMEX")
- tmpAppId = PaymentApp.AMEX;
- else if (appId == "CPN")
- tmpAppId = PaymentApp.CPN;
- else if (appId == "DC")
- tmpAppId = PaymentApp.DC;
- else if (appId == "NONE")
- tmpAppId = PaymentApp.NONE;
- else
- tmpAppId = PaymentApp.NONE;
- */
- if (dtxnId == null)
- dtxnId = getTxnId();
-
- string reqRefundStr = RefundResult.toJsonForRefund(dtxnId, txnAmt, tmpAppId, qrcValue);
- Console.WriteLine("reqRefundStr = " + reqRefundStr);
- if (reqRefundStr == null || "".Equals(reqRefundStr))
- {
- Console.WriteLine("reqRefundStr is null. ");
- refundResult = new RefundResult("99");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_PARAM);
- }
- currReqByteArr = packReqMsg(reqRefundStr);
- if (currReqByteArr == null || currReqByteArr.Length == 0)
- {
- Console.WriteLine("currReqByteArr is null. ");
- refundResult = new RefundResult("99");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_PARAM);
- }
-
- Console.WriteLine("currReqByteArr = " + currReqByteArr);
- Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
-
- this.sendReqMsg();
- }
- else
- {
- Console.WriteLine("serialPort no open. ");
- refundResult = new RefundResult("99");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_OPENCOM);
- }
-
- int sleepTime = timeOut / 1000;
-
- DateTime startTime = DateTime.Now;
- int inqCount = 0;
- DateTime lastInqTime = DateTime.Now;
- Boolean ifEnd = false;
- while (!ifEnd)
- {
- DateTime nowTime = DateTime.Now;
- TimeSpan sp = nowTime - startTime;
- if (sp.TotalSeconds > sleepTime)
- ifEnd = true;
- else if (sp.TotalSeconds < 30)
- {
- if (!isSending && !isGetACK)
- this.resendReqMsg();
- if (isReadyBack)
- {
- closeSerialPort();
- if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
- {
- ifBusy = false;
- return currResultJsonStr;
- }
- }
- }
- else
- {
- closeSerialPort();
- TimeSpan txnInqSp = nowTime - lastInqTime;
- if (inqCount >= 12)
- ifEnd = true;
- else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
- {
- string retrivReusltStr = requestRetrieval(dtxnId, 10000);
- inqCount++;
- lastInqTime = DateTime.Now;
- if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
- {
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "REFUND_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- ifBusy = false;
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string saleResultStr = "{\"EVENT_NAME\":\"REFUND_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
-
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
- ifBusy = false;
- return saleResultStr;
- }
-
- }
- }
- isReadyBack = false;
- }
- }
-
-
- Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- closeSerialPort();
- ifBusy = false;
return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_TIMEOUT);
}
@@ -1401,6 +403,7 @@ namespace n5coredll
closeSerialPort();
if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
{
+ currResultJsonStr = SettleResult.rebuildSettleRespMsg(currResultJsonStr);
ifBusy = false;
return currResultJsonStr;
}
@@ -1413,10 +416,10 @@ namespace n5coredll
return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_TIMEOUT);
}
- public string requestRetrieval(string txnId, int pTimeOut)
+ public string requestRetrieval(string txnId, string traceNo, int pTimeOut)
{
RetrievalResult retrievalResult = null;
- if (txnId == null || "".Equals(txnId.Trim()))
+ if (txnId == null)
{
Console.WriteLine("parameter error");
closeSerialPort();
@@ -1434,7 +437,7 @@ namespace n5coredll
if (openSerialPort())
{
- string reqRetrievalStr = RetrievalResult.toJsonForRetrieval(txnId);
+ string reqRetrievalStr = RetrievalResult.toJsonForRetrieval(txnId, traceNo);
Console.WriteLine("reqRetrievalStr = " + reqRetrievalStr);
if (reqRetrievalStr == null || "".Equals(reqRetrievalStr))
{
@@ -1482,6 +485,7 @@ namespace n5coredll
if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
{
ifBusy = false;
+ currResultJsonStr = RetrievalResult.rebuildRetrievalRespMsg(currResultJsonStr);
return currResultJsonStr;
}
}
@@ -1624,7 +628,7 @@ namespace n5coredll
}
int reprintTimeout = 60000;
- public string sendReprintRequest()
+ public string sendReprintRequest(string txnId, string traceNo, bool isReprint)
{
if (ifBusy)
return RequestResult.createRespErrJson("PRINT_RESP", ERR_STATUS_BUSY);
@@ -1639,7 +643,7 @@ namespace n5coredll
isGetACK = false;
if (openSerialPort())
{
- currReqByteArr = this.packReqMsg(RequestResult.toJsonForReprint());
+ currReqByteArr = this.packReqMsg(RequestResult.toJsonForReprint(txnId,traceNo,isReprint));
if (currReqByteArr == null || currReqByteArr.Length == 0)
{
closeSerialPort();
@@ -2276,7 +1280,7 @@ namespace n5coredll
{
Console.WriteLine("Check LRC success! LRC is [" + ObjectUtil.desToHex(new byte[] { nlrc }) + "]");
sendAck();
- string jsonMsg = System.Text.Encoding.Default.GetString(msg);
+ string jsonMsg = System.Text.Encoding.UTF8.GetString(msg);
onMsgReceived(jsonMsg);
reset();
diff --git a/n5coredll/ObjectUtil.cs b/n5coredll/ObjectUtil.cs
index 4f5311c..377d59a 100644
--- a/n5coredll/ObjectUtil.cs
+++ b/n5coredll/ObjectUtil.cs
@@ -155,6 +155,8 @@ namespace n5coredll
return PaymentType.ALP;
case "WCP":
return PaymentType.WCP;
+ case "EPS":
+ return PaymentType.EPS;
default:
return PaymentType.NONE;
}
@@ -186,6 +188,8 @@ namespace n5coredll
return "ALP";
case PaymentType.WCP:
return "WCP";
+ case PaymentType.EPS:
+ return "EPS";
default:
return "";
}
diff --git a/n5coredll/PaymentType.cs b/n5coredll/PaymentType.cs
index 156ee8b..0e8ae0e 100644
--- a/n5coredll/PaymentType.cs
+++ b/n5coredll/PaymentType.cs
@@ -18,6 +18,7 @@ namespace n5coredll
DC,
ALP,
WCP,
+ EPS,
NONE
}
}
diff --git a/n5coredll/RequestResult.cs b/n5coredll/RequestResult.cs
index fe57b84..fcb805c 100644
--- a/n5coredll/RequestResult.cs
+++ b/n5coredll/RequestResult.cs
@@ -27,7 +27,7 @@ namespace n5coredll
public static string toJsonForSettlement()
{
- return "{\"EVENT_NAME\":\"SETTLE\"}";
+ return "{\"EVENT_NAME\":\"SETTLE\",\"PAYMENT_APP_ID\":\"EPS\"}";
}
public static string toJsonForReprint()
@@ -35,6 +35,25 @@ namespace n5coredll
return "{\"EVENT_NAME\":\"PRINT\",\"IS_REPRINT\":true}";
}
+ public static string toJsonForReprint(string txnId, string traceNo, bool isReprint)
+ {
+ string reprintStr = "";
+ if (isReprint)
+ reprintStr = "true";
+ else
+ reprintStr = "false";
+
+ string result = "";
+ if (txnId!="" && traceNo!="")
+ result = "{\"EVENT_NAME\":\"PRINT\",\"PAYMENT_APP_ID\":\"EPS\",\"TXN_ID\":\"" + txnId + "\",\"TRACE_NO\":\"" + traceNo + "\",\"IS_REPRINT\":" + reprintStr + "}";
+ else if(txnId!="" && traceNo == "")
+ result = "{\"EVENT_NAME\":\"PRINT\",\"PAYMENT_APP_ID\":\"EPS\",\"TXN_ID\":\"" + txnId + "\",\"IS_REPRINT\":" + reprintStr + "}";
+ else if (traceNo != "" && txnId == "")
+ result = "{\"EVENT_NAME\":\"PRINT\",\"PAYMENT_APP_ID\":\"EPS\",\"TRACE_NO\":\"" + traceNo + "\",\"IS_REPRINT\":" + reprintStr + "}";
+
+ return result;
+ }
+
public static string toJsonForAbort()
{
return "{\"EVENT_NAME\":\"ABORT\"}";
diff --git a/n5coredll/RetrievalResult.cs b/n5coredll/RetrievalResult.cs
index 38cdaae..9f43f77 100644
--- a/n5coredll/RetrievalResult.cs
+++ b/n5coredll/RetrievalResult.cs
@@ -1,4 +1,6 @@
-using System;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
using System.Text;
namespace n5coredll
@@ -39,8 +41,11 @@ namespace n5coredll
private static string TC = "TC";
private static string APP = "APP";
private static string ACQUIRER = "ACQUIRER";
-
- private string eventName;
+ private static string AC_INDICATOR = "AC_INDICATOR";
+ private static string ECR_REF_NO = "ECR_REF_NO";
+ private static string BANKIN_VALUE_DATE = "BANKIN_VALUE_DATE";
+ private static string ACCOUNT_NO = "ACCOUNT_NO";
+ private static string BANK_ADDITIONAL_RESPONSE = "BANK_ADDITIONAL_RESPONSE";
private TxnType txnType;
private string ecrRefTxnId;
private string status;
@@ -75,6 +80,14 @@ namespace n5coredll
private string tc;
private string app;
private string acquirer;
+ private string eventName = "";
+ private string responseText = "";
+ private string acIndicator = "";
+ private string ecrRefNo = "";
+ private string bankinValueDate = "";
+ private string accountNo = "";
+ private string bankAdditionalResponse = "";
+ private decimal cashbackAmt;
public void setEventName(string pEventName)
{
@@ -298,6 +311,57 @@ namespace n5coredll
private void setAcquirer(string pAcquirer) {
this.acquirer = pAcquirer;
}
+ private void setBankinValueDate(string pBankinValueDate)
+ {
+ bankinValueDate = pBankinValueDate;
+ }
+
+ public string BankinValueDate
+ {
+ get { return bankinValueDate; }
+
+ }
+ private void setAccountNo(string pAccountNo)
+ {
+ accountNo = pAccountNo;
+ }
+
+ public string AccountNo
+ {
+ get { return accountNo; }
+
+ }
+ private void setBankAdditionalResponse(string pBankAdditionalResponse)
+ {
+ bankAdditionalResponse = pBankAdditionalResponse;
+ }
+
+ public string BankAdditionalResponse
+ {
+ get { return bankAdditionalResponse; }
+
+ }
+
+ private void setECRRefNo(string pECRRefNo)
+ {
+ ecrRefNo = pECRRefNo;
+ }
+
+ public string ECRRefNo
+ {
+ get { return ecrRefNo; }
+
+ }
+ private void setACIndicator(string pACIndicator)
+ {
+ acIndicator = pACIndicator;
+ }
+
+ public string ACIndicator
+ {
+ get { return acIndicator; }
+
+ }
public RetrievalResult() {
}
@@ -306,13 +370,13 @@ namespace n5coredll
this.setStatus(pStatus);
}
- public static string toJsonForRetrieval(string txnId) {
+ public static string toJsonForRetrieval(string txnId, string traceNo) {
- if (txnId == null || "".Equals(txnId)) {
+ if (txnId == null) {
Console.WriteLine("txnId is null ");
return null;
}
- string cardSaleMsg = "{\"EVENT_NAME\":\"RETRIEVAL\",\"TXN_ID\":\"" + txnId + "\"}";
+ string cardSaleMsg = "{\"EVENT_NAME\":\"RETRIEVAL\",\"TXN_ID\":\"" + txnId + "\",\"PAYMENT_APP_ID\":\"EPS\",\"TRACE_NO\":\"" + traceNo + "\"}";
return cardSaleMsg;
}
@@ -448,9 +512,6 @@ namespace n5coredll
if (RetrievalResult.ENTRY_MODE.Equals(valueColumn0)) {
retrievalResult.setEntryMode(valueColumn1);
}
- if (RetrievalResult.BATCH_NO.Equals(valueColumn0)) {
- retrievalResult.setBatchNo(valueColumn1);
- }
if (RetrievalResult.APP.Equals(valueColumn0)) {
retrievalResult.setApp(valueColumn1);
}
@@ -460,9 +521,86 @@ namespace n5coredll
if (RetrievalResult.ACQUIRER.Equals(valueColumn0)) {
retrievalResult.setAcquirer(valueColumn1);
}
+ if (RetrievalResult.AC_INDICATOR.Equals(valueColumn0))
+ {
+ retrievalResult.setACIndicator(valueColumn1);
+ }
+
+ if (RetrievalResult.ECR_REF_NO.Equals(valueColumn0))
+ {
+ retrievalResult.setECRRefNo(valueColumn1);
+ }
+ if (RetrievalResult.BANKIN_VALUE_DATE.Equals(valueColumn0))
+ {
+ retrievalResult.setBankinValueDate(valueColumn1);
+ }
+ if (RetrievalResult.ACCOUNT_NO.Equals(valueColumn0))
+ {
+ retrievalResult.setAccountNo(valueColumn1);
+ }
+ if (RetrievalResult.BANK_ADDITIONAL_RESPONSE.Equals(valueColumn0))
+ {
+ retrievalResult.setBankAdditionalResponse(valueColumn1);
+ }
}
return retrievalResult;
}
+ public static string rebuildRetrievalRespMsg(string retrievalJsonStr)
+ {
+ JObject tmp = (JObject)JsonConvert.DeserializeObject(retrievalJsonStr);
+ StringBuilder sb = new StringBuilder("");
+ sb.Append("{");
+ sb.Append("\"EVENT_NAME\":\"" + tmp.GetValue("EVENT_NAME") + "\",");
+ sb.Append("\"TXN_TYPE\":\"" + tmp.GetValue("TXN_TYPE") + "\",");
+ sb.Append("\"TXN_ID\":\"" + tmp.GetValue("TXN_ID") + "\",");
+ sb.Append("\"STATUS\":\"" + tmp.GetValue("STATUS") + "\",");
+ sb.Append("\"TXN_STATUS\":\"" + tmp.GetValue("TXN_STATUS") + "\",");
+ sb.Append("\"TXN_AMT\":" + tmp.GetValue("TXN_AMT") + ",");
+ if (tmp.GetValue("CASHBACK_AMT") != null)
+ sb.Append("\"CASHBACK_AMT\":" + tmp.GetValue("CASHBACK_AMT") + ",");
+ if (tmp.GetValue("PAYMENT_TYPE") != null)
+ sb.Append("\"PAYMENT_TYPE\":\"" + tmp.GetValue("PAYMENT_TYPE") + "\",");
+ if (tmp.GetValue("LOCAL_CUR") != null)
+ sb.Append("\"CURRENCY\":\"" + tmp.GetValue("LOCAL_CUR") + "\",");
+ sb.Append("\"RESP_CODE\":\"" + tmp.GetValue("RESP_CODE") + "\",");
+ if (tmp.GetValue("RESPONSE_TEXT") != null)
+ sb.Append("\"RESPONSE_TEXT\":\"" + tmp.GetValue("RESPONSE_TEXT") + "\",");
+ if (tmp.GetValue("TRACE_NO") != null)
+ sb.Append("\"TRACE_NO\":\"" + tmp.GetValue("TRACE_NO") + "\",");
+ if (tmp.GetValue("TXN_DATE") != null)
+ sb.Append("\"TXN_DATE\":\"" + tmp.GetValue("TXN_DATE") + "\",");
+ if (tmp.GetValue("TXN_TIME") != null)
+ sb.Append("\"TXN_TIME\":\"" + tmp.GetValue("TXN_TIME") + "\",");
+ if (tmp.GetValue("MID") != null)
+ sb.Append("\"MID\":\"" + tmp.GetValue("MID") + "\",");
+ if (tmp.GetValue("TID") != null)
+ sb.Append("\"TID\":\"" + tmp.GetValue("TID") + "\",");
+ if (tmp.GetValue("PAN") != null)
+ sb.Append("\"PAN\":\"" + tmp.GetValue("PAN") + "\",");
+ if (tmp.GetValue("ENTRYMODE") != null)
+ sb.Append("\"ENTRYMODE\":\"" + tmp.GetValue("PAN") + "\",");
+ if (tmp.GetValue("AC_INDICATOR") != null)
+ sb.Append("\"AC_INDICATOR\":\"" + tmp.GetValue("PAN") + "\",");
+ if (tmp.GetValue("AID") != null)
+ sb.Append("\"AID\":\"" + tmp.GetValue("AID") + "\",");
+ if (tmp.GetValue("TC") != null)
+ sb.Append("\"TC\":\"" + tmp.GetValue("TC") + "\",");
+ if (tmp.GetValue("APP") != null)
+ sb.Append("\"APP\":\"" + tmp.GetValue("APP") + "\",");
+ if (tmp.GetValue("ECR_REF_NO") != null)
+ sb.Append("\"ECR_REF_NO\":\"" + tmp.GetValue("ECR_REF_NO") + "\",");
+ if (tmp.GetValue("BANKIN_VALUE_DATE") != null)
+ sb.Append("\"BANKIN_VALUE_DATE\":\"" + tmp.GetValue("BANKIN_VALUE_DATE") + "\",");
+ if (tmp.GetValue("ACCOUNT_NO") != null)
+ sb.Append("\"ACCOUNT_NO\":\"" + tmp.GetValue("ACCOUNT_NO") + "\",");
+ if (tmp.GetValue("BANK_ADDITIONAL_RESPONSE") != null)
+ sb.Append("\"BANK_ADDITIONAL_RESPONSE\":\"" + tmp.GetValue("BANK_ADDITIONAL_RESPONSE") + "\"");
+ sb.Append("}");
+
+ return sb.ToString();
+ }
}
+
+
}
diff --git a/n5coredll/SaleResult.cs b/n5coredll/SaleResult.cs
index 107ab85..7830a84 100644
--- a/n5coredll/SaleResult.cs
+++ b/n5coredll/SaleResult.cs
@@ -1,44 +1,42 @@
-using System;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
using System.Text;
namespace n5coredll
{
public class SaleResult {
+ private static string EVENT_NAME = "EVENT_NAME";
private static string TXN_ID = "TXN_ID";
private static string STATUS = "STATUS";
private static string TXN_AMT = "TXN_AMT";
- private static string TIPS = "TIPS";
+ private static string CASHBACK_AMT = "CASHBACK_AMT";
private static string PAYMENT_TYPE = "PAYMENT_TYPE";
+ private static string LOCAL_CUR = "LOCAL_CUR";
private static string RESP_CODE = "RESP_CODE";
- private static string LOYALTY_TYPE = "LOYALTY_TYPE";
- private static string CAMPAIGN_ID = "CAMPAIGN_ID";
+ private static string RESPONSE_TEXT = "RESPONSE_TEXT";
private static string TRACE_NO = "TRACE_NO";
private static string TXN_DATE = "TXN_DATE";
private static string TXN_TIME = "TXN_TIME";
- private static string HOST_REF = "HOST_REF";
- private static string COUPON_ID = "COUPON_ID";
- private static string AUTH_CODE = "AUTH_CODE";
- private static string AUTH_AMT = "AUTH_AMT";
- private static string DISCOUNT = "DISCOUNT";
- private static string LOCAL_CUR = "LOCAL_CUR";
- private static string FOREIGN_CUR = "FOREIGN_CUR";
- private static string FXRATE = "FXRATE";
- private static string FOREIGN_AMT = "FOREIGN_AMT";
private static string MID = "MID";
private static string TID = "TID";
+
private static string PAN = "PAN";
- private static string EXPIRY_DATE = "EXPIRY_DATE";
- private static string LOYALTY_REF = "LOYALTY_REF";
- private static string AID = "AID";
private static string ENTRY_MODE = "ENTRY_MODE";
- private static string BATCH_NO = "BATCH_NO";
+ private static string AC_INDICATOR = "AC_INDICATOR";
+ private static string AID = "AID";
private static string TC = "TC";
private static string APP = "APP";
- private static string ACQUIRER = "ACQUIRER";
+ private static string ECR_REF_NO = "ECR_REF_NO";
+ private static string BATCH_NO = "BATCH_NO";
+ private static string BANKIN_VALUE_DATE = "BANKIN_VALUE_DATE";
+ private static string ACCOUNT_NO = "ACCOUNT_NO";
+ private static string BANK_ADDITIONAL_RESPONSE = "BANK_ADDITIONAL_RESPONSE";
private string ecrRefTxnId;
private string status;
private decimal txnAmt;
+ private decimal cashbackAmt;
private decimal tipAmt;
private PaymentType paymentType;
private string respCode;
@@ -64,9 +62,77 @@ namespace n5coredll
private string aid;
private string entryMode;
private string batchNo;
- private string tc;
- private string app;
- private string acquirer;
+ private string tc = "";
+ private string app = "";
+ private string acquirer = "";
+ private string eventName = "";
+ private string responseText = "";
+ private string acIndicator = "";
+ private string ecrRefNo = "";
+ private string bankinValueDate = "";
+ private string accountNo = "";
+ private string bankAdditionalResponse="";
+
+ private void setBankinValueDate(string pBankinValueDate)
+ {
+ bankinValueDate = pBankinValueDate;
+ }
+
+ public string BankinValueDate
+ {
+ get { return bankinValueDate; }
+
+ }
+ private void setAccountNo(string pAccountNo)
+ {
+ accountNo = pAccountNo;
+ }
+
+ public string AccountNo
+ {
+ get { return accountNo; }
+
+ }
+ private void setBankAdditionalResponse(string pBankAdditionalResponse)
+ {
+ bankAdditionalResponse = pBankAdditionalResponse;
+ }
+
+ public string BankAdditionalResponse
+ {
+ get { return bankAdditionalResponse; }
+
+ }
+
+ private void setECRRefNo(string pECRRefNo)
+ {
+ ecrRefNo = pECRRefNo;
+ }
+
+ public string ECRRefNo
+ {
+ get { return ecrRefNo; }
+
+ }
+ private void setACIndicator(string pACIndicator)
+ {
+ acIndicator = pACIndicator;
+ }
+
+ public string ACIndicator
+ {
+ get { return acIndicator; }
+
+ }
+ private void setEventName(string pEventName)
+ {
+ eventName = pEventName;
+ }
+
+ public string EventName
+ {
+ get { return eventName; }
+ }
private void setEcrRefTxnId(string pEcrRefTxnId) {
ecrRefTxnId = pEcrRefTxnId;
@@ -88,6 +154,14 @@ namespace n5coredll
private void setTxnAmt(decimal pTxnAmt) {
this.txnAmt = pTxnAmt;
}
+ public decimal CashbackAmt
+ {
+ get { return cashbackAmt; }
+ }
+ private void setCashbackAmt(decimal pCashbackAmt)
+ {
+ this.cashbackAmt = pCashbackAmt;
+ }
public decimal TipAmt {
get { return tipAmt; }
}
@@ -106,6 +180,14 @@ namespace n5coredll
private void setRespCode(string pRespCode) {
this.respCode = pRespCode;
}
+ public string ResponseText
+ {
+ get { return responseText; }
+ }
+ private void setResponseText(string pResponseText)
+ {
+ this.responseText = pResponseText;
+ }
public LoyaltyType LoyaltyType {
get { return loyaltyType; }
}
@@ -264,10 +346,10 @@ namespace n5coredll
return cardSaleMsg;
}
- public static string toJsonForSale(string txnId, decimal txnAmt, decimal tipAmt, PaymentApp appId, string qrcValue, string pan, string expDate)
+ public static string toJsonForSale(string txnId, decimal txnAmt, decimal tipAmt, decimal cashbackAmt, string ecrRefNo, String currency, PaymentApp appId, string qrcValue, string pan, string expDate)
{
- string cardSaleMsg = "{\"EVENT_NAME\":\"SALE\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TIPS\":" + tipAmt + ",\"TXN_AMT\":" + txnAmt + ",\"PAN\":\"" + pan + "\",\"EXPIRY_DATE\":\"" + expDate + "\",\"QRC_VALUE\":\"" + qrcValue + "\"}";
+ string cardSaleMsg = "{\"EVENT_NAME\":\"SALE\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TIPS\":" + tipAmt + ",\"TXN_AMT\":" + txnAmt + ",\"CASHBACK_AMT\":" + cashbackAmt + ",\"ECR_REF_NO\":\"" + ecrRefNo + "\",\"CURRENCY\":\"" + currency + "\",\"PAN\":\"" + pan + "\",\"EXPIRY_DATE\":\"" + expDate + "\",\"QRC_VALUE\":\"" + qrcValue + "\"}";
return cardSaleMsg;
}
public static string toJsonForPreauth(string txnId, decimal txnAmt, PaymentApp appId, string pan, string expDate)
@@ -342,6 +424,10 @@ namespace n5coredll
valueColumn = column[i].Split(':');
valueColumn0 = valueColumn[0].Replace('"', ' ').Trim();
valueColumn1 = valueColumn[1].Replace('"', ' ').Trim();
+ if (SaleResult.EVENT_NAME.Equals(valueColumn0))
+ {
+ saleResult.setEventName(valueColumn1);
+ }
if (SaleResult.TXN_ID.Equals(valueColumn0)) {
saleResult.setEcrRefTxnId(valueColumn1);
}
@@ -358,31 +444,32 @@ namespace n5coredll
}
}
- if (SaleResult.TIPS.Equals(valueColumn0)) {
- if (valueColumn1 == null || "".Equals(valueColumn1)) {
- saleResult.setTipAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ if (SaleResult.CASHBACK_AMT.Equals(valueColumn0))
+ {
+ if (valueColumn1 == null || "".Equals(valueColumn1))
+ {
+ saleResult.setCashbackAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
}
- else {
- saleResult.setTipAmt(decimal.Parse(valueColumn1, System.Globalization.NumberStyles.AllowDecimalPoint));
+ else
+ {
+ saleResult.setCashbackAmt(decimal.Parse(valueColumn1));
}
}
-
if (SaleResult.PAYMENT_TYPE.Equals(valueColumn0)) {
saleResult.setPaymentType(ObjectUtil.getPaymentType(valueColumn1));
}
+ if (SaleResult.LOCAL_CUR.Equals(valueColumn0))
+ {
+ saleResult.setLocalCur(valueColumn1);
+ }
if (SaleResult.RESP_CODE.Equals(valueColumn0)) {
saleResult.setRespCode(valueColumn1);
}
-
- if (SaleResult.LOYALTY_TYPE.Equals(valueColumn0)) {
- saleResult.setLoyaltyType(ObjectUtil.getLoyaltyType(valueColumn1));
- }
-
- if (SaleResult.CAMPAIGN_ID.Equals(valueColumn0)) {
- saleResult.setCampaignId(valueColumn1);
+ if (SaleResult.RESPONSE_TEXT.Equals(valueColumn0))
+ {
+ saleResult.setResponseText(valueColumn1);
}
-
if (SaleResult.TRACE_NO.Equals(valueColumn0)) {
saleResult.setTraceNo(valueColumn1);
}
@@ -392,70 +479,109 @@ namespace n5coredll
if (SaleResult.TXN_TIME.Equals(valueColumn0)) {
saleResult.setTxnTime(valueColumn1);
}
-
- if (SaleResult.HOST_REF.Equals(valueColumn0)) {
- saleResult.setHostRef(valueColumn1);
- }
- if (SaleResult.COUPON_ID.Equals(valueColumn0)) {
- saleResult.setCouponId(valueColumn1);
- }
- if (SaleResult.AUTH_CODE.Equals(valueColumn0)) {
- saleResult.setAuthCode(valueColumn1);
- }
- if (SaleResult.AUTH_AMT.Equals(valueColumn0)) {
- saleResult.setAuthAmt(valueColumn1);
- }
- if (SaleResult.DISCOUNT.Equals(valueColumn0)) {
- saleResult.setDiscAmt(valueColumn1);
- }
- if (SaleResult.LOCAL_CUR.Equals(valueColumn0)) {
- saleResult.setLocalCur(valueColumn1);
- }
- if (SaleResult.FOREIGN_CUR.Equals(valueColumn0)) {
- saleResult.setForeignCur(valueColumn1);
- }
- if (SaleResult.FXRATE.Equals(valueColumn0)) {
- saleResult.setFxRate(valueColumn1);
- }
- if (SaleResult.FOREIGN_AMT.Equals(valueColumn0)) {
- saleResult.setForeignAmt(valueColumn1);
- }
- if (SaleResult.MID.Equals(valueColumn0)) {
+ if (SaleResult.MID.Equals(valueColumn0))
+ {
saleResult.setMid(valueColumn1);
}
- if (SaleResult.TID.Equals(valueColumn0)) {
+ if (SaleResult.TID.Equals(valueColumn0))
+ {
saleResult.setTid(valueColumn1);
}
if (SaleResult.PAN.Equals(valueColumn0)) {
saleResult.setPan(valueColumn1);
}
- if (SaleResult.EXPIRY_DATE.Equals(valueColumn0)) {
- saleResult.setExpiryDate(valueColumn1);
+
+ if (SaleResult.ENTRY_MODE.Equals(valueColumn0))
+ {
+ saleResult.setEntryMode(valueColumn1);
}
- if (SaleResult.LOYALTY_REF.Equals(valueColumn0)) {
- saleResult.setLoyaltyRef(valueColumn1);
+ if (SaleResult.AC_INDICATOR.Equals(valueColumn0))
+ {
+ saleResult.setACIndicator(valueColumn1);
}
if (SaleResult.AID.Equals(valueColumn0)) {
saleResult.setAid(valueColumn1);
}
- if (SaleResult.ENTRY_MODE.Equals(valueColumn0)) {
- saleResult.setEntryMode(valueColumn1);
- }
- if (SaleResult.BATCH_NO.Equals(valueColumn0)) {
- saleResult.setBatchNo(valueColumn1);
+ if (SaleResult.TC.Equals(valueColumn0))
+ {
+ saleResult.setTc(valueColumn1);
}
if (SaleResult.APP.Equals(valueColumn0)) {
saleResult.setApp(valueColumn1);
}
- if (SaleResult.TC.Equals(valueColumn0)) {
- saleResult.setTc(valueColumn1);
+ if (SaleResult.ECR_REF_NO.Equals(valueColumn0))
+ {
+ saleResult.setECRRefNo(valueColumn1);
+ }
+ if (SaleResult.BANKIN_VALUE_DATE.Equals(valueColumn0))
+ {
+ saleResult.setBankinValueDate(valueColumn1);
}
- if (SaleResult.ACQUIRER.Equals(valueColumn0)) {
- saleResult.setAcquirer(valueColumn1);
+ if (SaleResult.ACCOUNT_NO.Equals(valueColumn0))
+ {
+ saleResult.setAccountNo(valueColumn1);
+ }
+ if (SaleResult.BANK_ADDITIONAL_RESPONSE.Equals(valueColumn0))
+ {
+ saleResult.setECRRefNo(valueColumn1);
}
}
return saleResult;
}
+
+ public static string rebuildSaleRespMsg(string saleResultJsonStr)
+ {
+ //SaleResult tmp = toSaleResultFromJsonMsg(saleResultJsonStr);
+ JObject tmp = (JObject)JsonConvert.DeserializeObject(saleResultJsonStr);
+ StringBuilder sb = new StringBuilder("");
+ sb.Append("{");
+ sb.Append("\"EVENT_NAME\":\"" + tmp.GetValue("EVENT_NAME") +"\",");
+ sb.Append("\"TXN_ID\":\"" + tmp.GetValue("TXN_ID") + "\",");
+ sb.Append("\"STATUS\":\"" + tmp.GetValue("STATUS") + "\",");
+ sb.Append("\"TXN_AMT\":" + tmp.GetValue("TXN_AMT") + ",");
+ if (tmp.GetValue("CASHBACK_AMT") != null)
+ sb.Append("\"CASHBACK_AMT\":" + tmp.GetValue("CASHBACK_AMT") + ",");
+ if (tmp.GetValue("PAYMENT_TYPE") != null)
+ sb.Append("\"PAYMENT_TYPE\":\"" + tmp.GetValue("PAYMENT_TYPE") + "\",");
+ if (tmp.GetValue("LOCAL_CUR") != null)
+ sb.Append("\"CURRENCY\":\"" + tmp.GetValue("LOCAL_CUR") + "\",");
+ sb.Append("\"RESP_CODE\":\"" + tmp.GetValue("RESP_CODE") + "\",");
+ if (tmp.GetValue("RESPONSE_TEXT") != null)
+ sb.Append("\"RESPONSE_TEXT\":\"" + tmp.GetValue("RESPONSE_TEXT") + "\",");
+ if (tmp.GetValue("TRACE_NO") != null)
+ sb.Append("\"TRACE_NO\":\"" + tmp.GetValue("TRACE_NO") + "\",");
+ if (tmp.GetValue("TXN_DATE") != null)
+ sb.Append("\"TXN_DATE\":\"" + tmp.GetValue("TXN_DATE") + "\",");
+ if (tmp.GetValue("TXN_TIME") != null)
+ sb.Append("\"TXN_TIME\":\"" + tmp.GetValue("TXN_TIME") + "\",");
+ if (tmp.GetValue("MID") != null)
+ sb.Append("\"MID\":\"" + tmp.GetValue("MID") + "\",");
+ if (tmp.GetValue("TID") != null)
+ sb.Append("\"TID\":\"" + tmp.GetValue("TID") + "\",");
+ if (tmp.GetValue("PAN") != null)
+ sb.Append("\"PAN\":\"" + tmp.GetValue("PAN") + "\",");
+ if (tmp.GetValue("ENTRYMODE") != null)
+ sb.Append("\"ENTRYMODE\":\"" + tmp.GetValue("PAN") + "\",");
+ if (tmp.GetValue("AC_INDICATOR") != null)
+ sb.Append("\"AC_INDICATOR\":\"" + tmp.GetValue("PAN") + "\",");
+ if (tmp.GetValue("AID") != null)
+ sb.Append("\"AID\":\"" + tmp.GetValue("AID") + "\",");
+ if (tmp.GetValue("TC") != null)
+ sb.Append("\"TC\":\"" + tmp.GetValue("TC") + "\",");
+ if (tmp.GetValue("APP") != null)
+ sb.Append("\"APP\":\"" + tmp.GetValue("APP") + "\",");
+ if (tmp.GetValue("ECR_REF_NO") != null)
+ sb.Append("\"ECR_REF_NO\":\"" + tmp.GetValue("ECR_REF_NO") + "\",");
+ if (tmp.GetValue("BANKIN_VALUE_DATE") != null)
+ sb.Append("\"BANKIN_VALUE_DATE\":\"" + tmp.GetValue("BANKIN_VALUE_DATE") + "\",");
+ if (tmp.GetValue("ACCOUNT_NO") != null)
+ sb.Append("\"ACCOUNT_NO\":\"" + tmp.GetValue("ACCOUNT_NO") + "\",");
+ if (tmp.GetValue("BANK_ADDITIONAL_RESPONSE") != null)
+ sb.Append("\"BANK_ADDITIONAL_RESPONSE\":\"" + tmp.GetValue("BANK_ADDITIONAL_RESPONSE") + "\"");
+ sb.Append("}");
+
+ return sb.ToString();
+ }
}
}
diff --git a/n5coredll/SettleResult.cs b/n5coredll/SettleResult.cs
new file mode 100644
index 0000000..54a8726
--- /dev/null
+++ b/n5coredll/SettleResult.cs
@@ -0,0 +1,482 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Text;
+
+namespace n5coredll
+{
+ public class SettleResult {
+ private static string EVENT_NAME = "EVENT_NAME";
+ private static string STATUS = "STATUS";
+ private static string RESP_CODE = "RESP_CODE";
+ private static string RESPONSE_TEXT = "RESPONSE_TEXT";
+
+ private static string TXN_DATE = "TXN_DATE";
+ private static string TXN_TIME = "TXN_TIME";
+ private static string MID = "MID";
+ private static string TID = "TID";
+
+ private static string HOST_COUNT = "HOST_COUNT";
+ private static string HOST_AMT = "HOST_AMT";
+ private static string BATCH = "BATCH";
+ private static string BANKIN_VALUE_DATE = "BANKIN_VALUE_DATE";
+ private static string EPS_TOTAL_COUNT = "EPS_TOTAL_COUNT";
+ private static string EPS_TOTAL_AMT = "EPS_TOTAL_AMT";
+ private static string CASHBACK_COUNT = "CASHBACK_COUNT";
+ private static string CASHBACK_AMT = "CASHBACK_AMT";
+ private static string PURCHASE_COUNT = "PURCHASE_COUNT";
+ private static string PURCHASE_AMT = "PURCHASE_AMT";
+ private static string TRACE_NO = "TRACE_NO";
+
+ private string eventName = "";
+ private string status;
+ private string respCode;
+ private string responseText = "";
+ private string txnDate;
+ private string txnTime;
+ private string mid;
+ private string tid;
+ private decimal hostCount;
+ private decimal hostAmt;
+ private string bankinValueDate = "";
+ private decimal eptTotalCount;
+ private decimal eptTotalAmt;
+ private decimal cashbackCount;
+ private decimal cashbackAmt;
+ private decimal purchaseCount;
+ private decimal purchaseAmt;
+ private string traceNo;
+
+
+ private void setEventName(string pEventName)
+ {
+ eventName = pEventName;
+ }
+
+ public string EventName
+ {
+ get { return eventName; }
+ }
+
+
+ public string Status {
+ get { return status; }
+ }
+ private void setStatus(string pStatus) {
+ this.status = pStatus;
+ }
+
+
+ public string RespCode
+ {
+ get { return respCode; }
+ }
+ private void setRespCode(string pRespCode)
+ {
+ this.respCode = pRespCode;
+ }
+ public string ResponseText
+ {
+ get { return responseText; }
+ }
+ private void setResponseText(string pResponseText)
+ {
+ this.responseText = pResponseText;
+ }
+
+
+ public string TraceNo {
+ get { return traceNo; }
+ }
+ private void setTraceNo(string pTraceNo) {
+ this.traceNo = pTraceNo;
+ }
+ public string TxnDate {
+ get { return txnDate; }
+ }
+ private void setTxnDate(string pTxnDate) {
+ this.txnDate = pTxnDate;
+ }
+ public string TxnTime {
+ get { return txnTime; }
+ }
+ private void setTxnTime(string pTxnTime) {
+ this.txnTime = pTxnTime;
+ }
+ public string getMid()
+ {
+ return mid;
+ }
+ private void setMid(string pMid)
+ {
+ this.mid = pMid;
+ }
+ public string getTid()
+ {
+ return tid;
+ }
+ private void setTid(string pTid)
+ {
+ this.tid = pTid;
+ }
+ public decimal HostCount
+ {
+ get { return hostCount; }
+ }
+ private void setHostCount(decimal pHostCount)
+ {
+ this.hostCount = pHostCount;
+ }
+
+ public decimal HostAmt
+ {
+ get { return hostAmt; }
+ }
+ private void setHostAmt(decimal pHostAmt)
+ {
+ this.hostAmt = pHostAmt;
+ }
+
+ private void setBankinValueDate(string pBankinValueDate)
+ {
+ bankinValueDate = pBankinValueDate;
+ }
+
+ public string BankinValueDate
+ {
+ get { return bankinValueDate; }
+ }
+
+ public decimal EPSTotalCount
+ {
+ get { return eptTotalCount; }
+ }
+ private void setEPSTotalCount(decimal pEptTotalCount)
+ {
+ this.eptTotalCount = pEptTotalCount;
+ }
+
+ public decimal EPSTotalAmt
+ {
+ get { return eptTotalAmt; }
+ }
+ private void setEPSTotalAmt(decimal pEptTotalAmt)
+ {
+ this.eptTotalAmt = pEptTotalAmt;
+ }
+
+ public decimal CashbackCount
+ {
+ get { return cashbackCount; }
+ }
+ private void setCashbackCount(decimal pCashbackCount)
+ {
+ this.cashbackCount = pCashbackCount;
+ }
+ public decimal CashbackAmt
+ {
+ get { return cashbackAmt; }
+ }
+ private void setCashbackAmt(decimal pCashbackAmt)
+ {
+ this.cashbackAmt = pCashbackAmt;
+ }
+ public decimal PurchaseCount
+ {
+ get { return purchaseCount; }
+ }
+ private void setPurchaseCount(decimal pPurchaseCount)
+ {
+ this.purchaseCount = pPurchaseCount;
+ }
+ public decimal PurchaseAmt
+ {
+ get { return purchaseAmt; }
+ }
+ private void setPurchaseAmt(decimal pPurchaseAmt)
+ {
+ this.purchaseAmt = pPurchaseAmt;
+ }
+ private static string curTxnId;
+ public static string toJsonForSale(string txnId, decimal txnAmt, decimal tipAmt, PaymentApp appId, string qrcValue) {
+
+ string cardSaleMsg = "{\"EVENT_NAME\":\"SALE\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TIPS\":" + tipAmt + ",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
+ return cardSaleMsg;
+ }
+
+ public static string toJsonForSale(string txnId, decimal txnAmt, decimal tipAmt, decimal cashbackAmt, string ecrRefNo, String currency, PaymentApp appId, string qrcValue, string pan, string expDate)
+ {
+
+ string cardSaleMsg = "{\"EVENT_NAME\":\"SALE\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TIPS\":" + tipAmt + ",\"TXN_AMT\":" + txnAmt + ",\"CASHBACK_AMT\":" + cashbackAmt + ",\"ECR_REF_NO\":\"" + ecrRefNo + "\",\"CURRENCY\":\"" + currency + "\",\"PAN\":\"" + pan + "\",\"EXPIRY_DATE\":\"" + expDate + "\",\"QRC_VALUE\":\"" + qrcValue + "\"}";
+ return cardSaleMsg;
+ }
+ public static string toJsonForPreauth(string txnId, decimal txnAmt, PaymentApp appId, string pan, string expDate)
+ {
+
+ string cardSaleMsg = "{\"EVENT_NAME\":\"PREAUTH\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TXN_AMT\":" + txnAmt + ",\"PAN\":\"" + pan + "\",\"EXPIRY_DATE\":\"" + expDate + "\"}";
+ return cardSaleMsg;
+ }
+ public static string toJsonForOffline(string txnId, decimal txnAmt, PaymentApp appId, string authCode, string pan, string expDate)
+ {
+
+ string cardSaleMsg = "{\"EVENT_NAME\":\"OFFLINE\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TXN_AMT\":" + txnAmt + ",\"AUTH_CODE\":\"" + authCode + "\""+ ",\"PAN\":\"" + pan + "\",\"EXPIRY_DATE\":\"" + expDate + "\"}";
+ return cardSaleMsg;
+ }
+ public static string toJsonForAdjust(string txnId, decimal totalAmt, decimal totalForeignAmt, PaymentApp appId)
+ {
+
+ string cardSaleMsg = "{\"EVENT_NAME\":\"ADJUST\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TOTAL_TXN_AMT\":" + totalAmt + ",\"TOTAL_FOREIGN_AMT\":" + totalForeignAmt + "}";
+ return cardSaleMsg;
+ }
+ private static string getTxnId() {
+ StringBuilder txnIdSb = new StringBuilder();
+ DateTime dt = DateTime.Now;
+ txnIdSb.Append(dt.ToString("yyyyMMddHHmmssfff"));
+ Console.WriteLine("txnIdSb = " + txnIdSb.ToString());
+ int randomTime = 0;
+ if (dt.Ticks.ToString().Length > 8) {
+ Console.WriteLine("Ticks.Length > 8 = " + dt.Ticks.ToString());
+ randomTime = int.Parse(dt.Ticks.ToString().Substring(0, 8));
+ }
+ else {
+ randomTime = int.Parse(dt.Ticks.ToString());
+ }
+
+ if (randomTime > 0) {
+ Random random = new Random(randomTime);
+ for (int i = 0; i < 15; i++) {
+ int thidRandom = random.Next(10);
+ txnIdSb.Append(thidRandom);
+ }
+ Console.WriteLine("txnIdSb.ToString = " + txnIdSb.ToString());
+ return txnIdSb.ToString();
+ }
+ else {
+ Console.WriteLine("randomTime is error = " + randomTime);
+ }
+
+ return "";
+ }
+
+ public SettleResult() {
+ }
+
+ public SettleResult(string pStatus) {
+ this.setStatus(pStatus);
+ }
+
+ public static SettleResult toSettleResultFromJsonMsg(string jsonMsg) {
+ if (jsonMsg == null || !jsonMsg.StartsWith("{") || !jsonMsg.EndsWith("}")) {
+ return null;
+ }
+ int jsonLength = jsonMsg.Length;
+ jsonMsg = jsonMsg.Substring(0, jsonLength - 1);
+ jsonMsg = jsonMsg.Substring(1, jsonLength - 2);
+ string[] column = jsonMsg.Split(',');
+ string[] valueColumn = null;
+ string valueColumn0 = null;
+ string valueColumn1 = null;
+ SettleResult saleResult = new SettleResult();
+
+ for (int i = 0; i < column.Length; i++) {
+ valueColumn = column[i].Split(':');
+ valueColumn0 = valueColumn[0].Replace('"', ' ').Trim();
+ valueColumn1 = valueColumn[1].Replace('"', ' ').Trim();
+ if (SettleResult.EVENT_NAME.Equals(valueColumn0))
+ {
+ saleResult.setEventName(valueColumn1);
+ }
+ if (SettleResult.STATUS.Equals(valueColumn0)) {
+ saleResult.setStatus(valueColumn1);
+ }
+ if (SettleResult.RESP_CODE.Equals(valueColumn0))
+ {
+ saleResult.setRespCode(valueColumn1);
+ }
+ if (SettleResult.RESPONSE_TEXT.Equals(valueColumn0))
+ {
+ saleResult.setResponseText(valueColumn1);
+ }
+ if (SettleResult.TXN_DATE.Equals(valueColumn0))
+ {
+ saleResult.setTxnDate(valueColumn1);
+ }
+ if (SettleResult.TXN_TIME.Equals(valueColumn0))
+ {
+ saleResult.setTxnTime(valueColumn1);
+ }
+ if (SettleResult.MID.Equals(valueColumn0))
+ {
+ saleResult.setMid(valueColumn1);
+ }
+ if (SettleResult.TID.Equals(valueColumn0))
+ {
+ saleResult.setTid(valueColumn1);
+ }
+ if (SettleResult.HOST_COUNT.Equals(valueColumn0)) {
+ if (valueColumn1 == null || "".Equals(valueColumn1)) {
+ saleResult.setHostCount(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else {
+ saleResult.setHostCount(decimal.Parse(valueColumn1));
+ }
+ }
+
+ if (SettleResult.HOST_AMT.Equals(valueColumn0))
+ {
+ if (valueColumn1 == null || "".Equals(valueColumn1))
+ {
+ saleResult.setHostAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else
+ {
+ saleResult.setHostAmt(decimal.Parse(valueColumn1));
+ }
+ }
+ if (SettleResult.BANKIN_VALUE_DATE.Equals(valueColumn0))
+ {
+ saleResult.setBankinValueDate(valueColumn1);
+ }
+ if (SettleResult.EPS_TOTAL_COUNT.Equals(valueColumn0))
+ {
+ if (valueColumn1 == null || "".Equals(valueColumn1))
+ {
+ saleResult.setEPSTotalCount(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else
+ {
+ saleResult.setEPSTotalCount(decimal.Parse(valueColumn1));
+ }
+ }
+ if (SettleResult.EPS_TOTAL_AMT.Equals(valueColumn0))
+ {
+ if (valueColumn1 == null || "".Equals(valueColumn1))
+ {
+ saleResult.setEPSTotalAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else
+ {
+ saleResult.setEPSTotalAmt(decimal.Parse(valueColumn1));
+ }
+ }
+ if (SettleResult.CASHBACK_COUNT.Equals(valueColumn0))
+ {
+ if (valueColumn1 == null || "".Equals(valueColumn1))
+ {
+ saleResult.setCashbackCount(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else
+ {
+ saleResult.setCashbackCount(decimal.Parse(valueColumn1));
+ }
+ }
+ if (SettleResult.CASHBACK_AMT.Equals(valueColumn0))
+ {
+ if (valueColumn1 == null || "".Equals(valueColumn1))
+ {
+ saleResult.setCashbackAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else
+ {
+ saleResult.setCashbackAmt(decimal.Parse(valueColumn1));
+ }
+ }
+ if (SettleResult.PURCHASE_COUNT.Equals(valueColumn0))
+ {
+ if (valueColumn1 == null || "".Equals(valueColumn1))
+ {
+ saleResult.setPurchaseCount(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else
+ {
+ saleResult.setPurchaseCount(decimal.Parse(valueColumn1));
+ }
+ }
+ if (SettleResult.PURCHASE_AMT.Equals(valueColumn0))
+ {
+ if (valueColumn1 == null || "".Equals(valueColumn1))
+ {
+ saleResult.setPurchaseAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else
+ {
+ saleResult.setPurchaseAmt(decimal.Parse(valueColumn1));
+ }
+ }
+ if (SettleResult.TRACE_NO.Equals(valueColumn0)) {
+ saleResult.setTraceNo(valueColumn1);
+ }
+
+
+
+ }
+ return saleResult;
+ }
+
+ public static string rebuildSettleRespMsg(string saleResultJsonStr)
+ {
+ //saleResultJsonStr = "{\"EVENT_NAME\":\"SETTLE_RESP\",\"MID\":\"000000888\",\"STATUS\":\"00\",\"TRACE_NO\":\"000485\",\"HOST_AMT\":2030.1,\"HOST_COUNT\":13,\"BATCH\":\"[{\\\"BANKIN_VALUE_DATE\\\":\\\"1117\\\",\\\"EPS_TOTAL_COUNT\\\":\\\"7\\\",\\\"EPS_TOTAL_AMT\\\":\\\"1118.10\\\"},{\\\"BANKIN_VALUE_DATE\\\":\\\"1118\\\",\\\"EPS_TOTAL_COUNT\\\":\\\"2\\\",\\\"EPS_TOTAL_AMT\\\":\\\"303.00\\\"},{\\\"BANKIN_VALUE_DATE\\\":\\\"1119\\\",\\\"EPS_TOTAL_COUNT\\\":\\\"4\\\",\\\"EPS_TOTAL_AMT\\\":\\\"609.00\\\"}]\",\"TID\":\"123372\",\"TXN_DATE\":\"091217\"}";
+ //saleResultJsonStr = "{\"EVENT_NAME\":\"SETTLE_RESP\",\"MID\":\"000000888\",\"STATUS\":\"00\",\"TRACE_NO\":\"000485\",\"HOST_AMT\":2030.1,\"HOST_COUNT\":13,\"TID\":\"123372\",\"TXN_DATE\":\"091217\"}";
+ StringBuilder sb = new StringBuilder("");
+ JObject jsonObj = null;
+ try
+ {
+ jsonObj = JObject.Parse(saleResultJsonStr);
+
+
+ sb.Append("{");
+ sb.Append("\"EVENT_NAME\":\"" + jsonObj.GetValue("EVENT_NAME") + "\",");
+ sb.Append("\"STATUS\":\"" + jsonObj.GetValue("STATUS") + "\",");
+ sb.Append("\"RESP_CODE\":\"" + jsonObj.GetValue("RESP_CODE") + "\",");
+ sb.Append("\"RESPONSE_TEXT\":\"" + jsonObj.GetValue("RESPONSE_TEXT") + "\",");
+ sb.Append("\"TXN_DATE\":\"" + jsonObj.GetValue("TXN_DATE") + "\",");
+ sb.Append("\"TXN_TIME\":\"" + jsonObj.GetValue("TXN_TIME") + "\",");
+ sb.Append("\"MID\":\"" + jsonObj.GetValue("MID") + "\",");
+ sb.Append("\"TID\":\"" + jsonObj.GetValue("TID") + "\",");
+ sb.Append("\"HOST_COUNT\":" + jsonObj.GetValue("HOST_COUNT") + ",");
+ sb.Append("\"HOST_AMT\":" + jsonObj.GetValue("HOST_AMT") + ",");
+
+ String batchJson = (String)jsonObj.GetValue("BATCH");
+ if (batchJson != null)
+ {
+ sb.Append("\"TRACE_NO\":\"" + jsonObj.GetValue("TRACE_NO") + "\",");
+ sb.Append("\"BATCH\":\"[");
+ JArray jlist = JArray.Parse(batchJson);
+ for (int i = 0; i < jlist.Count; ++i) //遍历JArray
+ {
+ JObject tempo = JObject.Parse(jlist[i].ToString());
+ sb.Append("{");
+ sb.Append("\\\"BANKIN_VALUE_DATE\\\":\\\"" + tempo.GetValue("BANKIN_VALUE_DATE") + "\\\",");
+ sb.Append("\\\"EPS_TOTAL_COUNT\\\":\\\"" + tempo.GetValue("EPS_TOTAL_COUNT") + "\\\",");
+ if (tempo.GetValue("CASHBACK_COUNT") != null && tempo.GetValue("PURCHASE_COUNT") != null)
+ {
+ sb.Append("\\\"EPS_TOTAL_AMT\\\":\\\"" + tempo.GetValue("EPS_TOTAL_AMT") + "\\\",");
+ sb.Append("\\\"CASHBACK_COUNT\\\":\\\"" + tempo.GetValue("CASHBACK_COUNT") + "\\\",");
+ sb.Append("\\\"CASHBACK_AMT\\\":\\\"" + tempo.GetValue("CASHBACK_AMT") + "\\\",");
+ sb.Append("\\\"PURCHASE_COUNT\\\":\\\"" + tempo.GetValue("PURCHASE_COUNT") + "\\\"");
+ }
+ else
+ {
+ sb.Append("\\\"EPS_TOTAL_AMT\\\":\\\"" + tempo.GetValue("EPS_TOTAL_AMT") + "\\\"");
+ }
+ if (i != jlist.Count - 1)
+ {
+ sb.Append("},");
+ }
+ else {
+ sb.Append("}]\"");
+ }
+ }
+
+ }
+ else
+ {
+ sb.Append("\"TRACE_NO\":\"" + jsonObj.GetValue("TRACE_NO") +"\"");
+ }
+ sb.Append("}");
+ }
+ catch (Exception ex) { }
+ return sb.ToString();
+ }
+ }
+}
diff --git a/n5coredll/n5coredll.csproj b/n5coredll/n5coredll.csproj
index 1709a56..c2a2f40 100644
--- a/n5coredll/n5coredll.csproj
+++ b/n5coredll/n5coredll.csproj
@@ -41,6 +41,9 @@
n5codedll.snk
+
+ ..\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll
+
@@ -49,6 +52,7 @@
+
@@ -64,6 +68,7 @@
+
@@ -72,6 +77,7 @@
+
SettingsSingleFileGenerator
Settings.Designer.cs
diff --git a/n5coredll/packages.config b/n5coredll/packages.config
new file mode 100644
index 0000000..0fa4e01
--- /dev/null
+++ b/n5coredll/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file