Tapaya

Android SDK

Android

Every API in the Tapaya Accept SDK for Android, what it is for, and how to call it.

The Accept SDK turns an Android device into a card terminal. Use it from your Android app to sign in a merchant, take card payments, refund them, and read NFC tags. This page lists every API with an example. For a guided setup, start with Mobile SDK Integration.

DetailValue
Packagecom.tapaya:accept on Maven Central
LanguageKotlin. Most calls are suspend functions; call them from a coroutine.
Payment appEvery card payment runs in the Tapaya Terminal app. See Terminal app.
NFC tagsOptional com.tapaya:accept-nfc, plus accept-nfc-sunmi for Sunmi P-series terminals
React Native@tapayadot/accept-react-native wraps this SDK. See Mobile SDK Integration.

Install and initialize

build.gradle.kts
dependencies {
    implementation("com.tapaya:accept:$acceptVersion")
}
App.kt
class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Accept.initialize(context = this, isProduction = !BuildConfig.DEBUG)
    }
}

Set acceptVersion to the latest release on Maven Central. Keep every Accept artifact on the same version.

All APIs

APIUse it to
Accept.initialize()Start the SDK once, when your app starts.
Accept.auth.authenticate()Sign in a merchant with a token from your backend.
Accept.stateReact when the SDK is ready.
Accept.clear()Sign out and clear everything the SDK stored.
Accept.setDebugLoggingEnabled()See detailed logs while you develop.
Accept.payments.pay()Take a card payment.
Accept.payments.setOptions()Set the receipt, timeout, tap animation, and screen for every payment.
Accept.payments.status()Read a payment's state, amounts, and receipt link.
Accept.payments.cancel()Stop a payment that is still running.
Accept.payments.refund()Give the money back for a completed payment.
Accept.plugin.isInstalled(), install()Check for the Tapaya Terminal app and open its store page.
Accept.plugin.activateTerminal()Link this device to the merchant, once per device.
Accept.plugin.status()Check whether the terminal is ready for payments.
Accept.plugin.updateInfo()Find out whether the terminal app needs an update.
Accept.plugin.logout()Sign the merchant out of the terminal app.
Accept.merchant.info()Read the merchant's business details.
Accept.merchant.config(), availableCurrencies()Find the currencies the merchant can accept.
Accept.merchant.onboardingStatus()Check whether the merchant may take payments yet.
Accept.sdkRead the environment, device ID, and minimum amounts.
Accept.displaysFind a customer-facing screen on two-screen terminals.
Accept.nfc.isSupported()Check whether this device can read NFC tags.
Accept.nfc.openSession()Wait for a tag tap and start talking to it.
Tag session commandsRead and write NTAG, MIFARE Classic, and smart cards.
session.close(), session.endedFree the reader, and learn why a session ended.

Amounts are whole numbers in the currency's minor unit: 1500 with CZK is 15.00 Kč.

Setup and sign-in

Start the SDK, sign in a merchant, and sign out again.

Payments

Take card payments, then read, cancel, or refund them. See Card Terminal for the full flow.

Terminal app

Every card payment runs in the Tapaya Terminal app. Install and activate it once per device.

Merchant

Read the signed-in merchant's details. Every call here needs a signed-in merchant.

Device and SDK

Read facts about this device and the SDK.

NFC tags

Read and write NFC tags, such as loyalty cards or access badges, with the same reader. Add com.tapaya:accept-nfc and import com.tapaya.accept.nfc.nfc. See NFC Tags for the full guide.

Errors

Use it to tell what went wrong and react.

try {
    val status = Accept.payments.status(paymentToken)
} catch (e: SessionExpired) {
    reauthenticate()
} catch (e: NoInternetConnection) {
    showOfflineMessage()
} catch (e: AcceptException) {
    showError(e)
}

Good to know:

  • Every SDK error extends AcceptException.
  • pay() never throws. The same errors arrive as PaymentEvent.CreationFailed.
  • NFC tag errors are TagSessionException, not AcceptException.

Errors:

ErrorWhen
NotInitialized, NotAuthenticatedCall initialize() or authenticate() first.
SessionExpiredSign in again.
PaymentInProgressAnother payment is still running.
CurrencyNotAvailableForMerchant, UnsupportedCurrencyThe merchant cannot accept this currency.
AmountBelowMinimumThe amount is below the currency's minimum.
TransactionTimeoutOutOfRangetransactionTimeout is over 120 seconds.
PaymentNotFoundThe payment token is unknown.
LocationPermissionRequired, LocationUnavailable, LocationTimeoutThe app has no location permission, or no location fix.
PluginUnavailable, PluginTimeoutThe terminal app is missing or not responding.
PluginNotReadyForPaymentsThe terminal is not ready. Check its status.
PluginMerchantMismatch, PluginAlreadyAuthenticatedThe terminal app is signed in already, maybe as another merchant.
ActivationInProgress, NoTidsAvailableForMerchantActivation is running, or the merchant has no free terminal.
MerchantOnboardingIncompleteThe merchant has not finished onboarding.
NoInternetConnectionThe device is offline.
PaymentCreationFailed, UnknownAnything else. Check cause.
Чогось бракує на цій сторінці?Надішліть запит на функцію. Ми додамо цю сторінку, щоб команда бачила контекст.