App Configuration for the Fast Android SDK

Recommendation: Create Sandbox Account

Sign up for a Fast Sandbox account so that you can test your integration with test cards before going live.

If you need help at any point, contact Customer Success at [email protected].

App Startup library dependency

The Fast SDK initializes at app start automatically via the AndroidX App Startup library. It is not required to initialize the SDK from your Application class.

Add your Fast App ID to AndroidManifest.xml:

Fast APP ID

The Fast App ID (app_id) can be found in the Install section of your Fast Seller Dashboard. You can also retrieve your Sandbox App ID from the Sandbox Seller Dashboard.

Copy
Copied to Clipboard
<application ...>

  <!-- Configure the Fast SDK -->
	<meta-data android:name="co.fast.app_id" android:value="YOUR_APP_ID" />

</application>

Initialize FastCheckout from your Activity or Fragment

Create an instance of FastCheckout from your Activity or Fragment's onCreate() method.

Copy
Copied to Clipboard
private lateinit var fastCheckout: FastCheckout

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    fastCheckout = FastCheckout(this, ::onFastCheckoutEvent)
}

// Optionally, handle any FastCheckoutEvents that are useful to your app.
// This is called once for each event emitted by the SDK, and provides your app info about the checkout.
private fun onFastCheckoutEvent(event: FastCheckoutEvent) {
    when (event) {
        is FastCheckoutEvent.OrderCanceled -> {
            // handle event, if desired
        }
        is FastCheckoutEvent.OrderCompleted -> {
            // handle event, if desired
        }
        is FastCheckoutEvent.OrderCreated -> {
            // handle event, if desired
        }
        is FastCheckoutEvent.OrderFailed -> {
            // handle event, if desired
        }
        is FastCheckoutEvent.OrderUpdated -> {
            // handle event, if desired
        }
        FastCheckoutEvent.SDKClosed -> {
            // handle event, if desired
        }

        // Please keep this else clause. Fast may add more events in the future without updating the SDK's major version.
        else -> Log.i(LOG_TAG, "Event: Unhandled event: $event")
    }
Callbacks

You can find more details about ::onFastCheckoutEvent in the callbacks section of the Handle Fast Events page

Add the Fast Checkout Button

On pages where you want the FastCheckoutButton to appear, add it to your layout.

Copy
Copied to Clipboard
    <!-- Fast recommends 56dp or 48dp for the height -->
    <co.fast.android.sdk.checkout.FastCheckoutButton
      android:id="@+id/fast_checkout"
      android:layout_width="match_parent"
      android:layout_height="56dp" />

Apps using Jetpack Compose can use the Compose Interoperability APIs to add FastCheckoutButton.

Start Fast Checkout when the button is clicked

Copy
Copied to Clipboard
    findViewById<FastCheckoutButton>(R.id.fast_checkout).setOnClickListener {

        // Checkout with products
        fastCheckout.checkoutWithProducts { options ->
          options.addProduct(...)
          options.addProduct(...)
        }

        // Or, checkout with cart id
        fastCheckout.checkoutWithCartId { options ->
          options.cartId = ...
        }
    }

More details about invoking Fast Checkout can be found here

Allow Users to Sign Out

Copy
Copied to Clipboard
Fast.reset()