From f9fed5117e74c63f813117d5eceafc4a000e17dc Mon Sep 17 00:00:00 2001 From: ArushKapoorJuspay <121166031+ArushKapoorJuspay@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:25:26 +0530 Subject: [PATCH 1/2] fix: added support for customPodUri instead of switchToCustomPod (#591) --- src/App.res | 2 + src/Components/SavedPaymentManagement.res | 4 +- src/LoaderController.res | 4 +- src/PaymentMethodCollectElement.res | 13 ++- src/Payments/PlaidSDKIframe.res | 2 +- src/Payments/PreMountLoader.res | 9 +- src/Payments/QRCodeDisplay.res | 6 +- src/Utilities/ApiEndpoint.res | 15 ++- src/Utilities/PaymentHelpers.res | 95 ++++++++----------- src/Utilities/RecoilAtoms.res | 2 +- src/orca-loader/Elements.res | 21 ++-- .../PaymentMethodsManagementElements.res | 11 +-- src/orca-loader/PaymentSession.res | 13 ++- src/orca-loader/PaymentSessionMethods.res | 16 ++-- 14 files changed, 101 insertions(+), 112 deletions(-) diff --git a/src/App.res b/src/App.res index 04b239690..020d9cd9a 100644 --- a/src/App.res +++ b/src/App.res @@ -45,6 +45,7 @@ let make = () => { "hyperComponentName", )->Types.getHyperComponentNameFromStr let merchantHostname = CardUtils.getQueryParamsDictforKey(url.search, "merchantHostname") + let customPodUri = CardUtils.getQueryParamsDictforKey(url.search, "customPodUri") { ephemeralKey hyperComponentName merchantHostname + customPodUri /> } | "achBankTransfer" diff --git a/src/Components/SavedPaymentManagement.res b/src/Components/SavedPaymentManagement.res index 05fc9f16b..f492b4b24 100644 --- a/src/Components/SavedPaymentManagement.res +++ b/src/Components/SavedPaymentManagement.res @@ -5,7 +5,7 @@ let make = (~savedMethods: array, ~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 = ( @@ -28,7 +28,7 @@ let make = (~savedMethods: array, ~setSavedMethods) ~ephemeralKey=config.ephemeralKey, ~paymentMethodId=paymentItem.paymentMethodId, ~logger, - ~switchToCustomPod, + ~customPodUri, ) ->then(res => { let dict = res->getDictFromJson diff --git a/src/LoaderController.res b/src/LoaderController.res index af25ede5c..d81b6457b 100644 --- a/src/LoaderController.res +++ b/src/LoaderController.res @@ -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) @@ -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 diff --git a/src/PaymentMethodCollectElement.res b/src/PaymentMethodCollectElement.res index a71fabe41..d85977268 100644 --- a/src/PaymentMethodCollectElement.res +++ b/src/PaymentMethodCollectElement.res @@ -100,7 +100,7 @@ let make = (~integrateError, ~logger) => { ~clientSecret=keys.clientSecret->Option.getOr(""), ~publishableKey=keys.publishableKey, ~logger, - ~switchToCustomPod=false, + ~customPodUri="", ~uri, ~body=pmdBody, ) @@ -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, ) @@ -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">

{React.string(`${options.currency} ${options.amount}`)}

-
- O +
+ O
diff --git a/src/Payments/PlaidSDKIframe.res b/src/Payments/PlaidSDKIframe.res index 4e2d68cc4..e3716d663 100644 --- a/src/Payments/PlaidSDKIframe.res +++ b/src/Payments/PlaidSDKIframe.res @@ -57,7 +57,7 @@ let make = () => { clientSecret, headers, ~optLogger=Some(logger), - ~switchToCustomPod=false, + ~customPodUri="", ~isForceSync=true, ) ->then(json => { diff --git a/src/Payments/PreMountLoader.res b/src/Payments/PreMountLoader.res index 4e3abf9a7..c600b7a84 100644 --- a/src/Payments/PreMountLoader.res +++ b/src/Payments/PreMountLoader.res @@ -7,6 +7,7 @@ let make = ( ~ephemeralKey, ~hyperComponentName: Types.hyperComponentName, ~merchantHostname, + ~customPodUri, ) => { open Utils let (paymentMethodsResponseSent, setPaymentMethodsResponseSent) = React.useState(_ => false) @@ -37,7 +38,7 @@ let make = ( ~clientSecret, ~publishableKey, ~logger, - ~switchToCustomPod=false, + ~customPodUri, ~endpoint, ) | _ => JSON.Encode.null->Promise.resolve @@ -49,7 +50,7 @@ let make = ( ~clientSecret, ~publishableKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, + ~customPodUri, ~endpoint, ) | _ => JSON.Encode.null->Promise.resolve @@ -61,7 +62,7 @@ let make = ( ~clientSecret, ~publishableKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, + ~customPodUri, ~endpoint, ~merchantHostname, ) @@ -73,7 +74,7 @@ let make = ( PaymentHelpers.fetchSavedPaymentMethodList( ~ephemeralKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, + ~customPodUri, ~endpoint, ) | _ => JSON.Encode.null->Promise.resolve diff --git a/src/Payments/QRCodeDisplay.res b/src/Payments/QRCodeDisplay.res index c73727eff..7507f1f01 100644 --- a/src/Payments/QRCodeDisplay.res +++ b/src/Payments/QRCodeDisplay.res @@ -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)]) @@ -55,7 +55,7 @@ let make = () => { paymentIntentId, headers->Dict.toArray, ~optLogger=Some(logger), - ~switchToCustomPod, + ~customPodUri, ) ->then(res => { Modal.close(setOpenModal) @@ -88,7 +88,7 @@ let make = () => { clientSecret, headers, ~optLogger=Some(logger), - ~switchToCustomPod, + ~customPodUri, ) ->then(json => { let dict = json->getDictFromJson diff --git a/src/Utilities/ApiEndpoint.res b/src/Utilities/ApiEndpoint.res index d8d032be3..9e0fefd51 100644 --- a/src/Utilities/ApiEndpoint.res +++ b/src/Utilities/ApiEndpoint.res @@ -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 } diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index 36e85ad34..e0c1e47fd 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -44,7 +44,7 @@ let retrievePaymentIntent = ( clientSecret, headers, ~optLogger, - ~switchToCustomPod, + ~customPodUri, ~isForceSync=false, ) => { open Promise @@ -61,7 +61,7 @@ let retrievePaymentIntent = ( ~logType=INFO, ~logCategory=API, ) - fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod)) + fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(res => { let statusCode = res->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { @@ -170,11 +170,11 @@ let rec pollRetrievePaymentIntent = ( clientSecret, headers, ~optLogger, - ~switchToCustomPod, + ~customPodUri, ~isForceSync=false, ) => { open Promise - retrievePaymentIntent(clientSecret, headers, ~optLogger, ~switchToCustomPod, ~isForceSync) + retrievePaymentIntent(clientSecret, headers, ~optLogger, ~customPodUri, ~isForceSync) ->then(json => { let dict = json->getDictFromJson let status = dict->getString("status", "") @@ -183,23 +183,17 @@ let rec pollRetrievePaymentIntent = ( resolve(json) } else { delay(2000)->then(_val => { - pollRetrievePaymentIntent( - clientSecret, - headers, - ~optLogger, - ~switchToCustomPod, - ~isForceSync, - ) + pollRetrievePaymentIntent(clientSecret, headers, ~optLogger, ~customPodUri, ~isForceSync) }) } }) ->catch(e => { Console.log2("Unable to retrieve payment due to following error", e) - pollRetrievePaymentIntent(clientSecret, headers, ~optLogger, ~switchToCustomPod, ~isForceSync) + pollRetrievePaymentIntent(clientSecret, headers, ~optLogger, ~customPodUri, ~isForceSync) }) } -let retrieveStatus = (~headers, ~switchToCustomPod, pollID, logger) => { +let retrieveStatus = (~headers, ~customPodUri, pollID, logger) => { open Promise let endpoint = ApiEndpoint.getApiEndPoint() let uri = `${endpoint}/poll/status/${pollID}` @@ -211,7 +205,7 @@ let retrieveStatus = (~headers, ~switchToCustomPod, pollID, logger) => { ~logType=INFO, ~logCategory=API, ) - fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod)) + fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(res => { let statusCode = res->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { @@ -249,17 +243,9 @@ let retrieveStatus = (~headers, ~switchToCustomPod, pollID, logger) => { }) } -let rec pollStatus = ( - ~headers, - ~switchToCustomPod, - ~pollId, - ~interval, - ~count, - ~returnUrl, - ~logger, -) => { +let rec pollStatus = (~headers, ~customPodUri, ~pollId, ~interval, ~count, ~returnUrl, ~logger) => { open Promise - retrieveStatus(~headers, ~switchToCustomPod, pollId, logger) + retrieveStatus(~headers, ~customPodUri, pollId, logger) ->then(json => { let dict = json->getDictFromJson let status = dict->getString("status", "") @@ -275,7 +261,7 @@ let rec pollStatus = ( _ => { pollStatus( ~headers, - ~switchToCustomPod, + ~customPodUri, ~pollId, ~interval, ~count=count - 1, @@ -297,7 +283,7 @@ let rec pollStatus = ( Console.log2("Unable to retrieve payment due to following error", e) pollStatus( ~headers, - ~switchToCustomPod, + ~customPodUri, ~pollId, ~interval, ~count=count - 1, @@ -325,7 +311,7 @@ let rec intentCall = ( ~iframeId, ~fetchMethod, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment, ~counter, ~isPaymentSession=false, @@ -360,7 +346,7 @@ let rec intentCall = ( fetchApi( uri, ~method=fetchMethod, - ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod), + ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri), ~bodyStr, ) ->then(res => { @@ -474,7 +460,7 @@ let rec intentCall = ( ~iframeId, ~fetchMethod=#GET, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment, ~counter=counter + 1, ) @@ -872,7 +858,7 @@ let rec intentCall = ( ~iframeId, ~fetchMethod=#GET, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment, ~counter=counter + 1, ~isPaymentSession, @@ -904,7 +890,7 @@ let usePaymentSync = (optLogger: option, paymentType: pay open RecoilAtoms let paymentMethodList = Recoil.useRecoilValueFromAtom(paymentMethodList) let keys = Recoil.useRecoilValueFromAtom(keys) - let switchToCustomPod = Recoil.useRecoilValueFromAtom(switchToCustomPod) + let customPodUri = Recoil.useRecoilValueFromAtom(customPodUri) let setIsManualRetryEnabled = Recoil.useSetRecoilState(isManualRetryEnabled) (~handleUserError=false, ~confirmParam: ConfirmType.confirmParams, ~iframeId="") => { switch keys.clientSecret { @@ -928,7 +914,7 @@ let usePaymentSync = (optLogger: option, paymentType: pay ~iframeId, ~fetchMethod=#GET, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment=keys.sdkHandleOneClickConfirmPayment, ~counter=0, )->ignore @@ -974,7 +960,7 @@ let usePaymentIntent = (optLogger, paymentType) => { let paymentTypeFromUrl = CardUtils.getQueryParamsDictforKey(url.search, "componentName")->CardThemeType.getPaymentMode let blockConfirm = Recoil.useRecoilValueFromAtom(isConfirmBlocked) - let switchToCustomPod = Recoil.useRecoilValueFromAtom(switchToCustomPod) + let customPodUri = Recoil.useRecoilValueFromAtom(customPodUri) let paymentMethodList = Recoil.useRecoilValueFromAtom(paymentMethodList) let keys = Recoil.useRecoilValueFromAtom(keys) @@ -1067,7 +1053,7 @@ let usePaymentIntent = (optLogger, paymentType) => { ~iframeId, ~fetchMethod=#POST, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment=keys.sdkHandleOneClickConfirmPayment, ~counter=0, ) @@ -1151,7 +1137,7 @@ let useCompleteAuthorize = (optLogger: option, paymentTyp open RecoilAtoms let paymentMethodList = Recoil.useRecoilValueFromAtom(paymentMethodList) let keys = Recoil.useRecoilValueFromAtom(keys) - let switchToCustomPod = Recoil.useRecoilValueFromAtom(switchToCustomPod) + let customPodUri = Recoil.useRecoilValueFromAtom(customPodUri) let setIsManualRetryEnabled = Recoil.useSetRecoilState(isManualRetryEnabled) let url = RescriptReactRouter.useUrl() let paymentTypeFromUrl = @@ -1194,7 +1180,7 @@ let useCompleteAuthorize = (optLogger: option, paymentTyp ~iframeId, ~fetchMethod=#POST, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment=keys.sdkHandleOneClickConfirmPayment, ~counter=0, )->ignore @@ -1218,7 +1204,7 @@ let fetchSessions = ( ~wallets=[], ~isDelayedSessionToken=false, ~optLogger, - ~switchToCustomPod, + ~customPodUri, ~endpoint, ~isPaymentSession=false, ~merchantHostname=Window.Location.hostname, @@ -1251,7 +1237,7 @@ let fetchSessions = ( uri, ~method=#POST, ~bodyStr=body->JSON.stringify, - ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod), + ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri), ) ->then(resp => { let statusCode = resp->Fetch.Response.status->Int.toString @@ -1302,7 +1288,7 @@ let fetchSessions = ( }) } -let confirmPayout = (~clientSecret, ~publishableKey, ~logger, ~switchToCustomPod, ~uri, ~body) => { +let confirmPayout = (~clientSecret, ~publishableKey, ~logger, ~customPodUri, ~uri, ~body) => { open Promise let headers = [("Content-Type", "application/json"), ("api-key", publishableKey)] logApi( @@ -1322,7 +1308,7 @@ let confirmPayout = (~clientSecret, ~publishableKey, ~logger, ~switchToCustomPod uri, ~method=#POST, ~bodyStr=body->JSON.stringify, - ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod), + ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri), ) ->then(resp => { let statusCode = resp->Fetch.Response.status->Int.toString @@ -1374,7 +1360,7 @@ let createPaymentMethod = ( ~clientSecret, ~publishableKey, ~logger, - ~switchToCustomPod, + ~customPodUri, ~endpoint, ~body, ) => { @@ -1398,7 +1384,7 @@ let createPaymentMethod = ( uri, ~method=#POST, ~bodyStr=body->JSON.stringify, - ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod), + ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri), ) ->then(resp => { let statusCode = resp->Fetch.Response.status->Int.toString @@ -1450,7 +1436,7 @@ let fetchPaymentMethodList = ( ~clientSecret, ~publishableKey, ~logger, - ~switchToCustomPod, + ~customPodUri, ~endpoint, ) => { open Promise @@ -1464,7 +1450,7 @@ let fetchPaymentMethodList = ( ~logType=INFO, ~logCategory=API, ) - fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod)) + fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(resp => { let statusCode = resp->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { @@ -1516,7 +1502,7 @@ let fetchCustomerPaymentMethodList = ( ~publishableKey, ~endpoint, ~optLogger, - ~switchToCustomPod, + ~customPodUri, ~isPaymentSession=false, ) => { open Promise @@ -1531,7 +1517,7 @@ let fetchCustomerPaymentMethodList = ( ~logCategory=API, ~isPaymentSession, ) - fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod)) + fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(res => { let statusCode = res->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { @@ -1588,6 +1574,7 @@ let paymentIntentForPaymentSession = ( ~publishableKey, ~clientSecret, ~logger, + ~customPodUri, ) => { let confirmParams = payload @@ -1640,7 +1627,7 @@ let paymentIntentForPaymentSession = ( ~iframeId="", ~fetchMethod=#POST, ~setIsManualRetryEnabled={_ => ()}, - ~switchToCustomPod=false, + ~customPodUri, ~sdkHandleOneClickConfirmPayment=false, ~counter=0, ~isPaymentSession=true, @@ -1817,7 +1804,7 @@ let callAuthExchange = ( ~clientSecret=clientSecret->Option.getOr(""), ~publishableKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, + ~customPodUri="", ~endpoint, ) ->then(customerListResponse => { @@ -1861,7 +1848,7 @@ let fetchSavedPaymentMethodList = ( ~ephemeralKey, ~endpoint, ~optLogger, - ~switchToCustomPod, + ~customPodUri, ~isPaymentSession=false, ) => { open Promise @@ -1876,7 +1863,7 @@ let fetchSavedPaymentMethodList = ( ~logCategory=API, ~isPaymentSession, ) - fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod)) + fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(res => { let statusCode = res->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { @@ -1926,7 +1913,7 @@ let fetchSavedPaymentMethodList = ( }) } -let deletePaymentMethod = (~ephemeralKey, ~paymentMethodId, ~logger, ~switchToCustomPod) => { +let deletePaymentMethod = (~ephemeralKey, ~paymentMethodId, ~logger, ~customPodUri) => { open Promise let endpoint = ApiEndpoint.getApiEndPoint() let headers = [("Content-Type", "application/json"), ("api-key", ephemeralKey)] @@ -1939,11 +1926,7 @@ let deletePaymentMethod = (~ephemeralKey, ~paymentMethodId, ~logger, ~switchToCu ~logType=INFO, ~logCategory=API, ) - fetchApi( - uri, - ~method=#DELETE, - ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod), - ) + fetchApi(uri, ~method=#DELETE, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(resp => { let statusCode = resp->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { diff --git a/src/Utilities/RecoilAtoms.res b/src/Utilities/RecoilAtoms.res index 46438cf75..96f3be110 100644 --- a/src/Utilities/RecoilAtoms.res +++ b/src/Utilities/RecoilAtoms.res @@ -10,7 +10,7 @@ let paymentMethodList = Recoil.atom("paymentMethodList", PaymentType.Loading) let loggerAtom = Recoil.atom("component", OrcaLogger.defaultLoggerConfig) let sessionId = Recoil.atom("sessionId", "") let isConfirmBlocked = Recoil.atom("isConfirmBlocked", false) -let switchToCustomPod = Recoil.atom("switchToCustomPod", false) +let customPodUri = Recoil.atom("customPodUri", "") let selectedOptionAtom = Recoil.atom("selectedOption", "") let paymentTokenAtom = Recoil.atom( "paymentToken", diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 9723d7d8e..8535a5180 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -49,13 +49,12 @@ let make = ( ->Option.flatMap(x => x->Dict.get("blockConfirm")) ->Option.flatMap(JSON.Decode.bool) ->Option.getOr(false) - let switchToCustomPod = - GlobalVars.isInteg && + let customPodUri = options ->JSON.Decode.object - ->Option.flatMap(x => x->Dict.get("switchToCustomPod")) - ->Option.flatMap(JSON.Decode.bool) - ->Option.getOr(false) + ->Option.flatMap(x => x->Dict.get("customPodUri")) + ->Option.flatMap(JSON.Decode.string) + ->Option.getOr("") let merchantHostname = Window.Location.hostname @@ -72,7 +71,7 @@ let make = ( @@ -313,7 +312,7 @@ let make = ( ("endpoint", endpoint->JSON.Encode.string), ("sdkSessionId", sdkSessionId->JSON.Encode.string), ("blockConfirm", blockConfirm->JSON.Encode.bool), - ("switchToCustomPod", switchToCustomPod->JSON.Encode.bool), + ("customPodUri", customPodUri->JSON.Encode.string), ("sdkHandleOneClickConfirmPayment", sdkHandleOneClickConfirmPayment->JSON.Encode.bool), ("parentURL", "*"->JSON.Encode.string), ("analyticsMetadata", analyticsMetadata), @@ -418,7 +417,7 @@ let make = ( clientSecret, headers, ~optLogger=Some(logger), - ~switchToCustomPod, + ~customPodUri, ~isForceSync=true, ) ) @@ -626,7 +625,7 @@ let make = ( let url = dict->getString("return_url_with_query_params", "") PaymentHelpers.pollStatus( ~headers, - ~switchToCustomPod, + ~customPodUri, ~pollId, ~interval, ~count, @@ -638,7 +637,7 @@ let make = ( clientSecret, headers, ~optLogger=Some(logger), - ~switchToCustomPod, + ~customPodUri, ~isForceSync=true, ) ->then(json => { @@ -688,7 +687,7 @@ let make = ( clientSecret, headers, ~optLogger=Some(logger), - ~switchToCustomPod, + ~customPodUri, ~isForceSync=true, ) ->then(json => { diff --git a/src/orca-loader/PaymentMethodsManagementElements.res b/src/orca-loader/PaymentMethodsManagementElements.res index 85dd27b17..720a2cf69 100644 --- a/src/orca-loader/PaymentMethodsManagementElements.res +++ b/src/orca-loader/PaymentMethodsManagementElements.res @@ -33,13 +33,12 @@ let make = ( ->Option.getOr([]) ->JSON.Encode.array - let switchToCustomPod = - GlobalVars.isInteg && + let customPodUri = options ->JSON.Decode.object - ->Option.flatMap(x => x->Dict.get("switchToCustomPod")) - ->Option.flatMap(JSON.Decode.bool) - ->Option.getOr(false) + ->Option.flatMap(x => x->Dict.get("customPodUri")) + ->Option.flatMap(JSON.Decode.string) + ->Option.getOr("") let localSelectorString = "hyper-preMountLoader-iframe" let mountPreMountLoaderIframe = () => { @@ -190,7 +189,7 @@ let make = ( ("publishableKey", publishableKey->JSON.Encode.string), ("endpoint", endpoint->JSON.Encode.string), ("sdkSessionId", sdkSessionId->JSON.Encode.string), - ("switchToCustomPod", switchToCustomPod->JSON.Encode.bool), + ("customPodUri", customPodUri->JSON.Encode.string), ("parentURL", "*"->JSON.Encode.string), ("analyticsMetadata", analyticsMetadata), ("launchTime", launchTime->JSON.Encode.float), diff --git a/src/orca-loader/PaymentSession.res b/src/orca-loader/PaymentSession.res index c1e32280e..751ebc0bb 100644 --- a/src/orca-loader/PaymentSession.res +++ b/src/orca-loader/PaymentSession.res @@ -8,13 +8,12 @@ let make = ( ~ephemeralKey, ) => { let logger = logger->Option.getOr(OrcaLogger.defaultLoggerConfig) - let switchToCustomPod = - GlobalVars.isInteg && + let customPodUri = options ->JSON.Decode.object - ->Option.flatMap(x => x->Dict.get("switchToCustomPod")) - ->Option.flatMap(JSON.Decode.bool) - ->Option.getOr(false) + ->Option.flatMap(x => x->Dict.get("customPodUri")) + ->Option.flatMap(JSON.Decode.string) + ->Option.getOr("") let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey) let defaultInitPaymentSession = { @@ -24,13 +23,13 @@ let make = ( ~publishableKey, ~endpoint, ~logger, - ~switchToCustomPod, + ~customPodUri, ), getPaymentManagementMethods: _ => PaymentSessionMethods.getPaymentManagementMethods( ~ephemeralKey, ~logger, - ~switchToCustomPod, + ~customPodUri, ~endpoint, ), } diff --git a/src/orca-loader/PaymentSessionMethods.res b/src/orca-loader/PaymentSessionMethods.res index ccceb1e7a..39633ef0d 100644 --- a/src/orca-loader/PaymentSessionMethods.res +++ b/src/orca-loader/PaymentSessionMethods.res @@ -7,7 +7,7 @@ let getCustomerSavedPaymentMethods = ( ~publishableKey, ~endpoint, ~logger, - ~switchToCustomPod, + ~customPodUri, ) => { open ApplePayTypes open GooglePayType @@ -17,7 +17,7 @@ let getCustomerSavedPaymentMethods = ( ~clientSecret, ~publishableKey, ~endpoint, - ~switchToCustomPod, + ~customPodUri, ~optLogger=Some(logger), ~isPaymentSession=true, ) @@ -114,6 +114,7 @@ let getCustomerSavedPaymentMethods = ( ~publishableKey, ~clientSecret, ~logger, + ~customPodUri, ) } | None => @@ -161,6 +162,7 @@ let getCustomerSavedPaymentMethods = ( ~publishableKey, ~clientSecret, ~logger, + ~customPodUri, )->then(val => { val->resolvePromise resolve() @@ -225,6 +227,7 @@ let getCustomerSavedPaymentMethods = ( ~publishableKey, ~clientSecret, ~logger, + ~customPodUri, ) } @@ -298,6 +301,7 @@ let getCustomerSavedPaymentMethods = ( ~publishableKey, ~clientSecret, ~logger, + ~customPodUri, ) } | None => @@ -331,7 +335,7 @@ let getCustomerSavedPaymentMethods = ( ~clientSecret, ~publishableKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, + ~customPodUri, ~endpoint, ) ->then(sessionDetails => { @@ -464,12 +468,12 @@ let getCustomerSavedPaymentMethods = ( }) } -let getPaymentManagementMethods = (~ephemeralKey, ~logger, ~switchToCustomPod, ~endpoint) => { +let getPaymentManagementMethods = (~ephemeralKey, ~logger, ~customPodUri, ~endpoint) => { let getSavedPaymentManagementMethodsList = _ => { PaymentHelpers.fetchSavedPaymentMethodList( ~ephemeralKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, + ~customPodUri, ~endpoint, ) ->then(response => { @@ -486,7 +490,7 @@ let getPaymentManagementMethods = (~ephemeralKey, ~logger, ~switchToCustomPod, ~ ~ephemeralKey, ~paymentMethodId={paymentMethodId->JSON.Decode.string->Option.getOr("")}, ~logger, - ~switchToCustomPod, + ~customPodUri, ) ->then(response => { response->resolve From 824b492b9dafad97cbe2b9a1253aa4ac0ea6cb6c Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 30 Aug 2024 10:56:56 +0000 Subject: [PATCH 2/2] chore(release): 0.84.6 [skip ci] ## [0.84.6](https://github.com/juspay/hyperswitch-web/compare/v0.84.5...v0.84.6) (2024-08-30) ### Bug Fixes * added support for customPodUri instead of switchToCustomPod ([#591](https://github.com/juspay/hyperswitch-web/issues/591)) ([f9fed51](https://github.com/juspay/hyperswitch-web/commit/f9fed5117e74c63f813117d5eceafc4a000e17dc)) --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9460d090c..1c41e4c69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.84.6](https://github.com/juspay/hyperswitch-web/compare/v0.84.5...v0.84.6) (2024-08-30) + + +### Bug Fixes + +* added support for customPodUri instead of switchToCustomPod ([#591](https://github.com/juspay/hyperswitch-web/issues/591)) ([f9fed51](https://github.com/juspay/hyperswitch-web/commit/f9fed5117e74c63f813117d5eceafc4a000e17dc)) + ## [0.84.5](https://github.com/juspay/hyperswitch-web/compare/v0.84.4...v0.84.5) (2024-08-26) ## [0.84.4](https://github.com/juspay/hyperswitch-web/compare/v0.84.3...v0.84.4) (2024-08-23) diff --git a/package-lock.json b/package-lock.json index 42a0726fe..d9793b9ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "orca-payment-page", - "version": "0.84.5", + "version": "0.84.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "orca-payment-page", - "version": "0.84.5", + "version": "0.84.6", "hasInstallScript": true, "dependencies": { "@glennsl/rescript-fetch": "^0.2.0", diff --git a/package.json b/package.json index d6398445c..ae16e824e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orca-payment-page", - "version": "0.84.5", + "version": "0.84.6", "main": "index.js", "private": true, "dependencies": {