Skip to content

Commit

Permalink
fix: customer-acceptance for saved pm
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja committed Oct 1, 2024
1 parent 458ee87 commit d8bd50a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Components/SavedMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ let make = (
open CardUtils
open Utils
open UtilityHooks

Js.log2("paymentTokenpaymentToken", paymentToken)
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 +74,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 +101,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

0 comments on commit d8bd50a

Please sign in to comment.