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 Hyperswitch Headless SDK onto your app with your publishable key.

To get a publishableKey and profileId, refer to your Hyperswitch dashboard here.

// pod 'hyperswitch-sdk-ios'
import Hyperswitch

let hyperswitchConfiguration = HyperswitchConfiguration(
    publishableKey: publishableKey,
    profileId: profileId
)
let hyperswitch = Hyperswitch(configuration: hyperswitchConfiguration)

2. Create a Payment Intent

Make a request to the endpoint on your server to create a new Payment. The sdkAuthorization 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

let paymentSessionConfiguration = PaymentSessionConfiguration(
    sdkAuthorization: sdkAuthorization
)

let paymentSession = hyperswitch.initPaymentSession(
    configuration: paymentSessionConfiguration
)
options (Required)
Description

sdkAuthorization (string)

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

4. Craft a customized payments experience

Call paymentSession.getCustomerSavedPaymentMethods, keep the PaymentSessionHandler it passes 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 (function)

Callback to get confirm response.

Last updated

Was this helpful?