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: customer-acceptance for saved pm #709

Merged
merged 3 commits into from
Oct 3, 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/Components/SaveDetailsCheckbox.res
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let make = (~isChecked, ~setIsChecked) => {
<label className={`container CheckboxInput ${checkedState}`}>
<input type_={`checkbox`} onChange />
<div className={`checkmark CheckboxInput ${checkedState} mt-1`} />
<div className={`CheckboxLabel ${checkBoxLabelState} ml-2 w-11/12`}>
<div className={`CheckboxLabel ${checkBoxLabelState} ml-2 w-11/12 opacity-50 text-xs`}>
{React.string(saveCardCheckboxLabel)}
</div>
</label>
Expand Down
10 changes: 5 additions & 5 deletions src/Components/SavedMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let make = (
open CardUtils
open Utils
open UtilityHooks

let {themeObj, localeString} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom)
let (showFields, setShowFields) = Recoil.useRecoilState(RecoilAtoms.showCardFieldsAtom)
let areRequiredFieldsValid = Recoil.useRecoilValueFromAtom(RecoilAtoms.areRequiredFieldsValid)
Expand Down Expand Up @@ -72,13 +73,12 @@ let make = (
| _ => false
}
let empty = cvcNumber == ""
let customerMethod =
let customerMethod = React.useMemo(_ =>
savedMethods
->Array.filter(savedMethod => {
savedMethod.paymentToken === paymentTokenVal
})
->Array.filter(savedMethod => savedMethod.paymentToken === paymentTokenVal)
->Array.get(0)
->Option.getOr(PaymentType.defaultCustomerMethods)
, [paymentTokenVal])
let isUnknownPaymentMethod = customerMethod.paymentMethod === ""
let isCardPaymentMethod = customerMethod.paymentMethod === "card"
let isCardPaymentMethodValid = !customerMethod.requiresCvv || (complete && !empty)
Expand All @@ -100,7 +100,7 @@ let make = (
let json = ev.data->safeParse
let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper

let isCustomerAcceptanceRequired = customerMethod.recurringEnabled->not
let isCustomerAcceptanceRequired = customerMethod.recurringEnabled->not || isSaveCardsChecked

let savedPaymentMethodBody = switch customerMethod.paymentMethod {
| "card" =>
Expand Down
Loading