Swift Function Reference

Last updated: 2026-05-20

Swift Function Reference

The Swift wrapper exposes its operational surface through the EpasClient actor, the EpasClientDelegate protocol, and the public request or response models in the Swift package.

Construction and Core Surface

MemberPurpose
init(delegate: EpasClientDelegate? = nil, operatingParameters: OperatingParameters = OperatingParameters(), logHandler: EpasLogHandler? = ConsoleLogHandler())Creates one client instance for one terminal integration context.
setDelegate(_:)Replaces or clears the delegate used for callbacks and notifications.
setOperatingParameters(_:)Updates runtime operating parameters such as currency, tip behavior, card-removal handling, and XML logging.
currentOperatingParameters()Returns the currently active operating parameters snapshot.
setNotificationOptions(_:)Updates optional notification enablement flags for raw-message, card-accepted, card-action, and busy-state callbacks.
currentNotificationOptions()Returns the currently active notification enablement flags.
cleanAllLogFiles()Deletes the wrapper-managed trace log files from the configured storage directory.
startNewLogFile()Starts a fresh trace log file and rotates older logs.
stopLogFileTemporarily()Temporarily stops file logging until the next log write resumes it automatically.
enableLogPart(_:)Enables one trace log category for file logging.
disableLogPart(_:)Disables one trace log category for file logging.
enableAllLogParts()Enables all trace log categories for file logging.
disableAllLogParts()Disables all trace log categories for file logging.
ConsoleLogHandlerDefault log handler that prints wrapper log messages.
EpasLogHandlerProtocol for custom log sinks.

Session and Connection Functions

FunctionPurpose
connect(_ connection: TerminalNetworkConnection) async throwsConnects the client to the terminal over TCP or IP.
connect(_ connection: TerminalNetworkConnection, forceReconnect: Bool) async throwsConnects to the terminal and optionally forces an existing connection to be torn down first.
disconnect() async -> ApiResultCloses the terminal connection and resets runtime state.
close() asyncConvenience shutdown helper that closes the active terminal connection and clears runtime state.
login(_ environment: TerminalEnvironment) async throws -> LoginResponseLogs in using terminal and backend environment data.
logout() async throws -> LogoutResponseLogs out the current terminal session.
status() -> ClientStatusReturns the current client-side connection and terminal status snapshot.

Purchase and Payment Functions

FunctionPurpose
purchase(_ request: PurchaseRequest) async throws -> TransactionResponseRuns a purchase using the full request model.
purchase(_ transactionAmounts: PurchaseTransactionAmounts) async throws -> TransactionResponseRuns a purchase using amount plus cashback style input.
purchase(_ transactionAmounts: PurchaseTransactionAmounts, paymentMethod: String, terminalId: String? = nil) async throws -> TransactionResponseRuns an alternative-payment purchase using amount-model input.
purchase(_ purchaseAmount: Decimal) async throws -> TransactionResponseRuns a simple amount-only purchase.
purchase(_ purchaseAmount: Decimal, paymentMethod: String, terminalId: String? = nil, merchantCategoryCode: Int? = nil) async throws -> TransactionResponseRuns a simple alternative-payment purchase, for example a Swish-style flow.
purchaseBeforeAmount() async throws -> TransactionResponseStarts a purchase before the final amount is known.
sendPurchaseAmounts(_ transactionAmounts: PurchaseTransactionAmounts) async throws -> ApiResultCompletes a pre-amount purchase by supplying the final amounts.
refund(_ request: RefundRequest) async throws -> TransactionResponseRuns a refund using the full refund model.
refund(_ amount: Decimal) async throws -> TransactionResponseRuns a simple refund by amount.
refund(_ amount: Decimal, paymentMethod: String, reference: String, terminalId: String? = nil, merchantCategoryCode: Int? = nil) async throws -> TransactionResponseRuns an alternative-payment refund using the method name and original transaction reference.
reverseLastTransaction(_:transactionTerminalId:) async throws -> TransactionResponseReverses the latest matching transaction when allowed.
cashAdvance(_ amount: Decimal) async throws -> TransactionResponseRuns a cash advance transaction.
getLastTransaction(_ terminalId: String) async throws -> LastTransactionResponseRetrieves the most recent transaction details from the terminal.
abort() async throwsSends a best-effort abort request for the active transaction.

Terminal Control and Diagnostics

FunctionPurpose
enableCardReaders(_ enable: Bool, _ options: EnableCardReaderOptions = ...) async throws -> EnableReadersResponseOpens or closes terminal card readers outside an active transaction.
requestAdministrativeOperation(_ operation: AdminOperation) async throws -> AdminResponseRequests host login, configuration print, or parameter update.
sendRawXml(_ xml: String) async throws -> ApiResultSends raw EPAS XML using the normal framed transport for diagnostics or parity testing.
sendRawXmlWithResult(_ xml: String) async throws -> String?Sends raw EPAS XML and returns the terminal's raw XML response when the message expects a service reply.
sendCustomerInquiry(_ request: CustomerInquiryRequest) async throws -> CustomerInquiryResponseShows a customer inquiry dialogue on the terminal and returns the customer selection.
abortCustomerInquiry() async throws -> ApiResultAborts the currently active customer inquiry dialogue.
requestPrint(_ request: PrintRequest) async throws -> PrintResponseRequests terminal-side printing using a structured print request.

Remaining Helper Gaps

The Swift wrapper now exposes the core logging helpers as well as the main payment and terminal-management surface. The remaining wrapper-level gaps are narrower and mostly support-oriented:

Function familyStatus in Swift
Explicit close or shutdown helperPresent through close().

Delegate Callbacks

Display, printing, logging, and status

FunctionPurpose
display(text:)Shows cashier-facing terminal text.
printReceipt(receipt:)Receives structured merchant or cardholder receipt data.
printReport(report:)Receives report text.
cardAccepted(args:)Receives accepted-card details such as masked PAN and alias data.
log(level:text:)Receives wrapper and terminal log messages.
linkStatusChanged(isConnected:)Reports connection state changes.
busyStatusChanged(isBusy:)Reports terminal busy-state changes.
cardStatusChanged(isInserted:)Reports card inserted or removed state.
epasMessageReceived(message:)Receives raw EPAS XML or message text for diagnostics.

Cashier decision callbacks

FunctionPurpose
verifySignature(displayText:)Requests a yes or no signature decision.
forceFallback(displayText:)Requests a yes or no fallback decision.
handleVoiceReferral(displayText:)Requests a voice referral approval code.
paymentCodeRequired(displayText:)Requests a payment code.
vatAmountRequired(displayText:)Requests VAT or sales tax amount input.
loyaltyCardPresented(cardNumber:)Requests a decision for a presented loyalty card.
checkDccOnOriginalTransaction(displayText:)Requests confirmation of prior DCC usage.
parameterDownloadAvailable(displayText:)Requests approval to perform parameter download.

Usage Notes

  • The Swift wrapper uses async or await and throws instead of ApiResult + out parameter or Pair<ApiResult, T>.
  • ClientStatus is a pollable snapshot, while the delegate methods are the event-driven surface.
  • NotificationOptions can be used to narrow optional callback traffic in integrations that do not want all notification categories enabled.
  • The wrapper keeps XML framing, socket handling, receipts, and callback routing inside the SDK so integrators can stay at the business-flow level in normal use.
  • The remaining parity gap is now mainly in a few lower-level convenience APIs and deeper support-surface details rather than in payment, customer-dialogue, raw XML handling, or log-file management flows.

Related Types

Notable Enum Coverage

  • ApiResult includes ErrorResponseTimeout
  • AdminOperation includes HostLogin, UpdateParameters, PrintConfiguration, ModeSwitch, and StartSwish