From b8b33a7f1b09a3eee0936f58ed5f44b6c767cd96 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Tue, 12 Mar 2024 18:48:07 +0530 Subject: [PATCH 1/8] fix: pay now button text --- src/Components/PayNowButton.res | 7 ++++++- src/Types/PaymentType.res | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Components/PayNowButton.res b/src/Components/PayNowButton.res index 4c8d3cc93..c8115142a 100644 --- a/src/Components/PayNowButton.res +++ b/src/Components/PayNowButton.res @@ -65,6 +65,11 @@ let make = ( Utils.handlePostMessage([("handleSdkConfirm", confirmPayload)]) } + let buttonText = + sdkHandleConfirmPayment.buttonText->String.length > 0 + ? sdkHandleConfirmPayment.buttonText + : localeString.payNowButton + React.useEffect4(() => { if showFields { if selectedOption === Card { @@ -104,7 +109,7 @@ let make = ( {if showLoader { } else { - localeString.payNowButton->React.string + buttonText->React.string }} diff --git a/src/Types/PaymentType.res b/src/Types/PaymentType.res index 586c310ae..3b022b3b6 100644 --- a/src/Types/PaymentType.res +++ b/src/Types/PaymentType.res @@ -134,6 +134,7 @@ type billingAddress = { type sdkHandleConfirmPayment = { handleConfirm: bool, + buttonText: string, confirmParams: ConfirmType.confirmParams, } @@ -259,6 +260,7 @@ let defaultBillingAddress = { let defaultSdkHandleConfirmPayment = { handleConfirm: false, + buttonText: "", confirmParams: ConfirmType.defaultConfirm, } @@ -896,6 +898,7 @@ let getConfirmParams = dict => { let getSdkHandleConfirmPaymentProps = dict => { handleConfirm: dict->getBool("handleConfirm", false), + buttonText: dict->getString("buttonText", ""), confirmParams: dict->getDictfromDict("confirmParams")->getConfirmParams, } From ab53eaf5b32c7830f0b830dda25cdf4b386fbf53 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Tue, 12 Mar 2024 20:03:05 +0530 Subject: [PATCH 2/8] fix: displaySavedPaymentMethods prop --- src/PaymentElement.res | 16 ++++++++++++---- src/Payments/CardPayment.res | 5 ++++- src/orca-loader/Elements.res | 4 +--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/PaymentElement.res b/src/PaymentElement.res index e61570840..0f5a01b56 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -21,6 +21,7 @@ let make = ( paymentMethodOrder, layout, customerPaymentMethods, + displaySavedPaymentMethods, displaySavedPaymentMethodsCheckbox, } = Recoil.useRecoilValueFromAtom(optionAtom) let isApplePayReady = Recoil.useRecoilValueFromAtom(isApplePayReady) @@ -369,13 +370,20 @@ let make = ( } - let paymentLabel = showFields - ? localeString.selectPaymentMethodLabel - : localeString.savedPaymentMethodsLabel + React.useEffect0(() => { + setShowFields(._ => !displaySavedPaymentMethods) + None + }) + + let paymentLabel = if displaySavedPaymentMethods { + showFields ? localeString.selectPaymentMethodLabel : localeString.savedPaymentMethodsLabel + } else { + localeString.selectPaymentMethodLabel + } <>
{React.string(paymentLabel)}
- + diff --git a/src/Payments/CardPayment.res b/src/Payments/CardPayment.res index 3d7c08669..30d71d577 100644 --- a/src/Payments/CardPayment.res +++ b/src/Payments/CardPayment.res @@ -271,7 +271,10 @@ let make = ( - Js.Array2.length > 0 && !isBancontact}> + Js.Array2.length > 0 && + !isBancontact}>
ignore fetchPaymentsList(mountedIframeRef) - if displaySavedPaymentMethods { - fetchCustomerDetails(mountedIframeRef) - } + fetchCustomerDetails(mountedIframeRef) mountedIframeRef->Window.iframePostMessage(message) } From b0c88fe3da32b6db7581b19d00c816eb71c77b00 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 13 Mar 2024 00:29:38 +0530 Subject: [PATCH 3/8] fix: theme based issue --- src/BrutalTheme.res | 2 +- src/CardTheme.res | 16 ++++++++-------- src/CharcoalTheme.res | 2 +- src/DefaultTheme.res | 2 +- src/MidnightTheme.res | 2 +- src/NoTheme.res | 2 +- src/Payments/CardPayment.res | 2 +- src/SoftTheme.res | 2 +- src/orca-loader/Elements.res | 1 - src/orca-loader/LoaderPaymentElement.res | 7 ------- 10 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/BrutalTheme.res b/src/BrutalTheme.res index 723960679..c13da8e99 100644 --- a/src/BrutalTheme.res +++ b/src/BrutalTheme.res @@ -40,7 +40,7 @@ let brutal = { spacingGridRow: "20px", buttonBackgroundColor: "#f5fb1f", buttonHeight: "48px", - buttonWidth: "thin", + buttonWidth: "100%", buttonBorderRadius: "6px", buttonBorderColor: "#566186", buttonTextColor: "#000000", diff --git a/src/CardTheme.res b/src/CardTheme.res index bc0e74bff..846c22f00 100644 --- a/src/CardTheme.res +++ b/src/CardTheme.res @@ -255,34 +255,34 @@ let getVariables = (str, dict, default, logger) => { buttonBackgroundColor: getWarningString( json, "buttonBackgroundColor", - default.spacingGridRow, + default.buttonBackgroundColor, ~logger, ), - buttonHeight: getWarningString(json, "buttonHeight", default.spacingGridRow, ~logger), - buttonWidth: getWarningString(json, "buttonWidth", default.spacingGridRow, ~logger), + buttonHeight: getWarningString(json, "buttonHeight", default.buttonHeight, ~logger), + buttonWidth: getWarningString(json, "buttonWidth", default.buttonWidth, ~logger), buttonBorderRadius: getWarningString( json, "buttonBorderRadius", - default.spacingGridRow, + default.buttonBorderRadius, ~logger, ), buttonBorderColor: getWarningString( json, "buttonBorderColor", - default.spacingGridRow, + default.buttonBorderColor, ~logger, ), - buttonTextColor: getWarningString(json, "buttonTextColor", default.spacingGridRow, ~logger), + buttonTextColor: getWarningString(json, "buttonTextColor", default.buttonTextColor, ~logger), buttonTextFontSize: getWarningString( json, "buttonTextFontSize", - default.spacingGridRow, + default.buttonTextFontSize, ~logger, ), buttonTextFontWeight: getWarningString( json, "buttonTextFontWeight", - default.spacingGridRow, + default.buttonTextFontWeight, ~logger, ), } diff --git a/src/CharcoalTheme.res b/src/CharcoalTheme.res index d42347b9f..2711ef31e 100644 --- a/src/CharcoalTheme.res +++ b/src/CharcoalTheme.res @@ -40,7 +40,7 @@ let charcoal = { spacingGridRow: "20px", buttonBackgroundColor: "#000000", buttonHeight: "48px", - buttonWidth: "thin", + buttonWidth: "100%", buttonBorderRadius: "6px", buttonBorderColor: "#000000", buttonTextColor: "#ffffff", diff --git a/src/DefaultTheme.res b/src/DefaultTheme.res index 9077766f3..99dd6bc17 100644 --- a/src/DefaultTheme.res +++ b/src/DefaultTheme.res @@ -40,7 +40,7 @@ let default = { spacingGridRow: "20px", buttonBackgroundColor: "#006df9", buttonHeight: "48px", - buttonWidth: "thin", + buttonWidth: "100%", buttonBorderRadius: "6px", buttonBorderColor: "#ffffff", buttonTextColor: "#ffffff", diff --git a/src/MidnightTheme.res b/src/MidnightTheme.res index b46337934..4b6c1201c 100644 --- a/src/MidnightTheme.res +++ b/src/MidnightTheme.res @@ -40,7 +40,7 @@ let midnight = { spacingGridRow: "20px", buttonBackgroundColor: "#85d996", buttonHeight: "48px", - buttonWidth: "thin", + buttonWidth: "100%", buttonBorderRadius: "6px", buttonBorderColor: "#85d996", buttonTextColor: "#000000", diff --git a/src/NoTheme.res b/src/NoTheme.res index 9f9df6f50..674b7003f 100644 --- a/src/NoTheme.res +++ b/src/NoTheme.res @@ -41,7 +41,7 @@ let nakedValues = { spacingGridRow: "20px", buttonBackgroundColor: "", buttonHeight: "48px", - buttonWidth: "thin", + buttonWidth: "100%", buttonBorderRadius: "6px", buttonBorderColor: "", buttonTextColor: "", diff --git a/src/Payments/CardPayment.res b/src/Payments/CardPayment.res index 30d71d577..ff5515705 100644 --- a/src/Payments/CardPayment.res +++ b/src/Payments/CardPayment.res @@ -273,7 +273,7 @@ let make = ( Js.Array2.length > 0 && + savedMethods->Array.length > 0 && !isBancontact}>
{ open Promise diff --git a/src/orca-loader/LoaderPaymentElement.res b/src/orca-loader/LoaderPaymentElement.res index 359155a91..7826ebb8d 100644 --- a/src/orca-loader/LoaderPaymentElement.res +++ b/src/orca-loader/LoaderPaymentElement.res @@ -22,12 +22,6 @@ let make = (componentType, options, setIframeRef, iframeRef, mountPostMessage) = true, ) - let displaySavedPaymentMethods = - options->getDecodedBoolFromJson( - callbackFuncForExtractingValFromDict("displaySavedPaymentMethods"), - true, - ) - let on = (eventType, eventHandler) => { switch eventType->eventTypeMapper { | Escape => @@ -296,7 +290,6 @@ let make = (componentType, options, setIframeRef, iframeRef, mountPostMessage) = Window.querySelector(`#orca-payment-element-iframeRef-${localSelectorString}`), localSelectorString, sdkHandleOneClickConfirmPayment, - displaySavedPaymentMethods, ) } } From 414b5e7ce776585bfb0c68536dab3614c853ea01 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 13 Mar 2024 11:56:23 +0530 Subject: [PATCH 4/8] fix: useEffect changes comment --- src/PaymentElement.res | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PaymentElement.res b/src/PaymentElement.res index 0f5a01b56..a6383ef0a 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -370,10 +370,10 @@ let make = ( } - React.useEffect0(() => { + React.useEffect1(() => { setShowFields(._ => !displaySavedPaymentMethods) None - }) + }, [displaySavedPaymentMethods]) let paymentLabel = if displaySavedPaymentMethods { showFields ? localeString.selectPaymentMethodLabel : localeString.savedPaymentMethodsLabel From d646e047389593cf11ef5b4ebe619e8225e25076 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 13 Mar 2024 12:11:44 +0530 Subject: [PATCH 5/8] fix: saved PM rendering issue on displaySavedPaymentMethods --- src/PaymentElement.res | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PaymentElement.res b/src/PaymentElement.res index a6383ef0a..55412efbe 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -51,7 +51,7 @@ let make = ( ) = React.useState(_ => PaymentType.LoadingSavedCards) React.useEffect2(() => { - switch (displaySavedPaymentMethodsCheckbox, customerPaymentMethods) { + switch (displaySavedPaymentMethods, customerPaymentMethods) { | (false, _) => { setShowFields(._ => true) setLoadSavedCards(_ => LoadedSavedCards([], true)) @@ -87,7 +87,7 @@ let make = ( } None - }, (customerPaymentMethods, displaySavedPaymentMethodsCheckbox)) + }, (customerPaymentMethods, displaySavedPaymentMethods)) React.useEffect1(() => { let defaultPaymentMethod = From 95f00f667b51f6a99e9a3a3277ced3a6e263a0af Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 13 Mar 2024 12:13:03 +0530 Subject: [PATCH 6/8] fix: warnings removed --- src/PaymentElement.res | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PaymentElement.res b/src/PaymentElement.res index 55412efbe..9c38dbecf 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -22,7 +22,6 @@ let make = ( layout, customerPaymentMethods, displaySavedPaymentMethods, - displaySavedPaymentMethodsCheckbox, } = Recoil.useRecoilValueFromAtom(optionAtom) let isApplePayReady = Recoil.useRecoilValueFromAtom(isApplePayReady) let isGooglePayReady = Recoil.useRecoilValueFromAtom(isGooglePayReady) From a6ae6fa2d4a3b99559addc2369eac8fa9546fae7 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 13 Mar 2024 13:30:19 +0530 Subject: [PATCH 7/8] fix: comments addressed --- src/Components/PayNowButton.res | 5 +---- src/Types/PaymentType.res | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Components/PayNowButton.res b/src/Components/PayNowButton.res index c8115142a..6de1aa890 100644 --- a/src/Components/PayNowButton.res +++ b/src/Components/PayNowButton.res @@ -65,10 +65,7 @@ let make = ( Utils.handlePostMessage([("handleSdkConfirm", confirmPayload)]) } - let buttonText = - sdkHandleConfirmPayment.buttonText->String.length > 0 - ? sdkHandleConfirmPayment.buttonText - : localeString.payNowButton + let buttonText = sdkHandleConfirmPayment.buttonText->Option.getOr(localeString.payNowButton) React.useEffect4(() => { if showFields { diff --git a/src/Types/PaymentType.res b/src/Types/PaymentType.res index 3b022b3b6..0acca83f5 100644 --- a/src/Types/PaymentType.res +++ b/src/Types/PaymentType.res @@ -134,7 +134,7 @@ type billingAddress = { type sdkHandleConfirmPayment = { handleConfirm: bool, - buttonText: string, + buttonText?: string, confirmParams: ConfirmType.confirmParams, } @@ -260,7 +260,6 @@ let defaultBillingAddress = { let defaultSdkHandleConfirmPayment = { handleConfirm: false, - buttonText: "", confirmParams: ConfirmType.defaultConfirm, } From 369452c3837570a51449a482c273392938c3bd58 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 13 Mar 2024 13:34:43 +0530 Subject: [PATCH 8/8] fix: comments addressed --- src/Types/PaymentType.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Types/PaymentType.res b/src/Types/PaymentType.res index 0acca83f5..43fa329c4 100644 --- a/src/Types/PaymentType.res +++ b/src/Types/PaymentType.res @@ -897,7 +897,7 @@ let getConfirmParams = dict => { let getSdkHandleConfirmPaymentProps = dict => { handleConfirm: dict->getBool("handleConfirm", false), - buttonText: dict->getString("buttonText", ""), + buttonText: ?dict->getOptionString("buttonText"), confirmParams: dict->getDictfromDict("confirmParams")->getConfirmParams, }