Weiter zum Inhalt
Konto erstellen
oder
anmelden
Das Logo der Stripe-Dokumentation
/
KI fragen
Konto erstellen
Anmelden
Jetzt starten
Zahlungen
Finanzautomatisierung
Plattformen und Marktplätze
Geldmanagement
Entwickler-Tools
Jetzt starten
Zahlungen
Finanzautomatisierung
Jetzt starten
Zahlungen
Finanzautomatisierung
Plattformen und Marktplätze
Geldmanagement
Übersicht
Informationen zu Stripe Payments
Aktualisieren Sie Ihre Integration
Zahlungsanalysefunktionen
Online-Zahlungen
ÜbersichtIhren Use case findenZahlungen verwalten
Payment Links verwenden
Bezahlseite erstellen
Erweiterte Integration erstellen
In-App-Integration erstellen
Zahlungsmethoden
Zahlungsmethoden hinzufügen
Zahlungsmethoden verwalten
Schnellerer Bezahlvorgang mit Link
Zahlungsschnittstellen
Payment Links
Checkout
Web Elements
In-App-Elements
Zahlungsszenarien
Nutzerdefinierte Zahlungsabläufe
Flexibles Acquiring
Orchestrierung
Präsenzzahlungen
Terminal
    Übersicht
    Persönliche Zahlungen akzeptieren
    Integrationsdesign
    Wählen Sie Ihr Lesegerät aus
    Konzipieren einer Integration
    Quickstart
    Beispielanwendungen
    Tests
    Terminal einrichten
    Integration einrichten
    Mit einem Lesegerät verbinden
    Zahlung annehmen
    Kartenzahlungen einziehen
    Weitere Zahlungsmethoden
    Offline-Zahlungen annehmen
    Versand-/Telefonbezahlung
    Regionale Aspekte
    Während des Bezahlvorgangs
    Trinkgelder einziehen
    Zahlungsdetails erfassen und für die zukünftige Verwendung speichern
    Flexible Autorisierungen
    Nach dem Bezahlen
    Transaktionen zurückerstatten
    Belege zur Verfügung stellen
    Checkout anpassen
    Anzeige des Warenkorbs
    Eingaben auf dem Bildschirm erfassen
    Ausgelesene Daten erfassen
    Erfassen von Daten durch Tippen für NFC-Geräte
    Apps auf Geräten
    Lesegeräte verwalten
    Lesegeräte anfordern, zurückgeben, ersetzen
    Lesegerät registrieren
    Standorte und Zonen verwalten
    Lesegeräte konfigurieren
    Verschlüsselung
    Quellen
    API-Referenzen
    Mobile Lesegeräte
    Intelligente Lesegeräte
    SDK-Migrationsleitfaden
    Bereitstellungscheckliste
    Produktdatenblätter für Lesegeräte von Stripe Terminal
Andere Stripe-Produkte
Financial Connections
Krypto
Climate
StartseiteZahlungenTerminal

Notiz

Bis jetzt ist diese Seite noch nicht in dieser Sprache verfügbar. Wir arbeiten aber verstärkt daran, unsere Dokumentation in weiteren Sprachen bereitzustellen, und werden die Übersetzung sofort anzeigen, sobald diese verfügbar ist.

Set up your integration

Set up a Stripe Terminal SDK or server-driven integration to accept in-person payments.

Seite kopieren

SDK Reference

If you’re looking for a more detailed reference with all available methods, objects, and errors, consult our full SDK reference.

Getting started with the Android SDK requires four steps:

  1. Install the SDK in your app.
  2. Configure your app.
  3. Set up the connection token endpoint in your app and backend.
  4. Initialize the SDK in your app.

Install the SDK
Client-side

Vorsicht

The SDK is no longer compatible with the support libraries, as we use Room to store and maintain state across the app lifecycle. Make sure your app has migrated to AndroidX.

To install the SDK, add stripeterminal to the dependencies block of your app’s build file:

build.gradle.kts
Kotlin
plugins { id("com.android.application") } android { ... } dependencies { implementation("com.stripe:stripeterminal:4.4.0") // ... }

Next, since the SDK relies on Java 8, your app’s build file needs to specify that as your target Java version:

build.gradle.kts
Kotlin
android { // ... compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = "1.8" } }

Notiz

For details on the latest SDK release and past versions, see the Releases page on GitHub. To receive notifications when a new release is published, watch releases for the repository.

For information on migrating from earlier beta versions of the Android SDK, see the Stripe Terminal Beta Migration Guide.

Configure your app
Client-side

You must enable the ACCESS_FINE_LOCATION permission. To connect a Bluetooth reader, you must also enable Bluetooth permissions. Add the appropriate permissions to your manifest as shown here:

AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />

Before initializing the Terminal object, add the following check to make sure that the ACCESS_FINE_LOCATION permission is enabled in your app:

MainActivity.kt
Kotlin
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { val permissions = arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION) ActivityCompat.requestPermissions(this, permissions, REQUEST_CODE_LOCATION) }

Also verify that the app user grants location permission—the SDK doesn’t function without it. To do this, override the onRequestPermissionsResult method in your app and check the permission result.

MainActivity.kt
Kotlin
override fun onRequestPermissionsResult( requestCode: Int, permissions: Array<String>, grantResults: IntArray ) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) if (requestCode == REQUEST_CODE_LOCATION && grantResults.isNotEmpty() && grantResults[0] != PackageManager.PERMISSION_GRANTED ) { throw RuntimeException("Location services are required to connect to a reader.") } }

Notiz

To reduce fraud risks associated with payments, and to minimize disputes, Stripe needs to know where payments occur. If the SDK can’t determine the location of the Android device, payments are disabled until location access is restored.

Set up the ConnectionToken endpoint
Server-side
Client-side

Server-side

To connect to a reader, your backend needs to give the SDK permission to use the reader with your Stripe account, by providing it with the secret from a ConnectionToken. Your backend needs to only create connection tokens for clients that it trusts.

Command Line
curl
curl https://api.stripe.com/v1/terminal/connection_tokens \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -X "POST"

Obtain the secret from the ConnectionToken on your server and pass it to the client side.

Ruby
post '/connection_token' do token = # ... Create or retrieve the ConnectionToken {secret: token.secret}.to_json end

Vorsicht

The secret from the ConnectionToken lets you connect to any Stripe Terminal reader and take payments with your Stripe account. Be sure to authenticate the endpoint for creating connection tokens and protect it from cross-site request forgery (CSRF).

Client-side

To give the SDK access to this endpoint, implement the ConnectionTokenProvider interface in your app, which defines a single function that requests a ConnectionToken from your backend.

CustomConnectionTokenProvider.kt
Kotlin
class CustomConnectionTokenProvider : ConnectionTokenProvider { override fun fetchConnectionToken(callback: ConnectionTokenCallback) { try { // Your backend should call /v1/terminal/connection_tokens and return the // JSON response from Stripe. When the request to your backend succeeds, // return the `secret` from the response to the SDK. callback.onSuccess(secret) } catch (e: Exception) { callback.onFailure( ConnectionTokenException("Failed to fetch connection token", e) ) } } }

This function is called whenever the SDK needs to authenticate with Stripe or the Reader. It’s also called when a new connection token is needed to connect to a reader (for example, when your app disconnects from a reader). If the SDK can’t retrieve a new connection token from your backend, connecting to a reader fails with the error from your server.

Vorsicht

Do not cache or hardcode the connection token. The SDK manages the connection token’s lifecycle.

Certificate pinning

In most cases, you shouldn’t configure your application with certificate pinning. If your application does require it, see the certificate pinning docs.

Initialize the SDK
Client-side

The Android SDK is lifecycle aware. To prevent memory leaks and ensure proper cleanup of long-running Terminal SDK processes, your application must implement an Application subclass that uses TerminalApplicationDelegate.onCreate() to inform the SDK about lifecycle events.

StripeTerminalApplication.kt
Kotlin
// Substitute with your application name, and remember to keep it the same as your AndroidManifest.xml class StripeTerminalApplication : Application() { override fun onCreate() { super.onCreate() TerminalApplicationDelegate.onCreate(this) } }

Notiz

If you want to use Tap to Pay on Android (TTPA), the initialization in Application is slightly different from this example. See Connect to a reader with TTPA.

The Terminal class made available by the Stripe Terminal SDK exposes a generic interface for discovering readers, connecting to a reader, and performing operations on the reader, such as displaying cart details, collecting payments, and saving cards for future use.

To get started, provide the current application context, the ConnectionTokenProvider implemented in Step 3, and a TerminalListener object. You can use this listener to handle events such as payment and connection status updates from the SDK.

MainActivity.kt
Kotlin
// Create your listener object. Override any methods that you want to be notified about val listener = object : TerminalListener { override fun onConnectionStatusChange(status: ConnectionStatus) { println("onConnectionStatusChange: $status"); } override fun onPaymentStatusChange(status: PaymentStatus) { println("onPaymentStatusChange: $status"); } } // Choose the level of messages that should be logged to your console val logLevel = LogLevel.VERBOSE // Create your token provider. val tokenProvider = CustomConnectionTokenProvider() // Pass in the current application context, your desired logging level, your token provider, and the listener you created if (!Terminal.isInitialized()) { Terminal.initTerminal(applicationContext, logLevel, tokenProvider, listener) } // Since the Terminal is a singleton, you can call getInstance whenever you need it Terminal.getInstance()

Vorsicht

If you’re upgrading from a version below 1.0.0-rc2, note that TerminalLifecycleObserver and Application classes are now mandatory.

SDK updates

Stripe periodically releases updates which can include new functionality, bug fixes, and security updates. Update your SDK as soon as a new version is available. The currently available SDKs are:

  • Stripe Terminal Android SDK
  • Stripe Terminal iOS SDK
  • Stripe Terminal JavaScript SDK
  • Stripe Terminal React Native SDK

Next steps

  • Connect to a reader
War diese Seite hilfreich?
JaNein
Benötigen Sie Hilfe? Kontaktieren Sie den Kundensupport.
Nehmen Sie an unserem Programm für frühzeitigen Zugriff teil.
Schauen Sie sich unser Änderungsprotokoll an.
Fragen? Sales-Team kontaktieren.
LLM? Lesen Sie llms.txt.
Unterstützt von Markdoc