Connection and Login

Last updated: 2026-05-19

Connection Lifecycle

The ECR must connect to the terminal and then log in before starting transactions.

  1. Create the EPAS client.
  2. Configure library options or parameters.
  3. Connect to the terminal network endpoint.
  4. Send login details with terminal ID, workstation ID, operator, language, configuration host, and authorisation host.
  5. Start transactions.

If the terminal disconnects, it aborts any active transaction and logs out. Reconnect by repeating the connect and login steps.

Network Connection

Use the tabs below to compare the same connection step across .NET, Java, and Swift.

.NET

csharp
var connection = new TerminalNetworkConnection
{
    TerminalConnectionDetails = new IPEndPoint(IPAddress.Parse("192.168.10.25"), 6001),
    UseKeepAlive = true
};

ApiResult result = epas.ConnectNetwork(connection, forceReconnect: false);

Java

java
ApiDefinitions definitions = new ApiDefinitions();
ApiDefinitions.TerminalNetworkConnection connection =
    definitions.new TerminalNetworkConnection();

connection.TerminalConnectionDetails = new IPEndPoint("192.168.10.25", 6001);
connection.UseKeepAlive = true;

ApiDefinitions.ApiResult result = epas.connectNetwork(connection, false);

Swift

swift
let connection = TerminalNetworkConnection(
    terminalConnectionDetails: IPEndPoint("192.168.10.25", 6001),
    useKeepAlive: true
)

try await client.connect(connection)

The Swift implementation throws on connection failure instead of returning an ApiResult. Use do/catch around connect.

Login

The ECR normally logs in once after connecting. Log in again after a disconnect or when changing terminal options such as terminal ID, workstation ID, or host settings.

.NET

csharp
var environment = new TerminalEnvironment
{
    TerminalId = "80000082",
    StoreId = "store_1",
    WorkstationId = "pos_1",
    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 result = epas.Login(environment, out LoginResponse response);
if (result == ApiResult.OK && response.LoggedIn)
{
    ui.ShowReady();
}

Java

java
ApiDefinitions.TerminalEnvironment environment =
    definitions.new TerminalEnvironment();

environment.TerminalId = "80000082";
environment.StoreId = "store_1";
environment.WorkstationId = "pos_1";
environment.OperatorId = "cashier_1";
environment.SetLanguageCode("sv-SE");
environment.ConfigurationServer = new IPEndPoint("185.27.171.42", 55133);
environment.AuthorisationServer = new IPEndPoint("185.27.171.42", 55144);

Pair<ApiDefinitions.ApiResult, LoginResponse> result = epas.login(environment);
if (result.getKey() == ApiDefinitions.ApiResult.OK && result.getValue().isLoggedIn()) {
    ui.showReady();
}

Swift

swift
let environment = TerminalEnvironment(
    terminalId: "80000082",
    storeId: "store_1",
    workstationId: "pos_1",
    configurationServer: IPEndPoint("185.27.171.42", 55133),
    authorisationServer: IPEndPoint("185.27.171.42", 55144),
    operatorId: "cashier_1",
    iso639_1_LanguageCode: TerminalEnvironment.langSwedish
)

let response = try await client.login(environment)
if response.loggedIn {
    ui.showReady()
}

Logout and Disconnect

Logout is rarely required during normal operation. Use it when the ECR intentionally changes login context. Disconnect closes the terminal link.

.NET

csharp
ApiResult logoutResult = epas.Logout(out LogoutResponse logout);
ApiResult disconnectResult = epas.Disconnect();

Java

java
Pair<ApiDefinitions.ApiResult, LogoutResponse> logoutResult = epas.logout();
ApiDefinitions.ApiResult disconnectResult = epas.disconnect();

Swift

swift
let logout = try await client.logout()
let disconnectResult = await client.disconnect()

Status and Reconnection

Status APIs are useful for UI state and recovery workflows.

.NET

csharp
epas.LinkStatus = linkUp =>
{
    if (!linkUp)
    {
        ui.ShowTerminalDisconnected();
        reconnectWorkflow.Schedule();
    }
};

Java

java
@Override
public void LinkStatusNotification(boolean linkUp) {
    if (!linkUp) {
        ui.showTerminalDisconnected();
        reconnectWorkflow.schedule();
    }
}

Swift

swift
let status = await client.status()

func linkStatusChanged(isConnected: Bool) {
    if !isConnected {
        ui.showTerminalDisconnected()
        reconnectWorkflow.schedule()
    }
}

ClientStatus in Swift exposes isConnected, isLoggedIn, isBusy, isCardInserted, and terminalId.