Android SDK
AndroidEvery 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.
| Detail | Value |
|---|---|
| Package | com.tapaya:accept on Maven Central |
| Language | Kotlin. Most calls are suspend functions; call them from a coroutine. |
| Payment app | Every card payment runs in the Tapaya Terminal app. See Terminal app. |
| NFC tags | Optional 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
dependencies {
implementation("com.tapaya:accept:$acceptVersion")
}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
| API | Use 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.state | React 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.sdk | Read the environment, device ID, and minimum amounts. |
Accept.displays | Find 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 commands | Read and write NTAG, MIFARE Classic, and smart cards. |
session.close(), session.ended | Free 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 asPaymentEvent.CreationFailed.- NFC tag errors are
TagSessionException, notAcceptException.
Errors:
| Error | When |
|---|---|
NotInitialized, NotAuthenticated | Call initialize() or authenticate() first. |
SessionExpired | Sign in again. |
PaymentInProgress | Another payment is still running. |
CurrencyNotAvailableForMerchant, UnsupportedCurrency | The merchant cannot accept this currency. |
AmountBelowMinimum | The amount is below the currency's minimum. |
TransactionTimeoutOutOfRange | transactionTimeout is over 120 seconds. |
PaymentNotFound | The payment token is unknown. |
LocationPermissionRequired, LocationUnavailable, LocationTimeout | The app has no location permission, or no location fix. |
PluginUnavailable, PluginTimeout | The terminal app is missing or not responding. |
PluginNotReadyForPayments | The terminal is not ready. Check its status. |
PluginMerchantMismatch, PluginAlreadyAuthenticated | The terminal app is signed in already, maybe as another merchant. |
ActivationInProgress, NoTidsAvailableForMerchant | Activation is running, or the merchant has no free terminal. |
MerchantOnboardingIncomplete | The merchant has not finished onboarding. |
NoInternetConnection | The device is offline. |
PaymentCreationFailed, Unknown | Anything else. Check cause. |