.NET Library
Last updated: 2026-05-19
.NET Library
The .NET EPAS Client Library is a C# class library for ECR applications that need direct terminal communication over the EPAS protocol. The public API is exposed through the Westpay.Epas namespace and the EpasClient class.
Requirements
| Item | Value |
|---|---|
| Runtime | .NET Framework 4.7.2 |
| Assembly | EpasClientLibrary.dll |
| Namespace | Westpay.Epas |
| Main client | EpasClient |
| Required callback interface | IClientApp |
Minimal Setup
csharpusing Westpay.Epas; public sealed class EcrApplication : IClientApp { private readonly EpasClient epas; public EcrApplication() { epas = new EpasClient(this); epas.LinkStatus = OnLinkStatus; epas.BusyStatus = OnBusyStatus; epas.CardStatus = OnCardStatus; } public void Display(string text) => Console.WriteLine(text); public void PrintReceipt(ReceiptData receipt) => Console.WriteLine(receipt.GenerateSimpleReceipt(32)); public void PrintReport(string report) => Console.WriteLine(report); public void Log(LogLevel level, string text) => Console.WriteLine($"[{level}] {text}"); public bool VerifySignature(string displayText, out bool signatureOk) { Display(displayText); signatureOk = true; return true; } public bool HandleVoiceReferral(string displayText, out string approvalCode) { Display(displayText); approvalCode = null; return false; } public bool PaymentCodeRequired(string displayText, out string paymentCode) { Display(displayText); paymentCode = null; return false; } public bool VatAmountRequired(string displayText, out decimal vatAmount) { Display(displayText); vatAmount = 0m; return false; } public bool LoyaltyCardPresented(string cardNumber, out bool useForPayment) { useForPayment = false; return true; } public bool CheckDccOnOriginalTransaction(string displayText, out bool dccWasUsed) { Display(displayText); dccWasUsed = false; return true; } public void ParameterDownloadAvailable(string displayText, out bool permitDownload) { Display(displayText); permitDownload = true; } private void OnLinkStatus(bool linkUp) => Console.WriteLine($"Link up: {linkUp}"); private void OnBusyStatus(bool busy) => Console.WriteLine($"Busy: {busy}"); private void OnCardStatus(bool inserted) => Console.WriteLine($"Card inserted: {inserted}"); }
Configuration
EpasClient.Options exposes OperatingParameters. Configure these before connecting or before starting transactions when your application needs non-default behaviour.
| Option | Purpose |
|---|---|
EnableTip | Enables or disables tipping for purchase transactions. Terminal configuration must also support tipping. |
TransactionCurrency | Sets the currency used in EPAS messages. It should match the terminal configuration. |
WaitForCardRemoval | Controls whether the terminal waits for card removal before completing the transaction flow. |
StorageDirectory | Sets where client-library trace log files are stored. |
csharpstring storage = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "EpasClientLibraryLogs"); Directory.CreateDirectory(storage); epas.Options.StorageDirectory = storage; epas.Options.EnableTip = true;
Connect and Login
csharpvar connection = new TerminalNetworkConnection { TerminalConnectionDetails = new IPEndPoint(IPAddress.Parse("192.168.10.25"), 6001), UseKeepAlive = true }; ApiResult connectResult = epas.ConnectNetwork(connection); if (connectResult != ApiResult.OK) { throw new InvalidOperationException($"Connect failed: {connectResult}"); } var environment = new TerminalEnvironment { TerminalId = "80000082", OperatorId = "cashier_1", ISO639_1_LanguageCode = TerminalEnvironment.LangSwedish, ConfigurationServer = new IPEndPoint(IPAddress.Parse("185.27.171.42"), 55133), AuthorisationServer = new IPEndPoint(IPAddress.Parse("185.27.171.42"), 55144) }; ApiResult loginResult = epas.Login(environment, out LoginResponse login); if (loginResult != ApiResult.OK || !login.LoggedIn) { throw new InvalidOperationException($"Login failed: {loginResult}"); }
Supported Operational Surface
The .NET library is the reference surface for the wrappers and includes the standard EPAS workflows:
- connect, disconnect, login, logout
- purchase, refund, reversal, cash advance
- pre-amount purchase and send amounts
- abort
- last transaction
- enable or disable card readers
- administrative operations such as host login, print configuration, and parameter update
- receipt, report, display, and cashier callbacks
See the shared pages for cross-language flow examples.
Transactions
All transaction calls are synchronous and return after the terminal finishes the transaction. Do not call them from the UI thread.
Purchase
csharpTransactionResponse response; ApiResult result = epas.Purchase(100.00m, out response); if (result == ApiResult.OK && response.Approved) { CompleteSale(response.TransactionReference, response.FinalAmount); }
Purchase with Cashback
csharpvar amounts = new PurchaseTransactionAmounts( purchaseAmount: 100.00m, cashbackAmount: 20.00m); ApiResult result = epas.Purchase(amounts, out TransactionResponse response);
Pre-Amount Purchase
csharpTask.Run(() => { ApiResult result = epas.PurchaseBeforeAmount(out TransactionResponse response); HandleTransactionResult(result, response); }); var amounts = new PurchaseTransactionAmounts(100.00m, 0.00m); ApiResult sendResult = epas.SendPurchaseAmounts(amounts);
Refund
csharpApiResult result = epas.Refund(45.00m, out TransactionResponse response);
Reversal
csharpApiResult result = epas.ReverseLastTransaction( transactionReference, out TransactionResponse response);
Abort
RequestTransactionAbort asks the terminal to abort the active transaction. The abort may arrive too late, so always wait for and process the final transaction response.
csharpApiResult result = epas.RequestTransactionAbort();
Optional Event Handlers
| Handler | Called when |
|---|---|
LinkStatus | The terminal link comes up or goes down. |
BusyStatus | The terminal starts or stops a long-running operation such as parameter download. |
CardStatus | A card is inserted or removed. |
CardAccepted | A payment card has been accepted by the terminal. |
RawMessageHandler | Raw EPAS messages are received and raw handling is enabled. |
Return Values
Most methods return ApiResult. This value describes communication and protocol success, not transaction approval.
ApiResult | Meaning |
|---|---|
OK | The request was successfully sent and parsed. Check the response object for business outcome. |
ErrorInvalidParameter | A parameter passed to the method was invalid. |
ErrorConnectionFailure | The library failed to connect to the terminal. |
ErrorNotConnected | The client is not connected. |
ErrorCommunicationsFailure | A request could not be sent to the terminal. |
ErrorLibraryFailure | An internal library error occurred. |
ErrorParseFailure | The terminal response could not be parsed. |