PAaS 2 Library

Last updated: 2026-05-14

PAaS 2 Library

PAaS 2 is distributed as paaslib_2.0.11.aar. The primary class is CarbonTerminal, which implements the PaymentTerminal interface and exposes payment, printer, terminal status, and device-control functions.

kotlin
import se.westpay.paaslib.service.CarbonTerminal

val terminal = CarbonTerminal()

Main Packages

PackagePurpose
se.westpay.paaslib.serviceCarbonTerminal, PaymentTerminal, service parameters, and terminal operations.
se.westpay.paaslib.initialisationTerminalSettings, initialisation response models, and status callbacks.
se.westpay.paaslib.transactionTransaction requests, responses, payment data, errors, and transaction enums.
se.westpay.paaslib.printerPrintJob, PrinterStatus, text and bitmap printing.
se.westpay.paaslib.notificationNotification data and notification callbacks.
se.westpay.paaslib.androidplatformNavigation bar and system UI controls.
se.westpay.paaslib.utilityUtility values such as suspend time options.

Core Lifecycle Methods

MethodPurpose
register(context, response)Creates resources needed to communicate with the Payment Application service.
initialise(settings, response, notification)Downloads terminal configuration, logs on to the host, and prepares the terminal for transactions.
createIntentForTransaction(transaction)Converts a TransactionRequest into an Android Intent used to launch payment.
createTransactionResponseFromIntent(intent)Converts the returned result Intent into a TransactionResponse.
startPrintJob(context)Starts a printer job for text or bitmap receipt printing.
notifyExit(context)Notifies the Payment Application before the PAaS app exits.

Register

kotlin
fun register(
    context: Context?,
    response: RegisterResponseHandler? = null
): Boolean

Example:

kotlin
val registered = terminal.register(
    requireContext(),
    object : RegisterResponseHandler {
        override fun onRegisterCompleted(success: Boolean) {
            Log.i("PAaS", "Connected to payment service: $success")
        }
    }
)

Initialise

kotlin
fun initialise(
    settings: TerminalSettings,
    response: InitialisationResponseHandler,
    notification: NotificationHandler?
): Boolean

initialise returns whether the request was accepted, not whether initialisation succeeded. The actual result is returned through the response callback.

kotlin
val settings = TerminalSettings(
    terminalId = "80000001",
    authHosts = arrayOf("185.27.171.42:55144"),
    configHosts = arrayOf("185.27.171.42:55133"),
    language = "sv-SE",
    forceLogin = false
)

terminal.initialise(
    settings = settings,
    response = object : InitialisationResponseHandler {
        override fun onInitialisationCompleted(result: InitialisationResponse) {
            Log.i("PAaS", "Initialised: ${result.getTerminalStatus()}")
        }
    },
    notification = object : NotificationHandler {
        override fun onNotification(event: NotificationEvent, info: String) {
            Log.i("PAaS", "Event: $event $info")
        }
    }
)

Transactions

kotlin
fun createIntentForTransaction(transaction: TransactionRequest): Intent?
fun createTransactionResponseFromIntent(intent: Intent?): TransactionResponse
kotlin
val purchase = PurchaseRequest(
    currencyId = Constants.CURRENCY_ID_NUMBER_DEFAULT,
    totalAmount = 10000,
    saleId = "sale-1001",
    loyaltyApplications = emptyArray(),
    paymentMethod = "",
    cashBackAmount = 0,
    tipAmount = 0,
    maximumTipAmount = 0,
    maximumTipPercent = 100,
    allowSkipTip = SkipTipOptions.NO
)

val intent = terminal.createIntentForTransaction(purchase)
transactionLauncher.launch(intent)

Printer

kotlin
fun startPrintJob(context: Context): PrintJob
kotlin
val printJob = terminal.startPrintJob(requireContext())
printJob.printTextLine("Merchant receipt", null, null, monospace = false, bold = true)
val status = printJob.finish()

Terminal and Device Operations

PAaS 2 also exposes operations for terminal state and Android terminal behaviour.

MethodPurpose
getTerminalStatusRetrieves terminal status after initialisation.
getLastTransactionResultRetrieves the last transaction result.
getPrinterStatusReads printer status.
enableNavigationBar / disableNavigationBarControls Android navigation bar visibility/buttons.
setSleepTime / getSleepTimeControls device sleep time.
setSuspendTime / getSuspendTimeControls suspend behaviour.
systemWakeUpWakes the terminal system.
validateMerchantPasswordValidates merchant password when required.
shutdownRequests terminal shutdown.

Exit

kotlin
fun notifyExit(context: Context): Boolean

Call this before leaving the PAaS application.

kotlin
terminal.notifyExit(requireContext())
requireActivity().finishAffinity()