From cd001c554b0ccf68f2eca08304e6d30abdca85b3 Mon Sep 17 00:00:00 2001 From: ArushKapoorJuspay <121166031+ArushKapoorJuspay@users.noreply.github.com> Date: Thu, 18 Jul 2024 14:39:22 +0530 Subject: [PATCH] feat: passing X-Merchant-Domain in the headers for Sessions Call (#504) Co-authored-by: Pritish Budhiraja --- src/App.res | 3 ++- src/Payments/PreMountLoader.res | 2 ++ src/Utilities/PaymentHelpers.res | 7 ++++++- src/Utilities/Utils.res | 2 -- src/orca-loader/Elements.res | 4 +++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/App.res b/src/App.res index 504867011..426a26aa7 100644 --- a/src/App.res +++ b/src/App.res @@ -44,9 +44,10 @@ let make = () => { url.search, "hyperComponentName", )->Types.getHyperComponentNameFromStr + let merchantHostname = CardUtils.getQueryParamsDictforKey(url.search, "merchantHostname") } | "achBankTransfer" diff --git a/src/Payments/PreMountLoader.res b/src/Payments/PreMountLoader.res index b35d5f5a7..36361c4f9 100644 --- a/src/Payments/PreMountLoader.res +++ b/src/Payments/PreMountLoader.res @@ -6,6 +6,7 @@ let make = ( ~endpoint, ~ephemeralKey, ~hyperComponentName: Types.hyperComponentName, + ~merchantHostname, ) => { open Utils let (paymentMethodsResponseSent, setPaymentMethodsResponseSent) = React.useState(_ => false) @@ -63,6 +64,7 @@ let make = ( ~optLogger=Some(logger), ~switchToCustomPod=false, ~endpoint, + ~merchantHostname, (), ) | _ => JSON.Encode.null->Promise.resolve diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index d6b5591b9..08b456285 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -1257,10 +1257,15 @@ let fetchSessions = ( ~switchToCustomPod, ~endpoint, ~isPaymentSession=false, + ~merchantHostname=Window.Location.hostname, (), ) => { open Promise - let headers = [("Content-Type", "application/json"), ("api-key", publishableKey)] + let headers = [ + ("Content-Type", "application/json"), + ("api-key", publishableKey), + ("X-Merchant-Domain", merchantHostname), + ] let paymentIntentID = clientSecret->getPaymentId let body = [ diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index 318e7a6bd..7a6490c65 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -815,8 +815,6 @@ let getHeaders = (~uri=?, ~token=?, ~headers=Dict.make(), ()) => { ("X-Payment-Confirm-Source", "sdk"), ("X-Browser-Name", OrcaLogger.arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others")), ("X-Browser-Version", OrcaLogger.arrayOfNameAndVersion->Array.get(1)->Option.getOr("0")), - ("browsername", OrcaLogger.arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others")), - ("browserversion", OrcaLogger.arrayOfNameAndVersion->Array.get(1)->Option.getOr("0")), ("X-Client-Platform", "web"), ]->Dict.fromArray diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index c69129e25..bf640d4df 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -57,6 +57,8 @@ let make = ( ->Option.flatMap(JSON.Decode.bool) ->Option.getOr(false) + let merchantHostname = Window.Location.hostname + let localSelectorString = "hyper-preMountLoader-iframe" let mountPreMountLoaderIframe = () => { if ( @@ -70,7 +72,7 @@ let make = (