API v1FiatPe Home
FiatPeDocs
ANDROID SDK

Java with XML Views

Add the FiatPe Partner SDK to a Java Android app using XML layouts.

Requirements

Android

minSdk 24+ and compileSdk 37+. Keep the target SDK required by your app and distribution policy.

Build tools

Supported API 37 tooling starts at AGP 9.1.1. Update the app's build tools only when required for that API level.

Runtime compatibility

Enable core-library desugaring with desugar_jdk_libs 2.1.5 or a compatible newer release.

AndroidX owner

Register from a ComponentActivity, subclass, or AndroidX Fragment—not a platform Activity or Fragment.

Prepare the API keys

FiatPe publishable key

Request a publishable key for the partner account and environment. Use ak_test_… for test/preproduction and ak_live_… for production. Never package a secret or server credential in the Android app.

Google Maps and Places key

  1. Enable billing, Maps SDK for Android, and Places API (New) in Google Cloud.
  2. Restrict the key to the application ID and signing-certificate SHA-1 used by each build.
  3. Add the Google key to the user-level Gradle properties file.
  4. For CI, provide the Gradle project environment variable. Do not commit either key.
gradle.properties
Copy
# ~/.gradle/gradle.properties
MAPS_API_KEY=YOUR_GOOGLE_MAPS_PLACES_KEY
CI environment variable
Copy
ORG_GRADLE_PROJECT_MAPS_API_KEY=YOUR_GOOGLE_MAPS_PLACES_KEY

Add the SDK and required configuration

Ensure the existing repositories include google() and mavenCentral(). Merge only these additions into the app module and retain its existing plugins, compiler configuration, UI dependencies, namespace, application ID, and target SDK.

app/build.gradle
Copy
android {
    compileSdk 37
    defaultConfig {
        minSdk 24
        manifestPlaceholders['MAPS_API_KEY'] =
            providers.gradleProperty('MAPS_API_KEY').orElse('').get()
    }
    compileOptions {
        coreLibraryDesugaringEnabled true
    }
}

dependencies {
    implementation 'com.fiatpe:partner:1.0.0'
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
}

Add this metadata inside the existing <application>, or reuse an existing Google key that has the required APIs and restrictions. Keep the app's existing Activity declaration.

AndroidManifest.xml
Copy
<meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="${MAPS_API_KEY}" />

Register in your existing Activity

Merge these fields and methods into the Activity that already owns the screen. MainActivity is only an example name. Creating the instance registers the result callback; it does not open the SDK.

MainActivity.java
Copy
import android.os.Bundle;
import android.widget.Toast;
import androidx.activity.ComponentActivity;
import com.fiatpe.partner.FiatPePartner;
import com.fiatpe.partner.FiatPePartnerResult;

public class MainActivity extends ComponentActivity {
    private FiatPePartner partner;
    private boolean isPartnerOpen;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Register early on every Activity creation, including recreation.
        partner = FiatPePartner.create(
            this,
            "ak_test_REPLACE_WITH_PUBLISHABLE_KEY",
            this::handlePartnerResult
        );

        // Keep your existing screen setup here.
    }

    private void openPartnerSdk() {
        if (isPartnerOpen) return;
        isPartnerOpen = true;
        partner.start();
    }

    private void handlePartnerResult(FiatPePartnerResult result) {
        isPartnerOpen = false;
        String message = result instanceof FiatPePartnerResult.Failure
            ? "Unable to open FiatPe Partner. Please contact support."
            : "Returned from FiatPe Partner";
        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
    }
}

Start from your existing UI action

Call openPartnerSdk() from the app's existing button, menu item, or another user action. No particular XML layout, widget, or view ID is required.

Views UI action (.java)
Copy
// Use the ID of your own launch control.
findViewById(R.id.openPartnerButton).setOnClickListener(view -> openPartnerSdk());

Optional branding and Fragment integration

Pass FiatPePartnerTheme while creating the instance to set an opaque ARGB primary color and explicit light/dark appearance. The key and theme are fixed for that instance.

Java theme configuration
Copy
partner = FiatPePartner.create(
    this,
    "ak_test_REPLACE_WITH_PUBLISHABLE_KEY",
    new com.fiatpe.partner.FiatPePartnerTheme(0xFF2458A6, false),
    this::handlePartnerResult
);

For an AndroidX Fragment, register from its onCreate using the Fragment overload (fragment = this for Kotlin or FiatPePartner.create(this, key, callback) for Java). Connect the UI action after view creation and forward results to a state holder instead of accessing a destroyed Fragment view.

Handle results correctly

ResultMeaningHost app action
ClosedThe user left the SDK.Re-enable launch and return to the host UI.
Failure(code, message)The SDK could not open or returned an unusable result.Re-enable launch, handle the code, and show safe guidance.
Closed does not mean completed.

A user may close before or after an onboarding or CPV operation. This SDK version has no business-success callback and returns no merchant ID, documents, VPA, or QR data. Confirm completion through the separate business-status integration agreed with FiatPe.

Failure codes

  • INVALID_MAPS_CONFIGURATION: fix a missing or blank Google key.
  • LAUNCH_FAILED: verify lifecycle, dependencies, and manifest configuration.
  • INVALID_REQUEST: verify the issued FiatPe key and partner configuration.
  • INVALID_RESULT: return safely and contact FiatPe with sanitized diagnostics.

Exceptions raised by integration errors

  • A blank key or unsupported key prefix causes IllegalArgumentException during create(...).
  • A non-opaque custom theme color causes IllegalArgumentException.
  • Registering after the owner has started causes a lifecycle registration error.
  • Calling start() while the same instance is already open causes IllegalStateException.

Lifecycle, permissions, and security

  • Create the SDK in Activity or Fragment onCreate, before STARTED, on the main thread.
  • Register after every owner recreation, including rotation. Do not guard registration with savedInstanceState == null.
  • Start only after a user action, block repeated taps, and never relaunch automatically from onResume.
  • Keep the instance with its Activity or Fragment, not a singleton or retained ViewModel.
  • The SDK requests camera, microphone, and coarse/fine location permissions only in relevant flows. Internet access is required.
  • Do not duplicate SDK Activity or provider declarations. Include permission and data-use explanations in the host app privacy disclosures.

Troubleshooting

Dependency not found

Confirm google() and mavenCentral(), the exact coordinate, and Gradle network access.

Duplicate classes

Remove old SDK AARs and keep transitive dependencies enabled. Do not force the dependency to non-transitive mode.

Maps or search blank

Check billing, enabled APIs, quota, key restrictions, signing certificate, connectivity, and Google services.

Works only in debug

Check production keys, release manifest placeholders, signing restrictions, and release-only build errors.

When contacting support, include SDK version, app version, Android version, device model, reproduction steps, and a sanitized failure code/message. Remove keys, documents, and personal data.