diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 802770da..f1967e0c 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -296,36 +296,38 @@ let make = ( ("loader", loader), ("fonts", fonts), ]->getJsonFromArrayOfJson - let message = - [ - ( - "paymentElementCreate", - componentType->getIsComponentTypeForPaymentElementCreate->JSON.Encode.bool, - ), - ("otherElements", otherElements->JSON.Encode.bool), - ("options", newOptions), - ("componentType", componentType->JSON.Encode.string), - ("paymentOptions", widgetOptions), - ("iframeId", selectorString->JSON.Encode.string), - ("publishableKey", publishableKey->JSON.Encode.string), - ("endpoint", endpoint->JSON.Encode.string), - ("sdkSessionId", sdkSessionId->JSON.Encode.string), - ("blockConfirm", blockConfirm->JSON.Encode.bool), - ("customPodUri", customPodUri->JSON.Encode.string), - ("sdkHandleOneClickConfirmPayment", sdkHandleOneClickConfirmPayment->JSON.Encode.bool), - ("parentURL", "*"->JSON.Encode.string), - ("analyticsMetadata", analyticsMetadata), - ("launchTime", launchTime->JSON.Encode.float), - ("customBackendUrl", customBackendUrl->JSON.Encode.string), - ( - "onCompleteDoThisUsed", - LoaderPaymentElement.onCompleteDoThisUsed.contents->JSON.Encode.bool, - ), - ( - "onSDKHandleClickIsUsed", - LoaderPaymentElement.onSDKHandleClickIsUsed.contents->JSON.Encode.bool, - ), - ]->Dict.fromArray + let message = [ + ( + "paymentElementCreate", + componentType->getIsComponentTypeForPaymentElementCreate->JSON.Encode.bool, + ), + ("otherElements", otherElements->JSON.Encode.bool), + ("options", newOptions), + ("componentType", componentType->JSON.Encode.string), + ("paymentOptions", widgetOptions), + ("iframeId", selectorString->JSON.Encode.string), + ("publishableKey", publishableKey->JSON.Encode.string), + ("endpoint", endpoint->JSON.Encode.string), + ("sdkSessionId", sdkSessionId->JSON.Encode.string), + ("blockConfirm", blockConfirm->JSON.Encode.bool), + ("customPodUri", customPodUri->JSON.Encode.string), + ("sdkHandleOneClickConfirmPayment", sdkHandleOneClickConfirmPayment->JSON.Encode.bool), + ("parentURL", "*"->JSON.Encode.string), + ("analyticsMetadata", analyticsMetadata), + ("launchTime", launchTime->JSON.Encode.float), + ("customBackendUrl", customBackendUrl->JSON.Encode.string), + ( + "onSDKHandleClickIsUsed", + LoaderPaymentElement.onSDKHandleClickIsUsed.contents->JSON.Encode.bool, + ), + ( + "onCompleteDoThisUsed", + EventListenerManager.eventListenerMap + ->Dict.get("onCompleteDoThis") + ->Option.isSome + ->JSON.Encode.bool, + ), + ]->Dict.fromArray let wallets = PaymentType.getWallets(newOptions->getDictFromJson, "wallets", logger) diff --git a/src/orca-loader/LoaderPaymentElement.res b/src/orca-loader/LoaderPaymentElement.res index 30462085..1ba66645 100644 --- a/src/orca-loader/LoaderPaymentElement.res +++ b/src/orca-loader/LoaderPaymentElement.res @@ -35,8 +35,10 @@ let make = ( ) let asyncWrapper = async fn => { + Console.log("Trying to execute OUTER>>>>>>>>>>>>>>>>!!!!!!!!!!!!!") try { await fn() + Console.log("Trying to execute!!!!!!!!!!!!!") } catch { | err => Console.log2("Async function call failure", err) } @@ -52,15 +54,19 @@ let make = ( let dict = json->getDictFromJson if dict->Dict.get("oneClickConfirmTriggered")->Option.isSome { + Console.log("1 Click msg recieved from iframe") switch currEventHandler.contents { - | Some(eH) => - asyncWrapper(eH) - ->Promise.then(() => { - let msg = [("walletClickEvent", true->JSON.Encode.bool)]->Dict.fromArray - event.source->Window.sendPostMessage(msg) - Promise.resolve() - }) - ->ignore + | Some(eH) => { + Console.log("SOME EVENT=-------------") + asyncWrapper(eH) + ->Promise.then(() => { + Console.log("SENDING MSG BACK TO IFRAME") + let msg = [("walletClickEvent", true->JSON.Encode.bool)]->Dict.fromArray + event.source->Window.sendPostMessage(msg) + Promise.resolve() + }) + ->ignore + } | None => () } @@ -70,6 +76,7 @@ let make = ( Window.addEventListener("message", walletOneClickEventHandler) let onSDKHandleClick = (eventHandler: option RescriptCore.Promise.t<'a>>) => { + Console.log("FLOW XXXXXXXXXXXXXXXX") currEventHandler := eventHandler onSDKHandleClickIsUsed := true } @@ -89,15 +96,13 @@ let make = ( }, "onEscape", ) - | CompleteDoThis => { - onCompleteDoThisUsed := true - eventHandlerFunc( - ev => ev.data.completeDoThis, - eventHandler, - CompleteDoThis, - "onCompleteDoThis", - ) - } + | CompleteDoThis => + eventHandlerFunc( + ev => ev.data.completeDoThis, + eventHandler, + CompleteDoThis, + "onCompleteDoThis", + ) | Change => eventHandlerFunc( ev => ev.data.elementType === componentType,