Getting Started

Last updated: 2026-03-13

Prerequisites

Before integrating with WestPay SoftPOS you will need:

  1. Android SDK 21 (Android 5.0) or higher.
  2. WestPay SoftPOS installed on the target Android device.
  3. Android Studio or equivalent Android development environment.
  4. Basic familiarity with Android Intents and the Activity Result API.

No additional library dependencies are required. The integration uses standard Android APIs only.

Step 1 — Check SoftPOS is Installed

Before launching any Intent, verify that SoftPOS is installed on the device to avoid an ActivityNotFoundException:

kotlin
fun isSoftPOSInstalled(): Boolean {
    val intent = Intent("se.westpay.softpos.PURCHASE").apply {
        addCategory(Intent.CATEGORY_DEFAULT)
    }
    return intent.resolveActivity(packageManager) != null
}

Step 2 — Register the Activity Result Launcher

In your Activity or Fragment, register a launcher to receive results from SoftPOS. This must be done before onStart() — typically at class instantiation time:

kotlin
private val resultLauncher = registerForActivityResult(
    ActivityResultContracts.StartActivityForResult()
) { result ->
    handleSoftPOSResult(result)
}

Use registerForActivityResult — the older startActivityForResult is deprecated.

Step 3 — Create and Launch an Intent

Build an Intent with the target action and required extras, then launch it:

kotlin
fun initiatePurchase(amount: String, currencyId: Int) {
    val intent = Intent("se.westpay.softpos.PURCHASE").apply {
        putExtra("amount", amount)           // e.g. "100,00"
        putExtra("currencyId", currencyId)   // e.g. 752 for SEK
        addCategory(Intent.CATEGORY_DEFAULT)
    }
    if (intent.resolveActivity(packageManager) != null) {
        resultLauncher.launch(intent)
    } else {
        showError("WestPay SoftPOS is not installed")
    }
}

All Intents must include Intent.CATEGORY_DEFAULT.

Amounts use a comma as the decimal separator: "100,50" not "100.50".

Step 4 — Handle the Result

Inspect the resultCode and read the extras from the returned Intent:

kotlin
private fun handleSoftPOSResult(result: ActivityResult) {
    when (result.resultCode) {
        Activity.RESULT_OK -> {
            val data = result.data
            val success = data?.getBooleanExtra("isSuccess", false) ?: false

            if (success) {
                val transactionId = data?.getStringExtra("transactionId")
                showSuccess("Payment successful: $transactionId")
            } else {
                val error = data?.getStringExtra("error")
                val denialReason = data?.getStringExtra("denialReason")
                showError("Payment failed: $error")
            }
        }
        Activity.RESULT_CANCELED -> {
            // Check both "error" and "Error" (capital E) for compatibility
            val error = result.data?.getStringExtra("error")
                ?: result.data?.getStringExtra("Error")
            showError("Operation cancelled: ${error ?: "Unknown reason"}")
        }
    }
}

When handling RESULT_CANCELED, always check both "error" and "Error" (capital E) to ensure compatibility across SoftPOS versions.

Currency Codes

Amounts are expressed using ISO 4217 numeric currency codes:

CurrencyCode
Swedish Krona (SEK)752
Euro (EUR)978
US Dollar (USD)840
British Pound (GBP)826

For a complete list, refer to the ISO 4217 standard.

Support

For additional support, contact the WestPay support team.