Folder | Description |
---|---|
IPInterface | A project with both event (EFTClientIP ) and async/await based (EFTClientIPAsync ) wrapper objects for the EFT-Client TCP/IP interface. |
IPInterface.SimpleDemoAsync | A basic sample app using the EFTClientIPAsync component |
IPInterface.SimpleDemo | A basic sample app using the EFTClientIP component |
IPInterface.TestPOS | A full featured sample app using the EFTClientIPAsync component |
- Clone this repository or grab the PCEFTPOS.EFTClient.IPInterface package from NuGet
- Decide which component to use.
EFTClientIP
is event based pattern andEFTClientIPAsync
uses the async/await pattern - Look at the
SimpleDemo
andSimpleDemoAsync
samples. There are also some simple examples listed below.
class EFTClientIPDemo
{
ManualResetEvent txnFired = new ManualResetEvent(false);
public void Run()
{
// Create new connection to EFT-Client
var eft = new EFTClientIP()
{
HostName = "127.0.0.1",
HostPort = 2011,
UseSSL = false
};
// Hook up events
eft.OnReceipt += Eft_OnReceipt;
eft.OnTransaction += Eft_OnTransaction;
eft.OnTerminated += Eft_OnTerminated;
// Connect
if (!eft.Connect())
{
// Handle failed connection
Console.WriteLine("Connect failed");
return;
}
// Build transaction request
var r = new EFTTransactionRequest()
{
// TxnType is required
TxnType = TransactionType.PurchaseCash,
// Set TxnRef to something unique
TxnRef = DateTime.Now.ToString("YYMMddHHmmsszzz"),
// Set AmtCash for cash out, and AmtPurchase for purchase/refund
AmtPurchase = 1.00M,
AmtCash = 0.00M,
// Set POS or pinpad printer
ReceiptPrintMode = ReceiptPrintModeType.POSPrinter,
// Set application. Used for gift card & 3rd party payment
Application = TerminalApplication.EFTPOS
};
// Send transaction
if (!eft.DoTransaction(r))
{
// Handle failed send
Console.WriteLine("Send failed");
return;
}
txnFired.WaitOne();
eft.Disconnect();
eft.Dispose();
}
private void Eft_OnTerminated(object sender, SocketEventArgs e)
{
// Handle socket close
Console.WriteLine($"Socket closed");
txnFired.Reset();
}
private void Eft_OnReceipt(object sender, EFTEventArgs<EFTReceiptResponse> e)
{
// Handle receipt
Console.WriteLine($"{e.Response.Type} receipt");
Console.WriteLine($"{e.Response.ReceiptText}");
}
private void Eft_OnTransaction(object sender, EFTEventArgs<EFTTransactionResponse> e)
{
// Handle transaction event
var displayText = e.Response.Success ? "successful" : "unsuccessful";
Console.WriteLine($"Transaction was {displayText}");
txnFired.Set();
}
}
class Program
{
static async void Main(string[] args)
{
(new EFTClientIPDemo()).Run();
Console.WriteLine("Press any key to quit");
Console.ReadLine();
}
}
class EFTClientIPDemoAsync
{
public async Task RunAsync()
{
// Create new connection to EFT-Client
var eft = new EFTClientIPAsync();
var connected = await eft.ConnectAsync("127.0.0.1", 2011, false);
if(!connected)
{
// Handle failed connection
Console.WriteLine("Connect failed");
}
// Build transaction request
var r = new EFTTransactionRequest()
{
// TxnType is required
TxnType = TransactionType.PurchaseCash,
// Set TxnRef to something unique
TxnRef = DateTime.Now.ToString("YYMMddHHmmsszzz"),
// Set AmtCash for cash out, and AmtPurchase for purchase/refund
AmtPurchase = 1.00M,
AmtCash = 0.00M,
// Set POS or pinpad printer
ReceiptPrintMode = ReceiptPrintModeType.POSPrinter,
// Set application. Used for gift card & 3rd party payment
Application = TerminalApplication.EFTPOS
};
// Send transaction
if (await eft.WriteRequestAsync(r) == false)
{
// Handle failed send
Console.WriteLine("Send failed");
return;
}
// Wait for response
var waitingForResponse = true;
do
{
EFTResponse eftResponse = null;
try
{
var timeoutToken = new CancellationTokenSource(new TimeSpan(0, 5, 0)).Token; // 5 minute timeout
eftResponse = await eft.ReadResponseAsync(timeoutToken);
switch(eftResponse)
{
case EFTReceiptResponse eftReceiptResponse:
Console.WriteLine($"{eftReceiptResponse.Type} receipt");
Console.WriteLine($"{eftReceiptResponse.ReceiptText}");
break;
case EFTTransactionResponse eftTransactionResponse:
var displayText = eftTransactionResponse.Success ? "successful" : "unsuccessful";
Console.WriteLine($"Transaction was {displayText}");
waitingForResponse = false;
break;
case null:
Console.WriteLine("Error reading response");
break;
}
}
catch(TaskCanceledException)
{
Console.WriteLine("EFT-Client timeout waiting for response");
waitingForResponse = false;
}
catch(ConnectionException)
{
Console.WriteLine("Socket closed");
waitingForResponse = false;
}
catch(Exception)
{
Console.WriteLine("Unhandled exception");
waitingForResponse = false;
}
}
while (waitingForResponse);
eft.Disconnect();
}
}
class Program
{
static async void Main(string[] args)
{
await (new EFTClientIPDemoAsync()).RunAsync();
Console.WriteLine("Press any key to quit");
Console.ReadLine();
}
}
• Added in Void transaction type... • Added in a check on msg length for parsing Duplicate Receipt responses so it can handle TPP duplicate responses • Fixed 'Display Swipe Card' slave command • Added in support for Input On POS display requests • Added in MerchantNumber field for GetLastReceipt
- Deleted a hard-coded TxnRef in TestPOS GetLast and ReprintReceipt command
- Fixed bug in MessageParser that padded the TxnRef rather than leaving it blank, so the EFTClient didn't like it
- Added new ReceiptAutoPrint modes for EFTRequests
- Updated MessageParser to use non-deprecated properties
- Updated TestPOS ClientViewModel to do the same
- Fixed for EFTTransactionResponse and typo
- Changes to fields ReceiptAutoPrint, CutReceipt, AccountType and DateSettlement
- Added support for EFTGetLastTransactionRequest by TxnRef
- Updated PadField to support IList
- Added IDialogUIHandler for easier handling of POS custom dialogs.
- Updated MessageParser to allow for custom parsing.
- Added support for .NET Standard 2.0
- 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.
- Changed internal namespaces from
PCEFTPOS.*
(PCEFTPOS.Net
,PCEFTPOS.Messaging
etc) toPCEFTPOS.EFTClient.IPInterface
. This was causing issues when combining the EFTClientIP Nuget package with the actual PCEFTPOS lib. EFTClientIP needs to remain totally self-contained.
- Updated nuspec for v1.3.2.0 release.
- Changed namespace from
PCEFTPOS.API.IPInterface
toPCEFTPOS.EFTClient.IPInterface
for new package - Created signed NuGet package
- Added CloudLogon event to EFTClientIP
- Fixed a bug that would cause the component to hang if an unknown message was received
- Improved handling of messages received across multiple IP packets
- Added support for Pay at Table
- Initial release