Skip to content

Commit

Permalink
fix: wrap session.canMakePayments() in try catch to catch exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrishab Srivatsa committed Apr 27, 2024
1 parent f2b2e19 commit b262496
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,32 @@ let make = (
if dict->Dict.get("applePayMounted")->Option.isSome {
switch sessionForApplePay->Nullable.toOption {
| Some(session) =>
if session.canMakePayments() {
let msg = [("applePayCanMakePayments", true->JSON.Encode.bool)]->Dict.fromArray
mountedIframeRef->Window.iframePostMessage(msg)
} else {
logger.setLogInfo(
~value="CANNOT MAKE PAYMENT USING APPLE PAY",
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
~logType=ERROR,
(),
)
try {
if session.canMakePayments() {
let msg = [("applePayCanMakePayments", true->JSON.Encode.bool)]->Dict.fromArray
mountedIframeRef->Window.iframePostMessage(msg)
} else {
Console.log("CANNOT MAKE PAYMENT USING APPLE PAY")
logger.setLogInfo(
~value="CANNOT MAKE PAYMENT USING APPLE PAY",
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
~logType=ERROR,
(),
)
}
} catch {
| exn => {
let exnString = exn->anyTypeToJson->JSON.stringify
Console.log("CANNOT MAKE PAYMENT USING APPLE PAY: " ++ exnString)
logger.setLogInfo(
~value=exnString,
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
~logType=ERROR,
(),
)
}
}

| None => ()
Expand Down

0 comments on commit b262496

Please sign in to comment.