.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

ItemValue
Runtime.NET Framework 4.7.2
AssemblyEpasClientLibrary.dll
NamespaceWestpay.Epas
Main clientEpasClient
Required callback interfaceIClientApp

Minimal Setup

csharp
using 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.

OptionPurpose
EnableTipEnables or disables tipping for purchase transactions. Terminal configuration must also support tipping.
TransactionCurrencySets the currency used in EPAS messages. It should match the terminal configuration.
WaitForCardRemovalControls whether the terminal waits for card removal before completing the transaction flow.
StorageDirectorySets where client-library trace log files are stored.
csharp
string storage = Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
    "EpasClientLibraryLogs");

Directory.CreateDirectory(storage);
epas.Options.StorageDirectory = storage;
epas.Options.EnableTip = true;

Connect and Login

csharp
var 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

csharp
TransactionResponse response;
ApiResult result = epas.Purchase(100.00m, out response);

if (result == ApiResult.OK && response.Approved)
{
    CompleteSale(response.TransactionReference, response.FinalAmount);
}

Purchase with Cashback

csharp
var amounts = new PurchaseTransactionAmounts(
    purchaseAmount: 100.00m,
    cashbackAmount: 20.00m);

ApiResult result = epas.Purchase(amounts, out TransactionResponse response);

Pre-Amount Purchase

csharp
Task.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

csharp
ApiResult result = epas.Refund(45.00m, out TransactionResponse response);

Reversal

csharp
ApiResult 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.

csharp
ApiResult result = epas.RequestTransactionAbort();

Optional Event Handlers

HandlerCalled when
LinkStatusThe terminal link comes up or goes down.
BusyStatusThe terminal starts or stops a long-running operation such as parameter download.
CardStatusA card is inserted or removed.
CardAcceptedA payment card has been accepted by the terminal.
RawMessageHandlerRaw 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.

ApiResultMeaning
OKThe request was successfully sent and parsed. Check the response object for business outcome.
ErrorInvalidParameterA parameter passed to the method was invalid.
ErrorConnectionFailureThe library failed to connect to the terminal.
ErrorNotConnectedThe client is not connected.
ErrorCommunicationsFailureA request could not be sent to the terminal.
ErrorLibraryFailureAn internal library error occurred.
ErrorParseFailureThe terminal response could not be parsed.

Related Pages