Skip to content

Commit

Permalink
Merge branch 'main' into async-await-refactoring-1
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Nov 7, 2024
2 parents 5b5ca16 + cdea8cd commit ebf8a1f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 49 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## [0.101.5](https://github.com/juspay/hyperswitch-web/compare/v0.101.4...v0.101.5) (2024-11-07)

## [0.101.4](https://github.com/juspay/hyperswitch-web/compare/v0.101.3...v0.101.4) (2024-11-07)

## [0.101.3](https://github.com/juspay/hyperswitch-web/compare/v0.101.2...v0.101.3) (2024-11-07)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orca-payment-page",
"version": "0.101.4",
"version": "0.101.5",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
19 changes: 10 additions & 9 deletions src/Payments/BacsBankTransfer.res
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ let default = (~paymentType: CardThemeType.mode) => {
let (email, _) = Recoil.useLoggedRecoilState(userEmailAddress, "email", loggerState)
let (fullName, _) = Recoil.useLoggedRecoilState(userFullName, "fullName", loggerState)
let setComplete = Recoil.useSetRecoilState(fieldsComplete)
let paymentMethodListValue = Recoil.useRecoilValueFromAtom(PaymentUtils.paymentMethodListValue)

let (requiredFieldsBody, setRequiredFieldsBody) = React.useState(_ => Dict.make())

let complete = email.value != "" && fullName.value != "" && email.isValid->Option.getOr(false)
let empty = email.value == "" || fullName.value == ""
Expand All @@ -28,13 +29,12 @@ let default = (~paymentType: CardThemeType.mode) => {
let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper
if confirm.doSubmit {
if complete {
let (connectors, _) = paymentMethodListValue->PaymentUtils.getConnectors(BankTransfer(Bacs))
let bodyArr =
PaymentBody.dynamicPaymentBody("bank_transfer", "bacs")->mergeAndFlattenToTuples(
requiredFieldsBody,
)
intent(
~bodyArr=PaymentBody.bacsBankTransferBody(
~email=email.value,
~name=fullName.value,
~connectors,
),
~bodyArr,
~confirmParam=confirm.confirmParams,
~handleUserError=false,
~iframeId,
Expand All @@ -48,8 +48,9 @@ let default = (~paymentType: CardThemeType.mode) => {
useSubmitPaymentData(submitCallback)

<div className="flex flex-col animate-slowShow" style={gridGap: themeObj.spacingTab}>
<EmailPaymentInput paymentType />
<FullNamePaymentInput paymentType />
<DynamicFields
paymentType paymentMethod="bank_transfer" paymentMethodType="bacs" setRequiredFieldsBody
/>
<Surcharge paymentMethod="bank_transfer" paymentMethodType="bacs" />
<InfoElement />
</div>
Expand Down
1 change: 1 addition & 0 deletions src/Utilities/DynamicFieldsUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let dynamicFieldsEnabledPaymentMethods = [
"sepa",
"affirm",
"ach",
"bacs",
]

let getName = (item: PaymentMethodsRecord.required_fields, field: RecoilAtomTypes.field) => {
Expand Down
31 changes: 1 addition & 30 deletions src/Utilities/PaymentBody.res
Original file line number Diff line number Diff line change
Expand Up @@ -654,35 +654,6 @@ let epsBody = (~name, ~bankName) => [
),
]

let bacsBankTransferBody = (~email, ~name, ~connectors) => {
let (firstName, lastName) = name->Utils.getFirstAndLastNameFromFullName

[
("payment_method", "bank_transfer"->JSON.Encode.string),
("connector", connectors->Utils.getArrofJsonString->JSON.Encode.array),
("payment_method_type", "bacs"->JSON.Encode.string),
(
"payment_method_data",
[
(
"billing",
[
("email", email->JSON.Encode.string),
(
"address",
[("first_name", firstName), ("last_name", lastName)]->Utils.getJsonFromArrayOfJson,
),
]->Utils.getJsonFromArrayOfJson,
),
(
"bank_transfer",
[("bacs_bank_transfer", Dict.make()->JSON.Encode.object)]->Utils.getJsonFromArrayOfJson,
),
]->Utils.getJsonFromArrayOfJson,
),
]
}

let blikBody = (~blikCode) => [
("payment_method", "bank_redirect"->JSON.Encode.string),
("payment_method_type", "blik"->JSON.Encode.string),
Expand Down Expand Up @@ -930,7 +901,7 @@ let appendRedirectPaymentMethods = [
]

let appendBankeDebitMethods = ["sepa"]
let appendBankTransferMethods = ["sepa", "ach"]
let appendBankTransferMethods = ["sepa", "ach", "bacs"]

let getPaymentMethodSuffix = (~paymentMethodType, ~paymentMethod, ~isQrPaymentMethod) => {
if isQrPaymentMethod {
Expand Down
9 changes: 2 additions & 7 deletions src/Utilities/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -1020,13 +1020,8 @@ let unflattenObject = obj => {
newDict
}

let mergeTwoFlattenedJsonDicts = (dict1, dict2) => {
dict1
->Dict.toArray
->Array.concat(dict2->Dict.toArray)
->getJsonFromArrayOfJson
->unflattenObject
}
let mergeTwoFlattenedJsonDicts = (dict1, dict2) =>
[...dict1->Dict.toArray, ...dict2->Dict.toArray]->getJsonFromArrayOfJson->unflattenObject

open Identity

Expand Down

0 comments on commit ebf8a1f

Please sign in to comment.