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
| Member | Purpose |
|---|---|
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. |
ConsoleLogHandler | Default log handler that prints wrapper log messages. |
EpasLogHandler | Protocol for custom log sinks. |
Session and Connection Functions
| Function | Purpose |
|---|---|
connect(_ connection: TerminalNetworkConnection) async throws | Connects the client to the terminal over TCP or IP. |
connect(_ connection: TerminalNetworkConnection, forceReconnect: Bool) async throws | Connects to the terminal and optionally forces an existing connection to be torn down first. |
disconnect() async -> ApiResult | Closes the terminal connection and resets runtime state. |
close() async | Convenience shutdown helper that closes the active terminal connection and clears runtime state. |
login(_ environment: TerminalEnvironment) async throws -> LoginResponse | Logs in using terminal and backend environment data. |
logout() async throws -> LogoutResponse | Logs out the current terminal session. |
status() -> ClientStatus | Returns the current client-side connection and terminal status snapshot. |
Purchase and Payment Functions
| Function | Purpose |
|---|---|
purchase(_ request: PurchaseRequest) async throws -> TransactionResponse | Runs a purchase using the full request model. |
purchase(_ transactionAmounts: PurchaseTransactionAmounts) async throws -> TransactionResponse | Runs a purchase using amount plus cashback style input. |
purchase(_ transactionAmounts: PurchaseTransactionAmounts, paymentMethod: String, terminalId: String? = nil) async throws -> TransactionResponse | Runs an alternative-payment purchase using amount-model input. |
purchase(_ purchaseAmount: Decimal) async throws -> TransactionResponse | Runs a simple amount-only purchase. |
purchase(_ purchaseAmount: Decimal, paymentMethod: String, terminalId: String? = nil, merchantCategoryCode: Int? = nil) async throws -> TransactionResponse | Runs a simple alternative-payment purchase, for example a Swish-style flow. |
purchaseBeforeAmount() async throws -> TransactionResponse | Starts a purchase before the final amount is known. |
sendPurchaseAmounts(_ transactionAmounts: PurchaseTransactionAmounts) async throws -> ApiResult | Completes a pre-amount purchase by supplying the final amounts. |
refund(_ request: RefundRequest) async throws -> TransactionResponse | Runs a refund using the full refund model. |
refund(_ amount: Decimal) async throws -> TransactionResponse | Runs a simple refund by amount. |
refund(_ amount: Decimal, paymentMethod: String, reference: String, terminalId: String? = nil, merchantCategoryCode: Int? = nil) async throws -> TransactionResponse | Runs an alternative-payment refund using the method name and original transaction reference. |
reverseLastTransaction(_:transactionTerminalId:) async throws -> TransactionResponse | Reverses the latest matching transaction when allowed. |
cashAdvance(_ amount: Decimal) async throws -> TransactionResponse | Runs a cash advance transaction. |
getLastTransaction(_ terminalId: String) async throws -> LastTransactionResponse | Retrieves the most recent transaction details from the terminal. |
abort() async throws | Sends a best-effort abort request for the active transaction. |
Terminal Control and Diagnostics
| Function | Purpose |
|---|---|
enableCardReaders(_ enable: Bool, _ options: EnableCardReaderOptions = ...) async throws -> EnableReadersResponse | Opens or closes terminal card readers outside an active transaction. |
requestAdministrativeOperation(_ operation: AdminOperation) async throws -> AdminResponse | Requests host login, configuration print, or parameter update. |
sendRawXml(_ xml: String) async throws -> ApiResult | Sends 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 -> CustomerInquiryResponse | Shows a customer inquiry dialogue on the terminal and returns the customer selection. |
abortCustomerInquiry() async throws -> ApiResult | Aborts the currently active customer inquiry dialogue. |
requestPrint(_ request: PrintRequest) async throws -> PrintResponse | Requests 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 family | Status in Swift |
|---|---|
| Explicit close or shutdown helper | Present through close(). |
Delegate Callbacks
Display, printing, logging, and status
| Function | Purpose |
|---|---|
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
| Function | Purpose |
|---|---|
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
asyncorawaitandthrowsinstead ofApiResult + out parameterorPair<ApiResult, T>. ClientStatusis a pollable snapshot, while the delegate methods are the event-driven surface.NotificationOptionscan 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
ApiResultincludesErrorResponseTimeoutAdminOperationincludesHostLogin,UpdateParameters,PrintConfiguration,ModeSwitch, andStartSwish