diff --git a/src/Payments/SepaBankTransfer.res b/src/Payments/SepaBankTransfer.res index fd88fb89..8f9c4bd2 100644 --- a/src/Payments/SepaBankTransfer.res +++ b/src/Payments/SepaBankTransfer.res @@ -4,27 +4,17 @@ open Utils @react.component let make = (~paymentType) => { let {iframeId} = Recoil.useRecoilValueFromAtom(keys) - let {fields} = Recoil.useRecoilValueFromAtom(optionAtom) let loggerState = Recoil.useRecoilValueFromAtom(loggerAtom) - let {config, themeObj, localeString} = Recoil.useRecoilValueFromAtom(configAtom) - let intent = PaymentHelpers.usePaymentIntent(Some(loggerState), BankTransfer) + let {themeObj} = Recoil.useRecoilValueFromAtom(configAtom) let isManualRetryEnabled = Recoil.useRecoilValueFromAtom(isManualRetryEnabled) - let (country, setCountry) = React.useState(_ => "France") + let setComplete = Recoil.useSetRecoilState(fieldsComplete) let (email, _) = Recoil.useLoggedRecoilState(userEmailAddress, "email", loggerState) let (fullName, _) = Recoil.useLoggedRecoilState(userFullName, "fullName", loggerState) - let showAddressDetails = PaymentType.getShowAddressDetails( - ~billingDetails=fields.billingDetails, - ~logger=loggerState, - ) - let countryNames = Utils.getCountryNames(Country.country) - let setComplete = Recoil.useSetRecoilState(fieldsComplete) - let clientCountryCode = - Country.country - ->Array.find(item => item.countryName == country) - ->Option.getOr(Country.defaultTimeZone) + let intent = PaymentHelpers.usePaymentIntent(Some(loggerState), BankTransfer) + + let (requiredFieldsBody, setRequiredFieldsBody) = React.useState(_ => Dict.make()) let complete = email.value != "" && fullName.value != "" && email.isValid->Option.getOr(false) let empty = email.value == "" || fullName.value == "" - let paymentMethodListValue = Recoil.useRecoilValueFromAtom(PaymentUtils.paymentMethodListValue) UtilityHooks.useHandlePostMessages(~complete, ~empty, ~paymentType="bank_transfer") @@ -38,14 +28,15 @@ let make = (~paymentType) => { let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { if complete { - let (connectors, _) = paymentMethodListValue->PaymentUtils.getConnectors(BankTransfer(Sepa)) + let bodyArr = + PaymentBody.dynamicPaymentBody("bank_transfer", "sepa") + ->getJsonFromArrayOfJson + ->flattenObject(true) + ->mergeTwoFlattenedJsonDicts(requiredFieldsBody) + ->getArrayOfTupleFromDict + intent( - ~bodyArr=PaymentBody.sepaBankTransferBody( - ~email=email.value, - ~name=fullName.value, - ~country=clientCountryCode.isoAlpha2, - ~connectors, - ), + ~bodyArr, ~confirmParam=confirm.confirmParams, ~handleUserError=false, ~iframeId, @@ -55,25 +46,13 @@ let make = (~paymentType) => { postFailedSubmitResponse(~errortype="validation_error", ~message="Please enter all fields") } } - }, (email, fullName, country, isManualRetryEnabled)) + }, (email, fullName, isManualRetryEnabled)) useSubmitPaymentData(submitCallback) - let updatedOptionsArrayForCountry = - countryNames->DropdownField.updateArrayOfStringToOptionsTypeArray -