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 3 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
7 changes: 6 additions & 1 deletion src/Components/PayNowButton.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -104,7 +109,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
16 changes: 12 additions & 4 deletions src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let make = (
paymentMethodOrder,
layout,
customerPaymentMethods,
displaySavedPaymentMethods,
displaySavedPaymentMethodsCheckbox,
} = Recoil.useRecoilValueFromAtom(optionAtom)
let isApplePayReady = Recoil.useRecoilValueFromAtom(isApplePayReady)
Expand Down Expand Up @@ -369,13 +370,20 @@ let make = (
</ErrorBoundary>
}

let paymentLabel = showFields
? localeString.selectPaymentMethodLabel
: localeString.savedPaymentMethodsLabel
React.useEffect0(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a dependency here on paymentMethods?
cc: @prafulkoppalkar @vsrivatsa-juspay

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

setShowFields(._ => !displaySavedPaymentMethods)
None
})

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
3 changes: 3 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 @@ -259,6 +260,7 @@ let defaultBillingAddress = {

let defaultSdkHandleConfirmPayment = {
handleConfirm: false,
buttonText: "",
confirmParams: ConfirmType.defaultConfirm,
}

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

let getSdkHandleConfirmPaymentProps = dict => {
handleConfirm: dict->getBool("handleConfirm", false),
buttonText: dict->getString("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