Kotlin with REST API Integration
Integrate hyper SDK to your Kotlin App using hyperswitch-node
Follow the Server Setup section.
hyperswitch {
// Optional: Specify main SDK version (defaults to latest if not specified)
sdkVersion = "latest_version"
// Optional features - only add what you need
features = [HyperFeature.SCANCARD, HyperFeature.NETCETERA]
}Next, implement the HyperInterface in your CheckoutActivity. This involves extending FragmentActivity or a subclass such as AppCompatActivity, and implementing the HyperInterface:
Create a HyperswitchInstance using the publishable key and optional profile ID returned by your server:
hyperswitchInstance = Hyperswitch.init(
activity = this,
config = HyperswitchConfiguration(
publishableKey = response.publishableKey,
profileId = response.profileId,
),
)Note:
For an open-source setup, use the following parameters:
val config = HyperswitchConfiguration(
publishableKey = response.publishableKey,
profileId = response.profileId,
customConfig = CustomEndpointConfiguration(
commonEndpoint = "https://your-hyperswitch-host.example.com",
),
)The SDK derives the backend, logging, and asset paths from commonEndpoint. Provide the base URL without a trailing slash.
Individual endpoints can be overridden when required:
val config = HyperswitchConfiguration(
publishableKey = response.publishableKey,
profileId = response.profileId,
customConfig = CustomEndpointConfiguration(
overrideEndpoints = OverrideEndpoints(
customBackendEndpoint =
"https://your-hyperswitch-host.example.com/api",
customLoggingEndpoint =
"https://your-hyperswitch-host.example.com/api/logs/sdk",
customAssetEndpoint =
"https://your-hyperswitch-host.example.com/assets/v2",
),
),
)Request your server to fetch a payment as soon as your view is loaded. Store the sdk_authorization returned by your server. The PaymentSession will use this to complete the payment process.
Initialize the payment session with the sdk_authorization:
Before you begin
Requirements
Android 7.0 (API level 24) and above
Android Gradle Plugin 8.13+
Gradle 8.13+
Setup the server
Complete the Server Setup guide before building the checkout page.
Build checkout page on your app
2.1 Add the Buildscript Classpath
To start integrating the Juspay Hyperswitch SDK, add the following classpath to the buildscript block of your project-level build.gradle file:
Check the latest plugin version before adding the dependency.
2.2 Add the Plugin
Add the following plugin to the plugins block of your app-level build.gradle file:
2.3 Configure the SDK
Configure the Hyperswitch SDK in your app-level build.gradle file. You can specify the main SDK version and enable optional features:
2.4 Implement the HyperInterface
Next, implement the HyperInterface in your CheckoutActivity. This involves extending FragmentActivity and implementing the HyperInterface:
2.5 Setup the SDK and fetch a Payment
Set up the SDK using your publishable key. This is essential for initializing a PaymentSession:
2.6 Fetch a Payment
Request your server to fetch a payment as soon as your view is loaded. Store the client_secret returned by your server. The PaymentSession will use this secret to complete the payment process.
Complete the payment on your app
3.1 Initialize Payment Session
Initialize the payment session with the client_secret:
3.2 Handle Payment Result
Handle the payment result in the completion block. Display appropriate messages to your customer based on the outcome of the payment:
Please retrieve the payment status from the Hyperswitch backend to get the terminal status of the payment. Do not rely solely on the status returned by the SDK, as it may not always reflect the final state of the transaction.
3.3 Present the Payment Page
Create a configuration object to customize the payment sheet and present the payment page:
3.4 Final Step
Congratulations! You have successfully integrated the Hyperswitch Android SDK into your app. You can now customize the payment sheet to match the look and feel of your app.
Next steps
Last updated
Was this helpful?

