React.useMemo(() => {
- if displaySavedPaymentMethodsCheckbox {
- isSaveCardsChecked || list.payment_type === SETUP_MANDATE
- } else {
- !(isGuestCustomer || list.payment_type === NORMAL)
- }
- }, (isSaveCardsChecked, list.payment_type))
diff --git a/src/Payments/CardPayment.res b/src/Payments/CardPayment.res
index 790ff4e5e..5757038dd 100644
--- a/src/Payments/CardPayment.res
+++ b/src/Payments/CardPayment.res
@@ -1,5 +1,7 @@
type target = {checked: bool}
type event = {target: target}
+open PaymentType
+open PaymentModeType
@react.component
let make = (
@@ -10,11 +12,7 @@ let make = (
~paymentType: CardThemeType.mode,
~list: PaymentMethodsRecord.list,
) => {
- open PaymentType
- open PaymentModeType
open Utils
- open UtilityHooks
-
let {config, themeObj, localeString} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom)
let options = Recoil.useRecoilValueFromAtom(RecoilAtoms.optionAtom)
let loggerState = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)
@@ -83,9 +81,13 @@ let make = (
None
}, [complete])
- useHandlePostMessages(~complete=complete && areRequiredFieldsValid, ~empty, ~paymentType="card")
+ UtilityHooks.useHandlePostMessages(
+ ~complete=complete && areRequiredFieldsValid,
+ ~empty,
+ ~paymentType="card",
+ )
- let isGuestCustomer = useIsGuestCustomer()
+ let isGuestCustomer = UtilityHooks.useIsGuestCustomer()
let isCvcValidValue = CardUtils.getBoolOptionVal(isCVCValid)
let (cardEmpty, cardComplete, cardInvalid) = CardUtils.useCardDetails(
~cvcNumber,
@@ -93,12 +95,13 @@ let make = (
~isCvcValidValue,
)
- let isCustomerAcceptanceRequired = useIsCustomerAcceptanceRequired(
- ~displaySavedPaymentMethodsCheckbox,
- ~isSaveCardsChecked,
- ~list,
- ~isGuestCustomer,
- )
+ let isCustomerAcceptanceRequired = React.useMemo(() => {
+ if displaySavedPaymentMethodsCheckbox {
+ isSaveCardsChecked || list.payment_type === SETUP_MANDATE
+ } else {
+ !(isGuestCustomer || list.payment_type === NORMAL)
+ }
+ }, (isSaveCardsChecked, list.payment_type))
let submitCallback = React.useCallback((ev: Window.event) => {
let json = ev.data->JSON.parseExn
@@ -187,6 +190,8 @@ let make = (
let nicknameFieldClassName = conditionsForShowingSaveCardCheckbox ? "pt-2" : "pt-5"
+ Js.log2("sdvjnsddsjd", (list.mandate_payment, options.terms.card))
+
@@ -292,19 +295,21 @@ let make = (
/>
- {switch (list.mandate_payment, options.terms.card) {
- | (Some(_), Auto)
- | (_, Always) =>
+ {switch (list.mandate_payment, options.terms.card, list.payment_type) {
+ | (Some(_), Auto, _)
+ | (_, Always, _)
+ | (_, _, NEW_MANDATE)
+ | (_, _, SETUP_MANDATE) =>
addSize(10.0, Pixel),
+ ~marginTop=themeObj.spacingGridColumn,
(),
)}>
- | (_, _) => React.null
+ | (_, _, _) => React.null
}}
diff --git a/src/Utilities/PaymentBody.res b/src/Utilities/PaymentBody.res
index 9ddae8ef2..740d8c93f 100644
--- a/src/Utilities/PaymentBody.res
+++ b/src/Utilities/PaymentBody.res
@@ -64,6 +64,20 @@ let boletoBody = (~socialSecurityNumber) => [
),
]
+let savedCardBody = (~paymentToken, ~customerId, ~cvcNumber, ~requiresCvv) => {
+ let savedCardBody = [
+ ("payment_method", "card"->JSON.Encode.string),
+ ("payment_token", paymentToken->JSON.Encode.string),
+ ("customer_id", customerId->JSON.Encode.string),
+ ]
+
+ if requiresCvv {
+ savedCardBody->Array.push(("card_cvc", cvcNumber->JSON.Encode.string))->ignore
+ }
+
+ savedCardBody
+}
+
let customerAcceptanceBody =
[
("acceptance_type", "online"->JSON.Encode.string),
@@ -78,51 +92,12 @@ let customerAcceptanceBody =
->Dict.fromArray
->JSON.Encode.object
-let savedPaymentMethodBody = (
- ~paymentToken,
- ~customerId,
- ~paymentMethod,
- ~paymentMethodType,
- ~isCustomerAcceptanceRequired,
-) => {
- let savedPaymentMethodBody = [
- ("payment_method", paymentMethod->JSON.Encode.string),
- ("payment_token", paymentToken->JSON.Encode.string),
- ("customer_id", customerId->JSON.Encode.string),
- ("payment_method_type", paymentMethodType),
- ]
-
- if isCustomerAcceptanceRequired {
- savedPaymentMethodBody->Array.push(("customer_acceptance", customerAcceptanceBody))->ignore
- }
-
- savedPaymentMethodBody
-}
-
-let savedCardBody = (
- ~paymentToken,
- ~customerId,
- ~cvcNumber,
- ~requiresCvv,
- ~isCustomerAcceptanceRequired,
-) => {
- let savedCardBody = [
- ("payment_method", "card"->JSON.Encode.string),
- ("payment_token", paymentToken->JSON.Encode.string),
- ("customer_id", customerId->JSON.Encode.string),
- ("customer_acceptance", customerAcceptanceBody),
- ]
-
- if requiresCvv {
- savedCardBody->Array.push(("card_cvc", cvcNumber->JSON.Encode.string))->ignore
- }
-
- if isCustomerAcceptanceRequired {
- savedCardBody->Array.push(("customer_acceptance", customerAcceptanceBody))->ignore
- }
-
- savedCardBody
-}
+let savedPaymentMethodBody = (~paymentToken, ~customerId, ~paymentMethod, ~paymentMethodType) => [
+ ("payment_method", paymentMethod->JSON.Encode.string),
+ ("payment_token", paymentToken->JSON.Encode.string),
+ ("customer_id", customerId->JSON.Encode.string),
+ ("payment_method_type", paymentMethodType),
+]
let mandateBody = paymentType => {
[