From 9fd5a08435e1775595008a52ad21a949849de22c Mon Sep 17 00:00:00 2001 From: sakksham7 <130480324+sakksham7@users.noreply.github.com> Date: Thu, 7 Nov 2024 19:26:35 +0530 Subject: [PATCH 1/2] chore: added dynamic fields support for bacs bank transfer (#780) --- src/Payments/BacsBankTransfer.res | 19 +++++++++-------- src/Utilities/DynamicFieldsUtils.res | 1 + src/Utilities/PaymentBody.res | 31 +--------------------------- src/Utilities/Utils.res | 9 ++------ 4 files changed, 14 insertions(+), 46 deletions(-) diff --git a/src/Payments/BacsBankTransfer.res b/src/Payments/BacsBankTransfer.res index 69ebea1bb..90c3d7bfa 100644 --- a/src/Payments/BacsBankTransfer.res +++ b/src/Payments/BacsBankTransfer.res @@ -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 == "" @@ -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, @@ -48,8 +48,9 @@ let default = (~paymentType: CardThemeType.mode) => { useSubmitPaymentData(submitCallback)
- - +
diff --git a/src/Utilities/DynamicFieldsUtils.res b/src/Utilities/DynamicFieldsUtils.res index 4861d6f45..20fac87b8 100644 --- a/src/Utilities/DynamicFieldsUtils.res +++ b/src/Utilities/DynamicFieldsUtils.res @@ -21,6 +21,7 @@ let dynamicFieldsEnabledPaymentMethods = [ "sepa", "affirm", "ach", + "bacs", ] let getName = (item: PaymentMethodsRecord.required_fields, field: RecoilAtomTypes.field) => { diff --git a/src/Utilities/PaymentBody.res b/src/Utilities/PaymentBody.res index eaa5c76bb..2d3d30a48 100644 --- a/src/Utilities/PaymentBody.res +++ b/src/Utilities/PaymentBody.res @@ -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), @@ -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 { diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index 45c43cc0d..68dd28128 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -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 From cdea8cda97a0013d10d0fb9060788c83a79b1331 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 7 Nov 2024 13:58:38 +0000 Subject: [PATCH 2/2] chore(release): 0.101.5 [skip ci] ## [0.101.5](https://github.com/juspay/hyperswitch-web/compare/v0.101.4...v0.101.5) (2024-11-07) --- CHANGELOG.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47dd6de53..d06c291dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/package-lock.json b/package-lock.json index 0bc63a4c3..7ef0ace84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "orca-payment-page", - "version": "0.101.4", + "version": "0.101.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "orca-payment-page", - "version": "0.101.4", + "version": "0.101.5", "hasInstallScript": true, "dependencies": { "@glennsl/rescript-fetch": "^0.2.0", diff --git a/package.json b/package.json index 45ae91ba5..66c33b0a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orca-payment-page", - "version": "0.101.4", + "version": "0.101.5", "main": "index.js", "private": true, "dependencies": {