From 025d29622d1801df35d9daa3d5772d1f6222d97f Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 8 May 2024 14:49:20 +0530 Subject: [PATCH 1/7] fix: apiendpointurl fix for custom backend url --- src/App.res | 4 +++- src/LoaderController.res | 3 +++ src/Payments/PreMountLoader.res | 4 +--- src/orca-loader/Elements.res | 33 +++++++++++++++++++-------------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/App.res b/src/App.res index 539bd21c1..a65801fd2 100644 --- a/src/App.res +++ b/src/App.res @@ -31,7 +31,9 @@ let make = () => { let clientSecret = CardUtils.getQueryParamsDictforKey(url.search, "clientSecret") let sessionId = CardUtils.getQueryParamsDictforKey(url.search, "sessionId") let publishableKey = CardUtils.getQueryParamsDictforKey(url.search, "publishableKey") - + let endpoint = CardUtils.getQueryParamsDictforKey(url.search, "endpoint") + Js.log2("endpointendpoint", endpoint) + } | "achBankTransfer" | "bacsBankTransfer" diff --git a/src/LoaderController.res b/src/LoaderController.res index 5db99284f..cca0ec685 100644 --- a/src/LoaderController.res +++ b/src/LoaderController.res @@ -359,6 +359,9 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime dict->getJsonObjectFromDict("isReadyToPay")->JSON.Decode.bool->Option.getOr(false) ) } + if dict->getDictIsSome("endpoint") { + ApiEndpoint.setApiEndPoint(dict->getString("endpoint", "")) + } if dict->getDictIsSome("paymentMethodList") { let paymentMethodList = dict->getJsonObjectFromDict("paymentMethodList") let listDict = paymentMethodList->getDictFromJson diff --git a/src/Payments/PreMountLoader.res b/src/Payments/PreMountLoader.res index ba75d49b1..3b531e00b 100644 --- a/src/Payments/PreMountLoader.res +++ b/src/Payments/PreMountLoader.res @@ -1,5 +1,5 @@ @react.component -let make = (~sessionId, ~publishableKey, ~clientSecret) => { +let make = (~sessionId, ~publishableKey, ~clientSecret, ~endpoint) => { open Utils let (paymentMethodsResponseSent, setPaymentMethodsResponseSent) = React.useState(_ => false) let ( @@ -15,8 +15,6 @@ let make = (~sessionId, ~publishableKey, ~clientSecret) => { (), ) - let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey, ()) - let paymentMethodsResponse = React.useMemo0(() => PaymentHelpers.fetchPaymentMethodList( ~clientSecret, diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 2531bd730..27cea38d9 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -27,7 +27,13 @@ let make = ( let logger = logger->Option.getOr(OrcaLogger.defaultLoggerConfig) let savedPaymentElement = Dict.make() let localOptions = options->JSON.Decode.object->Option.getOr(Dict.make()) - let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey, ()) + let apiEndPoint = ApiEndpoint.apiEndPoint.contents->Option.getOr("") + let endpoint = if apiEndPoint->String.length === 0 { + ApiEndpoint.getApiEndPoint(~publishableKey, ()) + } else { + apiEndPoint + } + let appearance = localOptions->Dict.get("appearance")->Option.getOr(Dict.make()->JSON.Encode.object) let launchTime = localOptions->getFloat("launchTime", 0.0) @@ -67,7 +73,7 @@ let make = ( @@ -99,9 +105,9 @@ let make = ( let preMountLoaderIframeCallback = (ev: Types.event) => { let json = ev.data->Identity.anyTypeToJson let dict = json->Utils.getDictFromJson - if dict->Dict.get("preMountLoaderIframeMountedCallback")->Belt.Option.isSome { + if dict->Dict.get("preMountLoaderIframeMountedCallback")->Option.isSome { resolve(true->JSON.Encode.bool) - } else if dict->Dict.get("preMountLoaderIframeUnMount")->Belt.Option.isSome { + } else if dict->Dict.get("preMountLoaderIframeUnMount")->Option.isSome { unMountPreMountLoaderIframe() } } @@ -125,16 +131,15 @@ let make = ( ->PaymentMethodsRecord.itemToObjMapper, ~paymentMethod="wallet", ~paymentMethodType="apple_pay", - )->Belt.Option.isSome - - let isGooglePayPresent = - PaymentMethodsRecord.getPaymentMethodTypeFromList( - ~paymentMethodListValue=json - ->Utils.getDictFromJson - ->PaymentMethodsRecord.itemToObjMapper, - ~paymentMethod="wallet", - ~paymentMethodType="google_pay", - )->Belt.Option.isSome + )->Option.isSome + + let isGooglePayPresent = PaymentMethodsRecord.getPaymentMethodTypeFromList( + ~paymentMethodListValue=json + ->Utils.getDictFromJson + ->PaymentMethodsRecord.itemToObjMapper, + ~paymentMethod="wallet", + ~paymentMethodType="google_pay", + )->Option.isSome if isApplePayPresent || isGooglePayPresent { if ( From 6eac4361e2a2e1568dc0c8a920387cb9d4be80b6 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 8 May 2024 14:52:01 +0530 Subject: [PATCH 2/7] fix: log remvoed --- src/App.res | 1 - 1 file changed, 1 deletion(-) diff --git a/src/App.res b/src/App.res index a65801fd2..1ba3ded35 100644 --- a/src/App.res +++ b/src/App.res @@ -32,7 +32,6 @@ let make = () => { let sessionId = CardUtils.getQueryParamsDictforKey(url.search, "sessionId") let publishableKey = CardUtils.getQueryParamsDictforKey(url.search, "publishableKey") let endpoint = CardUtils.getQueryParamsDictforKey(url.search, "endpoint") - Js.log2("endpointendpoint", endpoint) } | "achBankTransfer" From 593ccb803db7e8b83254ab8e8b94100364160f6b Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 8 May 2024 15:10:22 +0530 Subject: [PATCH 3/7] fix: comments addressed & refactor --- src/LoaderController.res | 5 ++++- src/orca-loader/Elements.res | 7 +------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/LoaderController.res b/src/LoaderController.res index cca0ec685..c051d5f69 100644 --- a/src/LoaderController.res +++ b/src/LoaderController.res @@ -360,7 +360,10 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime ) } if dict->getDictIsSome("endpoint") { - ApiEndpoint.setApiEndPoint(dict->getString("endpoint", "")) + switch dict->getString("endpoint", "") { + | "" => () + | endpoint => ApiEndpoint.setApiEndPoint(endpoint) + } } if dict->getDictIsSome("paymentMethodList") { let paymentMethodList = dict->getJsonObjectFromDict("paymentMethodList") diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 27cea38d9..fd89a7fc2 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -27,12 +27,7 @@ let make = ( let logger = logger->Option.getOr(OrcaLogger.defaultLoggerConfig) let savedPaymentElement = Dict.make() let localOptions = options->JSON.Decode.object->Option.getOr(Dict.make()) - let apiEndPoint = ApiEndpoint.apiEndPoint.contents->Option.getOr("") - let endpoint = if apiEndPoint->String.length === 0 { - ApiEndpoint.getApiEndPoint(~publishableKey, ()) - } else { - apiEndPoint - } + let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey, ()) let appearance = localOptions->Dict.get("appearance")->Option.getOr(Dict.make()->JSON.Encode.object) From 87983aa5529058f30c4ea127305c1ddb2f94283a Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 8 May 2024 17:13:04 +0530 Subject: [PATCH 4/7] fix: comments addressed --- src/LoaderController.res | 15 +++++++++++---- src/Payments/CardPayment.res | 7 ++++--- src/orca-loader/Elements.res | 3 ++- src/orca-loader/Hyper.res | 4 ++++ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/LoaderController.res b/src/LoaderController.res index c051d5f69..30553b27f 100644 --- a/src/LoaderController.res +++ b/src/LoaderController.res @@ -359,10 +359,17 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime dict->getJsonObjectFromDict("isReadyToPay")->JSON.Decode.bool->Option.getOr(false) ) } - if dict->getDictIsSome("endpoint") { - switch dict->getString("endpoint", "") { - | "" => () - | endpoint => ApiEndpoint.setApiEndPoint(endpoint) + if ( + dict->getDictIsSome("customBackendUrlVal") && + dict + ->getString("customBackendUrlVal", "") + ->String.length > 0 + ) { + if dict->getDictIsSome("endpoint") { + switch dict->getString("endpoint", "") { + | "" => () + | endpoint => ApiEndpoint.setApiEndPoint(endpoint) + } } } if dict->getDictIsSome("paymentMethodList") { diff --git a/src/Payments/CardPayment.res b/src/Payments/CardPayment.res index 85725a1ee..5568b2d53 100644 --- a/src/Payments/CardPayment.res +++ b/src/Payments/CardPayment.res @@ -280,9 +280,10 @@ let make = ( String.length > 0 || - cvcError->String.length > 0 || - expiryError->String.length > 0}> + condition={innerLayout === Compressed && + (cardError->String.length > 0 || + cvcError->String.length > 0 || + expiryError->String.length > 0)}>
, ~analyticsMetadata, + ~customBackendUrl, ) => { let applePaySessionRef = ref(Nullable.null) - try { let iframeRef = [] let logger = logger->Option.getOr(OrcaLogger.defaultLoggerConfig) @@ -297,6 +297,7 @@ let make = ( ("parentURL", "*"->JSON.Encode.string), ("analyticsMetadata", analyticsMetadata), ("launchTime", launchTime->JSON.Encode.float), + ("customBackendUrlVal", customBackendUrl->JSON.Encode.string), ]->Dict.fromArray let wallets = PaymentType.getWallets(newOptions->getDictFromJson, "wallets", logger) diff --git a/src/orca-loader/Hyper.res b/src/orca-loader/Hyper.res index 35569eeda..fb39f0356 100644 --- a/src/orca-loader/Hyper.res +++ b/src/orca-loader/Hyper.res @@ -415,6 +415,10 @@ let make = (publishableKey, options: option, analyticsInfo: optionOption.getOr(JSON.Encode.null) + ->getDictFromJson + ->getString("customBackendUrl", ""), ) } let confirmCardPaymentFn = ( From 381615e82028f6519ccf767a116aa2df122fcfb5 Mon Sep 17 00:00:00 2001 From: Vrishab Srivatsa <136090360+vsrivatsa-juspay@users.noreply.github.com> Date: Thu, 9 May 2024 14:32:03 +0530 Subject: [PATCH 5/7] refactor: src/orca-loader/Elements.res --- src/orca-loader/Elements.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 6fc6fe66a..96ba341e2 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -297,7 +297,7 @@ let make = ( ("parentURL", "*"->JSON.Encode.string), ("analyticsMetadata", analyticsMetadata), ("launchTime", launchTime->JSON.Encode.float), - ("customBackendUrlVal", customBackendUrl->JSON.Encode.string), + ("customBackendUrl", customBackendUrl->JSON.Encode.string), ]->Dict.fromArray let wallets = PaymentType.getWallets(newOptions->getDictFromJson, "wallets", logger) From 86c098fcc27265cb609476bf9f41e677d4fe1189 Mon Sep 17 00:00:00 2001 From: Vrishab Srivatsa <136090360+vsrivatsa-juspay@users.noreply.github.com> Date: Thu, 9 May 2024 14:32:11 +0530 Subject: [PATCH 6/7] refactor: src/orca-loader/Elements.res --- src/LoaderController.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoaderController.res b/src/LoaderController.res index 30553b27f..2fbd578f9 100644 --- a/src/LoaderController.res +++ b/src/LoaderController.res @@ -362,7 +362,7 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime if ( dict->getDictIsSome("customBackendUrlVal") && dict - ->getString("customBackendUrlVal", "") + ->getString("customBackendUrl", "") ->String.length > 0 ) { if dict->getDictIsSome("endpoint") { From 7f06b283c59ee81025e29a039710ce329bfe29fa Mon Sep 17 00:00:00 2001 From: Vrishab Srivatsa <136090360+vsrivatsa-juspay@users.noreply.github.com> Date: Thu, 9 May 2024 14:32:18 +0530 Subject: [PATCH 7/7] refactor: src/orca-loader/Elements.res --- src/LoaderController.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoaderController.res b/src/LoaderController.res index 2fbd578f9..3146e791b 100644 --- a/src/LoaderController.res +++ b/src/LoaderController.res @@ -360,7 +360,7 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime ) } if ( - dict->getDictIsSome("customBackendUrlVal") && + dict->getDictIsSome("customBackendUrl") && dict ->getString("customBackendUrl", "") ->String.length > 0