From 52c14ff0ad9760e35f111361c12dc29b856db851 Mon Sep 17 00:00:00 2001 From: Arush Date: Wed, 3 Jul 2024 16:30:27 +0530 Subject: [PATCH] fix: fixed netcetra 3ds not opening and added fallback log --- src/ThreeDSMethod.res | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/ThreeDSMethod.res b/src/ThreeDSMethod.res index 1c16cc447..6edf11412 100644 --- a/src/ThreeDSMethod.res +++ b/src/ThreeDSMethod.res @@ -12,19 +12,21 @@ let make = () => { stateMetadata->Utils.getDictFromJson->Dict.set("3dsMethodComp", "Y"->JSON.Encode.string) let metadataDict = stateMetadata->JSON.Decode.object->Option.getOr(Dict.make()) let iframeId = metadataDict->getString("iframeId", "") - LoggerUtils.handleLogging( - ~optLogger=Some(logger), - ~eventName=THREE_DS_METHOD_RESULT, - ~value="Y", - ~paymentMethod="CARD", - (), - ) - handlePostMessage([ - ("fullscreen", true->JSON.Encode.bool), - ("param", `3dsAuth`->JSON.Encode.string), - ("iframeId", iframeId->JSON.Encode.string), - ("metadata", stateMetadata), - ]) + if iframeId->String.length > 0 { + LoggerUtils.handleLogging( + ~optLogger=Some(logger), + ~eventName=THREE_DS_METHOD_RESULT, + ~value="Y", + ~paymentMethod="CARD", + (), + ) + handlePostMessage([ + ("fullscreen", true->JSON.Encode.bool), + ("param", `3dsAuth`->JSON.Encode.string), + ("iframeId", iframeId->JSON.Encode.string), + ("metadata", stateMetadata), + ]) + } } observer.current = Some( @@ -42,6 +44,17 @@ let make = () => { | _ => () } + let handleOnLoad = _ => { + setTimeout(() => { + logger.setLogError( + ~value="ThreeDS Method Opened for more than 20 seconds", + ~eventName=THREE_DS_METHOD_RESULT, + ~logType=DEBUG, + (), + ) + }, 20000)->ignore + } + React.useEffect0(() => { handlePostMessage([("iframeMountedCallback", true->JSON.Encode.bool)]) let handle = (ev: Window.event) => { @@ -130,6 +143,7 @@ let make = () => { name="threeDsInvisibleIframe" className="h-96 invisible" ref={divRef->ReactDOM.Ref.domRef} + onLoad={handleOnLoad} /> }