Skip to content

fix: sdk authorization dependency across all the flows#1576

Merged
ArushKapoorJuspay merged 2 commits into
mainfrom
fix/sdk-auth-dep
May 19, 2026
Merged

fix: sdk authorization dependency across all the flows#1576
ArushKapoorJuspay merged 2 commits into
mainfrom
fix/sdk-auth-dep

Conversation

@sakksham7

Copy link
Copy Markdown
Contributor

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

#1575
After an updateIntent flow completes, the SDK returns a new sdkAuthorization. All subsequent confirm calls must use this updated token. Inside the iframe, usePaymentIntent reads sdkAuthorization from the Recoil keys atom at render time and closes over it in the returned intent function. Each payment method component memoizes its submitCallback via React.useCallback — if sdkAuthorization is not in the dependency array, the callback captures a stale intent with the old token even after the Recoil atom is updated.

Root cause: sdkAuthorization was missing from the useCallback dependency array in all payment method submitCallback hooks. This caused the confirm API call to be made with the pre-updateIntent authorization token, resulting in an auth failure.

Fix: Added sdkAuthorization (from the keys Recoil atom) to the useCallback dependency array in all affected payment method components. For components that did not already destructure sdkAuthorization from keys, the destructuring was updated accordingly.

How did you test it?

Tested manually using the Hyperswitch React Demo App:

  1. Loaded the payment form with EPS selected (required fields pre-filled, no user input needed)
  2. Clicked "update use elements + confirm" — which calls elements.updateIntent(...) then hyper.confirmPayment(...)
  3. Before fix: confirm API call used the old sdkAuthorization, resulting in an auth error
  4. After fix: confirm API call correctly used the new sdkAuthorization returned by updateIntent, payment proceeded successfully
    Also verified the same flow with Trustly (no required fields) and other bank redirect / bank debit / bank transfer payment methods continued to work correctly.
Screen.Recording.2026-05-19.at.10.47.06.PM.mov

Checklist

  • I ran npm run re:build
  • I reviewed submitted code
  • I added unit tests for my changes where possible

@semanticdiff-com

Copy link
Copy Markdown

Review changes with  SemanticDiff

@sakksham7 sakksham7 linked an issue May 19, 2026 that may be closed by this pull request
@sakksham7 sakksham7 changed the title fix: sdk authorization dependency across all teh files fix: sdk authorization dependency across all the flows May 19, 2026
@ArushKapoorJuspay ArushKapoorJuspay merged commit 307a8ac into main May 19, 2026
9 of 10 checks passed
@ArushKapoorJuspay ArushKapoorJuspay deleted the fix/sdk-auth-dep branch May 19, 2026 18:23
@github-actions github-actions Bot added the Closed Label will be automatically added when the PR will get merged to main label May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Closed Label will be automatically added when the PR will get merged to main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update sdkAuth dependency

3 participants