feat: add confirmPayment on paymentElement - #16
Conversation
| }, | ||
| [hyperSwitch], | ||
| ) | ||
|
|
There was a problem hiding this comment.
The imperative handle is installed on the first commit, while switchContext is still defaultSwitchContext. Calling ref.current.confirmPayment() before the Hyper promise/element is ready therefore resolves {} and performs no request. Should we gate this on real element readiness (or reject with a stable sdk_not_ready error) instead of exposing the default no-op implementation?
There was a problem hiding this comment.
The handle isn't frozen on mount — useImperativeHandle1 re-runs whenever hyperSwitch changes (the [hyperSwitch] dep array), so once the SDK context resolves the ref updates automatically.
That said, you're right that there's a window where calling ref.current.confirmPayment() too early would silently no-op using defaultSwitchContext. We could address this by checking ready event which is fired in almost every widget.

| onReady=props["onReady"] | ||
| onFocus=props["onFocus"] | ||
| onBlur=props["onBlur"] | ||
| onClick=props["onClick"] |
There was a problem hiding this comment.
why these changes were needed?
There was a problem hiding this comment.
The change from @react.component let make = (~id, ...) to React.forwardRef((props, ref_) => ...) was required to support ref-forwarding.
Also, the peer dependency is "react": "^17.0.0 || ^18.0.0 || ^19.0.0". This is a library, and its consumers may be on React 17 or 18. Dropping forwardRef in favor of React 19's ref-as-prop would silently break for those consumers.
Type of Change
Description
Adds support for the Elements embedded UI integration pattern .
Impact on existing functionality:
hyper.confirmPayment()is unchanged — existing integrations continue to work.elements.create('payment', options)— old two-arg JS call sites will still receive a function and the second arg is silently ignored; no runtime break.New Integration Steps:
React
Js
How did you test it?
case 1: js old integration
Screen.Recording.2026-07-20.at.4.15.36.pm.mov
case 2: js new integration
Screen.Recording.2026-07-20.at.4.18.27.pm.mov
case 3: react old integration
Screen.Recording.2026-07-20.at.4.20.01.pm.mov
case 4: react new integration
Screen.Recording.2026-07-20.at.4.21.55.pm.mov
Version Update
package.jsonfollowing semantic versioning:x.x.xfor major changes (breaking).x.x.xfor minor changes (new feature, no breaking changes).x.x.xfor patch changes (bug fixes, minor improvements).Checklist
npm run re:buildand verified the build artifacts.