diff --git a/CHANGELOG.md b/CHANGELOG.md index 08b576efa..cc5731fd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.84.14](https://github.com/juspay/hyperswitch-web/compare/v0.84.13...v0.84.14) (2024-09-04) + + +### Bug Fixes + +* changed post message from parent window to current window ([#598](https://github.com/juspay/hyperswitch-web/issues/598)) ([46b0ef4](https://github.com/juspay/hyperswitch-web/commit/46b0ef46f7af2aa8fbd5ac59c4fa8b0903b21c03)) + ## [0.84.13](https://github.com/juspay/hyperswitch-web/compare/v0.84.12...v0.84.13) (2024-09-03) diff --git a/Hyperswitch-React-Demo-App/server.js b/Hyperswitch-React-Demo-App/server.js index 13cd945c2..514948cef 100644 --- a/Hyperswitch-React-Demo-App/server.js +++ b/Hyperswitch-React-Demo-App/server.js @@ -54,6 +54,7 @@ const paymentData = { authentication_type: "three_ds", customer_id: "hyperswitch_sdk_demo_id", email: "hyperswitch_sdk_demo_id@gmail.com", + request_external_three_ds_authentication: false, description: "Hello this is description", shipping: { address: { @@ -97,7 +98,7 @@ const paymentData = { } const profileId = process.env.PROFILE_ID; -if(profileId) { +if (profileId) { paymentData.profile_id = profileId; } diff --git a/package-lock.json b/package-lock.json index cb606634b..93cfa4bd5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "orca-payment-page", - "version": "0.84.13", + "version": "0.84.14", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "orca-payment-page", - "version": "0.84.13", + "version": "0.84.14", "hasInstallScript": true, "dependencies": { "@glennsl/rescript-fetch": "^0.2.0", diff --git a/package.json b/package.json index 471f1ce7e..257382a6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orca-payment-page", - "version": "0.84.13", + "version": "0.84.14", "main": "index.js", "private": true, "dependencies": { diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index deb9d3fa6..572300a53 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -1,8 +1,6 @@ @val external document: 'a = "document" -type window -type parent -@val external window: window = "window" -@val @scope("window") external iframeParent: parent = "parent" +@val external window: Dom.element = "window" +@val @scope("window") external iframeParent: Dom.element = "parent" type event = {data: string} external dictToObj: Dict.t<'a> => {..} = "%identity" @@ -15,12 +13,17 @@ type dateTimeFormat = {resolvedOptions: unit => options} @send external remove: Dom.element => unit = "remove" -@send external postMessage: (parent, JSON.t, string) => unit = "postMessage" +@send external postMessage: (Dom.element, JSON.t, string) => unit = "postMessage" + open ErrorUtils let messageParentWindow = (~targetOrigin="*", messageArr) => { iframeParent->postMessage(messageArr->Dict.fromArray->JSON.Encode.object, targetOrigin) } +let messageCurrentWindow = (~targetOrigin="*", messageArr) => { + window->postMessage(messageArr->Dict.fromArray->JSON.Encode.object, targetOrigin) +} + let handleOnFocusPostMessage = (~targetOrigin="*") => { messageParentWindow([("focus", true->JSON.Encode.bool)], ~targetOrigin) } diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 96bb201cd..691372db5 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -612,7 +612,7 @@ let make = ( } switch eventDataObject->getOptionalJsonFromJson("poll_status") { | Some(val) => { - messageParentWindow([ + messageCurrentWindow([ ("fullscreen", true->JSON.Encode.bool), ("param", "paymentloader"->JSON.Encode.string), ("iframeId", selectorString->JSON.Encode.string), @@ -650,7 +650,7 @@ let make = ( ) resolve(JSON.Encode.null) } else { - messageParentWindow([ + messageCurrentWindow([ ("fullscreen", false->JSON.Encode.bool), ("submitSuccessful", true->JSON.Encode.bool), ("data", json), @@ -662,7 +662,7 @@ let make = ( if redirect.contents === "always" { Window.Location.replace(url) } - messageParentWindow([ + messageCurrentWindow([ ("submitSuccessful", false->JSON.Encode.bool), ("error", err->Identity.anyTypeToJson), ]) @@ -679,7 +679,7 @@ let make = ( switch eventDataObject->getOptionalJsonFromJson("openurl_if_required") { | Some(val) => - messageParentWindow([ + messageCurrentWindow([ ("fullscreen", true->JSON.Encode.bool), ("param", "paymentloader"->JSON.Encode.string), ("iframeId", selectorString->JSON.Encode.string), @@ -696,17 +696,17 @@ let make = ( ~isForceSync=true, ) ->then(json => { - messageParentWindow([("submitSuccessful", true->JSON.Encode.bool), ("data", json)]) + messageCurrentWindow([("submitSuccessful", true->JSON.Encode.bool), ("data", json)]) resolve(json) }) ->catch(err => { - messageParentWindow([ + messageCurrentWindow([ ("submitSuccessful", false->JSON.Encode.bool), ("error", err->Identity.anyTypeToJson), ]) resolve(err->Identity.anyTypeToJson) }) - ->finally(_ => messageParentWindow([("fullscreen", false->JSON.Encode.bool)])) + ->finally(_ => messageCurrentWindow([("fullscreen", false->JSON.Encode.bool)])) }->ignore | None => ()