Skip to content

About

Spreedly Checkout Android SDK Example App - reference integration using Gradle

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Spreedly Checkout — Android Example

This sample app demonstrates the Spreedly Android Checkout SDK at version 1.6.0 (tag v1.6.0).

Setup

  1. Clone this repository
  2. Add your GitHub Packages credentials to ~/.gradle/gradle.properties:
gpr.usr=YOUR_GITHUB_USERNAME
gpr.key=YOUR_GITHUB_TOKEN
  1. Add your Spreedly environment key and other API keys to apikeys.properties (see apikeys.properties.example)
  2. demoBackendUrl near the top of app/build.gradle.kts points at Spreedly's sample backend (https://checkout.spreedly-demo.app) by default. That host uses HTTP Basic auth — set backendBasicAuthUser and backendBasicAuthPassword in apikeys.properties when your team provides them (Demo backend). Basic auth is sent only on HTTPS to that configured origin, not to other hosts or plain-HTTP local backends, using UTF-8 encoding in the Authorization header. Values compile into debug builds only. When you change demoBackendUrl to your own host (for example https://backend.example.com), purchase JSON includes redirect_url again (omission applies only to the exact HTTPS origin of the default hosted sample). Gradle turns the omit flag off by default for a custom host; if you force spreedlyOmitRedirectUrl=true in apikeys.properties, omission still does not apply unless the request targets that hosted origin. On the canonical hosted default URL only, the app may omit redirect_url, stores saved cards on the device, and tags tokenization with sample_app_owner for retain ownership. Any other demoBackendUrl (other host, path prefix, or port) uses custom mode: GET /api/v1/payment_methods sync, legacy retain (success: true), no ownership metadata. Saved cards are scoped per backend URL and environmentKey; custom-backend upgrades hide unscoped local cards until GET /api/v1/payment_methods succeeds on the relevant demo screens (Basic Form, recache flows, and Java examples; offline mock seeding runs only on the hosted sample and is skipped on custom backends, including after a successful empty list sync). Delete on a custom backend only removes the card from the demo list (local suppression; no backend delete API; up to 20 visible cards after hide). Hosted sample owner and saved-card storage are excluded from Android cloud backup and device-to-device transfer (see the demo-backend section in the testing guide). Endpoint shapes are in the same guide.
  3. Open the project in Android Studio and sync Gradle

Secure tokenization: This sample fetches its nonce, signature, and certificate token from the backend at demoBackendUrl (AuthService). That backend must sign with the certificate private key of the environment key in apikeys.properties: once Enable secure tokenization (Environment settings → Security → Enhanced Security, in app.spreedly.com) is on, a signature from any other certificate fails its check, and a certificate never authorizes a different organization's environment (nor, by default, a different environment at all — certificates are scoped to one environment unless created with organization-level scope). Never leave secure tokenization disabled on a production environment. It's still required there. For your own app, replace AuthService with a backend that signs with your own certificate — see the SDK docs' Getting Started guide for the full steps.

Dependencies

All SDK modules are resolved from GitHub Packages:

implementation("com.spreedly:checkout-paymentsheet:1.6.0")
implementation("com.spreedly:checkout-braintree-apm:1.6.0")
implementation("com.spreedly:checkout-stripe-apm:1.6.0")
implementation("com.spreedly:checkout-threeds:1.6.0")
implementation("com.spreedly:checkout-stripe-radar:1.6.0")
implementation("com.spreedly:checkout-clicktopay:1.6.0")

Installation notes

Card payments — checkout-payments-core is always required. Use checkout-paymentsheet for the pre-built bottom sheet (expressCheckout()). Use checkout-hostedfields for custom forms with SPLTextField (also included transitively by checkout-paymentsheet).

3D Secure — Add checkout-threeds only for Global or Gateway-Specific 3DS. It pulls the Forter SDK transitively, so add the Forter Maven repository (with credentials) whenever you depend on checkout-threeds. See Global 3DS — Step 1.

APM, Radar & wallets — Add checkout-braintree-apm, checkout-stripe-apm, checkout-stripe-radar, checkout-clicktopay and/or checkout-googlepay only when you need those payment methods, fraud sessions or wallets. See their prerequisites under Compatibility below.

Required: Generating auth details on your backend is not enough. Enable secure tokenization for each Spreedly environment in app.spreedly.com before production tokenization. Full steps, payment-method submission notes, staging checks, and platform behavior: Enable secure tokenization (required).

Compatibility

Component Minimum Recommended
Android API Level 26 (Android 8.0) 35 (Android 15)
Compile SDK 36 36
JDK 17 21
Kotlin 2.1.20 2.1.20
Android Gradle Plugin 8.13.2 8.13.2
KSP 2.1.20-2.0.1 2.1.20-2.0.1
Gradle 8.14.3 8.14.3
Android Studio Narwhal Narwhal Feature Drop 2

SDK libraries target JVM 17. JDK 17 is the minimum build JDK (AGP 8.13); JDK 21 is recommended.

This SDK uses Kotlin 2.1.20 with AGP 8.13.2 and Gradle 8.14.3. That combination is outside JetBrains' fully tested KGP/AGP/Gradle matrix.

KSP applies when your app uses Kotlin symbol processors (e.g. Hilt, Room). Match the Kotlin Gradle plugin and KSP versions to avoid “KSP too old for Kotlin” errors.

Optional checkout-clicktopay requires Android System WebView / Chrome with WEB_MESSAGE_LISTENER (82+). See Click to Pay — Prerequisites.

The demo app targets SDK 36 and its Robolectric tests pin sdk=34 (app/src/test/resources/robolectric.properties), because Robolectric doesn't run at SDK 36. SDK libraries still target 35.

ProGuard / R8

The SDK is fully compatible with code obfuscation. If you encounter issues:

# Spreedly SDK
-keep class com.spreedly.** { *; }
-keepclassmembers class com.spreedly.** { *; }

# Ktor (if using custom ProGuard rules)
-keep class io.ktor.** { *; }

SDK Documentation

Support

For questions or issues, please contact Spreedly Support.

About

Spreedly Checkout Android SDK Example App - reference integration using Gradle

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages