Skip to content

Commit

Permalink
refactor(payout): make BIC optional for SEPA txns (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
kashif-m authored Jul 23, 2024
1 parent d352b7b commit 967b9f5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/CollectWidget.res
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ let make = (
->React.array}
</div>
<div
className="flex flex-row items-center min-w-full m5 py-1.5 px-2.5 text-xs border border-solid border-blue-200 rounded bg-blue-50">
className="flex flex-row items-center min-w-full my-5 px-2.5 py-1.5 text-xs border border-solid border-blue-200 rounded bg-blue-50">
<img src={"merchantLogo"} alt="" className="h-3 w-auto mr-1.5" />
{React.string(
`Your funds will be deposited in the selected ${paymentMethod
->getPaymentMethodLabel
->String.toLowerCase}.`,
)}
</div>
<div className="flex m5 text-lg font-semibold w-full">
<div className="flex my-5 text-lg font-semibold w-full">
<button
onClick={_ => setSavedPMD(_ => None)}
disabled={submitted}
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentMethodCollectElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let make = (~integrateError, ~logger) => {
React.useEffect(() => {
let availablePM: array<paymentMethod> = []
let availablePMT: array<paymentMethodType> = []
let _ = options.enabledPaymentMethods->Array.map(pm => {
options.enabledPaymentMethods->Array.forEach(pm => {
switch pm {
| Card(_) =>
if !(availablePM->Array.includes(Card)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Types/PaymentMethodCollectTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ let decodePaymentMethodType = (json: JSON.t): option<array<paymentMethodType>> =
->Dict.get("payment_method_types")
->Option.flatMap(JSON.Decode.array)
->Option.flatMap(pmts => {
let _ = pmts->Array.map(pmt => {
pmts->Array.forEach(pmt => {
let payment_method_type = pmt->JSON.Decode.string
let _ = switch (payment_method, payment_method_type) {
switch (payment_method, payment_method_type) {
| (Some("card"), Some(cardType)) =>
switch decodeCard(cardType) {
| Some(card) => payment_methods->Array.push(Card(card))
Expand Down
26 changes: 13 additions & 13 deletions src/Utilities/PaymentMethodCollectUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ let getPaymentMethodDataFieldLabel = (key: paymentMethodDataField): string =>
| ACHAccountNumber | BacsAccountNumber => "Account Number"
| BacsSortCode => "Sort Code"
| SepaIban => "International Bank Account Number (IBAN)"
| SepaBic => "Bank Identifier Code (BIC)"
| SepaBic => "Bank Identifier Code (Optional)"
| PixId => "Pix ID"
| PixBankAccountNumber => "Bank Account Number"
| PaypalMail => "Email"
Expand Down Expand Up @@ -347,7 +347,7 @@ let getPaymentMethodDataErrorString = (key: paymentMethodDataField, value): stri

let getPaymentMethodIcon = (paymentMethod: paymentMethod) =>
switch paymentMethod {
| Card => <Icon name="card-generic-line" size=20 />
| Card => <Icon name="default-card" size=20 />
| BankTransfer => <Icon name="bank" size=20 />
| Wallet => <Icon name="wallet-generic-line" size=20 />
}
Expand Down Expand Up @@ -578,8 +578,8 @@ let formPaymentMethodData = (
| false => None
| true =>
let pmd = [(ACHRoutingNumber, routingNumber), (ACHAccountNumber, accountNumber)]
let _ = bankName->Option.map(bankName => pmd->Array.push((ACHBankName, bankName)))
let _ = city->Option.map(city => pmd->Array.push((ACHBankCity, city)))
bankName->Option.forEach(bankName => pmd->Array.push((ACHBankName, bankName)))
city->Option.forEach(city => pmd->Array.push((ACHBankCity, city)))
Some(BankTransfer, BankTransfer(ACH), pmd)
}
| _ => None
Expand All @@ -603,8 +603,8 @@ let formPaymentMethodData = (
| false => None
| true =>
let pmd = [(BacsSortCode, sortCode), (BacsAccountNumber, accountNumber)]
let _ = bankName->Option.map(bankName => pmd->Array.push((BacsBankName, bankName)))
let _ = city->Option.map(city => pmd->Array.push((BacsBankCity, city)))
bankName->Option.forEach(bankName => pmd->Array.push((BacsBankName, bankName)))
city->Option.forEach(city => pmd->Array.push((BacsBankCity, city)))
Some(BankTransfer, BankTransfer(Bacs), pmd)
}
| _ => None
Expand All @@ -619,7 +619,7 @@ let formPaymentMethodData = (
paymentMethodDataDict->getValue(SepaBankCity->getPaymentMethodDataFieldKey),
paymentMethodDataDict->getValue(SepaCountryCode->getPaymentMethodDataFieldKey),
) {
| (Some(iban), Some(bic), bankName, city, countryCode) =>
| (Some(iban), bic, bankName, city, countryCode) =>
switch [
SepaIban->getPaymentMethodDataFieldKey,
SepaBic->getPaymentMethodDataFieldKey,
Expand All @@ -629,11 +629,11 @@ let formPaymentMethodData = (
]->checkValidity(fieldValidityDict) {
| false => None
| true =>
let pmd = [(SepaIban, iban), (SepaBic, bic)]
let _ = bankName->Option.map(bankName => pmd->Array.push((SepaBankName, bankName)))
let _ = city->Option.map(city => pmd->Array.push((SepaBankCity, city)))
let _ =
countryCode->Option.map(countryCode => pmd->Array.push((SepaCountryCode, countryCode)))
let pmd = [(SepaIban, iban)]
bic->Option.forEach(bic => pmd->Array.push((SepaBic, bic)))
bankName->Option.forEach(bankName => pmd->Array.push((SepaBankName, bankName)))
city->Option.forEach(city => pmd->Array.push((SepaBankCity, city)))
countryCode->Option.forEach(countryCode => pmd->Array.push((SepaCountryCode, countryCode)))
Some(BankTransfer, BankTransfer(Sepa), pmd)
}
| _ => None
Expand All @@ -655,7 +655,7 @@ let formBody = (flow: paymentMethodCollectFlow, paymentMethodData: paymentMethod
let (paymentMethod, paymentMethodType, fields) = paymentMethodData
let pmdApiFields = []

let _ = fields->Array.map(field => {
fields->Array.forEach(field => {
let (key, value) = field
switch key {
// Card
Expand Down
6 changes: 2 additions & 4 deletions src/Utilities/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,7 @@ let rec flatten = (obj, addIndicatorForObject) => {
let arrayArray = []
dictArray->Array.forEachWithIndex((item, index) => {
switch item->JSON.Classify.classify {
| String(_str) =>
let _ = stringArray->Array.push(item)
| String(_str) => stringArray->Array.push(item)
| Object(_obj) => {
let flattenedSubObj = flatten(item, addIndicatorForObject)
flattenedSubObj
Expand All @@ -1109,8 +1108,7 @@ let rec flatten = (obj, addIndicatorForObject) => {
)
}

| _ =>
let _ = arrayArray->Array.push(item)
| _ => arrayArray->Array.push(item)
}
})
if stringArray->Array.length > 0 {
Expand Down

0 comments on commit 967b9f5

Please sign in to comment.