feat: add Redsys 3DS invoke_hidden_iframe flow via native module bridge#458
Open
ArushKapoorJuspay wants to merge 3 commits into
Open
feat: add Redsys 3DS invoke_hidden_iframe flow via native module bridge#458ArushKapoorJuspay wants to merge 3 commits into
ArushKapoorJuspay wants to merge 3 commits into
Conversation
- Replace @set 'style.cssText' (compiles to bracket notation) with setAttribute('style', ...) for proper DOM styling - Track iframe load count to prevent premature 'Y' completion on initial blank iframe attachment (2nd load = form POST response)
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.
Summary
Add support for the
invoke_hidden_iframenext action type returned by the Hyperswitch backend for Redsys 3DS authentication. This flow was previously silently failing on mobile — falling through to the wildcard_case inAllPaymentHooks.res, which calledhandleDefaultPaymentFlowswith an empty redirect URL.The implementation follows the native module bridge pattern (same architecture as
Netcetera3dsModule.res), with a DOM-based web fallback for React Native Web.Motivation
invoke_hidden_iframefor 3DS method callsnext_action.type: "invoke_hidden_iframe"withiframe_datacontainingthree_ds_method_url,three_ds_method_data, andmethod_keyPOST /payments/{id}/complete_authorizewiththreeds_method_comp_ind_wildcard inhandleApiRes, hittinghandleDefaultPaymentFlowswhich tried a browser redirect with an empty URLImplementation Details
Architecture: Native Module Bridge + Web Fallback
Two alternative approaches were prototyped and reviewed:
Files Changed (5 files, 318 insertions)
src/components/modules/ThreeDsMethodModule.res(NEW, 117 lines)@juspay-tech/react-native-hyperswitch-3ds-method— callsperformThreeDsMethodPost(url, data, methodKey, timeoutMs)on iOS (WKWebView) / Android (WebView)"N"immediately (3DS proceeds without method completion — still valid per spec)ReactNative.Platform.os == #web): Creates a hidden container div + iframe + form, performs POST, listens for 2nd load event (1st is blank iframe attach), 10s timeout → "N"setAttribute(el, "style", ...)instead of@set external setStyleCssTextwhich compiles to broken bracket notation (elem["style.cssText"])src/hooks/Redsys3dsHooks.res(NEW, 145 lines)useRedsys3dsFlowhook: Orchestrates the full Redsys 3DS flowclientSecret(split on_secret_)ThreeDsMethodModule.performThreeDsMethod(native or web)POST /payments/{id}/complete_authorizewiththreeds_method_comp_ind("Y" or "N")succeeded/processing→ success,requires_customer_action→ browser redirect, else → errorTHREE_DS_METHOD_CALL(start),COMPLETE_AUTHORIZE_CALL_INIT+COMPLETE_AUTHORIZE_CALL(API call)src/hooks/AllPaymentHooks.res(+30 lines)"invoke_hidden_iframe"case tohandleApiResswitch (previously fell through to_wildcard)iframeDatafromnextAction, delegates touseRedsys3dsFlowuseBrowserHookinterfacesrc/types/AllApiDataTypes/PaymentConfirmTypes.res(+25 lines)iframeDatarecord type:{threeDsMethodUrl, threeDsMethodData, methodKey}getNextActionnow extractsiframe_datafromnext_actiondictmethodKey: "threeDSMethodData"(matches web SDK reference)src/types/LoggerTypes.res(+6 lines)THREE_DS_METHOD_CALL,COMPLETE_AUTHORIZE_CALL_INIT,COMPLETE_AUTHORIZE_CALLevent typesCOMPLETE_AUTHORIZE_CALLtogetApiInitEventmapping3DS Method Flow
Testing
npm run re:checkwith-warn-error +a-4-9)@juspay-tech/react-native-hyperswitch-3ds-methodmodule (not yet implemented — gracefully returns "N")