From c6f7dbbc24acb2788f8a287001ed3a26798d0238 Mon Sep 17 00:00:00 2001 From: Arush Date: Mon, 16 Sep 2024 15:49:57 +0530 Subject: [PATCH 01/15] feat: working on support for dynamic fields for sepa debit --- Hyperswitch-React-Demo-App/src/Payment.js | 1 + src/App.res | 44 ++ src/CardTheme.res | 4 +- src/CardUtils.res | 2 +- src/Components/AddBankAccount.res | 5 +- src/Components/DynamicFields.res | 35 ++ src/LoaderController.res | 2 +- src/Payments/ACHBankDebit.res | 2 +- src/Payments/BankDebitModal.res | 313 ++++++------ src/Payments/BecsBankDebit.res | 2 +- src/Payments/PaymentMethodsRecord.res | 3 + src/Payments/SepaBankDebit.res | 14 +- src/Utilities/DynamicFieldsUtils.res | 27 +- src/Utilities/PaymentHelpers.res | 550 +++++++++++++++++++++- src/Utilities/RecoilAtoms.res | 1 + src/Utilities/Utils.res | 8 +- src/orca-loader/Elements.res | 2 +- src/orca-loader/LoaderPaymentElement.res | 4 + 18 files changed, 852 insertions(+), 167 deletions(-) diff --git a/Hyperswitch-React-Demo-App/src/Payment.js b/Hyperswitch-React-Demo-App/src/Payment.js index b7710ec25..eb0586f93 100644 --- a/Hyperswitch-React-Demo-App/src/Payment.js +++ b/Hyperswitch-React-Demo-App/src/Payment.js @@ -83,6 +83,7 @@ function Payment() { options={{ clientSecret, appearance: { + // theme: "midnight", labels: "floating", }, }} diff --git a/src/App.res b/src/App.res index 020d9cd9a..dbcd1557b 100644 --- a/src/App.res +++ b/src/App.res @@ -16,6 +16,50 @@ let make = () => { None }, [logger]) + React.useEffect0(() => { + let handleApplePayMessages = (ev: Window.event) => { + let json = ev.data->Utils.safeParse + let dict = json->Utils.getDictFromJson + + if dict->Dict.get("metadata")->Option.isSome { + let metadata = dict->Utils.getJsonObjectFromDict("metadata") + let config = metadata->Utils.getDictFromJson->Dict.get("config") + + switch config { + | Some(config) => { + let config = CardTheme.itemToObjMapper( + config->Utils.getDictFromJson, + DefaultTheme.default, + DefaultTheme.defaultRules, + logger, + ) + + CardUtils.generateFontsLink(config.fonts) + let dict = config.appearance.rules->Utils.getDictFromJson + if dict->Dict.toArray->Array.length > 0 { + Utils.generateStyleSheet("", dict, "mystyle") + } + } + | None => () + } + } + + // if dict->Dict.get("fullScreenIframeMounted")->Option.isSome { + // let metadata = dict->getJsonObjectFromDict("metadata") + // setStateMetadata(_ => metadata) + // let metaDataDict = metadata->JSON.Decode.object->Option.getOr(Dict.make()) + + // let metadata = dict->getJsonObjectFromDict("metadata") + // if dict-> + } + Window.addEventListener("message", handleApplePayMessages) + Some( + () => { + Window.removeEventListener("message", handleApplePayMessages) + }, + ) + }) + let renderFullscreen = switch paymentMode { | "paymentMethodCollect" => diff --git a/src/CardTheme.res b/src/CardTheme.res index 17f9fd8ec..74f3df112 100644 --- a/src/CardTheme.res +++ b/src/CardTheme.res @@ -3,7 +3,7 @@ open Utils open ErrorUtils let getTheme = (val, logger) => { - switch val { + switch val->String.toLowerCase { | "default" => Default | "brutal" => Brutal | "midnight" => Midnight @@ -359,7 +359,7 @@ let getAppearance = ( variables: getVariables("variables", json, default, logger), rules: mergeJsons(rulesJson, getJsonObjectFromDict(json, "rules")), innerLayout: getWarningString(json, "innerLayout", "spaced", ~logger)->getInnerLayout, - labels: switch getWarningString(json, "labels", "above", ~logger) { + labels: switch getWarningString(json, "labels", "above", ~logger)->String.toLowerCase { | "above" => Above | "floating" => Floating | "none" => Never diff --git a/src/CardUtils.res b/src/CardUtils.res index a20967fdc..66531fd91 100644 --- a/src/CardUtils.res +++ b/src/CardUtils.res @@ -423,7 +423,7 @@ let cvcNumberInRange = (val, cardBrand) => { }) cvcLengthInRange } -let genreateFontsLink = (fonts: array) => { +let generateFontsLink = (fonts: array) => { if fonts->Array.length > 0 { fonts ->Array.map(item => diff --git a/src/Components/AddBankAccount.res b/src/Components/AddBankAccount.res index b89e379a2..81332cdf4 100644 --- a/src/Components/AddBankAccount.res +++ b/src/Components/AddBankAccount.res @@ -30,15 +30,18 @@ module ToolTip = { @react.component let make = (~modalData, ~setModalData) => { let isDataAvailable = modalData->Option.isSome - let {themeObj, localeString} = Recoil.useRecoilValueFromAtom(configAtom) + let {themeObj, localeString, config} = Recoil.useRecoilValueFromAtom(configAtom) let {iframeId} = Recoil.useRecoilValueFromAtom(keys) let (openToolTip, setOpenToolTip) = React.useState(_ => false) let toolTipRef = React.useRef(Nullable.null) let openModal = () => { + let metaData = [("config", config->Identity.anyTypeToJson)]->getJsonFromArrayOfJson + messageParentWindow([ ("fullscreen", true->JSON.Encode.bool), ("iframeId", iframeId->JSON.Encode.string), + ("metadata", metaData), ]) }
(), @@ -461,6 +468,33 @@ let make = ( | PixKey => | PixCPF => | PixCNPJ => + | BankAccountNumber => + { + let value = ReactEvent.Form.target(ev)["value"] + setBankAccountNumber(prev => { + isValid: value !== "" ? Some(true) : Some(false), + value, + errorString: value !== "" ? "" : prev.errorString, + }) + }} + onBlur={ev => { + let value = ReactEvent.Focus.target(ev)["value"] + setBankAccountNumber(prev => { + ...prev, + isValid: Some(value !== ""), + }) + }} + paymentType + type_="text" + name="bankAccountNumber" + maxLength=42 + inputRef=bankAccountNumberRef + placeholder="DE00 0000 0000 0000 0000 00" + /> | Email | InfoElement | Country @@ -775,6 +809,7 @@ let make = ( | PhoneCountryCode | VpaId | LanguagePreference(_) + | BankAccountNumber | None => React.null }}
diff --git a/src/LoaderController.res b/src/LoaderController.res index d81b6457b..e86f65cf9 100644 --- a/src/LoaderController.res +++ b/src/LoaderController.res @@ -183,7 +183,7 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime }) React.useEffect(() => { - CardUtils.genreateFontsLink(config.fonts) + CardUtils.generateFontsLink(config.fonts) let dict = config.appearance.rules->getDictFromJson if dict->Dict.toArray->Array.length > 0 { generateStyleSheet("", dict, "themestyle") diff --git a/src/Payments/ACHBankDebit.res b/src/Payments/ACHBankDebit.res index 1dfb6e605..55eb6184a 100644 --- a/src/Payments/ACHBankDebit.res +++ b/src/Payments/ACHBankDebit.res @@ -127,7 +127,7 @@ let make = (~paymentType: CardThemeType.mode) => { - + diff --git a/src/Payments/BankDebitModal.res b/src/Payments/BankDebitModal.res index 2476e3f40..5675194a5 100644 --- a/src/Payments/BankDebitModal.res +++ b/src/Payments/BankDebitModal.res @@ -106,7 +106,7 @@ module AccountNumberCard = { let clearSpaces = str => str->String.replaceRegExp(%re("/\D+/g"), "") @react.component -let make = (~setModalData) => { +let make = (~setModalData, ~paymentType: CardThemeType.mode) => { let selectedOption = Recoil.useRecoilValueFromAtom(RecoilAtoms.selectedOptionAtom) let (routingNumber, setRoutingNumber) = React.useState(_ => "") let (iban, setIban) = React.useState(_ => "") @@ -116,6 +116,12 @@ let make = (~setModalData) => { let {themeObj, config, localeString} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) let (accountType, setAccountType) = React.useState(() => "Savings") + let {config} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) + + let (requiredFieldsBody, setRequiredFieldsBody) = React.useState(_ => Dict.make()) + let areRequiredFieldsValid = Recoil.useRecoilValueFromAtom(RecoilAtoms.areRequiredFieldsValid) + let areRequiredFieldsEmpty = Recoil.useRecoilValueFromAtom(RecoilAtoms.areRequiredFieldsEmpty) + let (openModal, setOpenModal) = React.useState(_ => false) let (accountNum, setAccountNum) = React.useState(_ => "") @@ -186,65 +192,52 @@ let make = (~setModalData) => {
-
- {React.string(localeString.billingDetailsText)} -
-
- -
-
- {React.string("Bank Details")} -
-
- {React.string("Account Holder Name")} -
- setInputFocus(_ => NONE)} - /> - -
- {React.string("IBAN")} -
- -
-
- -
+ {if isSepaDebit { + <> + + + + } else { + <> +
+ {React.string(localeString.billingDetailsText)} +
+
+ +
+
+ {React.string("Bank Details")} +
+
+ {React.string("Account Holder Name")} +
+ setInputFocus(_ => NONE)} + /> +
{ color: themeObj.colorText, marginBottom: "5px", }> - {React.string("Routing number")} + {React.string("IBAN")}
setInputFocus(_ => Routing)} + value=iban + onChange=changeIBAN + type_="text" + maxLength=42 + inputRef=ibanRef + placeholder="eg: DE00 0000 0000 0000 0000 00" /> +
+
+ +
+
+ {React.string("Routing number")} +
+ setInputFocus(_ => Routing)} + /> +
+
+ +
+
+ {React.string("Account number")} +
+ setInputFocus(_ => Account)} + onBlur={_ => setInputFocus(_ => NONE)} + /> +
+
- - -
+ +
+ +
+
+
{ color: themeObj.colorText, marginBottom: "5px", }> - {React.string("Account number")} + {React.string("BSB")}
setInputFocus(_ => Account)} - onBlur={_ => setInputFocus(_ => NONE)} + maxLength=7 + placeholder="eg: 000-000" /> -
-
-
- -
- +
-
- -
- {React.string("BSB")} -
- -
-
diff --git a/src/Payments/BecsBankDebit.res b/src/Payments/BecsBankDebit.res index 5efaab715..fc34d78fd 100644 --- a/src/Payments/BecsBankDebit.res +++ b/src/Payments/BecsBankDebit.res @@ -90,7 +90,7 @@ let make = (~paymentType: CardThemeType.mode) => { - + diff --git a/src/Payments/PaymentMethodsRecord.res b/src/Payments/PaymentMethodsRecord.res index 5803f6aba..ff45a80b3 100644 --- a/src/Payments/PaymentMethodsRecord.res +++ b/src/Payments/PaymentMethodsRecord.res @@ -44,6 +44,7 @@ type paymentMethodsFields = | PixCPF | PixCNPJ | LanguagePreference(array) + | BankAccountNumber let getPaymentMethodsFieldsOrder = paymentMethodField => { switch paymentMethodField { @@ -586,6 +587,7 @@ let getPaymentMethodsFieldTypeFromString = (str, isBancontact) => { | ("user_cpf", _) => PixCPF | ("user_cnpj", _) => PixCNPJ | ("user_pix_key", _) => PixKey + | ("user_bank_account_number", _) => BankAccountNumber | _ => None } } @@ -668,6 +670,7 @@ let dynamicFieldsEnabledPaymentMethods = [ "afterpay_clearpay", "mifinity", "upi_collect", + "sepa", ] let getIsBillingField = requiredFieldType => { diff --git a/src/Payments/SepaBankDebit.res b/src/Payments/SepaBankDebit.res index 8570a25b0..a6378021d 100644 --- a/src/Payments/SepaBankDebit.res +++ b/src/Payments/SepaBankDebit.res @@ -93,11 +93,11 @@ let make = (~paymentType: CardThemeType.mode) => { } }, (email, fullName, modalData, isManualRetryEnabled)) useSubmitPaymentData(submitCallback) - <> - + + { + if isVerifyPMAuthConnectorConfigured { - - + } else {
{ - +
-
- + } + } } let default = make diff --git a/src/Utilities/DynamicFieldsUtils.res b/src/Utilities/DynamicFieldsUtils.res index 8c3d70b9f..2866c7c7d 100644 --- a/src/Utilities/DynamicFieldsUtils.res +++ b/src/Utilities/DynamicFieldsUtils.res @@ -131,6 +131,7 @@ let useRequiredFieldsEmptyAndValid = ( let {billingAddress} = Recoil.useRecoilValueFromAtom(optionAtom) let cryptoCurrencyNetworks = Recoil.useRecoilValueFromAtom(cryptoCurrencyNetworks) let dateOfBirth = Recoil.useRecoilValueFromAtom(dateOfBirth) + let bankAccountNumber = Recoil.useRecoilValueFromAtom(userBankAccountNumber) let fieldsArrWithBillingAddress = fieldsArr->addBillingAddressIfUseBillingAddress(billingAddress) @@ -173,6 +174,7 @@ let useRequiredFieldsEmptyAndValid = ( | PixCNPJ => pixCNPJ.isValid->Option.getOr(false) | PixCPF => pixCPF.isValid->Option.getOr(false) | PixKey => pixKey.isValid->Option.getOr(false) + | BankAccountNumber => bankAccountNumber.value !== "" | _ => true } }) @@ -221,6 +223,7 @@ let useRequiredFieldsEmptyAndValid = ( let (month, year) = getExpiryDates(cardExpiry) month === "" || year === "" || cvcNumber === "" | DateOfBirth => dateOfBirth->Js.Nullable.isNullable + | BankAccountNumber => bankAccountNumber.value === "" | _ => false } }) @@ -299,6 +302,11 @@ let useSetInitialRequiredFields = ( "dateOfBirth", logger, ) + let (bankAccountNumber, setBankAccountNumber) = Recoil.useLoggedRecoilState( + userBankAccountNumber, + "bankAccountNumber", + logger, + ) React.useEffect(() => { let getNameValue = (item: PaymentMethodsRecord.required_fields) => { @@ -423,6 +431,8 @@ let useSetInitialRequiredFields = ( } | None => () } + | BankAccountNumber => + setFields(setBankAccountNumber, bankAccountNumber, requiredField, false) | LanguagePreference(_) | SpecialField(_) | InfoElement @@ -478,6 +488,7 @@ let useRequiredFieldsBody = ( let {billingAddress} = Recoil.useRecoilValueFromAtom(optionAtom) let cryptoCurrencyNetworks = Recoil.useRecoilValueFromAtom(cryptoCurrencyNetworks) let dateOfBirth = Recoil.useRecoilValueFromAtom(dateOfBirth) + let bankAccountNumber = Recoil.useRecoilValueFromAtom(userBankAccountNumber) let getFieldValueFromFieldType = (fieldType: PaymentMethodsRecord.paymentMethodsFields) => { switch fieldType { @@ -531,6 +542,7 @@ let useRequiredFieldsBody = ( | PixCNPJ => pixCNPJ.value | PixCPF => pixCPF.value | PixKey => pixKey.value + | BankAccountNumber => bankAccountNumber.value | StateAndCity | CountryAndPincode(_) | SpecialField(_) @@ -545,6 +557,7 @@ let useRequiredFieldsBody = ( | ShippingAddressPincode | ShippingAddressState | ShippingAddressCountry(_) + | BankAccountNumber | None => "" } } @@ -649,7 +662,8 @@ let isFieldTypeToRenderOutsideBilling = (fieldType: PaymentMethodsRecord.payment | PixCNPJ | DateOfBirth | Currency(_) - | VpaId => true + | VpaId + | BankAccountNumber => true | _ => false } } @@ -768,6 +782,11 @@ let useSubmitCallback = () => { logger, ) let (city, setCity) = Recoil.useLoggedRecoilState(userAddressCity, "city", logger) + let (bankAccountNumber, setBankAccountNumber) = Recoil.useLoggedRecoilState( + userBankAccountNumber, + "bankAccountNumber", + logger, + ) let {billingAddress} = Recoil.useRecoilValueFromAtom(optionAtom) let {localeString} = Recoil.useRecoilValueFromAtom(configAtom) @@ -806,6 +825,12 @@ let useSubmitCallback = () => { errorString: localeString.cityEmptyText, }) } + if bankAccountNumber.value === "" { + setCity(prev => { + ...prev, + errorString: localeString.cityEmptyText, + }) + } } }, (line1, line2, state, city, postalCode)) } diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index af404ea10..58b5376df 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -1479,7 +1479,555 @@ let fetchPaymentMethodList = ( ~logType=INFO, ~logCategory=API, ) - Fetch.Response.json(resp) + let val = { + "redirect_url": null, + "currency": "USD", + "payment_methods": [ + { + "payment_method": "wallet", + "payment_method_types": [ + { + "payment_method_type": "apple_pay", + "payment_experience": [ + { + "payment_experience_type": "invoke_sdk_client", + "eligible_connectors": ["cybersource"], + }, + ], + "card_networks": null, + "bank_names": null, + "bank_debits": null, + "bank_transfers": null, + "required_fields": { + "billing.address.first_name": { + "required_field": "payment_method_data.billing.address.first_name", + "display_name": "billing_first_name", + "field_type": "user_billing_name", + "value": "joseph", + }, + "billing.address.zip": { + "required_field": "payment_method_data.billing.address.zip", + "display_name": "zip", + "field_type": "user_address_pincode", + "value": "94122", + }, + "billing.address.last_name": { + "required_field": "payment_method_data.billing.address.last_name", + "display_name": "billing_last_name", + "field_type": "user_billing_name", + "value": "Doe", + }, + "email": { + "required_field": "email", + "display_name": "email", + "field_type": "user_email_address", + "value": "hyperswitch_sdk_demo_id@gmail.com", + }, + "billing.address.country": { + "required_field": "payment_method_data.billing.address.country", + "display_name": "country", + "field_type": { + "user_address_country": { + "options": ["ALL"], + }, + }, + "value": "US", + }, + "billing.address.city": { + "required_field": "payment_method_data.billing.address.city", + "display_name": "city", + "field_type": "user_address_city", + "value": "San Fransico", + }, + "billing.address.state": { + "required_field": "payment_method_data.billing.address.state", + "display_name": "state", + "field_type": "user_address_state", + "value": "California", + }, + "billing.address.line1": { + "required_field": "payment_method_data.billing.address.line1", + "display_name": "line1", + "field_type": "user_address_line1", + "value": "1467", + }, + }, + "surcharge_details": null, + "pm_auth_connector": null, + }->Identity.anyTypeToJson, + { + "payment_method_type": "google_pay", + "payment_experience": [ + { + "payment_experience_type": "invoke_sdk_client", + "eligible_connectors": ["cybersource"], + }, + ], + "card_networks": null, + "bank_names": null, + "bank_debits": null, + "bank_transfers": null, + "required_fields": { + "billing.address.zip": { + "required_field": "payment_method_data.billing.address.zip", + "display_name": "zip", + "field_type": "user_address_pincode", + "value": "94122", + }, + "billing.address.country": { + "required_field": "payment_method_data.billing.address.country", + "display_name": "country", + "field_type": { + "user_address_country": { + "options": ["ALL"], + }, + }, + "value": "US", + }, + "billing.address.last_name": { + "required_field": "payment_method_data.billing.address.last_name", + "display_name": "billing_last_name", + "field_type": "user_billing_name", + "value": "Doe", + }, + "email": { + "required_field": "email", + "display_name": "email", + "field_type": "user_email_address", + "value": "hyperswitch_sdk_demo_id@gmail.com", + }, + "billing.address.state": { + "required_field": "payment_method_data.billing.address.state", + "display_name": "state", + "field_type": "user_address_state", + "value": "California", + }, + "billing.address.city": { + "required_field": "payment_method_data.billing.address.city", + "display_name": "city", + "field_type": "user_address_city", + "value": "San Fransico", + }, + "billing.address.first_name": { + "required_field": "payment_method_data.billing.address.first_name", + "display_name": "billing_first_name", + "field_type": "user_billing_name", + "value": "joseph", + }, + "billing.address.line1": { + "required_field": "payment_method_data.billing.address.line1", + "display_name": "line1", + "field_type": "user_address_line1", + "value": "1467", + }, + }, + "surcharge_details": null, + "pm_auth_connector": null, + }->Identity.anyTypeToJson, + { + "payment_method_type": "paypal", + "payment_experience": [ + { + "payment_experience_type": "redirect_to_url", + "eligible_connectors": ["paypal"], + }, + { + "payment_experience_type": "invoke_sdk_client", + "eligible_connectors": ["paypal"], + }, + ], + "card_networks": null, + "bank_names": null, + "bank_debits": null, + "bank_transfers": null, + "required_fields": null, + "surcharge_details": null, + "pm_auth_connector": null, + }->Identity.anyTypeToJson, + ], + }->Identity.anyTypeToJson, + { + "payment_method": "pay_later", + "payment_method_types": [ + { + "payment_method_type": "klarna", + "payment_experience": [ + { + "payment_experience_type": "invoke_sdk_client", + "eligible_connectors": ["klarna"], + }, + ], + "card_networks": null, + "bank_names": null, + "bank_debits": null, + "bank_transfers": null, + "required_fields": { + "billing.address.country": { + "required_field": "payment_method_data.billing.address.country", + "display_name": "country", + "field_type": { + "user_address_country": { + "options": [ + "AU", + "AT", + "BE", + "CA", + "CZ", + "DK", + "FI", + "FR", + "DE", + "GR", + "IE", + "IT", + "NL", + "NZ", + "NO", + "PL", + "PT", + "ES", + "SE", + "CH", + "GB", + "US", + ], + }, + }, + "value": "US", + }, + }, + "surcharge_details": null, + "pm_auth_connector": null, + }, + ], + }->Identity.anyTypeToJson, + { + "payment_method": "card", + "payment_method_types": [ + { + "payment_method_type": "debit", + "payment_experience": null, + "card_networks": [ + { + "card_network": "UnionPay", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "Visa", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "CartesBancaires", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "Mastercard", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "JCB", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "DinersClub", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "Interac", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "AmericanExpress", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "Discover", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + ], + "bank_names": null, + "bank_debits": null, + "bank_transfers": null, + "required_fields": { + "payment_method_data.card.card_cvc": { + "required_field": "payment_method_data.card.card_cvc", + "display_name": "card_cvc", + "field_type": "user_card_cvc", + "value": null, + }, + "billing.address.state": { + "required_field": "payment_method_data.billing.address.state", + "display_name": "state", + "field_type": "user_address_state", + "value": "California", + }, + "email": { + "required_field": "email", + "display_name": "email", + "field_type": "user_email_address", + "value": "hyperswitch_sdk_demo_id@gmail.com", + }, + "billing.address.first_name": { + "required_field": "payment_method_data.billing.address.first_name", + "display_name": "card_holder_name", + "field_type": "user_full_name", + "value": "joseph", + }, + "payment_method_data.card.card_exp_year": { + "required_field": "payment_method_data.card.card_exp_year", + "display_name": "card_exp_year", + "field_type": "user_card_expiry_year", + "value": null, + }, + "billing.address.country": { + "required_field": "payment_method_data.billing.address.country", + "display_name": "country", + "field_type": { + "user_address_country": { + "options": ["ALL"], + }, + }, + "value": "US", + }, + "billing.address.line1": { + "required_field": "payment_method_data.billing.address.line1", + "display_name": "line1", + "field_type": "user_address_line1", + "value": "1467", + }, + "billing.address.zip": { + "required_field": "payment_method_data.billing.address.zip", + "display_name": "zip", + "field_type": "user_address_pincode", + "value": "94122", + }, + "billing.address.last_name": { + "required_field": "payment_method_data.billing.address.last_name", + "display_name": "card_holder_name", + "field_type": "user_full_name", + "value": "Doe", + }, + "payment_method_data.card.card_number": { + "required_field": "payment_method_data.card.card_number", + "display_name": "card_number", + "field_type": "user_card_number", + "value": null, + }, + "payment_method_data.card.card_exp_month": { + "required_field": "payment_method_data.card.card_exp_month", + "display_name": "card_exp_month", + "field_type": "user_card_expiry_month", + "value": null, + }, + "billing.address.city": { + "required_field": "payment_method_data.billing.address.city", + "display_name": "city", + "field_type": "user_address_city", + "value": "San Fransico", + }, + }, + "surcharge_details": null, + "pm_auth_connector": null, + }->Identity.anyTypeToJson, + { + "payment_method_type": "credit", + "payment_experience": null, + "card_networks": [ + { + "card_network": "UnionPay", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "JCB", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "Visa", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "Interac", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "AmericanExpress", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "DinersClub", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "Discover", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "Mastercard", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + { + "card_network": "CartesBancaires", + "surcharge_details": null, + "eligible_connectors": ["bankofamerica", "cybersource"], + }, + ], + "bank_names": null, + "bank_debits": null, + "bank_transfers": null, + "required_fields": { + "billing.address.last_name": { + "required_field": "payment_method_data.billing.address.last_name", + "display_name": "card_holder_name", + "field_type": "user_full_name", + "value": "Doe", + }, + "payment_method_data.card.card_number": { + "required_field": "payment_method_data.card.card_number", + "display_name": "card_number", + "field_type": "user_card_number", + "value": null, + }, + "payment_method_data.card.card_cvc": { + "required_field": "payment_method_data.card.card_cvc", + "display_name": "card_cvc", + "field_type": "user_card_cvc", + "value": null, + }, + "billing.address.country": { + "required_field": "payment_method_data.billing.address.country", + "display_name": "country", + "field_type": { + "user_address_country": { + "options": ["ALL"], + }, + }, + "value": "US", + }, + "billing.address.first_name": { + "required_field": "payment_method_data.billing.address.first_name", + "display_name": "card_holder_name", + "field_type": "user_full_name", + "value": "joseph", + }, + "billing.address.state": { + "required_field": "payment_method_data.billing.address.state", + "display_name": "state", + "field_type": "user_address_state", + "value": "California", + }, + "payment_method_data.card.card_exp_year": { + "required_field": "payment_method_data.card.card_exp_year", + "display_name": "card_exp_year", + "field_type": "user_card_expiry_year", + "value": null, + }, + "billing.address.city": { + "required_field": "payment_method_data.billing.address.city", + "display_name": "city", + "field_type": "user_address_city", + "value": "San Fransico", + }, + "billing.address.zip": { + "required_field": "payment_method_data.billing.address.zip", + "display_name": "zip", + "field_type": "user_address_pincode", + "value": "94122", + }, + "email": { + "required_field": "email", + "display_name": "email", + "field_type": "user_email_address", + "value": "hyperswitch_sdk_demo_id@gmail.com", + }, + "payment_method_data.card.card_exp_month": { + "required_field": "payment_method_data.card.card_exp_month", + "display_name": "card_exp_month", + "field_type": "user_card_expiry_month", + "value": null, + }, + "billing.address.line1": { + "required_field": "payment_method_data.billing.address.line1", + "display_name": "line1", + "field_type": "user_address_line1", + "value": "1467", + }, + }, + "surcharge_details": null, + "pm_auth_connector": null, + }->Identity.anyTypeToJson, + ], + }->Identity.anyTypeToJson, + { + "payment_method": "bank_debit", + "payment_method_types": [ + { + "payment_method_type": "sepa", + "payment_experience": [ + { + "payment_experience_type": "redirect_to_url", + "eligible_connectors": ["adyen"], + }, + ], + "card_networks": null, + "bank_names": null, + "bank_debits": null, + "bank_transfers": null, + "required_fields": { + "billing.address.first_name": { + "required_field": "payment_method_data.billing.address.first_name", + "display_name": "owner_name", + "field_type": "user_billing_name", + // "value": "joseph", + "value": null, + }, + "billing.address.last_name": { + "required_field": "payment_method_data.billing.address.last_name", + "display_name": "owner_name", + "field_type": "user_billing_name", + // "value": "Doe", + "value": null, + }, + "payment_method_data.bank_debit.sepa.iban": { + "required_field": "payment_method_data.bank_debit.bacs.iban", + "display_name": "bank_account_number", + "field_type": "user_bank_account_number", + "value": null, + }, + }, + "surcharge_details": null, + "pm_auth_connector": null, + }, + ], + }->Identity.anyTypeToJson, + ], + "mandate_payment": null, + "merchant_name": "new", + "show_surcharge_breakup_screen": false, + "payment_type": "normal", + "request_external_three_ds_authentication": false, + "collect_shipping_details_from_wallets": false, + "collect_billing_details_from_wallets": false, + }->Identity.anyTypeToJson + // Fetch.Response.json(resp) + + val->resolve } }) ->catch(err => { diff --git a/src/Utilities/RecoilAtoms.res b/src/Utilities/RecoilAtoms.res index 26752e0f4..c0163330a 100644 --- a/src/Utilities/RecoilAtoms.res +++ b/src/Utilities/RecoilAtoms.res @@ -73,6 +73,7 @@ let userVpaId = Recoil.atom("userVpaId", defaultFieldValues) let userPixKey = Recoil.atom("userPixKey", defaultFieldValues) let userPixCPF = Recoil.atom("userPixCPF", defaultFieldValues) let userPixCNPJ = Recoil.atom("userPixCNPJ", defaultFieldValues) +let userBankAccountNumber = Recoil.atom("userBankAccountNumber", defaultFieldValues) type areOneClickWalletsRendered = { isGooglePay: bool, diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index e6f1e9f13..c0ded999f 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -1,6 +1,8 @@ @val external document: 'a = "document" @val external window: Dom.element = "window" @val @scope("window") external iframeParent: Dom.element = "parent" +@send external body: ('a, Dom.element) => Dom.element = "body" + type event = {data: string} external dictToObj: Dict.t<'a> => {..} = "%identity" @@ -582,10 +584,12 @@ let constructClass = (~classname, ~dict) => { let generateStyleSheet = (classname, dict, id) => { let createStyle = () => { let style = document["createElement"]("style") - style["type"] = "text/css" + let style1 = Window.createElement("style") + // style["type"] = "text/css" style["id"] = id style["appendChild"](document["createTextNode"](constructClass(~classname, ~dict)))->ignore - document["body"]["appendChild"](style)->ignore + let obj = document["body"] + obj["appendChild"](style)->ignore } switch Window.window->Window.document->Window.getElementById(id)->Nullable.toOption { | Some(val) => { diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 1785ab672..70195b62c 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -93,7 +93,7 @@ let make = ( let unMountPreMountLoaderIframe = () => { switch preMountLoaderIframeDiv->Nullable.toOption { - | Some(iframe) => iframe->remove + | Some(iframe) => () //iframe->remove | None => () } } diff --git a/src/orca-loader/LoaderPaymentElement.res b/src/orca-loader/LoaderPaymentElement.res index 028e50132..1c2bf6151 100644 --- a/src/orca-loader/LoaderPaymentElement.res +++ b/src/orca-loader/LoaderPaymentElement.res @@ -281,6 +281,10 @@ let make = ( ("options", options), ]->Dict.fromArray, ) + let fullScreenEle = Window.querySelector(`#orca-fullscreen`) + fullScreenEle->Window.iframePostMessage( + [("metadata", fullscreenMetadata.contents)]->Dict.fromArray, + ) } } addSmartEventListener( From a5143113ce41e7a9c1f1caf4c67631d0dfbb27e0 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Wed, 18 Sep 2024 11:01:47 +0530 Subject: [PATCH 02/15] fix: some issues --- src/Payments/PaymentMethodsRecord.res | 2 +- src/Payments/SepaBankDebit.res | 14 +++----- src/Utilities/DynamicFieldsUtils.res | 1 - src/Utilities/PaymentHelpers.res | 51 +++++++++++++++++++++++---- src/orca-loader/Elements.res | 5 ++- 5 files changed, 55 insertions(+), 18 deletions(-) diff --git a/src/Payments/PaymentMethodsRecord.res b/src/Payments/PaymentMethodsRecord.res index ff45a80b3..6c40fb137 100644 --- a/src/Payments/PaymentMethodsRecord.res +++ b/src/Payments/PaymentMethodsRecord.res @@ -1030,7 +1030,7 @@ let itemToObjMapper = dict => { "collect_billing_details_from_wallets", true, ), - is_tax_calculation_enabled: getBool(dict,"is_tax_calculation_enabled",false) + is_tax_calculation_enabled: getBool(dict, "is_tax_calculation_enabled", false), } } diff --git a/src/Payments/SepaBankDebit.res b/src/Payments/SepaBankDebit.res index a6378021d..81ff70dfb 100644 --- a/src/Payments/SepaBankDebit.res +++ b/src/Payments/SepaBankDebit.res @@ -94,17 +94,15 @@ let make = (~paymentType: CardThemeType.mode) => { }, (email, fullName, modalData, isManualRetryEnabled)) useSubmitPaymentData(submitCallback) - { - if isVerifyPMAuthConnectorConfigured { - - } else { -
+ :
- - + // + // @@ -112,8 +110,6 @@ let make = (~paymentType: CardThemeType.mode) => {
- } - } } let default = make diff --git a/src/Utilities/DynamicFieldsUtils.res b/src/Utilities/DynamicFieldsUtils.res index 2866c7c7d..51890eda7 100644 --- a/src/Utilities/DynamicFieldsUtils.res +++ b/src/Utilities/DynamicFieldsUtils.res @@ -557,7 +557,6 @@ let useRequiredFieldsBody = ( | ShippingAddressPincode | ShippingAddressState | ShippingAddressCountry(_) - | BankAccountNumber | None => "" } } diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index 58b5376df..799326cda 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -1978,7 +1978,7 @@ let fetchPaymentMethodList = ( "payment_method": "bank_debit", "payment_method_types": [ { - "payment_method_type": "sepa", + "payment_method_type": "becs", "payment_experience": [ { "payment_experience_type": "redirect_to_url", @@ -1994,26 +1994,65 @@ let fetchPaymentMethodList = ( "required_field": "payment_method_data.billing.address.first_name", "display_name": "owner_name", "field_type": "user_billing_name", - // "value": "joseph", + "value": null, + }, + "payment_method_data.bank_debit.bacs.account_number": { + "required_field": "payment_method_data.bank_debit.bacs.account_number", + "display_name": "bank_account_number", + "field_type": "user_bank_account_number", "value": null, }, "billing.address.last_name": { "required_field": "payment_method_data.billing.address.last_name", "display_name": "owner_name", "field_type": "user_billing_name", - // "value": "Doe", "value": null, }, + "payment_method_data.bank_debit.bacs.sort_code": { + "required_field": "payment_method_data.bank_debit.bacs.sort_code", + "display_name": "bank_sort_code", + "field_type": "text", + "value": null, + }, + }, + "surcharge_details": null, + "pm_auth_connector": null, + }->Identity.anyTypeToJson, + { + "payment_method_type": "sepa", + "payment_experience": [ + { + "payment_experience_type": "redirect_to_url", + "eligible_connectors": ["adyen"], + }, + ], + "card_networks": null, + "bank_names": null, + "bank_debits": null, + "bank_transfers": null, + "required_fields": { "payment_method_data.bank_debit.sepa.iban": { - "required_field": "payment_method_data.bank_debit.bacs.iban", - "display_name": "bank_account_number", + "required_field": "payment_method_data.bank_debit.sepa.iban", + "display_name": "iban", "field_type": "user_bank_account_number", "value": null, }, + "billing.address.first_name": { + "required_field": "payment_method_data.billing.address.first_name", + "display_name": "owner_name", + "field_type": "user_billing_name", + "value": null, + }, + "billing.address.last_name": { + "required_field": "payment_method_data.billing.address.last_name", + "display_name": "owner_name", + "field_type": "user_billing_name", + "value": null, + }, }, "surcharge_details": null, "pm_auth_connector": null, - }, + }->Identity.anyTypeToJson, ], }->Identity.anyTypeToJson, ], diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 70195b62c..ec50fbc18 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -774,7 +774,10 @@ let make = ( switch ( dict->Dict.get("applePayButtonClicked"), dict->Dict.get("applePayPaymentRequest"), - dict->Dict.get("isTaxCalculationEnabled")->Option.flatMap(JSON.Decode.bool)->Option.getOr(false), + dict + ->Dict.get("isTaxCalculationEnabled") + ->Option.flatMap(JSON.Decode.bool) + ->Option.getOr(false), ) { | (Some(val), Some(paymentRequest), isTaxCalculationEnabled) => if val->JSON.Decode.bool->Option.getOr(false) { From 96b6c8ad86ddb2a70ce05f0091ca742de5c272c1 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Wed, 18 Sep 2024 16:01:45 +0530 Subject: [PATCH 03/15] fix: response fix --- src/Utilities/PaymentHelpers.res | 589 +------------------------------ 1 file changed, 1 insertion(+), 588 deletions(-) diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index 799326cda..af404ea10 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -1479,594 +1479,7 @@ let fetchPaymentMethodList = ( ~logType=INFO, ~logCategory=API, ) - let val = { - "redirect_url": null, - "currency": "USD", - "payment_methods": [ - { - "payment_method": "wallet", - "payment_method_types": [ - { - "payment_method_type": "apple_pay", - "payment_experience": [ - { - "payment_experience_type": "invoke_sdk_client", - "eligible_connectors": ["cybersource"], - }, - ], - "card_networks": null, - "bank_names": null, - "bank_debits": null, - "bank_transfers": null, - "required_fields": { - "billing.address.first_name": { - "required_field": "payment_method_data.billing.address.first_name", - "display_name": "billing_first_name", - "field_type": "user_billing_name", - "value": "joseph", - }, - "billing.address.zip": { - "required_field": "payment_method_data.billing.address.zip", - "display_name": "zip", - "field_type": "user_address_pincode", - "value": "94122", - }, - "billing.address.last_name": { - "required_field": "payment_method_data.billing.address.last_name", - "display_name": "billing_last_name", - "field_type": "user_billing_name", - "value": "Doe", - }, - "email": { - "required_field": "email", - "display_name": "email", - "field_type": "user_email_address", - "value": "hyperswitch_sdk_demo_id@gmail.com", - }, - "billing.address.country": { - "required_field": "payment_method_data.billing.address.country", - "display_name": "country", - "field_type": { - "user_address_country": { - "options": ["ALL"], - }, - }, - "value": "US", - }, - "billing.address.city": { - "required_field": "payment_method_data.billing.address.city", - "display_name": "city", - "field_type": "user_address_city", - "value": "San Fransico", - }, - "billing.address.state": { - "required_field": "payment_method_data.billing.address.state", - "display_name": "state", - "field_type": "user_address_state", - "value": "California", - }, - "billing.address.line1": { - "required_field": "payment_method_data.billing.address.line1", - "display_name": "line1", - "field_type": "user_address_line1", - "value": "1467", - }, - }, - "surcharge_details": null, - "pm_auth_connector": null, - }->Identity.anyTypeToJson, - { - "payment_method_type": "google_pay", - "payment_experience": [ - { - "payment_experience_type": "invoke_sdk_client", - "eligible_connectors": ["cybersource"], - }, - ], - "card_networks": null, - "bank_names": null, - "bank_debits": null, - "bank_transfers": null, - "required_fields": { - "billing.address.zip": { - "required_field": "payment_method_data.billing.address.zip", - "display_name": "zip", - "field_type": "user_address_pincode", - "value": "94122", - }, - "billing.address.country": { - "required_field": "payment_method_data.billing.address.country", - "display_name": "country", - "field_type": { - "user_address_country": { - "options": ["ALL"], - }, - }, - "value": "US", - }, - "billing.address.last_name": { - "required_field": "payment_method_data.billing.address.last_name", - "display_name": "billing_last_name", - "field_type": "user_billing_name", - "value": "Doe", - }, - "email": { - "required_field": "email", - "display_name": "email", - "field_type": "user_email_address", - "value": "hyperswitch_sdk_demo_id@gmail.com", - }, - "billing.address.state": { - "required_field": "payment_method_data.billing.address.state", - "display_name": "state", - "field_type": "user_address_state", - "value": "California", - }, - "billing.address.city": { - "required_field": "payment_method_data.billing.address.city", - "display_name": "city", - "field_type": "user_address_city", - "value": "San Fransico", - }, - "billing.address.first_name": { - "required_field": "payment_method_data.billing.address.first_name", - "display_name": "billing_first_name", - "field_type": "user_billing_name", - "value": "joseph", - }, - "billing.address.line1": { - "required_field": "payment_method_data.billing.address.line1", - "display_name": "line1", - "field_type": "user_address_line1", - "value": "1467", - }, - }, - "surcharge_details": null, - "pm_auth_connector": null, - }->Identity.anyTypeToJson, - { - "payment_method_type": "paypal", - "payment_experience": [ - { - "payment_experience_type": "redirect_to_url", - "eligible_connectors": ["paypal"], - }, - { - "payment_experience_type": "invoke_sdk_client", - "eligible_connectors": ["paypal"], - }, - ], - "card_networks": null, - "bank_names": null, - "bank_debits": null, - "bank_transfers": null, - "required_fields": null, - "surcharge_details": null, - "pm_auth_connector": null, - }->Identity.anyTypeToJson, - ], - }->Identity.anyTypeToJson, - { - "payment_method": "pay_later", - "payment_method_types": [ - { - "payment_method_type": "klarna", - "payment_experience": [ - { - "payment_experience_type": "invoke_sdk_client", - "eligible_connectors": ["klarna"], - }, - ], - "card_networks": null, - "bank_names": null, - "bank_debits": null, - "bank_transfers": null, - "required_fields": { - "billing.address.country": { - "required_field": "payment_method_data.billing.address.country", - "display_name": "country", - "field_type": { - "user_address_country": { - "options": [ - "AU", - "AT", - "BE", - "CA", - "CZ", - "DK", - "FI", - "FR", - "DE", - "GR", - "IE", - "IT", - "NL", - "NZ", - "NO", - "PL", - "PT", - "ES", - "SE", - "CH", - "GB", - "US", - ], - }, - }, - "value": "US", - }, - }, - "surcharge_details": null, - "pm_auth_connector": null, - }, - ], - }->Identity.anyTypeToJson, - { - "payment_method": "card", - "payment_method_types": [ - { - "payment_method_type": "debit", - "payment_experience": null, - "card_networks": [ - { - "card_network": "UnionPay", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "Visa", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "CartesBancaires", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "Mastercard", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "JCB", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "DinersClub", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "Interac", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "AmericanExpress", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "Discover", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - ], - "bank_names": null, - "bank_debits": null, - "bank_transfers": null, - "required_fields": { - "payment_method_data.card.card_cvc": { - "required_field": "payment_method_data.card.card_cvc", - "display_name": "card_cvc", - "field_type": "user_card_cvc", - "value": null, - }, - "billing.address.state": { - "required_field": "payment_method_data.billing.address.state", - "display_name": "state", - "field_type": "user_address_state", - "value": "California", - }, - "email": { - "required_field": "email", - "display_name": "email", - "field_type": "user_email_address", - "value": "hyperswitch_sdk_demo_id@gmail.com", - }, - "billing.address.first_name": { - "required_field": "payment_method_data.billing.address.first_name", - "display_name": "card_holder_name", - "field_type": "user_full_name", - "value": "joseph", - }, - "payment_method_data.card.card_exp_year": { - "required_field": "payment_method_data.card.card_exp_year", - "display_name": "card_exp_year", - "field_type": "user_card_expiry_year", - "value": null, - }, - "billing.address.country": { - "required_field": "payment_method_data.billing.address.country", - "display_name": "country", - "field_type": { - "user_address_country": { - "options": ["ALL"], - }, - }, - "value": "US", - }, - "billing.address.line1": { - "required_field": "payment_method_data.billing.address.line1", - "display_name": "line1", - "field_type": "user_address_line1", - "value": "1467", - }, - "billing.address.zip": { - "required_field": "payment_method_data.billing.address.zip", - "display_name": "zip", - "field_type": "user_address_pincode", - "value": "94122", - }, - "billing.address.last_name": { - "required_field": "payment_method_data.billing.address.last_name", - "display_name": "card_holder_name", - "field_type": "user_full_name", - "value": "Doe", - }, - "payment_method_data.card.card_number": { - "required_field": "payment_method_data.card.card_number", - "display_name": "card_number", - "field_type": "user_card_number", - "value": null, - }, - "payment_method_data.card.card_exp_month": { - "required_field": "payment_method_data.card.card_exp_month", - "display_name": "card_exp_month", - "field_type": "user_card_expiry_month", - "value": null, - }, - "billing.address.city": { - "required_field": "payment_method_data.billing.address.city", - "display_name": "city", - "field_type": "user_address_city", - "value": "San Fransico", - }, - }, - "surcharge_details": null, - "pm_auth_connector": null, - }->Identity.anyTypeToJson, - { - "payment_method_type": "credit", - "payment_experience": null, - "card_networks": [ - { - "card_network": "UnionPay", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "JCB", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "Visa", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "Interac", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "AmericanExpress", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "DinersClub", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "Discover", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "Mastercard", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - { - "card_network": "CartesBancaires", - "surcharge_details": null, - "eligible_connectors": ["bankofamerica", "cybersource"], - }, - ], - "bank_names": null, - "bank_debits": null, - "bank_transfers": null, - "required_fields": { - "billing.address.last_name": { - "required_field": "payment_method_data.billing.address.last_name", - "display_name": "card_holder_name", - "field_type": "user_full_name", - "value": "Doe", - }, - "payment_method_data.card.card_number": { - "required_field": "payment_method_data.card.card_number", - "display_name": "card_number", - "field_type": "user_card_number", - "value": null, - }, - "payment_method_data.card.card_cvc": { - "required_field": "payment_method_data.card.card_cvc", - "display_name": "card_cvc", - "field_type": "user_card_cvc", - "value": null, - }, - "billing.address.country": { - "required_field": "payment_method_data.billing.address.country", - "display_name": "country", - "field_type": { - "user_address_country": { - "options": ["ALL"], - }, - }, - "value": "US", - }, - "billing.address.first_name": { - "required_field": "payment_method_data.billing.address.first_name", - "display_name": "card_holder_name", - "field_type": "user_full_name", - "value": "joseph", - }, - "billing.address.state": { - "required_field": "payment_method_data.billing.address.state", - "display_name": "state", - "field_type": "user_address_state", - "value": "California", - }, - "payment_method_data.card.card_exp_year": { - "required_field": "payment_method_data.card.card_exp_year", - "display_name": "card_exp_year", - "field_type": "user_card_expiry_year", - "value": null, - }, - "billing.address.city": { - "required_field": "payment_method_data.billing.address.city", - "display_name": "city", - "field_type": "user_address_city", - "value": "San Fransico", - }, - "billing.address.zip": { - "required_field": "payment_method_data.billing.address.zip", - "display_name": "zip", - "field_type": "user_address_pincode", - "value": "94122", - }, - "email": { - "required_field": "email", - "display_name": "email", - "field_type": "user_email_address", - "value": "hyperswitch_sdk_demo_id@gmail.com", - }, - "payment_method_data.card.card_exp_month": { - "required_field": "payment_method_data.card.card_exp_month", - "display_name": "card_exp_month", - "field_type": "user_card_expiry_month", - "value": null, - }, - "billing.address.line1": { - "required_field": "payment_method_data.billing.address.line1", - "display_name": "line1", - "field_type": "user_address_line1", - "value": "1467", - }, - }, - "surcharge_details": null, - "pm_auth_connector": null, - }->Identity.anyTypeToJson, - ], - }->Identity.anyTypeToJson, - { - "payment_method": "bank_debit", - "payment_method_types": [ - { - "payment_method_type": "becs", - "payment_experience": [ - { - "payment_experience_type": "redirect_to_url", - "eligible_connectors": ["adyen"], - }, - ], - "card_networks": null, - "bank_names": null, - "bank_debits": null, - "bank_transfers": null, - "required_fields": { - "billing.address.first_name": { - "required_field": "payment_method_data.billing.address.first_name", - "display_name": "owner_name", - "field_type": "user_billing_name", - "value": null, - }, - "payment_method_data.bank_debit.bacs.account_number": { - "required_field": "payment_method_data.bank_debit.bacs.account_number", - "display_name": "bank_account_number", - "field_type": "user_bank_account_number", - "value": null, - }, - "billing.address.last_name": { - "required_field": "payment_method_data.billing.address.last_name", - "display_name": "owner_name", - "field_type": "user_billing_name", - "value": null, - }, - "payment_method_data.bank_debit.bacs.sort_code": { - "required_field": "payment_method_data.bank_debit.bacs.sort_code", - "display_name": "bank_sort_code", - "field_type": "text", - "value": null, - }, - }, - "surcharge_details": null, - "pm_auth_connector": null, - }->Identity.anyTypeToJson, - { - "payment_method_type": "sepa", - "payment_experience": [ - { - "payment_experience_type": "redirect_to_url", - "eligible_connectors": ["adyen"], - }, - ], - "card_networks": null, - "bank_names": null, - "bank_debits": null, - "bank_transfers": null, - "required_fields": { - "payment_method_data.bank_debit.sepa.iban": { - "required_field": "payment_method_data.bank_debit.sepa.iban", - "display_name": "iban", - "field_type": "user_bank_account_number", - "value": null, - }, - "billing.address.first_name": { - "required_field": "payment_method_data.billing.address.first_name", - "display_name": "owner_name", - "field_type": "user_billing_name", - "value": null, - }, - "billing.address.last_name": { - "required_field": "payment_method_data.billing.address.last_name", - "display_name": "owner_name", - "field_type": "user_billing_name", - "value": null, - }, - }, - "surcharge_details": null, - "pm_auth_connector": null, - }->Identity.anyTypeToJson, - ], - }->Identity.anyTypeToJson, - ], - "mandate_payment": null, - "merchant_name": "new", - "show_surcharge_breakup_screen": false, - "payment_type": "normal", - "request_external_three_ds_authentication": false, - "collect_shipping_details_from_wallets": false, - "collect_billing_details_from_wallets": false, - }->Identity.anyTypeToJson - // Fetch.Response.json(resp) - - val->resolve + Fetch.Response.json(resp) } }) ->catch(err => { From 8e750ae7d4a8a506d6514bcd20a406b404430004 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Thu, 19 Sep 2024 21:34:17 +0530 Subject: [PATCH 04/15] fix: iban added --- src/Components/DynamicFields.res | 5 ++- src/Payments/PaymentMethodsRecord.res | 2 + src/Utilities/DynamicFieldsUtils.res | 54 +++++++++++++++------------ 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/Components/DynamicFields.res b/src/Components/DynamicFields.res index 4eb125e7f..a34580993 100644 --- a/src/Components/DynamicFields.res +++ b/src/Components/DynamicFields.res @@ -470,7 +470,7 @@ let make = ( | PixKey => | PixCPF => | PixCNPJ => - | BankAccountNumber => + | BankAccountNumber | IBAN => { let value = ReactEvent.Form.target(ev)["value"] setBankAccountNumber(prev => { - isValid: value !== "" ? Some(true) : Some(false), + isValid: Some(value !== ""), value, errorString: value !== "" ? "" : prev.errorString, }) @@ -812,6 +812,7 @@ let make = ( | VpaId | LanguagePreference(_) | BankAccountNumber + | IBAN | None => React.null }}
diff --git a/src/Payments/PaymentMethodsRecord.res b/src/Payments/PaymentMethodsRecord.res index f8eecbe0e..d235c6bec 100644 --- a/src/Payments/PaymentMethodsRecord.res +++ b/src/Payments/PaymentMethodsRecord.res @@ -45,6 +45,7 @@ type paymentMethodsFields = | PixCNPJ | LanguagePreference(array) | BankAccountNumber + | IBAN let getPaymentMethodsFieldsOrder = paymentMethodField => { switch paymentMethodField { @@ -595,6 +596,7 @@ let getPaymentMethodsFieldTypeFromString = (str, isBancontact) => { | ("user_cnpj", _) => PixCNPJ | ("user_pix_key", _) => PixKey | ("user_bank_account_number", _) => BankAccountNumber + | ("user_iban", _) => BankAccountNumber | _ => None } } diff --git a/src/Utilities/DynamicFieldsUtils.res b/src/Utilities/DynamicFieldsUtils.res index 51890eda7..e3ec18962 100644 --- a/src/Utilities/DynamicFieldsUtils.res +++ b/src/Utilities/DynamicFieldsUtils.res @@ -174,7 +174,9 @@ let useRequiredFieldsEmptyAndValid = ( | PixCNPJ => pixCNPJ.isValid->Option.getOr(false) | PixCPF => pixCPF.isValid->Option.getOr(false) | PixKey => pixKey.isValid->Option.getOr(false) - | BankAccountNumber => bankAccountNumber.value !== "" + | BankAccountNumber + | IBAN => + bankAccountNumber.value !== "" | _ => true } }) @@ -223,7 +225,9 @@ let useRequiredFieldsEmptyAndValid = ( let (month, year) = getExpiryDates(cardExpiry) month === "" || year === "" || cvcNumber === "" | DateOfBirth => dateOfBirth->Js.Nullable.isNullable - | BankAccountNumber => bankAccountNumber.value === "" + | BankAccountNumber + | IBAN => + bankAccountNumber.value === "" | _ => false } }) @@ -237,26 +241,25 @@ let useRequiredFieldsEmptyAndValid = ( billingName.value, line1.value, dateOfBirth, - ( - email, - vpaId, - line2.value, - selectedBank, - phone.value, - city.value, - postalCode, - state.value, - blikCode.value, - pixCNPJ.value, - pixKey.value, - pixCPF.value, - isCardValid, - isExpiryValid, - isCVCValid, - cardNumber, - cardExpiry, - cvcNumber, - ), + email, + vpaId, + line2.value, + selectedBank, + phone.value, + city.value, + postalCode, + state.value, + blikCode.value, + pixCNPJ.value, + pixKey.value, + pixCPF.value, + isCardValid, + isExpiryValid, + isCVCValid, + cardNumber, + cardExpiry, + cvcNumber, + bankAccountNumber, )) } @@ -431,6 +434,7 @@ let useSetInitialRequiredFields = ( } | None => () } + | IBAN | BankAccountNumber => setFields(setBankAccountNumber, bankAccountNumber, requiredField, false) | LanguagePreference(_) @@ -542,7 +546,9 @@ let useRequiredFieldsBody = ( | PixCNPJ => pixCNPJ.value | PixCPF => pixCPF.value | PixKey => pixKey.value - | BankAccountNumber => bankAccountNumber.value + | IBAN + | BankAccountNumber => + bankAccountNumber.value | StateAndCity | CountryAndPincode(_) | SpecialField(_) @@ -643,6 +649,7 @@ let useRequiredFieldsBody = ( selectedBank, cryptoCurrencyNetworks, dateOfBirth, + bankAccountNumber, )) } @@ -662,6 +669,7 @@ let isFieldTypeToRenderOutsideBilling = (fieldType: PaymentMethodsRecord.payment | DateOfBirth | Currency(_) | VpaId + | IBAN | BankAccountNumber => true | _ => false } From 8a85f8822c8c38bc25a079722f8f81fdbd5b43d4 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Fri, 20 Sep 2024 12:07:38 +0530 Subject: [PATCH 05/15] fix: some more changes --- src/Components/PayNowButton.res | 12 +++++-- src/Payments/BankDebitModal.res | 14 +++++++- src/Payments/PaymentMethodsWrapper.res | 14 +++++--- src/Payments/SepaBankDebit.res | 47 ++++++++++++++------------ src/Utilities/DynamicFieldsUtils.res | 1 + 5 files changed, 58 insertions(+), 30 deletions(-) diff --git a/src/Components/PayNowButton.res b/src/Components/PayNowButton.res index b2f6edd0b..d43fe7c21 100644 --- a/src/Components/PayNowButton.res +++ b/src/Components/PayNowButton.res @@ -10,7 +10,7 @@ module Loader = { } } @react.component -let make = () => { +let make = (~onClickHandler=?) => { open RecoilAtoms open Utils let (showLoader, setShowLoader) = React.useState(() => false) @@ -21,7 +21,6 @@ let make = () => { let confirmPayload = sdkHandleConfirmPayment->PaymentBody.confirmPayloadForSDKButton let buttonText = sdkHandleConfirmPayment.buttonText->Option.getOr(localeString.payNowButton) - let handleMessage = (event: Types.event) => { let json = event.data->Identity.anyTypeToJson->getStringFromJson("")->safeParse let dict = json->getDictFromJson @@ -35,6 +34,13 @@ let make = () => { } } + let onClickHandlerFunc = _ => { + switch onClickHandler { + | Some(fn) => fn() + | None => () + } + } + let handleOnClick = _ => { setIsPayNowButtonDisable(_ => true) setShowLoader(_ => true) @@ -45,7 +51,7 @@ let make = () => {
+ +
+ +
+ +
+
+ +
+ {React.string("BSB")} +
+ +
+