diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index f57b10fbc..b770dd946 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -175,12 +175,8 @@ let intentCall = ( resolve() }) ->catch(err => { - let exceptionJson = - err - ->Js.Exn.asJsExn - ->Belt.Option.flatMap(Js.Exn.message) - ->Belt.Option.flatMap(OrcaUtils.safeParseOpt) - ->Belt.Option.getWithDefault(Js.Json.null) + let exceptionJson = err->toJson + logApi( ~optLogger, ~url=uri, @@ -357,12 +353,7 @@ let intentCall = ( let url = urlSearch(confirmParam.return_url) url.searchParams.set(. "payment_intent_client_secret", clientSecret) url.searchParams.set(. "status", "failed") - let exceptionJson = - err - ->Js.Exn.asJsExn - ->Belt.Option.flatMap(Js.Exn.message) - ->Belt.Option.flatMap(OrcaUtils.safeParseOpt) - ->Belt.Option.getWithDefault(Js.Json.null) + let exceptionJson = err->toJson logApi( ~optLogger, ~url=uri, @@ -672,12 +663,8 @@ let useSessions = ( json->resolve }) ->catch(err => { - let exceptionJson = - err - ->Js.Exn.asJsExn - ->Belt.Option.flatMap(Js.Exn.message) - ->Belt.Option.flatMap(OrcaUtils.safeParseOpt) - ->Belt.Option.getWithDefault(Js.Json.null) + let exceptionJson = err->toJson + logApi( ~optLogger, ~url=uri, @@ -746,12 +733,8 @@ let usePaymentMethodList = (~clientSecret, ~publishableKey, ~logger) => { json->resolve }) ->catch(err => { - let exceptionJson = - err - ->Js.Exn.asJsExn - ->Belt.Option.flatMap(Js.Exn.message) - ->Belt.Option.flatMap(OrcaUtils.safeParseOpt) - ->Belt.Option.getWithDefault(Js.Json.null) + let exceptionJson = err->toJson + logApi( ~optLogger=Some(logger), ~url=uri, @@ -817,12 +800,8 @@ let useCustomerDetails = (~clientSecret, ~publishableKey, ~optLogger) => { }) ->then(res => resolve(res)) ->catch(err => { - let exceptionJson = - err - ->Js.Exn.asJsExn - ->Belt.Option.flatMap(Js.Exn.message) - ->Belt.Option.flatMap(OrcaUtils.safeParseOpt) - ->Belt.Option.getWithDefault(Js.Json.null) + let exceptionJson = err->toJson + logApi( ~optLogger, ~url=uri, diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index e7f1d9a39..10e56d615 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -305,11 +305,7 @@ let make = ( resolve() }) ->catch(err => { - let exceptionMessage = - err - ->Js.Exn.asJsExn - ->Belt.Option.flatMap(Js.Exn.message) - ->Belt.Option.getWithDefault("TrustPay GooglePay Error") + let exceptionMessage = err->toJson->Js.Json.stringify logger.setLogInfo( ~value=exceptionMessage, ~eventName=GOOGLE_PAY_FLOW, @@ -522,11 +518,8 @@ let make = ( resolve() }) ->catch(err => { - let exceptionMessage = - err - ->Js.Exn.asJsExn - ->Belt.Option.flatMap(Js.Exn.message) - ->Belt.Option.getWithDefault("TrustPay ApplePay Error") + let exceptionMessage = err->toJson->Js.Json.stringify + logger.setLogInfo( ~eventName=APPLE_PAY_FLOW, ~paymentMethod="APPLE_PAY",