Skip to content

Commit

Permalink
Merge branch 'main' of github.com:juspay/hyperswitch-web into feat/cv…
Browse files Browse the repository at this point in the history
…c-nickname-gpay
  • Loading branch information
Pritish Budhiraja committed Mar 13, 2024
2 parents 88d9ba3 + 993767f commit a8e5c1d
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 34 deletions.
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 @@ -390,13 +390,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 @@ -292,7 +292,10 @@ let make = (
<NicknamePaymentInput paymentType value=nickname setValue=setNickname />
</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 @@ -136,6 +136,7 @@ type billingAddress = {

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

Expand Down Expand Up @@ -903,6 +904,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

0 comments on commit a8e5c1d

Please sign in to comment.