Skip to content

Commit

Permalink
fix: HS-158: TrustPay ApplePay user gesture fix for MWeb (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArushKapoorJuspay authored Nov 8, 2023
1 parent 2b03b47 commit 6d1bbc4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/GlobalVars.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@val external repoVersion: string = "repoVersion"
@val external repoPublicPath: string = "publicPath"
@val external backendEndPoint: string = "backendEndPoint"
@val external confirmEndPoint: string = "confirmEndPoint"
@val external sdkUrl: string = "sdkUrl"
@val external logEndpoint: string = "logEndpoint"
@val external sentryDSN: string = "sentryDSN"
Expand Down
7 changes: 4 additions & 3 deletions src/Utilities/ApiEndpoint.res
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ let setApiEndPoint = str => {
apiEndPoint := Some(str)
}

let getApiEndPoint = (~publishableKey="", ()) => {
let getApiEndPoint = (~publishableKey="", ~isConfirmCall=false, ()) => {
let testMode = publishableKey->Js.String2.startsWith("pk_snd_")
switch apiEndPoint.contents {
| Some(str) => str
| None =>
let backendEndPoint = isConfirmCall ? GlobalVars.confirmEndPoint : GlobalVars.backendEndPoint
if GlobalVars.isProd {
testMode ? "https://sandbox.hyperswitch.io" : {GlobalVars.backendEndPoint}
testMode ? "https://sandbox.hyperswitch.io" : backendEndPoint
} else {
{GlobalVars.backendEndPoint}
backendEndPoint
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/Utilities/PaymentHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,11 @@ let usePaymentIntent = (optLogger: option<OrcaLogger.loggerMake>, paymentType: p
returnUrlArr,
manual_retry,
])
let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey=confirmParam.publishableKey, ())
let endpoint = ApiEndpoint.getApiEndPoint(
~publishableKey=confirmParam.publishableKey,
~isConfirmCall=true,
(),
)
let uri = `${endpoint}/payments/${paymentIntentID}/confirm`
let fetchMethod = Fetch.Post
let loggerPayload = body->Js.Dict.fromArray->maskPayload
Expand Down
26 changes: 18 additions & 8 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,28 @@ let sdkUrl =
sdkEnv === "prod"
? "https://checkout.hyperswitch.io"
: sdkEnv === "sandbox"
? "https://beta.hyperswitch.io"
: sdkEnv === "integ"
? "https://dev.hyperswitch.io"
: "http://localhost:9050";
? "https://beta.hyperswitch.io"
: sdkEnv === "integ"
? "https://dev.hyperswitch.io"
: "http://localhost:9050";

let backendEndPoint =
sdkEnv === "prod"
? "https://checkout.hyperswitch.io/api"
: sdkEnv === "sandbox"
? "https://beta.hyperswitch.io/api"
: sdkEnv === "integ"
? "https://integ-api.hyperswitch.io"
: "https://beta.hyperswitch.io/api";
? "https://beta.hyperswitch.io/api"
: sdkEnv === "integ"
? "https://integ-api.hyperswitch.io"
: "https://beta.hyperswitch.io/api";

let confirmEndPoint =
sdkEnv === "prod"
? "https://api.hyperswitch.io"
: sdkEnv === "sandbox"
? "https://sandbox.hyperswitch.io"
: sdkEnv === "integ"
? "https://integ-api.hyperswitch.io"
: "https://sandbox.hyperswitch.io";

let logEndpoint =
sdkEnv === "prod"
Expand Down Expand Up @@ -89,6 +98,7 @@ module.exports = (publicPath = "auto") => {
publicPath: JSON.stringify(repoPublicPath),
sdkUrl: JSON.stringify(sdkUrl),
backendEndPoint: JSON.stringify(backendEndPoint),
confirmEndPoint: JSON.stringify(confirmEndPoint),
logEndpoint: JSON.stringify(logEndpoint),
sentryDSN: JSON.stringify(process.env.SENTRY_DSN),
sentryScriptUrl: JSON.stringify(process.env.SENTRY_SCRIPT_URL),
Expand Down

0 comments on commit 6d1bbc4

Please sign in to comment.