SDK

Tokenize cards and manage saved payment methods using Juspay Hyperswitch's PCI-compliant Vault SDK - available for React and Vanilla JS

The Juspay Hyperswitch Vault SDK provides a secure, PCI-compliant iframe for merchants to collect, store, and manage customer payment methods - without raw card data ever touching your servers.

What the Widget Does

The PaymentMethodsManagementElement / paymentMethodsManagement widget embeds a secure iframe that lets customers:

  • View all saved payment methods

  • Add a new card (captured and tokenized without touching your servers)

  • Delete an existing saved payment method

After a successful confirmTokenization(), you receive a payment_method_id that can be reused in future Vault-Then-Pay flows - no need to re-collect card details.


Key Benefits

  • Minimal PCI scope - Card data is captured inside a Hyperswitch-hosted iframe; your servers only ever see tokens.

  • Pre-built Payment Methods Management UI - Customers can view, add, and delete saved cards through the embedded widget.

  • One-click repeat purchases - Reuse a payment_method_id for future payments without re-collecting card details.

  • Customizable appearance - Theme the widget to match your brand.


Before You Start

To integrate with the Hyperswitch Vault, configure your API credentials and profile settings first.

Step 1: Generate API Key

  1. Access Dashboard - Log into the Hyperswitch Control Centre.

  2. Navigate to API Keys - In the left-hand navigation menu, select Developers > API Keys.

  3. Create Key - Click Create New API Key.

  4. Secure Storage - Copy the generated key immediately and store it securely (it will not be shown again). Use this key in the Authorization: api-key=<YOUR_VAULT_API_KEY> header for all Vault API calls.

API Keys Dashboard
Navigate to Developers > API Keys to create and manage your API credentials

Step 2: Access Profile ID

  1. Navigate to Payment Settings - In the left-hand navigation menu, select Developers > Payment Settings.

  2. Copy Profile ID - Locate and copy your Profile ID from the Payment Settings page. This ID is required for API calls that specify which merchant profile to use.

Payment Settings - Profile ID
Navigate to Developers > Payment Settings to access your Profile ID

Step 1 - Server-Side Setup: Create a Payment Method Session Endpoint

Your backend creates a payment method session and returns the sdkAuthorization to your frontend. The client uses this token to initialize the SDK.

Replace YOUR_PROFILE_ID and YOUR_VAULT_API_KEY with your credentials. See Vault Configuration.

Ensure that customer_id is included in the request body. Refer to the API reference for customer creation for details.

API reference: Payment Method Session — Create


Step 2 - Client-Side Integration

Choose your frontend framework:

React Integration

2.1 Install Libraries

2.2 Initialize HyperLoader

Configure with your publishable key and profile ID (safe for frontend use):

2.3 Fetch Session Details

2.4 Mount the HyperManagementElements Component

2.5 Access Hyper Hooks in the Child Component

2.6 Render the Payment Methods Management Element

2.7 Confirm Tokenization

Call confirmTokenization() when the user submits. Hyper handles any required 3DS redirect and returns the user to return_url.


See It in Action

First-Time User: Saving a New Card

A new customer enters their card details inside the secure iframe. The card is tokenized and vaulted - your servers never see the raw number.

First-time user saving a card
New customer adding and vaulting a card through the Vault SDK widget

Returning User: Viewing Saved Cards

A returning customer opens the widget and instantly sees all their previously vaulted cards - no need to re-enter any details.

Returning user viewing saved cards
Returning customer viewing their vaulted cards in the widget

Managing Saved Cards: Delete and Update

Customers can view all their saved cards, remove ones they no longer need, and update existing card details - all from within the widget.

Managing saved cards - delete and update
Deleting and updating saved cards through the Vault SDK widget

Customizing the SDK Appearance

The widget supports theming to match your brand - colors, fonts, and layout can all be configured via the customization options.

SDK appearance customization
Theming the Vault SDK widget to match your brand

Last updated

Was this helpful?