Android SDK for integrating Tapaya Accept payment processing into your app.
Add the dependency to your project:
// app/build.gradle.kts
dependencies {
implementation("com.tapaya:accept:<version>")
}Maven Central is included by default in Android projects. No additional repository configuration is needed.
- Min SDK 30 (Android 11)
- Target SDK 36
- Kotlin / JVM 11
The SDK merges the permissions it needs into your app automatically:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />Location must be granted at runtime before taking a payment. Request it with the standard
Android permission flow; if it is missing, pay() fails with LocationPermissionRequired.
The entire SDK is reached through the Accept object. A typical flow is
initialize → authenticate → take a payment.
Call once, typically from Application.onCreate:
import com.tapaya.accept.Accept
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
Accept.initialize(this, isProduction = false) // false = sandbox (default)
}
}Accept.state is a StateFlow<SdkState> that transitions through
Idle → Initialized → Authenticated:
lifecycleScope.launch {
Accept.state.collect { state ->
when (state) {
SdkState.Idle -> {} // not initialized yet
SdkState.Initialized -> {} // ready to authenticate
SdkState.Authenticated -> {} // merchant + payments usable
}
}
}try {
Accept.auth.authenticate("merchant_token_here")
// state transitions to Authenticated
} catch (e: AcceptException) {
// handle failure
}pay() returns a Flow<PaymentEvent>; it never throws — failures arrive as
PaymentEvent.CreationFailed:
Accept.payments.pay(
amount = 1000, // minor units (cents)
currency = "USD",
paymentToken = null, // set to resume an existing payment
receiptConfig = PaymentReceiptConfig.Show(), // shown after an approved payment
nfcPosition = NfcPositionConfig.Unspecified, // let the companion resolve antenna position
metadata = mapOf("orderId" to "12345"), // echoed back on every PayResult
tip = 200, // minor units; skips the plugin's own tip screen
)
.collect { event ->
when (event) {
PaymentEvent.Creating -> {} // building the request
is PaymentEvent.Created -> event.paymentToken // token available before launch
PaymentEvent.Launched -> {} // plugin UI shown
is PaymentEvent.Result -> event.payResult // terminal outcome
is PaymentEvent.CreationFailed -> event.cause
}
}receiptConfig and nfcPosition default to whatever was last set via
Accept.payments.setOptions(...), if anything. On success, PayResult.Success
exposes the processor's authCode when the terminal reports one.
All surfaces are accessed via the Accept object.
| Surface | Access | Purpose |
|---|---|---|
| State | Accept.state |
Lifecycle StateFlow<SdkState> |
| Auth | Accept.auth |
authenticate(merchantToken) |
| SDK config | Accept.sdk |
version, isProduction, deviceId(), minimumAmounts() |
| Merchant | Accept.merchant |
info(), config(), onboardingStatus(), availableCurrencies() |
| Payments | Accept.payments |
pay(...), setOptions(...), status(token), cancel(token) |
| Plugin | Accept.plugin |
isInstalled(), install(), activateTerminal(), status(), logout() |
Top-level helpers on Accept:
initialize(context, isProduction)— set up and choose environment.setLogLevel(level)— set diagnostic log verbosity (AcceptLogLevel).setLogger(logger)— route SDK logs into a custom sink (Timber, Crashlytics, etc.).setDebugLoggingEnabled(enabled)— shorthand forsetLogLevel(DEBUG or NONE).clear()— wipe local state (auth token, device id, cached config); call on logout.
Physical-terminal payments require a one-time terminal activation against the external Accept plugin app:
if (!Accept.plugin.isInstalled()) {
Accept.plugin.install() // opens the store listing
}
when (val result = Accept.plugin.activateTerminal()) {
ActivateTerminalResult.Success -> {}
ActivateTerminalResult.Canceled -> {}
is ActivateTerminalResult.Failed -> result.reason // ActivateTerminalFailureReason
}Every checked failure is a subclass of the sealed AcceptException. Catch it broadly, or
branch on specific cases (e.g. NotInitialized, NotAuthenticated, SessionExpired,
NoInternetConnection, LocationPermissionRequired, CurrencyNotAvailableForMerchant,
AmountBelowMinimum). Each public function documents which exceptions it can throw via
@throws in its KDoc.
| Environment | Usage |
|---|---|
Sandbox (isProduction = false) |
Development and testing |
Production (isProduction = true) |
Live payments |
Full documentation is available at docs.tapaya.com.
Licensed under the Apache License, Version 2.0.
