Skip to content

Commit

Permalink
Merge branch 'main' into feat/unsupported_card_networks
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja authored May 15, 2024
2 parents 484bb21 + 7a759a0 commit ef3f7db
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 16 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## [0.52.1](https://github.com/juspay/hyperswitch-web/compare/v0.52.0...v0.52.1) (2024-05-14)


### Bug Fixes

* do not unmount preMountLoader iframe ([#367](https://github.com/juspay/hyperswitch-web/issues/367)) ([ba47e5f](https://github.com/juspay/hyperswitch-web/commit/ba47e5f4faece8be2ec5a374bafd266da7d591e4))

# [0.52.0](https://github.com/juspay/hyperswitch-web/compare/v0.51.1...v0.52.0) (2024-05-14)


### Features

* added content length ([#366](https://github.com/juspay/hyperswitch-web/issues/366)) ([2a1b42a](https://github.com/juspay/hyperswitch-web/commit/2a1b42ad2e62b6cd5461345516e5d0ddcaa0abeb))

## [0.51.1](https://github.com/juspay/hyperswitch-web/compare/v0.51.0...v0.51.1) (2024-05-14)


### Bug Fixes

* added display_voucher_information again ([#369](https://github.com/juspay/hyperswitch-web/issues/369)) ([91978a9](https://github.com/juspay/hyperswitch-web/commit/91978a9db150ea3f1ce4518fcbace4142ef28343))

# [0.51.0](https://github.com/juspay/hyperswitch-web/compare/v0.50.14...v0.51.0) (2024-05-10)


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.51.0",
"version": "0.52.1",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion src/Payments/PreMountLoader.res
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ let make = (~sessionId, ~publishableKey, ~clientSecret, ~endpoint) => {
if (
paymentMethodsResponseSent && customerPaymentMethodsResponseSent && sessionTokensResponseSent
) {
handlePostMessage([("preMountLoaderIframeUnMount", true->JSON.Encode.bool)])
Window.removeEventListener("message", handle)
}
None
Expand Down
41 changes: 38 additions & 3 deletions src/Utilities/PaymentHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,40 @@ let rec intentCall = (
("metadata", metaData->JSON.Encode.object),
])
}
} else if intent.nextAction.type_ === "display_voucher_information" {
let voucherData = intent.nextAction.voucher_details->Option.getOr({
download_url: "",
reference: "",
})
let headerObj = Dict.make()
headers->Array.forEach(
entries => {
let (x, val) = entries
Dict.set(headerObj, x, val->JSON.Encode.string)
},
)
let metaData =
[
("voucherUrl", voucherData.download_url->JSON.Encode.string),
("reference", voucherData.reference->JSON.Encode.string),
("returnUrl", url.href->JSON.Encode.string),
("paymentMethod", paymentMethod->JSON.Encode.string),
("payment_intent_data", data),
]->Dict.fromArray
handleLogging(
~optLogger,
~value="",
~internalMetadata=metaData->JSON.Encode.object->JSON.stringify,
~eventName=DISPLAY_VOUCHER,
~paymentMethod,
(),
)
handlePostMessage([
("fullscreen", true->JSON.Encode.bool),
("param", `voucherData`->JSON.Encode.string),
("iframeId", iframeId->JSON.Encode.string),
("metadata", metaData->JSON.Encode.object),
])
} else if intent.nextAction.type_ == "third_party_sdk_session_token" {
let session_token = switch intent.nextAction.session_token {
| Some(token) => token->getDictFromJson
Expand Down Expand Up @@ -948,6 +982,7 @@ let usePaymentIntent = (optLogger, paymentType) => {
let uri = `${endpoint}/payments/${paymentIntentID}/confirm`

let callIntent = body => {
let contentLength = body->String.length->Int.toString
let maskedPayload =
body->safeParseOpt->Option.getOr(JSON.Encode.null)->maskPayload->JSON.stringify
let loggerPayload =
Expand All @@ -972,17 +1007,17 @@ let usePaymentIntent = (optLogger, paymentType) => {
handleLogging(
~optLogger,
~internalMetadata=loggerPayload,
~value="",
~value=contentLength,
~eventName=PAYMENT_ATTEMPT,
~paymentMethod="CARD",
(),
)
| _ =>
let _ = bodyArr->Array.map(((str, json)) => {
bodyArr->Array.forEach(((str, json)) => {
if str === "payment_method_type" {
handleLogging(
~optLogger,
~value="",
~value=contentLength,
~internalMetadata=loggerPayload,
~eventName=PAYMENT_ATTEMPT,
~paymentMethod=json->getStringFromJson(""),
Expand Down
9 changes: 0 additions & 9 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,12 @@ let make = (

let preMountLoaderIframeDiv = mountPreMountLoaderIframe()

let unMountPreMountLoaderIframe = () => {
switch preMountLoaderIframeDiv->Nullable.toOption {
| Some(iframe) => iframe->remove
| None => ()
}
}

let preMountLoaderMountedPromise = Promise.make((resolve, _reject) => {
let preMountLoaderIframeCallback = (ev: Types.event) => {
let json = ev.data->Identity.anyTypeToJson
let dict = json->Utils.getDictFromJson
if dict->Dict.get("preMountLoaderIframeMountedCallback")->Option.isSome {
resolve(true->JSON.Encode.bool)
} else if dict->Dict.get("preMountLoaderIframeUnMount")->Option.isSome {
unMountPreMountLoaderIframe()
}
}
addSmartEventListener(
Expand Down

0 comments on commit ef3f7db

Please sign in to comment.