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

React Native Reference

Complete reference of everything you pass into the SDK

Package: @juspay-tech/react-native-hyperswitch

Hyperswitch React Native SDK — API Reference

Complete reference of everything you pass into the SDK: every configuration object, every prop, every option — plus what the SDK returns back to you.

Package: @juspay-tech/react-native-hyperswitch


1. Hyperswitch.init(config) — HyperswitchConfiguration

Called once to configure the SDK with your account credentials.

Prop
Type
Required
Default
Description

publishableKey

string

Yes

—

Publishable key from the Hyperswitch dashboard (pk_snd_... / pk_prd_...)

profileId

string

No

—

Business profile id (pro_...)

platformPublishableKey

string

No

—

Optional platform-specific publishable key

environment

'PROD' | 'SANDBOX' | 'INTEG'

No

'PROD'

Target environment

customEndpoints

CommonEndpoint | OverrideEndpoints

No

—

Endpoint overrides (below)

// CommonEndpoint
{ commonEndpoint: string }

// OverrideEndpoints
{
  overrideEndpoints: {
    customBackendEndpoint?: string;
    customLoggingEndpoint?: string;
    customAssetEndpoint?: string;
    customSDKConfigEndpoint?: string;
    customAirborneEndpoint?: string;
  }
}

Example


2. initPaymentSession(options) — PaymentSessionConfiguration

Creates a payment session from the client secret your backend returns after creating a Payment Intent (or calling /payments/session).

Prop
Type
Required
Description

sdkAuthorization

string

Yes

Client secret / sdk_authorization returned by your server

The same object is accepted by hyper.elements(options) and by the options prop of <HyperElements>.


3. presentPaymentSheet(configuration) — PaymentSheetConfiguration

Passed to paymentSession.presentPaymentSheet(...) and as the options prop of PaymentElement, ApplePayButton, GooglePayButton.

Prop
Type
Required
Description

merchantDisplayName

string

Yes

Your store name — shown in the sheet, wallet dialogs and 3DS screens

appearance

Appearance

No

Theme, colors, shapes, fonts, pay-button & logo customization

paymentMethodLayout

PaymentMethodLayout

No

Tabs/accordion layout + saved-method customization

walletButtonsConfiguration

WalletButtonsConfiguration

No

Wallet button type/style/visibility

subscribedEvents

SubscriptionEvent[]

No

Events delivered through onChange

locale

Locale

No

Sheet language: 'en', 'en-GB', 'fr', 'fr-BE', 'de', 'es', 'ca', 'pt', 'it', 'pl', 'nl', 'nI-BE', 'sv', 'ru', 'lt', 'cs', 'sk', 'ls', 'cy', 'el', 'et', 'fi', 'nb', 'bs', 'da', 'ms', 'tr-CY', 'ar', 'he', 'ja'

primaryButtonLabel

string

No

Custom pay-button text (e.g. "Complete Purchase")

paymentSheetHeaderLabel

string

No

Custom header of the payment sheet

savedPaymentSheetHeaderLabel

string

No

Custom header of the saved-methods screen

paymentMethodOrder

string[]

No

Payment method ordering, e.g. ['card', 'google_pay', 'apple_pay']

paymentMethodsConfig

{ paymentMethod: string; message?: string }[]

No

Per-method info messages

displaySavedPaymentMethods

boolean

No

Show/hide the customer's saved payment methods section

displaySavedPaymentMethodsCheckbox

boolean

No

Show/hide the "save for future use" checkbox

displayDefaultSavedPaymentIcon

boolean

No

Show the default badge on the default saved method

displayPayButton

boolean

No

Show/hide the internal pay button (hide it if you render your own)

stickyPayButton

boolean

No

Pin the pay button to the bottom

allowsDelayedPaymentMethods

boolean

No

Allow async payment methods (e.g. bank debits)

allowsPaymentMethodsRequiringShippingAddress

boolean

No

Allow methods that require a shipping address

disableBranding

boolean

No

Hide Hyperswitch branding

preloadCardElement

boolean

No

Preload the card form for faster first paint

redirectionInfo

'hidden' | 'shown'

No

Show/hide the redirection notice

opensCardScannerAutomatically

boolean

No

Open the card scanner automatically on entry

alwaysSendCustomerAcceptance

boolean

No

Always send save-for-future-use consent

customer

{ id?: string; ephemeralKeySecret?: string }

No

Customer override for this presentation

billingDetails

AddressDetails

No

Pre-fill billing details

shippingDetails

AddressDetails

No

Pre-fill shipping details

placeholder

{ cardNumber?: string; expiryDate?: string; cvv?: string }

No

Custom input placeholders

splitCardFields

boolean

No

Show card number / expiry / CVC as separate fields

netceteraSDKApiKey

string

No

Netcetera 3DS SDK key, if applicable

3.1 Appearance

ColorType — separate palettes for light & dark:

Shapes:

Font:

PrimaryButton:

LogoCustomization:

3.2 PaymentMethodLayout

3.3 WalletButtonsConfiguration

3.4 SubscriptionEvent

Passed via subscribedEvents, received via onChange.

Event
Payload
Meaning

PAYMENT_METHOD_STATUS

{ paymentMethod: string; paymentMethodType: string; isSavedPaymentMethod: boolean; isOneClickWallet: boolean }

A payment method is selected/ready

PAYMENT_METHOD_INFO_CARD

CardInfo → below

Live card input details

PAYMENT_METHOD_INFO_BILLING_ADDRESS

{ country: string; state: string; postalCode: string }

Billing address inputs

FORM_STATUS

{ status: string }

Overall form validity

CVC_STATUS

{ isCvcFocused: boolean; isCvcBlur: boolean; isCvcEmpty: boolean }

CVC widget state (CardCVCElement)

3.5 AddressDetails (billing / shipping pre-fill)


4. Components — props you pass

4.1 <HyperElements>

Provider that creates the Elements context. Everything below only works inside it.

Prop
Type
Required
Description

hyper

HyperswitchSession | Promise<HyperswitchSession> | null

Yes

Initialized SDK (or its promise)

options

{ sdkAuthorization: string }

Yes

Client secret from your backend

children

ReactNode

Yes

Your checkout UI

4.2 <PaymentElement>

Prop
Type
Required
Description

widgetId

string

Yes

Unique id — can also be passed as a string to elements.confirmPayment('widgetId')

options

PaymentSheetConfiguration

No

Everything from §3

onPaymentResult

(result: PaymentResult) => void

Yes

Result when the internal pay button is used

onChange

(event: PaymentEventResult) => void

No

Subscribed events (§3.4)

onReady

() => void

No

Native view mounted (use PAYMENT_METHOD_STATUS for full readiness)

style

ViewStyle

No

Layout

ref

PaymentElementHandle

No

Imperative confirm, below

4.3 <CardCVCElement>

Prop
Type
Required
Description

id

string

For headless confirm

Widget id — must be passed to confirmWithCustomerLastUsedPaymentMethod({ id })

options

CvcWidgetOptions

No

See below

onChange

(event: PaymentEventResult) => void

No

CVC_STATUS events

onReady

() => void

No

Widget ready for input

onFocus

() => void

No

CVC field focused

onBlur

() => void

No

CVC field blurred

onPaymentResult

(result: PaymentResult) => void

No

Result if this widget completes a payment

style

ViewStyle

No

Layout

4.4 <ApplePayButton> / <GooglePayButton>

Identical props for both:

Prop
Type
Required
Description

widgetId

string

Yes

Unique widget id

options

PaymentSheetConfiguration

No

merchantDisplayName + appearance + walletButtonsConfiguration

onPaymentResult

(result: PaymentResult) => void

Yes

Wallet payment result

onChange

(event: PaymentEventResult) => void

No

PAYMENT_METHOD_STATUS = wallet usable

onReady

() => void

No

Native view mounted

style

ViewStyle

No

Layout

PaymentEventResult (delivered to every onChange):


5. Methods & return types — what the SDK gives back

5.1 HyperswitchSession

Member
Type

publishableKey

string

initPaymentSession(options)

({ sdkAuthorization: string }) => Promise<PaymentSession>

elements(options)

({ sdkAuthorization: string }) => Promise<Elements>

5.2 PaymentSession

Method
Signature
Returns

presentPaymentSheet(configuration?)

(PaymentSheetConfiguration?) => Promise<PaymentResult>

PaymentResult

getCustomerSavedPaymentMethods(options?)

({ hiddenPaymentMethods?: string[] }?) => Promise<CustomerSavedPaymentMethodsSession>

CustomerSavedPaymentMethodsSession

updateIntent(intentResolver)

(() => Promise<{ sdkAuthorization: string } | null>) => Promise<void>

Re-syncs all widgets with the new intent

5.3 Elements

Method
Signature

confirmPayment(paymentElementRef, options?)

({ current: PaymentElementHandle | null } | string, { confirmParams?: Record<string, any> }?) => Promise<PaymentResult>

presentPaymentSheet(configuration?)

(PaymentSheetConfiguration?) => Promise<PaymentResult>

updateIntent(intentResolver)

(() => Promise<{ sdkAuthorization: string }>) => Promise<void>

getCustomerSavedPaymentMethods(options?)

({ hiddenPaymentMethods?: string[] }?) => Promise<CustomerSavedPaymentMethodsSession>

5.4 Hooks

Hook
Returns
Notes

usePaymentSession()

PaymentSession | null

Null until HyperElements finishes initializing

useWidgets()

Elements | null

Alias: useElements()

5.5 PaymentResult — returned everywhere

5.6 CustomerSavedPaymentMethodsSession

Method
Signature
Description

getCustomerLastUsedPaymentMethodData()

() => Promise<CustomerLastUsedPaymentMethod | null>

Most recently used saved method

getCustomerDefaultSavedPaymentMethodData()

() => Promise<CustomerLastUsedPaymentMethod | null>

Customer's default saved method

getCustomerSavedPaymentMethodData()

() => Promise<CustomerLastUsedPaymentMethod | null>

First available saved method

confirmWithCustomerLastUsedPaymentMethod(args?)

({ id?: string }?) => Promise<PaymentResult>

One-click confirm with last-used method. id = mounted CardCVCElement id (required)

confirmWithCustomerDefaultPaymentMethod(args?)

({ id?: string }?) => Promise<PaymentResult>

One-click confirm with default method

5.7 CustomerLastUsedPaymentMethod


6. Minimal cheat-sheet

You want to…
Pass this

Initialize the SDK

Hyperswitch.init({ publishableKey, profileId })

Start a payment

hyper.initPaymentSession({ sdkAuthorization })

Drop-in checkout

session.presentPaymentSheet({ merchantDisplayName, appearance })

Custom checkout

<HyperElements hyper options={{ sdkAuthorization }}> + PaymentElement / wallet buttons

Confirm manually

widgets.confirmPayment(paymentRef) or paymentRef.current.confirmPayment()

Saved card + CVC

session.getCustomerSavedPaymentMethods() → CardCVCElement id="x" → methodsSession.confirmWithCustomerLastUsedPaymentMethod({ id: 'x' })

Change amount mid-flow

session.updateIntent(async () => ({ sdkAuthorization: newSecret }))

Handle every result

PaymentResult.status → 'completed' | 'canceled' | 'failed'

Last updated

Was this helpful?