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

feat: passing X-Merchant-Domain in the headers for Sessions Call #504

Merged
merged 2 commits into from
Jul 18, 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
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")),
ArushKapoorJuspay marked this conversation as resolved.
Show resolved Hide resolved
("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
Loading