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

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,
          ),
      )

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

Download the demo app

You can use this demo app as a reference with your Juspay Hyperswitch credentials to test the setup.

1

Setup the server

Complete the Server Setup guide before building the checkout page.

2

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:

Configuration notes
  • If you don't specify sdkVersion, the plugin will automatically use the latest available version.

  • You only need to enable the features you plan to use.

  • Individual feature versions are optional—the plugin will use recommended compatible versions.

  • PaymentSession is designed to work with AndroidX activities. Ensure that your CheckoutActivity extends FragmentActivity or its subclass from the AndroidX library.

  • Initialize PaymentSession in the onCreate method of your FragmentActivity.

For an open-source setup, use the following parameters:

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.

3

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:

3.3 Present the Payment Page

Create a configuration object to customize the payment sheet and present the payment page:

3.4 Final Step

Next steps

Last updated

Was this helpful?