Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: HS-166: New Elements fle without PreMountLoader #29

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/LoaderController.res
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger) => {
let sdkSessionId = dict->getString("sdkSessionId", "no-element")
logger.setSessionId(sdkSessionId)
if Window.isInteg {
setBlockConfirm(._ => dict->getBool("AOrcaBBlockPConfirm", false))
setSwitchToCustomPod(._ => dict->getBool("switchToCustomPodABP", false))
setBlockConfirm(._ => dict->getBool("blockConfirm", false))
setSwitchToCustomPod(._ => dict->getBool("switchToCustomPod", false))
}
updateOptions(dict)
setSessionId(._ => {
Expand Down
36 changes: 30 additions & 6 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type trustPayFunctions = {
let make = (
options,
setIframeRef,
~clientSecret,
~sdkSessionId,
~publishableKey,
~logger: option<OrcaLogger.loggerMake>,
Expand All @@ -30,7 +31,6 @@ let make = (
let logger = logger->Belt.Option.getWithDefault(OrcaLogger.defaultLoggerConfig)
let savedPaymentElement = Js.Dict.empty()
let localOptions = options->Js.Json.decodeObject->Belt.Option.getWithDefault(Js.Dict.empty())
let clientSecretId = localOptions->getRequiredString("clientSecret", "", ~logger)
let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey, ())
let appearance =
localOptions
Expand All @@ -44,15 +44,30 @@ let make = (
->Belt.Option.getWithDefault([])
->Js.Json.array

let blockConfirm =
GlobalVars.isInteg &&
options
->Js.Json.decodeObject
->Belt.Option.flatMap(x => x->Js.Dict.get("blockConfirm"))
->Belt.Option.flatMap(Js.Json.decodeBoolean)
->Belt.Option.getWithDefault(false)
let switchToCustomPod =
GlobalVars.isInteg &&
options
->Js.Json.decodeObject
->Belt.Option.flatMap(x => x->Js.Dict.get("switchToCustomPod"))
->Belt.Option.flatMap(Js.Json.decodeBoolean)
->Belt.Option.getWithDefault(false)

let paymentMethodListPromise = PaymentHelpers.usePaymentMethodList(
~clientSecret=clientSecretId,
~clientSecret,
~publishableKey,
~endpoint,
~logger,
)

let sessionsPromise = PaymentHelpers.useSessions(
~clientSecret=clientSecretId,
~clientSecret,
~publishableKey,
~endpoint,
~optLogger=Some(logger),
Expand Down Expand Up @@ -110,7 +125,7 @@ let make = (
}
let fetchCustomerDetails = mountedIframeRef => {
let customerDetailsPromise = PaymentHelpers.useCustomerDetails(
~clientSecret=clientSecretId,
~clientSecret,
~publishableKey,
~endpoint,
~optLogger=Some(logger),
Expand Down Expand Up @@ -223,6 +238,9 @@ let make = (
("publishableKey", publishableKey->Js.Json.string),
("sdkSessionId", sdkSessionId->Js.Json.string),
("sdkHandleConfirmPayment", sdkHandleConfirmPayment->Js.Json.boolean),
("blockConfirm", blockConfirm->Js.Json.boolean),
("switchToCustomPod", switchToCustomPod->Js.Json.boolean),
("endpoint", endpoint->Js.Json.string),
("parentURL", "*"->Js.Json.string),
]->Js.Dict.fromArray

Expand All @@ -237,7 +255,13 @@ let make = (
let msg = [("applePayCanMakePayments", true->Js.Json.boolean)]->Js.Dict.fromArray
mountedIframeRef->Window.iframePostMessage(msg)
} else {
Utils.logInfo(Js.log("CANNOT MAKE PAYMENT USING APPLE PAY"))
logger.setLogInfo(
~value="CANNOT MAKE PAYMENT USING APPLE PAY",
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
~logType=ERROR,
(),
)
}

| None => ()
Expand Down Expand Up @@ -327,7 +351,7 @@ let make = (

addSmartEventListener("message", handleApplePayMounted, "onApplePayMount")
addSmartEventListener("message", handleGooglePayThirdPartyFlow, "onGooglePayThirdParty")
Window.removeEventListener("message", handleApplePayMessages.contents)

sessionsPromise
->then(json => {
let sessionsArr =
Expand Down
1 change: 1 addition & 0 deletions src/orca-loader/Hyper.res
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ let make = (publishableKey, options: option<Js.Json.t>, analyticsInfo: option<Js
setIframeRef,
~sdkSessionId=sessionID,
~publishableKey,
~clientSecret={clientSecretId},
~logger=Some(logger),
)
}
Expand Down