Skip to content

Commit

Permalink
fix: added support for customPodUri instead of switchToCustomPod (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArushKapoorJuspay authored Aug 30, 2024
1 parent e32f47e commit f9fed51
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 112 deletions.
2 changes: 2 additions & 0 deletions src/App.res
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ let make = () => {
"hyperComponentName",
)->Types.getHyperComponentNameFromStr
let merchantHostname = CardUtils.getQueryParamsDictforKey(url.search, "merchantHostname")
let customPodUri = CardUtils.getQueryParamsDictforKey(url.search, "customPodUri")

<PreMountLoader
publishableKey
Expand All @@ -54,6 +55,7 @@ let make = () => {
ephemeralKey
hyperComponentName
merchantHostname
customPodUri
/>
}
| "achBankTransfer"
Expand Down
4 changes: 2 additions & 2 deletions src/Components/SavedPaymentManagement.res
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let make = (~savedMethods: array<PaymentType.customerMethods>, ~setSavedMethods)

let {iframeId} = Recoil.useRecoilValueFromAtom(RecoilAtoms.keys)
let {config} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom)
let switchToCustomPod = Recoil.useRecoilValueFromAtom(RecoilAtoms.switchToCustomPod)
let customPodUri = Recoil.useRecoilValueFromAtom(RecoilAtoms.customPodUri)
let logger = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)

let removeSavedMethod = (
Expand All @@ -28,7 +28,7 @@ let make = (~savedMethods: array<PaymentType.customerMethods>, ~setSavedMethods)
~ephemeralKey=config.ephemeralKey,
~paymentMethodId=paymentItem.paymentMethodId,
~logger,
~switchToCustomPod,
~customPodUri,
)
->then(res => {
let dict = res->getDictFromJson
Expand Down
4 changes: 2 additions & 2 deletions src/LoaderController.res
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
let (optionsPayment, setOptionsPayment) = Recoil.useRecoilState(optionAtom)
let setSessionId = Recoil.useSetRecoilState(sessionId)
let setBlockConfirm = Recoil.useSetRecoilState(isConfirmBlocked)
let setSwitchToCustomPod = Recoil.useSetRecoilState(switchToCustomPod)
let setCustomPodUri = Recoil.useSetRecoilState(customPodUri)
let setIsGooglePayReady = Recoil.useSetRecoilState(isGooglePayReady)
let setIsApplePayReady = Recoil.useSetRecoilState(isApplePayReady)
let (divH, setDivH) = React.useState(_ => 0.0)
Expand Down Expand Up @@ -231,8 +231,8 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
logger.setSessionId(sdkSessionId)
if Window.isInteg {
setBlockConfirm(_ => dict->getBool("blockConfirm", false))
setSwitchToCustomPod(_ => dict->getBool("switchToCustomPod", false))
}
setCustomPodUri(_ => dict->getString("customPodUri", ""))
updateOptions(dict)
setSessionId(_ => {
sdkSessionId
Expand Down
13 changes: 9 additions & 4 deletions src/PaymentMethodCollectElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ let make = (~integrateError, ~logger) => {
~clientSecret=keys.clientSecret->Option.getOr(""),
~publishableKey=keys.publishableKey,
~logger,
~switchToCustomPod=false,
~customPodUri="",
~uri,
~body=pmdBody,
)
Expand Down Expand Up @@ -171,7 +171,7 @@ let make = (~integrateError, ~logger) => {
~clientSecret=keys.clientSecret->Option.getOr(""),
~publishableKey=keys.publishableKey,
~logger,
~switchToCustomPod=false,
~customPodUri="",
~endpoint=ApiEndpoint.getApiEndPoint(),
~body=pmdBody,
)
Expand Down Expand Up @@ -296,8 +296,13 @@ let make = (~integrateError, ~logger) => {
className="font-bold text-5xl mt-5 lg:mt-0 lg:text-3xl flex justify-center items-center">
<p> {React.string(`${options.currency} ${options.amount}`)} </p>
</div>
<div className="flex items-center justify-center h-12 w-auto bg-white rounded-sm">
<img className="max-h-12 w-auto max-w-21 h-auto w-auto" src={merchantLogo} alt="O" />
<div
className="flex items-center justify-center h-12 w-auto bg-white rounded-sm">
<img
className="max-h-12 w-auto max-w-21 h-auto w-auto"
src={merchantLogo}
alt="O"
/>
</div>
</div>
<div className="lg:mx-5">
Expand Down
2 changes: 1 addition & 1 deletion src/Payments/PlaidSDKIframe.res
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ let make = () => {
clientSecret,
headers,
~optLogger=Some(logger),
~switchToCustomPod=false,
~customPodUri="",
~isForceSync=true,
)
->then(json => {
Expand Down
9 changes: 5 additions & 4 deletions src/Payments/PreMountLoader.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let make = (
~ephemeralKey,
~hyperComponentName: Types.hyperComponentName,
~merchantHostname,
~customPodUri,
) => {
open Utils
let (paymentMethodsResponseSent, setPaymentMethodsResponseSent) = React.useState(_ => false)
Expand Down Expand Up @@ -37,7 +38,7 @@ let make = (
~clientSecret,
~publishableKey,
~logger,
~switchToCustomPod=false,
~customPodUri,
~endpoint,
)
| _ => JSON.Encode.null->Promise.resolve
Expand All @@ -49,7 +50,7 @@ let make = (
~clientSecret,
~publishableKey,
~optLogger=Some(logger),
~switchToCustomPod=false,
~customPodUri,
~endpoint,
)
| _ => JSON.Encode.null->Promise.resolve
Expand All @@ -61,7 +62,7 @@ let make = (
~clientSecret,
~publishableKey,
~optLogger=Some(logger),
~switchToCustomPod=false,
~customPodUri,
~endpoint,
~merchantHostname,
)
Expand All @@ -73,7 +74,7 @@ let make = (
PaymentHelpers.fetchSavedPaymentMethodList(
~ephemeralKey,
~optLogger=Some(logger),
~switchToCustomPod=false,
~customPodUri,
~endpoint,
)
| _ => JSON.Encode.null->Promise.resolve
Expand Down
6 changes: 3 additions & 3 deletions src/Payments/QRCodeDisplay.res
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let make = () => {
let (clientSecret, setClientSecret) = React.useState(_ => "")
let (headers, setHeaders) = React.useState(_ => [])
let logger = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)
let switchToCustomPod = Recoil.useRecoilValueFromAtom(RecoilAtoms.switchToCustomPod)
let customPodUri = Recoil.useRecoilValueFromAtom(RecoilAtoms.customPodUri)

React.useEffect0(() => {
messageParentWindow([("iframeMountedCallback", true->JSON.Encode.bool)])
Expand Down Expand Up @@ -55,7 +55,7 @@ let make = () => {
paymentIntentId,
headers->Dict.toArray,
~optLogger=Some(logger),
~switchToCustomPod,
~customPodUri,
)
->then(res => {
Modal.close(setOpenModal)
Expand Down Expand Up @@ -88,7 +88,7 @@ let make = () => {
clientSecret,
headers,
~optLogger=Some(logger),
~switchToCustomPod,
~customPodUri,
)
->then(json => {
let dict = json->getDictFromJson
Expand Down
15 changes: 6 additions & 9 deletions src/Utilities/ApiEndpoint.res
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ let getApiEndPoint = (~publishableKey="", ~isConfirmCall=false) => {
}
}

let addCustomPodHeader = (arr: array<(string, string)>, ~switchToCustomPod=?) => {
let customPod = switch switchToCustomPod {
| Some(val) => val
| None => false
}
if customPod {
arr->Array.concat([("x-feature", "router-custom-dbd")])->Dict.fromArray
} else {
arr->Dict.fromArray
let addCustomPodHeader = (arr: array<(string, string)>, ~customPodUri=?) => {
switch customPodUri {
| Some("")
| None => ()
| Some(customPodVal) => arr->Array.push(("x-feature", customPodVal))
}
arr->Dict.fromArray
}
Loading

0 comments on commit f9fed51

Please sign in to comment.