diff --git a/IPInterface.TestPOS/ViewModels/ClientViewModel.cs b/IPInterface.TestPOS/ViewModels/ClientViewModel.cs index f1e31d1..7f75a83 100644 --- a/IPInterface.TestPOS/ViewModels/ClientViewModel.cs +++ b/IPInterface.TestPOS/ViewModels/ClientViewModel.cs @@ -8,411 +8,411 @@ namespace PCEFTPOS.EFTClient.IPInterface.TestPOS { - public class ClientViewModel : INotifyPropertyChanged - { - const string QPAD_FILENAME = "QueryCard_List.json"; - const string TRACK2_FILENAME = "Track2_List.json"; - const string SETTINGS_FILENAME = "settings.json"; - - ClientData _data = new ClientData(); - EftWrapper _eftw = null; - ProxyDialog _proxy = new ProxyDialog(); - - public event LogEvent OnLog; - - public ClientViewModel() - { - // initialize external data - PadEditor editor = new PadEditor(TRACK2_FILENAME); - _data.Track2Items = editor.ViewModel.UpdatedExternalData; - editor = new PadEditor(QPAD_FILENAME); - _data.PadItems = editor.ViewModel.UpdatedExternalData; - - // setup data - _data.PropertyChanged += _data_PropertyChanged; - _eftw = new EftWrapper(_data); - - _data.OnLog += _data_OnLog; - _data.OnDisplay += _data_OnDisplay; - _data.OnDisplayChanged += _data_OnDisplayChanged; - - _proxyVM.OnSendKey += _proxyVM_OnSendKey; - } - - private void _data_OnDisplayChanged(object sender, EventArgs e) - { - ProxyVM.DisplayDetails = _data.DisplayDetails; - } - - private async void _proxyVM_OnSendKey(object sender, EFTPOSKey e) - { - await _eftw.SendKey(e); - } - - private void _data_OnDisplay(bool show) - { - ShowProxyDialog(show); - } - - public async void Initialize() - { - // auto-login to cloud if user chose it - LoadSettings(); - if (_data.Settings != null && _data.Settings.CloudInfo != null && _data.Settings.CloudInfo.IsAutoLogin && _data.Settings.UseSSL) - { - if (!string.IsNullOrEmpty(_data.Settings.CloudInfo.ClientId) - && !string.IsNullOrEmpty(_data.Settings.CloudInfo.Password) - && !string.IsNullOrEmpty(_data.Settings.CloudInfo.PairingCode)) - { - await DoCloudLogon(_data.Settings.CloudInfo.Password, true); - } - else - { - _data_OnLog("Cloud logon details are empty."); - } - } - } - - private void _data_OnLog(string message) - { - OnLog?.Invoke(message); - } - - #region Common - public event PropertyChangedEventHandler PropertyChanged; - - protected void NotifyPropertyChanged(string info) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(info)); - } - - private void _data_PropertyChanged(object sender, PropertyChangedEventArgs e) - { - NotifyPropertyChanged(e.PropertyName); - } - - private bool EnumContains(string val, out T item ) - { - bool result = false; - item = default(T); - - foreach (var i in Enum.GetValues(typeof(T))) - { - string s = i.ToString(); - if (s.ToUpper().Contains(val.ToUpper())) - { - T x = (T)Enum.Parse(typeof(T), s); - item = x; - result = true; - break; - } - } - - return result; - } - - #endregion - - #region Properties - public ClientData Data - { - get { return _data; } - } - - #endregion - - #region Commmands - - #region Common - public RelayCommand ClearResult - { - get - { - return new RelayCommand((o) => - { - Data.LastTxnResult = new Dictionary(); - }); - } - } - - private void LoadSettings() - { - try - { - UserSettings data = new UserSettings(); - - JsonWriter settings = new JsonWriter(); - settings.Load(SETTINGS_FILENAME, out data); - - if (data != default(UserSettings)) - { - data.CloudInfo.LoadCredentials(); - Data.Settings = data; - } - } - catch - { - } - } - - public void SaveSettings() - { - try - { - Data.Settings.CloudInfo.SaveCredentials(); - - JsonWriter settings = new JsonWriter(); - settings.Save(Data.Settings, SETTINGS_FILENAME); - } - catch(Exception ex) - { - Trace.WriteLine(ex.Message); - } - } - - #endregion - - #region Connection - public async Task ConnectAsync() - { - await _eftw.Connect(Data.Settings.Host, Data.Settings.Port, Data.Settings.UseSSL); - } - - public void Disconnect() - { - _eftw.Disconnect(); - } - - public RelayCommand Connect - { - get - { - return new RelayCommand(async (o) => - { - if (Data.ConnectedState == ConnectedStatus.Disconnected) - { - if (Data.Settings.UseSSL) - { - string p = (string)o; - await DoCloudLogon(p); - } - else - { - await _eftw.Connect(Data.Settings.Host, Data.Settings.Port, Data.Settings.UseSSL); - } - } - else - { - _eftw.Disconnect(); - } - }); - } - } - #endregion - - #region Logon - public RelayCommand Logon - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.Logon(Data.SelectedLogon, Data.CutReceiptMode, Data.PrintMode, false); - }); - } - } - - public RelayCommand CloudLogon - { - get - { - return new RelayCommand(async (o) => - { - string p = (string)o; - await DoCloudLogon(p); - }); - } - } - - public async Task DoCloudLogon(string password, bool autoLogin = false) - { - try - { - if (_data.ConnectedState == ConnectedStatus.Disconnected) - { - var r = await _eftw.Connect(Data.Settings.Host, Data.Settings.Port, Data.Settings.UseSSL); - if (r == false) - return; - } - - Data.Settings.CloudInfo.Password = password; - await _eftw.CloudLogon(Data.Settings.CloudInfo.ClientId, Data.Settings.CloudInfo.Password, Data.Settings.CloudInfo.PairingCode); - - if (Data.Settings.CloudInfo.IsAutoLogin && !autoLogin) - { - SaveSettings(); - } - } - catch (Exception ex) - { - _data_OnLog(ex.Message); - } - } - - public RelayCommand ToggleLogon - { - get - { - return new RelayCommand(async (o) => - { - if (!Data.LogonTestEnabled) - { - Data.LogonTestEnabled = true; - await _eftw.StartLogonTest(Data.SelectedLogon, Data.CutReceiptMode, Data.PrintMode); - } - else - { - Data.LogonTestEnabled = false; - _eftw.StopLogonTest(); - } - }); - } - } - - #endregion - - #region Transaction - public RelayCommand Transaction - { - get - { - return new RelayCommand(async (o) => - { - try - { - if (!string.IsNullOrEmpty(Data.SelectedPad)) - { - string pad = Data.PadItems.Find(x => x.ToString().Equals(Data.SelectedPad)).Value; - Data.TransactionRequest.PurchaseAnalysisData = new PadField(pad); - } - - if (!string.IsNullOrEmpty(Data.SelectedTrack2) && Data.TransactionRequest.PanSource == PanSource.POSSwiped) - { - var selectedTrack = Data.Track2Items.Find(x => x.ToString().Equals(Data.SelectedTrack2)); - Data.TransactionRequest.Track2 = (selectedTrack != null) ? selectedTrack.Value : Data.SelectedTrack2; - } - else - { - Data.SelectedTrack2 = string.Empty; - } - - if (!Data.IsETS) - { - Data.TransactionRequest.Application = TerminalApplication.EFTPOS; - } - - Data.TransactionRequest.TxnRef = Data.TransactionReference; - Data.TransactionRequest.ReceiptPrintMode = Data.PrintMode; - Data.TransactionRequest.ReceiptCutMode = Data.CutReceiptMode; - - await _eftw.DoTransaction(Data.TransactionRequest); - } - catch (Exception ex) - { - Data.Log(ex.Message); - } - }); - } - } - - public RelayCommand QueryTransaction - { - get - { - return new RelayCommand(async (o) => - { - try - { - PadField p = new PadField(); - if (!string.IsNullOrEmpty(Data.SelectedPad)) - { - string pad = Data.PadItems.Find(x => x.ToString().Equals(Data.SelectedPad)).Value; - p = new PadField(pad); - } - - if (!Data.IsETS) - { - Data.TransactionRequest.Application = TerminalApplication.EFTPOS; - } - - Data.TransactionRequest.TxnRef = Data.TransactionReference; - - await _eftw.QueryCard(p, QueryCardType.ReadCard); - - string output = string.Empty; - Data.LastTxnResult.TryGetValue("Success", out output); - if (output != null && output.Equals("True")) - { - if (!string.IsNullOrEmpty(Data.SelectedTrack2)) - { - Data.SelectedCardSource = PanSource.POSSwiped.ToString(); - Data.TransactionRequest.PanSource = PanSource.POSSwiped; - Data.TransactionRequest.Track2 = Data.SelectedTrack2; - await _eftw.DoTransaction(Data.TransactionRequest); - } - } - } - catch (Exception ex) - { - Data.Log(ex.Message); - } - }); - } - } - - public RelayCommand LaunchTrack2 - { - get - { - return new RelayCommand((o) => - { - PadEditor editor = new PadEditor(TRACK2_FILENAME, "Track"); - if (editor.ShowDialog() == true) - { - Data.Track2Items = editor.ViewModel.UpdatedExternalData; - } - }); - } - } - - public RelayCommand LaunchPad - { - get - { - return new RelayCommand((o) => - { - PadEditor editor = new PadEditor(QPAD_FILENAME); - if (editor.ShowDialog() == true) - { - Data.PadItems = editor.ViewModel.UpdatedExternalData; - } - }); - } - } - - #endregion - - #region Status - public RelayCommand Status - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.GetStatus(Data.SelectedStatus); - }); - } - } + public class ClientViewModel : INotifyPropertyChanged + { + const string QPAD_FILENAME = "QueryCard_List.json"; + const string TRACK2_FILENAME = "Track2_List.json"; + const string SETTINGS_FILENAME = "settings.json"; + + ClientData _data = new ClientData(); + EftWrapper _eftw = null; + ProxyDialog _proxy = new ProxyDialog(); + + public event LogEvent OnLog; + + public ClientViewModel() + { + // initialize external data + PadEditor editor = new PadEditor(TRACK2_FILENAME); + _data.Track2Items = editor.ViewModel.UpdatedExternalData; + editor = new PadEditor(QPAD_FILENAME); + _data.PadItems = editor.ViewModel.UpdatedExternalData; + + // setup data + _data.PropertyChanged += _data_PropertyChanged; + _eftw = new EftWrapper(_data); + + _data.OnLog += _data_OnLog; + _data.OnDisplay += _data_OnDisplay; + _data.OnDisplayChanged += _data_OnDisplayChanged; + + _proxyVM.OnSendKey += _proxyVM_OnSendKey; + } + + private void _data_OnDisplayChanged(object sender, EventArgs e) + { + ProxyVM.DisplayDetails = _data.DisplayDetails; + } + + private async void _proxyVM_OnSendKey(object sender, EFTPOSKey e) + { + await _eftw.SendKey(e); + } + + private void _data_OnDisplay(bool show) + { + ShowProxyDialog(show); + } + + public async void Initialize() + { + // auto-login to cloud if user chose it + LoadSettings(); + if (_data.Settings != null && _data.Settings.CloudInfo != null && _data.Settings.CloudInfo.IsAutoLogin && _data.Settings.UseSSL) + { + if (!string.IsNullOrEmpty(_data.Settings.CloudInfo.ClientId) + && !string.IsNullOrEmpty(_data.Settings.CloudInfo.Password) + && !string.IsNullOrEmpty(_data.Settings.CloudInfo.PairingCode)) + { + await DoCloudLogon(_data.Settings.CloudInfo.Password, true); + } + else + { + _data_OnLog("Cloud logon details are empty."); + } + } + } + + private void _data_OnLog(string message) + { + OnLog?.Invoke(message); + } + + #region Common + public event PropertyChangedEventHandler PropertyChanged; + + protected void NotifyPropertyChanged(string info) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(info)); + } + + private void _data_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + NotifyPropertyChanged(e.PropertyName); + } + + private bool EnumContains(string val, out T item) + { + bool result = false; + item = default(T); + + foreach (var i in Enum.GetValues(typeof(T))) + { + string s = i.ToString(); + if (s.ToUpper().Contains(val.ToUpper())) + { + T x = (T)Enum.Parse(typeof(T), s); + item = x; + result = true; + break; + } + } + + return result; + } + + #endregion + + #region Properties + public ClientData Data + { + get { return _data; } + } + + #endregion + + #region Commmands + + #region Common + public RelayCommand ClearResult + { + get + { + return new RelayCommand((o) => + { + Data.LastTxnResult = new Dictionary(); + }); + } + } + + private void LoadSettings() + { + try + { + UserSettings data = new UserSettings(); + + JsonWriter settings = new JsonWriter(); + settings.Load(SETTINGS_FILENAME, out data); + + if (data != default(UserSettings)) + { + data.CloudInfo.LoadCredentials(); + Data.Settings = data; + } + } + catch + { + } + } + + public void SaveSettings() + { + try + { + Data.Settings.CloudInfo.SaveCredentials(); + + JsonWriter settings = new JsonWriter(); + settings.Save(Data.Settings, SETTINGS_FILENAME); + } + catch (Exception ex) + { + Trace.WriteLine(ex.Message); + } + } + + #endregion + + #region Connection + public async Task ConnectAsync() + { + await _eftw.Connect(Data.Settings.Host, Data.Settings.Port, Data.Settings.UseSSL); + } + + public void Disconnect() + { + _eftw.Disconnect(); + } + + public RelayCommand Connect + { + get + { + return new RelayCommand(async (o) => + { + if (Data.ConnectedState == ConnectedStatus.Disconnected) + { + if (Data.Settings.UseSSL) + { + string p = (string)o; + await DoCloudLogon(p); + } + else + { + await _eftw.Connect(Data.Settings.Host, Data.Settings.Port, Data.Settings.UseSSL); + } + } + else + { + _eftw.Disconnect(); + } + }); + } + } + #endregion + + #region Logon + public RelayCommand Logon + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.Logon(Data.SelectedLogon, Data.CutReceiptMode, Data.PrintMode, false); + }); + } + } + + public RelayCommand CloudLogon + { + get + { + return new RelayCommand(async (o) => + { + string p = (string)o; + await DoCloudLogon(p); + }); + } + } + + public async Task DoCloudLogon(string password, bool autoLogin = false) + { + try + { + if (_data.ConnectedState == ConnectedStatus.Disconnected) + { + var r = await _eftw.Connect(Data.Settings.Host, Data.Settings.Port, Data.Settings.UseSSL); + if (r == false) + return; + } + + Data.Settings.CloudInfo.Password = password; + await _eftw.CloudLogon(Data.Settings.CloudInfo.ClientId, Data.Settings.CloudInfo.Password, Data.Settings.CloudInfo.PairingCode); + + if (Data.Settings.CloudInfo.IsAutoLogin && !autoLogin) + { + SaveSettings(); + } + } + catch (Exception ex) + { + _data_OnLog(ex.Message); + } + } + + public RelayCommand ToggleLogon + { + get + { + return new RelayCommand(async (o) => + { + if (!Data.LogonTestEnabled) + { + Data.LogonTestEnabled = true; + await _eftw.StartLogonTest(Data.SelectedLogon, Data.CutReceiptMode, Data.PrintMode); + } + else + { + Data.LogonTestEnabled = false; + _eftw.StopLogonTest(); + } + }); + } + } + + #endregion + + #region Transaction + public RelayCommand Transaction + { + get + { + return new RelayCommand(async (o) => + { + try + { + if (!string.IsNullOrEmpty(Data.SelectedPad)) + { + string pad = Data.PadItems.Find(x => x.ToString().Equals(Data.SelectedPad)).Value; + Data.TransactionRequest.PurchaseAnalysisData = new PadField(pad); + } + + if (!string.IsNullOrEmpty(Data.SelectedTrack2) && Data.TransactionRequest.PanSource == PanSource.POSSwiped) + { + var selectedTrack = Data.Track2Items.Find(x => x.ToString().Equals(Data.SelectedTrack2)); + Data.TransactionRequest.Track2 = (selectedTrack != null) ? selectedTrack.Value : Data.SelectedTrack2; + } + else + { + Data.SelectedTrack2 = string.Empty; + } + + if (!Data.IsETS) + { + Data.TransactionRequest.Application = TerminalApplication.EFTPOS; + } + + Data.TransactionRequest.TxnRef = Data.TransactionReference; + Data.TransactionRequest.ReceiptAutoPrint = Data.PrintMode; + Data.TransactionRequest.CutReceipt = Data.CutReceiptMode; + + await _eftw.DoTransaction(Data.TransactionRequest); + } + catch (Exception ex) + { + Data.Log(ex.Message); + } + }); + } + } + + public RelayCommand QueryTransaction + { + get + { + return new RelayCommand(async (o) => + { + try + { + PadField p = new PadField(); + if (!string.IsNullOrEmpty(Data.SelectedPad)) + { + string pad = Data.PadItems.Find(x => x.ToString().Equals(Data.SelectedPad)).Value; + p = new PadField(pad); + } + + if (!Data.IsETS) + { + Data.TransactionRequest.Application = TerminalApplication.EFTPOS; + } + + Data.TransactionRequest.TxnRef = Data.TransactionReference; + + await _eftw.QueryCard(p, QueryCardType.ReadCard); + + string output = string.Empty; + Data.LastTxnResult.TryGetValue("Success", out output); + if (output != null && output.Equals("True")) + { + if (!string.IsNullOrEmpty(Data.SelectedTrack2)) + { + Data.SelectedCardSource = PanSource.POSSwiped.ToString(); + Data.TransactionRequest.PanSource = PanSource.POSSwiped; + Data.TransactionRequest.Track2 = Data.SelectedTrack2; + await _eftw.DoTransaction(Data.TransactionRequest); + } + } + } + catch (Exception ex) + { + Data.Log(ex.Message); + } + }); + } + } + + public RelayCommand LaunchTrack2 + { + get + { + return new RelayCommand((o) => + { + PadEditor editor = new PadEditor(TRACK2_FILENAME, "Track"); + if (editor.ShowDialog() == true) + { + Data.Track2Items = editor.ViewModel.UpdatedExternalData; + } + }); + } + } + + public RelayCommand LaunchPad + { + get + { + return new RelayCommand((o) => + { + PadEditor editor = new PadEditor(QPAD_FILENAME); + if (editor.ShowDialog() == true) + { + Data.PadItems = editor.ViewModel.UpdatedExternalData; + } + }); + } + } + + #endregion + + #region Status + public RelayCommand Status + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.GetStatus(Data.SelectedStatus); + }); + } + } #endregion @@ -433,337 +433,337 @@ public RelayCommand ClientList #region Configure Merchant public RelayCommand ConfigureMerchant - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.ConfigureMerchant(Data.MerchantDetails); - }); - } - } - #endregion - - #region Settlement - public RelayCommand Settlement - { - get - { - return new RelayCommand(async (o) => - { - var pad = ""; - if (!string.IsNullOrEmpty(Data.SelectedPad)) - { - pad = Data.PadItems.Find(x => x.ToString().Equals(Data.SelectedPad)).Value; - } - - await _eftw.DoSettlement(Data.SelectedSettlement, Data.CutReceiptMode, new PadField(pad), Data.PrintMode, Data.ResetTotals); - }); - } - } - #endregion - - #region Control Panel - - public RelayCommand DisplayControlPanel - { - get { return new RelayCommand(async (o) => await _eftw.DisplayControlPanel(Data.SelectedDisplay, Data.CutReceiptMode, Data.PrintMode)); } - } - - #endregion - - #region Query Card - - public RelayCommand QueryCard - { - get - { - return new RelayCommand(async (o) => - { - string pad = string.Empty; - if (!string.IsNullOrEmpty(Data.SelectedPad)) - { - pad = Data.PadItems.Find(x => x.ToString().Equals(Data.SelectedPad)).Value; - } - - await _eftw.QueryCard(new PadField(pad), Data.SelectedQuery); - }); - } - } - - - #endregion - - #region Last Transaction - - public RelayCommand LastTransaction - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.GetLastTransaction(); - }); - } - } - - - #endregion - - #region Re-print Receipt - - public RelayCommand ReprintReceipt - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.LastReceipt(Data.CutReceiptMode, Data.PrintMode, ReprintType.Reprint); - }); - } - } - - public RelayCommand GetLastReceipt - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.LastReceipt(Data.CutReceiptMode, Data.PrintMode, ReprintType.GetLast); - }); - } - } - - #endregion - - #region Verify Cheque - - public RelayCommand VerifyCheque - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.DoVerifyCheque(Data.ChequeRequest); - }); - } - } - - - #endregion - - #region Set Dialog - public RelayCommand SetDialog - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.SetDialog(Data.DialogRequest); - }); - } - } - - public RelayCommand HideDialog - { - get - { - return new RelayCommand(async (o) => - { - DialogType t = ((bool)o ? DialogType.Hidden : DialogType.Standard); - SetDialogRequest r = new SetDialogRequest - { - DialogX = Data.DialogRequest.DialogX, - DialogY = Data.DialogRequest.DialogY, - DialogPosition = Data.DialogRequest.DialogPosition, - DialogTitle = Data.DialogRequest.DialogTitle, - EnableTopmost = Data.DialogRequest.EnableTopmost, - DialogType = t - }; - - await _eftw.SetDialog(r); - }); - } - } - - - #endregion - - #region Slave Mode - public RelayCommand SlaveMode - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.DoSlaveMode(Data.CommandRequest); - }); - } - } - #endregion - - #region Send Key - public RelayCommand SendKey - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.SendKey(Data.SelectedPosKey, Data.PosData); - }); - } - } - - public RelayCommand ToggleSendKey - { - get - { - return new RelayCommand(async (o) => - { - if (!Data.SendKeyEnabled) - { - Data.SendKeyEnabled = true; - await _eftw.StartSendKeysTest(Data.SelectedPosKey); - } - else - { - Data.SendKeyEnabled = false; - _eftw.StopSendKeysTest(); - - } - }); - } - } - - public async void ToggleStop() - { - if (!Data.SendKeyEnabled) - { - Data.SendKeyEnabled = true; - await _eftw.StartSendKeysTest(Data.SelectedPosKey); - } - else - { - Data.SendKeyEnabled = false; - _eftw.StopSendKeysTest(); - - } - } - - //RelayCommand _proxySendKey; - //public RelayCommand ProxySendKey => _proxySendKey ?? (_proxySendKey = new RelayCommand(async (o) => - //{ - // string name = o.ToString(); - // EFTPOSKey key = EFTPOSKey.OkCancel; - - // if (EnumContains(name, out key)) - // { - // await _eftw.SendKey(key, (key == EFTPOSKey.Authorise) ? _data.PosData : string.Empty); - // ShowProxyDialog(false); - // } - //})); - - //public RelayCommand ProxySendKey - //{ - // get - // { - // return new RelayCommand(async (o) => - // { - // string name = o.ToString(); - // EFTPOSKey key = EFTPOSKey.OkCancel; - - // if (EnumContains(name, out key)) - // { - // await _eftw.SendKey(key, (key == EFTPOSKey.Authorise) ? _data.PosData : string.Empty); - // ShowProxyDialog(false); - // } - // }); - // } - //} - - //public async Task ProxySendKeyFunc(EFTPOSKey key) - //{ - // await _eftw.SendKey(key); - //} - - #endregion - - #region PIN - public RelayCommand AuthPin - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.AuthPin(); - }); - } - } - - public RelayCommand ChangePin - { - get - { - return new RelayCommand(async (o) => - { - await _eftw.ChangePin(); - }); - } - } - #endregion - - #region Proxy Dialog - - //public bool ProxyWindowClosing = false; - public RelayCommand UseProxyDialog - { - get - { - return new RelayCommand((o) => - { - ShowProxyDialog(true); - }); - } - } - - ViewModels.ProxyViewModel _proxyVM = new ViewModels.ProxyViewModel(); - public ViewModels.ProxyViewModel ProxyVM - { - get { return _proxyVM; } - set - { - _proxyVM = value; NotifyPropertyChanged(nameof(ProxyVM)); - } - } - - public void ShowProxyDialog(bool show) - { - if (show) - { - if (!_proxy.IsVisible) - { - ProxyVM.ProxyWindowClosing = true; - _proxy.Close(); - _proxy = new ProxyDialog - { - DataContext = ProxyVM // this; - }; - _proxy.Show(); - ProxyVM.ProxyWindowClosing = false; - } - } - else - { - if (_data.Settings.DemoDialogOption != DemoDialogMode.AlwaysShow) - { - _proxy.Hide(); - } - } - } - - #endregion - - #endregion - } + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.ConfigureMerchant(Data.MerchantDetails); + }); + } + } + #endregion + + #region Settlement + public RelayCommand Settlement + { + get + { + return new RelayCommand(async (o) => + { + var pad = ""; + if (!string.IsNullOrEmpty(Data.SelectedPad)) + { + pad = Data.PadItems.Find(x => x.ToString().Equals(Data.SelectedPad)).Value; + } + + await _eftw.DoSettlement(Data.SelectedSettlement, Data.CutReceiptMode, new PadField(pad), Data.PrintMode, Data.ResetTotals); + }); + } + } + #endregion + + #region Control Panel + + public RelayCommand DisplayControlPanel + { + get { return new RelayCommand(async (o) => await _eftw.DisplayControlPanel(Data.SelectedDisplay, Data.CutReceiptMode, Data.PrintMode)); } + } + + #endregion + + #region Query Card + + public RelayCommand QueryCard + { + get + { + return new RelayCommand(async (o) => + { + string pad = string.Empty; + if (!string.IsNullOrEmpty(Data.SelectedPad)) + { + pad = Data.PadItems.Find(x => x.ToString().Equals(Data.SelectedPad)).Value; + } + + await _eftw.QueryCard(new PadField(pad), Data.SelectedQuery); + }); + } + } + + + #endregion + + #region Last Transaction + + public RelayCommand LastTransaction + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.GetLastTransaction(); + }); + } + } + + + #endregion + + #region Re-print Receipt + + public RelayCommand ReprintReceipt + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.LastReceipt(Data.CutReceiptMode, Data.PrintMode, ReprintType.Reprint); + }); + } + } + + public RelayCommand GetLastReceipt + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.LastReceipt(Data.CutReceiptMode, Data.PrintMode, ReprintType.GetLast); + }); + } + } + + #endregion + + #region Verify Cheque + + public RelayCommand VerifyCheque + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.DoVerifyCheque(Data.ChequeRequest); + }); + } + } + + + #endregion + + #region Set Dialog + public RelayCommand SetDialog + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.SetDialog(Data.DialogRequest); + }); + } + } + + public RelayCommand HideDialog + { + get + { + return new RelayCommand(async (o) => + { + DialogType t = ((bool)o ? DialogType.Hidden : DialogType.Standard); + SetDialogRequest r = new SetDialogRequest + { + DialogX = Data.DialogRequest.DialogX, + DialogY = Data.DialogRequest.DialogY, + DialogPosition = Data.DialogRequest.DialogPosition, + DialogTitle = Data.DialogRequest.DialogTitle, + EnableTopmost = Data.DialogRequest.EnableTopmost, + DialogType = t + }; + + await _eftw.SetDialog(r); + }); + } + } + + + #endregion + + #region Slave Mode + public RelayCommand SlaveMode + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.DoSlaveMode(Data.CommandRequest); + }); + } + } + #endregion + + #region Send Key + public RelayCommand SendKey + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.SendKey(Data.SelectedPosKey, Data.PosData); + }); + } + } + + public RelayCommand ToggleSendKey + { + get + { + return new RelayCommand(async (o) => + { + if (!Data.SendKeyEnabled) + { + Data.SendKeyEnabled = true; + await _eftw.StartSendKeysTest(Data.SelectedPosKey); + } + else + { + Data.SendKeyEnabled = false; + _eftw.StopSendKeysTest(); + + } + }); + } + } + + public async void ToggleStop() + { + if (!Data.SendKeyEnabled) + { + Data.SendKeyEnabled = true; + await _eftw.StartSendKeysTest(Data.SelectedPosKey); + } + else + { + Data.SendKeyEnabled = false; + _eftw.StopSendKeysTest(); + + } + } + + //RelayCommand _proxySendKey; + //public RelayCommand ProxySendKey => _proxySendKey ?? (_proxySendKey = new RelayCommand(async (o) => + //{ + // string name = o.ToString(); + // EFTPOSKey key = EFTPOSKey.OkCancel; + + // if (EnumContains(name, out key)) + // { + // await _eftw.SendKey(key, (key == EFTPOSKey.Authorise) ? _data.PosData : string.Empty); + // ShowProxyDialog(false); + // } + //})); + + //public RelayCommand ProxySendKey + //{ + // get + // { + // return new RelayCommand(async (o) => + // { + // string name = o.ToString(); + // EFTPOSKey key = EFTPOSKey.OkCancel; + + // if (EnumContains(name, out key)) + // { + // await _eftw.SendKey(key, (key == EFTPOSKey.Authorise) ? _data.PosData : string.Empty); + // ShowProxyDialog(false); + // } + // }); + // } + //} + + //public async Task ProxySendKeyFunc(EFTPOSKey key) + //{ + // await _eftw.SendKey(key); + //} + + #endregion + + #region PIN + public RelayCommand AuthPin + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.AuthPin(); + }); + } + } + + public RelayCommand ChangePin + { + get + { + return new RelayCommand(async (o) => + { + await _eftw.ChangePin(); + }); + } + } + #endregion + + #region Proxy Dialog + + //public bool ProxyWindowClosing = false; + public RelayCommand UseProxyDialog + { + get + { + return new RelayCommand((o) => + { + ShowProxyDialog(true); + }); + } + } + + ViewModels.ProxyViewModel _proxyVM = new ViewModels.ProxyViewModel(); + public ViewModels.ProxyViewModel ProxyVM + { + get { return _proxyVM; } + set + { + _proxyVM = value; NotifyPropertyChanged(nameof(ProxyVM)); + } + } + + public void ShowProxyDialog(bool show) + { + if (show) + { + if (!_proxy.IsVisible) + { + ProxyVM.ProxyWindowClosing = true; + _proxy.Close(); + _proxy = new ProxyDialog + { + DataContext = ProxyVM // this; + }; + _proxy.Show(); + ProxyVM.ProxyWindowClosing = false; + } + } + else + { + if (_data.Settings.DemoDialogOption != DemoDialogMode.AlwaysShow) + { + _proxy.Hide(); + } + } + } + + #endregion + + #endregion + } } diff --git a/IPInterface.TestPOS/ViewModels/EftWrapper.cs b/IPInterface.TestPOS/ViewModels/EftWrapper.cs index 2cfcb28..4f70c1a 100644 --- a/IPInterface.TestPOS/ViewModels/EftWrapper.cs +++ b/IPInterface.TestPOS/ViewModels/EftWrapper.cs @@ -79,34 +79,34 @@ private void Eft_OnLog(object sender, LogEventArgs e) string value = p.ToString(); Type tt = p.GetType(); - if (p is TransactionType txn) - { - value = txn.ToTransactionString(); - } - else if (tt.IsClass && tt != typeof(string) && !tt.IsArray) - { - var e = DictionaryFromType(p); - if (e.Count > 0) - { - value = string.Empty; - foreach (var i in e) - { - value += $"{i.Key}: {i.Value};{Environment.NewLine}"; - } - } - } - else if (tt == typeof(string[])) - { - value = string.Empty; - string[] arr = p as string[]; - foreach (string s in arr) - { - value += s + Environment.NewLine; - } - _data.Log(value); - } - - d.Add(prp.Name, value); + if (p is TransactionType txn) + { + value = txn.ToTransactionString(); + } + else if (tt.IsClass && tt != typeof(string) && !tt.IsArray) + { + var e = DictionaryFromType(p); + if (e.Count > 0) + { + value = string.Empty; + foreach (var i in e) + { + value += $"{i.Key}: {i.Value};{Environment.NewLine}"; + } + } + } + else if (tt == typeof(string[])) + { + value = string.Empty; + string[] arr = p as string[]; + foreach (string s in arr) + { + value += s + Environment.NewLine; + } + _data.Log(value); + } + + d.Add(prp.Name, value); } } } @@ -330,8 +330,8 @@ public async Task Logon(LogonType logonType, ReceiptCutModeType cutMode, Receipt await SendRequest(new EFTLogonRequest() { LogonType = logonType, - ReceiptCutMode = cutMode, - ReceiptPrintMode = printMode + CutReceipt = cutMode, + ReceiptAutoPrint = printMode }, autoApproveDialogs); } @@ -442,8 +442,8 @@ public async Task LastReceipt(ReceiptCutModeType cutMode, ReceiptPrintModeType p { await SendRequest(new EFTReprintReceiptRequest() { - ReceiptCutMode = cutMode, - ReceiptPrintMode = printMode, + CutReceipt = cutMode, + ReceiptAutoPrint = printMode, ReprintType = type, OriginalTxnRef = "1234" }); @@ -546,9 +546,9 @@ public async Task ConfigureMerchant(EFTConfigureMerchantRequest request) await SendRequest(new EFTSettlementRequest { SettlementType = settlement, - ReceiptCutMode = cutMode, + CutReceipt = cutMode, PurchaseAnalysisData = padInfo, - ReceiptPrintMode = printMode, + ReceiptAutoPrint = printMode, ResetTotals = resetTotals }); } @@ -564,11 +564,11 @@ public async Task DoVerifyCheque(EFTChequeAuthRequest request) #region Slave Mode public async Task DoSlaveMode(string cmd) { - //await SendRequest(new EFTSlaveRequest - //{ - // Command = cmd - //}); - await Task.CompletedTask; + //await SendRequest(new EFTSlaveRequest + //{ + // Command = cmd + //}); + await Task.CompletedTask; } #endregion diff --git a/IPInterface/IPInterface.csproj b/IPInterface/IPInterface.csproj index 786936c..1c7488a 100644 --- a/IPInterface/IPInterface.csproj +++ b/IPInterface/IPInterface.csproj @@ -5,8 +5,8 @@ PCEFTPOS.EFTClient.IPInterface PCEFTPOS.EFTClient.IPInterface PCEFTPOS.EFTClient.IPInterface - 1.4.1.3 - 1.4.1.3 + 1.4.2.0 + 1.4.2.0 TCP/IP library used for connecting to PC-EFTPOS Client PC-EFTPOS Pty Ltd PC-EFTPOS Pty Ltd @@ -17,10 +17,15 @@ false pceftpos.pfx - 1.4.1.3 (2018-09-12) -* Fixed for EFTTransactionResponse and typo +1.4.2.0 (2018-09-19) +* Added new ReceiptAutoPrint modes for EFTRequests +* Updated MessageParser to use non-deprecated properties - 1.4.1.3 (2018-09-12) + 1.4.2.0 (2018-09-19) +* Added new ReceiptAutoPrint modes for EFTRequests +* Updated MessageParser to use non-deprecated properties + + 1.4.1.3 (2018-09-12) * Fixed for EFTTransactionResponse and typo 1.4.1.2 (2018-09-12) @@ -41,8 +46,8 @@ * Added support for basket data API * Updated some property names to bring EFTClientIP more inline with the existing ActiveX interface. Old property names have been marked obsolete, but are still supported. - 1.4.1.3 - 1.4.1.3 + 1.4.2.0 + 1.4.2.0 true diff --git a/IPInterface/Model/EFTRequest.cs b/IPInterface/Model/EFTRequest.cs index b6a7862..dac6423 100644 --- a/IPInterface/Model/EFTRequest.cs +++ b/IPInterface/Model/EFTRequest.cs @@ -2,98 +2,102 @@ namespace PCEFTPOS.EFTClient.IPInterface { - /// - /// Receipt mode (pos, windows or pinpad printer). - /// Sometimes called the "ReceiptAutoPrint" flag - /// - public enum ReceiptPrintModeType - { - /// Receipts will be passed back to the POS in the PrintReceipt event - POSPrinter = '0', - /// The EFT-Client will attempt to print using the printer configured in the EFT-Client (Windows only) - EFTClientPrinter = '1', - /// Receipts will be printed using the pinpad printer - PinpadPrinter = '9' - } + /// + /// Receipt mode (pos, windows or pinpad printer). + /// Sometimes called the "ReceiptAutoPrint" flag + /// + public enum ReceiptPrintModeType + { + /// Receipts will be passed back to the POS in the PrintReceipt event + POSPrinter = '0', + /// The EFT-Client will attempt to print using the printer configured in the EFT-Client (Windows only) + EFTClientPrinter = '1', + /// Receipts will be printed using the pinpad printer + PinpadPrinter = '9', + /// Merchant receipts print on internal printer, all other print on POS + MerchantPOSPrinter = '7', + /// Merchant receipts print on internal printer, all other print using the printer configured in the EFT-Client (Windows only) + MerchantEFTClientPrinter = '8' + } - /// - /// Receipt cut mode (cut or don't cut). Used when the EFT-Client is handling receipts (ReceiptPrintMode = ReceiptPrintModeType.EFTClientPrinter) - /// Sometimes called the "CutReceipt" flag - /// - public enum ReceiptCutModeType - { - /// Don't cut receipts - DontCut = '0', - /// Cut receipts - Cut = '1' - } + /// + /// Receipt cut mode (cut or don't cut). Used when the EFT-Client is handling receipts (ReceiptPrintMode = ReceiptPrintModeType.EFTClientPrinter) + /// Sometimes called the "CutReceipt" flag + /// + public enum ReceiptCutModeType + { + /// Don't cut receipts + DontCut = '0', + /// Cut receipts + Cut = '1' + } - /// Abstract base class for EFT client requests. - public abstract class EFTRequest - { - protected bool isStartOfTransactionRequest = true; - protected Type pairedResponseType = null; + /// Abstract base class for EFT client requests. + public abstract class EFTRequest + { + protected bool isStartOfTransactionRequest = true; + protected Type pairedResponseType = null; - private EFTRequest() - { + private EFTRequest() + { - } + } - /// - /// - /// - /// - /// - public EFTRequest(bool isStartOfTransactionRequest, Type pairedResponseType) - { - if(pairedResponseType != null && pairedResponseType.IsSubclassOf(typeof(EFTResponse)) != true) - { - throw new InvalidOperationException("pairedResponseType must be based on EFTResponse"); - } + /// + /// + /// + /// + /// + public EFTRequest(bool isStartOfTransactionRequest, Type pairedResponseType) + { + if (pairedResponseType != null && pairedResponseType.IsSubclassOf(typeof(EFTResponse)) != true) + { + throw new InvalidOperationException("pairedResponseType must be based on EFTResponse"); + } - this.isStartOfTransactionRequest = isStartOfTransactionRequest; - this.pairedResponseType = pairedResponseType; - } + this.isStartOfTransactionRequest = isStartOfTransactionRequest; + this.pairedResponseType = pairedResponseType; + } - /// - /// True if this request starts a paired transaction request/response with displays etc (i.e. transaction, logon, settlement etc) - /// - public virtual bool GetIsStartOfTransactionRequest() { return isStartOfTransactionRequest; } + /// + /// True if this request starts a paired transaction request/response with displays etc (i.e. transaction, logon, settlement etc) + /// + public virtual bool GetIsStartOfTransactionRequest() { return isStartOfTransactionRequest; } - /// - /// Indicates the paired EFTResponse for this EFTRequest if one exists. Null otherwise. - /// e.g. EFTLogonRequest will have a paired EFTLogonResponse response - /// - public virtual Type GetPairedResponseType() { return pairedResponseType; } - } + /// + /// Indicates the paired EFTResponse for this EFTRequest if one exists. Null otherwise. + /// e.g. EFTLogonRequest will have a paired EFTLogonResponse response + /// + public virtual Type GetPairedResponseType() { return pairedResponseType; } + } - /// Abstract base class for EFT client responses. - public abstract class EFTResponse - { - protected Type pairedRequestType = null; + /// Abstract base class for EFT client responses. + public abstract class EFTResponse + { + protected Type pairedRequestType = null; - /// - /// Hidden default constructor - /// - private EFTResponse() - { + /// + /// Hidden default constructor + /// + private EFTResponse() + { - } + } - public EFTResponse(Type pairedRequestType) - { - if (pairedRequestType != null && pairedRequestType.IsSubclassOf(typeof(EFTRequest)) != true) - { - throw new InvalidOperationException("pairedRequestType must be based on EFTRequest"); - } + public EFTResponse(Type pairedRequestType) + { + if (pairedRequestType != null && pairedRequestType.IsSubclassOf(typeof(EFTRequest)) != true) + { + throw new InvalidOperationException("pairedRequestType must be based on EFTRequest"); + } - this.pairedRequestType = pairedRequestType; - } + this.pairedRequestType = pairedRequestType; + } - /// - /// Indicates the paired EFTRequest for this EFTResponse if one exists. Null otherwise. - /// e.g. EFTLogonResponse will have a paired EFTLogonRequest request - /// - public virtual Type GetPairedRequestType() { return pairedRequestType; } - } + /// + /// Indicates the paired EFTRequest for this EFTResponse if one exists. Null otherwise. + /// e.g. EFTLogonResponse will have a paired EFTLogonRequest request + /// + public virtual Type GetPairedRequestType() { return pairedRequestType; } + } } diff --git a/IPInterface/Util/MessageParser.cs b/IPInterface/Util/MessageParser.cs index 7b016b7..381e8fe 100644 --- a/IPInterface/Util/MessageParser.cs +++ b/IPInterface/Util/MessageParser.cs @@ -102,6 +102,7 @@ T TryParse(string input, int length, ref int index) { return TryParse(input, length, ref index, ""); } + T TryParse(string input, int length, ref int index, string format) { T result = default(T); @@ -178,6 +179,7 @@ EFTResponse ParseEFTTransactionResponse(string msg) return r; } + EFTResponse ParseEFTGetLastTransactionResponse(string msg) { var index = 1; @@ -226,6 +228,7 @@ EFTResponse ParseEFTGetLastTransactionResponse(string msg) return r; } + EFTResponse ParseSetDialogResponse(string msg) { var index = 1; @@ -236,6 +239,7 @@ EFTResponse ParseSetDialogResponse(string msg) return r; } + EFTResponse ParseEFTLogonResponse(string msg) { var index = 1; @@ -257,6 +261,7 @@ EFTResponse ParseEFTLogonResponse(string msg) } return r; } + EFTResponse ParseDisplayResponse(string msg) { int index = 1; @@ -280,6 +285,7 @@ EFTResponse ParseDisplayResponse(string msg) return r; } + EFTResponse ParseReceiptResponse(string msg) { int index = 1; @@ -318,6 +324,7 @@ EFTResponse ParseReceiptResponse(string msg) return r; } + EFTResponse ParseControlPanelResponse(string msg) { int index = 1; @@ -330,6 +337,7 @@ EFTResponse ParseControlPanelResponse(string msg) return r; } + EFTResponse ParseEFTReprintReceiptResponse(string msg) { int index = 1; @@ -360,6 +368,7 @@ EFTResponse ParseEFTReprintReceiptResponse(string msg) return r; } + EFTResponse ParseEFTSettlementResponse(string msg) { var index = 1; @@ -456,6 +465,7 @@ EFTResponse ParseEFTSettlementResponse(string msg) return r; } + EFTResponse ParseQueryCardResponse(string msg) { int index = 1; @@ -511,6 +521,7 @@ EFTResponse ParseQueryCardResponse(string msg) return r; } + EFTResponse ParseClientListResponse(string msg) { var r = new EFTClientListResponse(); @@ -563,6 +574,7 @@ EFTResponse ParseClientListResponse(string msg) } return r; } + EFTResponse ParseEFTConfigureMerchantResponse(string msg) { int index = 1; @@ -575,6 +587,7 @@ EFTResponse ParseEFTConfigureMerchantResponse(string msg) return r; } + EFTResponse ParseEFTStatusResponse(string msg) { int index = 1; @@ -632,6 +645,7 @@ TerminalCommsType ParseTerminalCommsType(char CommsType) return commsType; } + KeyHandlingType ParseKeyHandlingType(char KeyHandlingScheme) { KeyHandlingType keyHandlingType = KeyHandlingType.Unknown; @@ -641,6 +655,7 @@ KeyHandlingType ParseKeyHandlingType(char KeyHandlingScheme) return keyHandlingType; } + EFTTerminalType ParseEFTTerminalType(string TerminalType) { EFTTerminalType terminalType = EFTTerminalType.Unknown; @@ -652,6 +667,7 @@ EFTTerminalType ParseEFTTerminalType(string TerminalType) return terminalType; } + PINPadOptionFlags ParseStatusOptionFlags(char[] Flags) { PINPadOptionFlags flags = 0; @@ -674,6 +690,7 @@ PINPadOptionFlags ParseStatusOptionFlags(char[] Flags) if (Flags[index++] == '1') flags |= PINPadOptionFlags.StartCash; return flags; } + EFTResponse ParseChequeAuthResponse(string msg) { int index = 1; @@ -698,6 +715,7 @@ EFTResponse ParseChequeAuthResponse(string msg) return r; } + EFTResponse ParseGenericPOSCommandResponse(string msg) { // Validate response length @@ -756,6 +774,7 @@ EFTResponse ParseGenericPOSCommandResponse(string msg) return null; } + EFTResponse ParseConfigMerchantResponse(string msg) { int index = 1; @@ -768,6 +787,7 @@ EFTResponse ParseConfigMerchantResponse(string msg) return r; } + EFTResponse ParseCloudLogonResponse(string msg) { int index = 1; @@ -958,7 +978,6 @@ StringBuilder BuildRequest(EFTRequest eftRequest) throw new Exception("Unknown EFTRequest type."); } - StringBuilder BuildEFTTransactionRequest(EFTTransactionRequest v) { var r = new StringBuilder(); @@ -972,13 +991,13 @@ StringBuilder BuildEFTTransactionRequest(EFTTransactionRequest v) r.Append(v.AmtPurchase.PadLeftAsInt(9)); r.Append(v.AuthCode.PadLeft(6)); r.Append(v.TxnRef.PadRightAndCut(16)); - r.Append((char)v.ReceiptPrintMode); - r.Append((char)v.ReceiptCutMode); + r.Append((char)v.ReceiptAutoPrint); + r.Append((char)v.CutReceipt); r.Append((char)v.PanSource); r.Append(v.Pan.PadRightAndCut(20)); r.Append(v.DateExpiry.PadRightAndCut(4)); r.Append(v.Track2.PadRightAndCut(40)); - r.Append((char)v.CardAccountType); + r.Append((char)v.AccountType); r.Append(v.Application.ToApplicationString()); r.Append(v.RRN.PadRightAndCut(12)); r.Append(v.CurrencyCode.PadRightAndCut(3)); @@ -990,40 +1009,44 @@ StringBuilder BuildEFTTransactionRequest(EFTTransactionRequest v) return r; } + StringBuilder BuildEFTLogonRequest(EFTLogonRequest v) { var r = new StringBuilder(); r.Append("G"); r.Append((char)v.LogonType); r.Append(v.Merchant.PadRightAndCut(2)); - r.Append((char)v.ReceiptPrintMode); - r.Append((char)v.ReceiptCutMode); + r.Append((char)v.ReceiptAutoPrint); + r.Append((char)v.CutReceipt); r.Append(v.Application.ToApplicationString()); r.Append(v.PurchaseAnalysisData.GetAsString(true)); return r; } + StringBuilder BuildEFTReprintReceiptRequest(EFTReprintReceiptRequest v) { var r = new StringBuilder(); r.Append("C"); r.Append((char)v.ReprintType); r.Append(v.Merchant.PadRightAndCut(2)); - r.Append((char)v.ReceiptCutMode); - r.Append((char)v.ReceiptPrintMode); + r.Append((char)v.CutReceipt); + r.Append((char)v.ReceiptAutoPrint); r.Append(v.Application.ToApplicationString()); r.Append(v.OriginalTxnRef.PadRightAndCut(16)); return r; } + StringBuilder BuildEFTGetLastTransactionRequest(EFTGetLastTransactionRequest v) { var r = new StringBuilder(); r.Append("N"); r.Append("0"); - r.Append(v.Application.ToApplicationString()); - r.Append(v.Merchant.PadRightAndCut(2)); - r.Append(v.TxnRef.PadRightAndCut(16)); - return r; + r.Append(v.Application.ToApplicationString()); + r.Append(v.Merchant.PadRightAndCut(2)); + r.Append(v.TxnRef.PadRightAndCut(16)); + return r; } + StringBuilder BuildSetDialogRequest(SetDialogRequest v) { var r = new StringBuilder(); @@ -1037,6 +1060,7 @@ StringBuilder BuildSetDialogRequest(SetDialogRequest v) r.Append(v.DialogTitle.PadRightAndCut(32)); return r; } + StringBuilder BuildControlPanelRequest(EFTControlPanelRequest v) { var r = new StringBuilder(); @@ -1047,19 +1071,21 @@ StringBuilder BuildControlPanelRequest(EFTControlPanelRequest v) r.Append((char)v.ReturnType); return r; } + StringBuilder BuildSettlementRequest(EFTSettlementRequest v) { var r = new StringBuilder(); r.Append("P"); r.Append((char)v.SettlementType); r.Append(v.Merchant.PadRightAndCut(2)); - r.Append((char)v.ReceiptPrintMode); - r.Append((char)v.ReceiptCutMode); + r.Append((char)v.ReceiptAutoPrint); + r.Append((char)v.CutReceipt); r.Append(v.ResetTotals ? '1' : '0'); r.Append(v.Application.ToApplicationString()); r.Append(v.PurchaseAnalysisData.GetAsString(true)); return r; } + StringBuilder BuildQueryCardRequest(EFTQueryCardRequest v) { var r = new StringBuilder(); @@ -1070,6 +1096,7 @@ StringBuilder BuildQueryCardRequest(EFTQueryCardRequest v) r.Append(v.PurchaseAnalysisData.GetAsString(true)); return r; } + StringBuilder BuildConfigMerchantRequest(EFTConfigureMerchantRequest v) { var r = new StringBuilder(); @@ -1083,6 +1110,7 @@ StringBuilder BuildConfigMerchantRequest(EFTConfigureMerchantRequest v) r.Append(v.Application.ToApplicationString()); return r; } + StringBuilder BuildStatusRequest(EFTStatusRequest v) { var r = new StringBuilder(); @@ -1092,6 +1120,7 @@ StringBuilder BuildStatusRequest(EFTStatusRequest v) r.Append(v.Application.ToApplicationString()); return r; } + StringBuilder BuildChequeAuthRequest(EFTChequeAuthRequest v) { var r = new StringBuilder(); diff --git a/README.md b/README.md index 3f75c00..9af56f1 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,11 @@ class EFTClientIPDemoAsync ## Release notes +### 1.4.2.0 (2018-09-19) +* Added new ReceiptAutoPrint modes for EFTRequests +* Updated MessageParser to use non-deprecated properties +* Updated TestPOS ClientViewModel to do the same + ### 1.4.1.3 (2018-09-12) * Fixed for EFTTransactionResponse and typo