Skip to content

fix: mising required params error due to race in mounting superposition configs - #552

Merged
sh-iv-am merged 4 commits into
v1.9.0-patchfrom
v1.9.1-patch
Aug 19, 2026
Merged

fix: mising required params error due to race in mounting superposition configs#552
sh-iv-am merged 4 commits into
v1.9.0-patchfrom
v1.9.1-patch

Conversation

@Shivam25092001

@Shivam25092001 Shivam25092001 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Type of Change

  • Bugfix
  • Feature
  • Refactor
  • Chore
  • CI/CD
  • Docs

What & Why

A. Fixes /confirm failing with IR_04 "Missing required param: payment_method_data"

  • Fixes /confirm failing with IR_04 "Missing required param: payment_method_data" when the card form renders empty and Pay is still tappable.

  • Root cause: The card form's fields come from the superposition configuration service, which is fetched asynchronously and stored in a module-level ref with no re-render mechanism. If fields are computed before the config loads, zero fields are returned, the card form silently renders nothing, and the Pay button — not gated on config readiness — stays active. Tapping Pay sends a confirm body with billing (prefilled from PML required_fields) but no card, causing the 400. It "works on the next open" only because the module-level ref persists across the runtime and is populated by then.

  • Fix: The config hook now exposes a completion signal (isInitialized) threaded through DynamicFieldsContext to every consumer. It:

  1. Invalidates the memoized field calculation — the signal is added to each field-computing useMemo dependency list, so fields recompute from empty → populated when the config lands.
  2. Gates submission and the Pay button — while loading, the Pay button shows a spinner and its handler is a no-op, so the initial empty calculation can never be confirmed.

B. Fixes paymentSheet drop-offs with error: "APPLE_PAY_PRESENT_FAIL_FROM_NATIVE"


Screenshots / Recordings

Screen.Recording.2026-07-29.at.3.56.24.PM.mov

Affected Area & Impact

  • Client Core
  • Shared Codebase
  • Android
  • iOS

Android PR / status (if any):
iOS PR / status (if any):
Shared Codebase PR / status (if any): juspay/hyperswitch-sdk-utils#84


Testing

  • JS bundle built
  • Tested in Android app
  • Tested in iOS app

Notes:
Reproduced by injecting latency into the config load (temporary in-code delay before service := ..., and a mock-server proxy GET /s3-proxy/<path>?delay=<ms> in mockServer.js). With a delay active, opening the Card tab and tapping Pay within the window reproduces the failure (confirm body with billing, no card, IR_04). After the fix, the Pay button stays in a loading state until the config lands, then the card form renders and payment succeeds.


Checklist

  • Tested in consuming Android app
  • Tested in consuming iOS app
  • Tested in consuming web app

@sh-iv-am
sh-iv-am merged commit 2121e95 into v1.9.0-patch Aug 19, 2026
3 of 8 checks passed
@sh-iv-am
sh-iv-am deleted the v1.9.1-patch branch August 19, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants