Skip to content

Commit

Permalink
Merge branch 'main' into pagobancomat-regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanskar2001 authored Sep 4, 2024
2 parents 6dea520 + fa06e12 commit bda6bd2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
3 changes: 2 additions & 1 deletion Hyperswitch-React-Demo-App/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const paymentData = {
authentication_type: "three_ds",
customer_id: "hyperswitch_sdk_demo_id",
email: "[email protected]",
request_external_three_ds_authentication: false,
description: "Hello this is description",
shipping: {
address: {
Expand Down Expand Up @@ -97,7 +98,7 @@ const paymentData = {
}

const profileId = process.env.PROFILE_ID;
if(profileId) {
if (profileId) {
paymentData.profile_id = profileId;
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orca-payment-page",
"version": "0.84.13",
"version": "0.84.14",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
13 changes: 8 additions & 5 deletions src/Utilities/Utils.res
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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)
}
Expand Down
14 changes: 7 additions & 7 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand All @@ -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),
])
Expand All @@ -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),
Expand All @@ -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 => ()
Expand Down

0 comments on commit bda6bd2

Please sign in to comment.