Headless SDK

Hyperswitch is designed to facilitate the integration and management of payment-related functionalities in a decoupled or headless architecture with flexibility to customize your checkout UI.

Customize the payment experience using Headless functions

1. Initialize the Hyperswitch SDK

Initialize Hyperswitch Headless SDK onto your app with your publishable key. To get a Publishable Key please find it here.

// dependencies: implementation 'io.hyperswitch:hyperswitch-sdk-android:+' val 
paymentSession = PaymentSession(applicationContext, "YOUR_PUBLISHABLE_KEY")

2. Create a Payment Intent

Make a request to the endpoint on your server to create a new Payment. The clientSecret returned by your endpoint is used to initialize the payment session.

3. Initialize your Payment Session

Initialize a Payment Session by passing the clientSecret to the initPaymentSession

paymentSession.initPaymentSession(paymentIntentClientSecret)
options (Required)
Description

paymentIntentClientSecret (string)

Required. Required to use as the identifier of the payment.

4. Craft a customized payments experience

Using the paymentSession object, the default customer payment method data can be fetched, using which you can craft your own payments experience. The paymentSession object also exposes a confirmWithCustomerDefaultPaymentMethod function, using which you can confirm and handle the payment session.

var handler: PaymentSessionHandler? = null

paymentSession.getCustomerSavedPaymentMethods { paymentSessionHandler ->
    handler = paymentSessionHandler
}

val savedPaymentMethid = handler!!.getCustomerLastUsedSavedPaymentMethodData()

button.setOnClickListener { 
    handler!!.confirmWithCustomerLastUsedPaymentMethod { paymentResult -> 
        println(paymentResult)
    }
}

Payload for confirmWithCustomerLastUsedPaymentMethod(callback)

options (Required)
Description

callback (method)

Callback to get confirm response.

Last updated

Was this helpful?