Skip to content

Commit

Permalink
feat: passing X-Merchant-Domain in the headers for Sessions Call (#504)
Browse files Browse the repository at this point in the history
Co-authored-by: Pritish Budhiraja <[email protected]>
  • Loading branch information
ArushKapoorJuspay and PritishBudhiraja authored Jul 18, 2024
1 parent e026108 commit cd001c5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/App.res
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ let make = () => {
url.search,
"hyperComponentName",
)->Types.getHyperComponentNameFromStr
let merchantHostname = CardUtils.getQueryParamsDictforKey(url.search, "merchantHostname")

<PreMountLoader
publishableKey sessionId clientSecret endpoint ephemeralKey hyperComponentName
publishableKey sessionId clientSecret endpoint ephemeralKey hyperComponentName merchantHostname
/>
}
| "achBankTransfer"
Expand Down
2 changes: 2 additions & 0 deletions src/Payments/PreMountLoader.res
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let make = (
~endpoint,
~ephemeralKey,
~hyperComponentName: Types.hyperComponentName,
~merchantHostname,
) => {
open Utils
let (paymentMethodsResponseSent, setPaymentMethodsResponseSent) = React.useState(_ => false)
Expand Down Expand Up @@ -63,6 +64,7 @@ let make = (
~optLogger=Some(logger),
~switchToCustomPod=false,
~endpoint,
~merchantHostname,
(),
)
| _ => JSON.Encode.null->Promise.resolve
Expand Down
7 changes: 6 additions & 1 deletion src/Utilities/PaymentHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
[
Expand Down
2 changes: 0 additions & 2 deletions src/Utilities/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -70,7 +72,7 @@ let make = (
<iframe
id ="orca-payment-element-iframeRef-${localSelectorString}"
name="orca-payment-element-iframeRef-${localSelectorString}"
src="${ApiEndpoint.sdkDomainUrl}/index.html?fullscreenType=${componentType}&publishableKey=${publishableKey}&clientSecret=${clientSecret}&sessionId=${sdkSessionId}&endpoint=${endpoint}"
src="${ApiEndpoint.sdkDomainUrl}/index.html?fullscreenType=${componentType}&publishableKey=${publishableKey}&clientSecret=${clientSecret}&sessionId=${sdkSessionId}&endpoint=${endpoint}&merchantHostname=${merchantHostname}"
allow="*"
name="orca-payment"
></iframe>
Expand Down

0 comments on commit cd001c5

Please sign in to comment.