Express Checkout

Purpose: One click solution for last used saved payment method

Add Express Checkout Widget to Layout

<io.hyperswitch.view.BasePaymentWidget
    android:id="@+id/expressCheckoutWidget"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:paymentMethod="expressCheckout" />

<Button
    android:id="@+id/confirmEC"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Confirm EC" />

Initialize Express Checkout Launcher

private lateinit var ecLauncherInstance: UnifiedPaymentLauncher

private fun setupECLauncher() {
    ecLauncherInstance = UnifiedPaymentLauncher.createExpressCheckoutLauncher(
        activity = this,
        clientSecret = paymentIntentClientSecret,
        readyCallback = ::onExpressCheckoutReady,
        resultCallback = ::onExpressCheckoutResult
    )

    findViewById<View>(R.id.confirmEC).setOnClickListener {
        if (::ecLauncherInstance.isInitialized) {
            ecLauncherInstance.presentForPayment(paymentIntentClientSecret)
        } else {
            Toast.makeText(this, "Express Checkout Launcher not initialized", Toast.LENGTH_SHORT).show()
        }
    }
}

Handle Express Checkout Callbacks

Last updated

Was this helpful?