Skip to content

tapayadot/accept-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AcceptSDK

Platform Android Docs License Maven

Android SDK for integrating Tapaya Accept payment processing into your app.

Installation

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.

Requirements

  • Min SDK 30 (Android 11)
  • Target SDK 36
  • Kotlin / JVM 11

Permissions

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.

Usage

The entire SDK is reached through the Accept object. A typical flow is initialize → authenticate → take a payment.

Initialize

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)
    }
}

Observe state

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
        }
    }
}

Authenticate

try {
    Accept.auth.authenticate("merchant_token_here")
    // state transitions to Authenticated
} catch (e: AcceptException) {
    // handle failure
}

Take a payment

pay() returns a Flow<PaymentEvent>; it never throws — failures arrive as PaymentEvent.CreationFailed:

Accept.payments.pay(amount = 1000, currency = "USD") // minor units (cents)
    .collect { event ->
        when (event) {
            PaymentEvent.Creating -> {}                 // building the request
            PaymentEvent.Launched -> {}                 // plugin UI shown
            is PaymentEvent.Result -> event.payResult   // terminal outcome
            is PaymentEvent.CreationFailed -> event.cause
        }
    }

API surface

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 minimumAmounts()
Merchant Accept.merchant info(), config(), onboardingStatus(), availableCurrencies()
Payments Accept.payments pay(...), 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.
  • setDebugLoggingEnabled(enabled) — toggle internal debug logging.
  • clear() — wipe local state (auth token, device id, cached config); call on logout.

Terminal activation

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
}

Error handling

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.

Environments

Environment Usage
Sandbox (isProduction = false) Development and testing
Production (isProduction = true) Live payments

Documentation

Full documentation is available at docs.tapaya.com.

License

Licensed under the Apache License, Version 2.0.

About

Official repository for the Accept SDK, including public documentation, packages, and integration resources.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors