feat: added initPaymentSession and usePaymentSession#10
Merged
ArushKapoorJuspay merged 3 commits intomainfrom Apr 8, 2026
Merged
feat: added initPaymentSession and usePaymentSession#10ArushKapoorJuspay merged 3 commits intomainfrom
ArushKapoorJuspay merged 3 commits intomainfrom
Conversation
AbhishekChorotiya
approved these changes
Apr 8, 2026
aritro2002
approved these changes
Apr 8, 2026
ArushKapoorJuspay
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
Adds Payment Session support to @juspay-tech/react-hyper-js, exposing the SDK's initPaymentSession and updateIntent capabilities to React consumers via two approaches:
React Wrapper (react-hyper-js/)
Demo App (Hyperswitch-React-Demo-App/)
How did you test it?
Usage Notes
No breaking changes. All additions are purely additive.
New APIs
initPaymentSession(hyperPromise, options) — Standalone async function.
import { initPaymentSession } from "@juspay-tech/react-hyper-js";
const session = await initPaymentSession(hyperPromise, { clientSecret });
const savedPMs = await session.getCustomerSavedPaymentMethods();
const result = await session.updateIntent(async () => {
// Call your server to update payment, return new sdkAuthorization
return newSdkAuthorization;
});
usePaymentSession() — React hook (must be used inside ).
import { usePaymentSession } from "@juspay-tech/react-hyper-js";
const paymentSession = usePaymentSession();
await paymentSession.updateIntent(async () => {
return newSdkAuthorization;
});
Version Update
Checklist
Screenshots or Logs
Console output on page load:
[initPaymentSession standalone] Payment session created: {getCustomerSavedPaymentMethods: ƒ, updateIntent: ƒ}
[initPaymentSession standalone] Saved PMs: {...}
Console output on "Update Amount (initPaymentSession)" click:
[initPaymentSession standalone] updateIntent response: {sdkAuthorization: "...", clientSecret: "..."}
[initPaymentSession standalone] updateIntent result: {...}
Console output on "Update Amount (usePaymentSession)" click:
[usePaymentSession] updateIntent response: {sdkAuthorization: "...", clientSecret: "..."}
[usePaymentSession] updateIntent result: {...}
Files Changed
File Change
src/OrcaJs.res Added initPaymentSessionType and initPaymentSession to switchInstance
src/Context.res Added payment session context type, default, context, and provider
src/components/HyperElements.res Calls initPaymentSession and provides PaymentSessionContextProvider
src/Index.res Added usePaymentSession hook and initPaymentSession standalone function
src/Index.resi Added type signatures for new exports
Demo: server.js Added POST /update-payment endpoint
Demo: webpack.dev.js Added proxy rule for /update-payment
Demo: src/Payment.js Standalone initPaymentSession test with update button
Demo: src/CheckoutForm.js usePaymentSession hook test with update button
Demo: src/App.css Added .update-amount-btn styles