Skip to content

Commit

Permalink
fix: bacs bank debit added to pm auth
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja committed Jul 4, 2024
1 parent 3245296 commit 58e2c85
Showing 1 changed file with 50 additions and 32 deletions.
82 changes: 50 additions & 32 deletions src/Payments/BacsBankDebit.res
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ let make = (~paymentType: CardThemeType.mode) => {
let loggerState = Recoil.useRecoilValueFromAtom(loggerAtom)
let isManualRetryEnabled = Recoil.useRecoilValueFromAtom(RecoilAtoms.isManualRetryEnabled)
let {config, themeObj, localeString} = Recoil.useRecoilValueFromAtom(configAtom)
let {displaySavedPaymentMethods} = Recoil.useRecoilValueFromAtom(optionAtom)

let intent = PaymentHelpers.usePaymentIntent(Some(loggerState), BankDebits)
let (email, _) = Recoil.useLoggedRecoilState(userEmailAddress, "email", loggerState)
Expand All @@ -38,12 +39,22 @@ let make = (~paymentType: CardThemeType.mode) => {
let setComplete = Recoil.useSetRecoilState(fieldsComplete)
let (sortcode, setSortcode) = React.useState(_ => "")
let (accountNumber, setAccountNumber) = React.useState(_ => "")
let paymentMethodListValue = Recoil.useRecoilValueFromAtom(PaymentUtils.paymentMethodListValue)

let (sortCodeError, setSortCodeError) = React.useState(_ => "")

let sortCodeRef = React.useRef(Nullable.null)
let accNumRef = React.useRef(Nullable.null)

let pmAuthMapper = React.useMemo1(
() =>
PmAuthConnectorUtils.findPmAuthAllPMAuthConnectors(paymentMethodListValue.payment_methods),
[paymentMethodListValue.payment_methods],
)

let isVerifyPMAuthConnectorConfigured =
displaySavedPaymentMethods && pmAuthMapper->Dict.get("sepa")->Option.isSome

let complete =
email.value != "" &&
email.isValid->Option.getOr(false) &&
Expand Down Expand Up @@ -120,38 +131,45 @@ let make = (~paymentType: CardThemeType.mode) => {
}
}

<div className="flex flex-col animate-slowShow" style={gridGap: themeObj.spacingGridColumn}>
<div className="flex flex-row" style={gridGap: themeObj.spacingGridRow}>
<PaymentInputField
fieldName=localeString.sortCodeText
value=sortcode
onChange=changeSortCode
paymentType
errorString=sortCodeError
isValid={sortCodeError == "" ? None : Some(false)}
type_="tel"
appearance=config.appearance
maxLength=8
onBlur=sortcodeBlur
inputRef=sortCodeRef
placeholder="10-80-00"
/>
<PaymentInputField
fieldName=localeString.accountNumberText
value=accountNumber
onChange=changeAccNum
paymentType
type_="text"
appearance=config.appearance
inputRef=accNumRef
placeholder="00012345"
/>
</div>
<EmailPaymentInput paymentType />
<FullNamePaymentInput paymentType={paymentType} customFieldName=Some("Bank Holder Name") />
<AddressPaymentInput paymentType />
<Surcharge paymentMethod="bank_debit" paymentMethodType="bacs" />
</div>
<>
<RenderIf condition={isVerifyPMAuthConnectorConfigured}>
<AddBankDetails paymentMethodType="bacs" />
</RenderIf>
<RenderIf condition={!isVerifyPMAuthConnectorConfigured}>
<div className="flex flex-col animate-slowShow" style={gridGap: themeObj.spacingGridColumn}>
<div className="flex flex-row" style={gridGap: themeObj.spacingGridRow}>
<PaymentInputField
fieldName=localeString.sortCodeText
value=sortcode
onChange=changeSortCode
paymentType
errorString=sortCodeError
isValid={sortCodeError == "" ? None : Some(false)}
type_="tel"
appearance=config.appearance
maxLength=8
onBlur=sortcodeBlur
inputRef=sortCodeRef
placeholder="10-80-00"
/>
<PaymentInputField
fieldName=localeString.accountNumberText
value=accountNumber
onChange=changeAccNum
paymentType
type_="text"
appearance=config.appearance
inputRef=accNumRef
placeholder="00012345"
/>
</div>
<EmailPaymentInput paymentType />
<FullNamePaymentInput paymentType={paymentType} customFieldName=Some("Bank Holder Name") />
<AddressPaymentInput paymentType />
<Surcharge paymentMethod="bank_debit" paymentMethodType="bacs" />
</div>
</RenderIf>
</>
}

let default = make

0 comments on commit 58e2c85

Please sign in to comment.