For the complete documentation index, see llms.txt. This page is also available as Markdown.

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 Juspay Hyperswitch SDK

Initialize Juspay 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 
hyperswitchInstance = Hyperswitch.init(
          activity = this,
          config = HyperswitchConfiguration(
              publishableKey = publishableKey,
              profileId = profileId,
          ),
      )

2. Create a Payment Intent

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

3. Initialize your Payment Session

Initialize a Payment Session by passing the sdk_authorization to the initPaymentSession

lifecycleScope.launch {
          paymentSession = instance.initPaymentSession(
              PaymentSessionConfiguration(
                  sdkAuthorization = sdkAuthorization,
              ),
          )
      }

4. Craft a customized payments experience

Call paymentSession.getCustomerSavedPaymentMethods, keep the PaymentSessionHandler it hands to your callback, and work from that handler. It carries the saved payment method data and the confirm functions, as the example below shows. paymentSession itself does not expose them.

Payload for confirmWithCustomerLastUsedPaymentMethod(callback)

options (Required)
Description

callback (method)

Callback to get confirm response.

Last updated

Was this helpful?