Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pay now button text & theme based changes #223

Merged
merged 8 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BrutalTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let brutal = {
spacingGridRow: "20px",
buttonBackgroundColor: "#f5fb1f",
buttonHeight: "48px",
buttonWidth: "thin",
buttonWidth: "100%",
buttonBorderRadius: "6px",
buttonBorderColor: "#566186",
buttonTextColor: "#000000",
Expand Down
16 changes: 8 additions & 8 deletions src/CardTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
}
Expand Down
2 changes: 1 addition & 1 deletion src/CharcoalTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let charcoal = {
spacingGridRow: "20px",
buttonBackgroundColor: "#000000",
buttonHeight: "48px",
buttonWidth: "thin",
buttonWidth: "100%",
buttonBorderRadius: "6px",
buttonBorderColor: "#000000",
buttonTextColor: "#ffffff",
Expand Down
4 changes: 3 additions & 1 deletion src/Components/PayNowButton.res
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ let make = (
Utils.handlePostMessage([("handleSdkConfirm", confirmPayload)])
}

let buttonText = sdkHandleConfirmPayment.buttonText->Option.getOr(localeString.payNowButton)

React.useEffect4(() => {
if showFields {
if selectedOption === Card {
Expand Down Expand Up @@ -104,7 +106,7 @@ let make = (
{if showLoader {
<Loader />
} else {
localeString.payNowButton->React.string
buttonText->React.string
}}
</span>
</button>
Expand Down
2 changes: 1 addition & 1 deletion src/DefaultTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let default = {
spacingGridRow: "20px",
buttonBackgroundColor: "#006df9",
buttonHeight: "48px",
buttonWidth: "thin",
buttonWidth: "100%",
buttonBorderRadius: "6px",
buttonBorderColor: "#ffffff",
buttonTextColor: "#ffffff",
Expand Down
2 changes: 1 addition & 1 deletion src/MidnightTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let midnight = {
spacingGridRow: "20px",
buttonBackgroundColor: "#85d996",
buttonHeight: "48px",
buttonWidth: "thin",
buttonWidth: "100%",
buttonBorderRadius: "6px",
buttonBorderColor: "#85d996",
buttonTextColor: "#000000",
Expand Down
2 changes: 1 addition & 1 deletion src/NoTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let nakedValues = {
spacingGridRow: "20px",
buttonBackgroundColor: "",
buttonHeight: "48px",
buttonWidth: "thin",
buttonWidth: "100%",
buttonBorderRadius: "6px",
buttonBorderColor: "",
buttonTextColor: "",
Expand Down
21 changes: 14 additions & 7 deletions src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let make = (
paymentMethodOrder,
layout,
customerPaymentMethods,
displaySavedPaymentMethodsCheckbox,
displaySavedPaymentMethods,
} = Recoil.useRecoilValueFromAtom(optionAtom)
let isApplePayReady = Recoil.useRecoilValueFromAtom(isApplePayReady)
let isGooglePayReady = Recoil.useRecoilValueFromAtom(isGooglePayReady)
Expand Down Expand Up @@ -50,7 +50,7 @@ let make = (
) = React.useState(_ => PaymentType.LoadingSavedCards)

React.useEffect2(() => {
switch (displaySavedPaymentMethodsCheckbox, customerPaymentMethods) {
switch (displaySavedPaymentMethods, customerPaymentMethods) {
| (false, _) => {
setShowFields(._ => true)
setLoadSavedCards(_ => LoadedSavedCards([], true))
Expand Down Expand Up @@ -86,7 +86,7 @@ let make = (
}

None
}, (customerPaymentMethods, displaySavedPaymentMethodsCheckbox))
}, (customerPaymentMethods, displaySavedPaymentMethods))

React.useEffect1(() => {
let defaultPaymentMethod =
Expand Down Expand Up @@ -369,13 +369,20 @@ let make = (
</ErrorBoundary>
}

let paymentLabel = showFields
? localeString.selectPaymentMethodLabel
: localeString.savedPaymentMethodsLabel
React.useEffect1(() => {
setShowFields(._ => !displaySavedPaymentMethods)
None
}, [displaySavedPaymentMethods])

let paymentLabel = if displaySavedPaymentMethods {
showFields ? localeString.selectPaymentMethodLabel : localeString.savedPaymentMethodsLabel
} else {
localeString.selectPaymentMethodLabel
}

<>
<div className="text-2xl font-semibold text-[#151619] mb-6"> {React.string(paymentLabel)} </div>
<RenderIf condition={!showFields}>
<RenderIf condition={!showFields && displaySavedPaymentMethods}>
<SavedMethods
paymentToken setPaymentToken savedMethods loadSavedCards cvcProps paymentType list
/>
Expand Down
5 changes: 4 additions & 1 deletion src/Payments/CardPayment.res
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ let make = (
<AnimatedCheckbox isChecked=isSaveCardsChecked setIsChecked=setIsSaveCardsChecked />
</div>
</RenderIf>
<RenderIf condition={savedMethods->Js.Array2.length > 0 && !isBancontact}>
<RenderIf
condition={options.displaySavedPaymentMethods &&
savedMethods->Array.length > 0 &&
!isBancontact}>
<div
className="Label flex flex-row gap-3 items-end cursor-pointer"
style={ReactDOMStyle.make(
Expand Down
2 changes: 1 addition & 1 deletion src/SoftTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let soft = {
spacingGridRow: "20px",
buttonBackgroundColor: "#3c3d3e",
buttonHeight: "48px",
buttonWidth: "thin",
buttonWidth: "100%",
buttonBorderRadius: "6px",
buttonBorderColor: "#7d8fff",
buttonTextColor: "#7d8fff",
Expand Down
2 changes: 2 additions & 0 deletions src/Types/PaymentType.res
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ type billingAddress = {

type sdkHandleConfirmPayment = {
handleConfirm: bool,
buttonText?: string,
confirmParams: ConfirmType.confirmParams,
}

Expand Down Expand Up @@ -896,6 +897,7 @@ let getConfirmParams = dict => {

let getSdkHandleConfirmPaymentProps = dict => {
handleConfirm: dict->getBool("handleConfirm", false),
buttonText: ?dict->getOptionString("buttonText"),
confirmParams: dict->getDictfromDict("confirmParams")->getConfirmParams,
}

Expand Down
5 changes: 1 addition & 4 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ let make = (
mountedIframeRef,
selectorString,
sdkHandleOneClickConfirmPayment,
displaySavedPaymentMethods,
) => {
open Promise

Expand Down Expand Up @@ -712,9 +711,7 @@ let make = (
})
->ignore
fetchPaymentsList(mountedIframeRef)
if displaySavedPaymentMethods {
fetchCustomerDetails(mountedIframeRef)
}
fetchCustomerDetails(mountedIframeRef)
mountedIframeRef->Window.iframePostMessage(message)
}

Expand Down
7 changes: 0 additions & 7 deletions src/orca-loader/LoaderPaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down Expand Up @@ -296,7 +290,6 @@ let make = (componentType, options, setIframeRef, iframeRef, mountPostMessage) =
Window.querySelector(`#orca-payment-element-iframeRef-${localSelectorString}`),
localSelectorString,
sdkHandleOneClickConfirmPayment,
displaySavedPaymentMethods,
)
}
}
Expand Down
Loading