From 10bc54c0b3309b972c3853427f2edd3e26483bee Mon Sep 17 00:00:00 2001 From: Vrishab Srivatsa <136090360+vsrivatsa-juspay@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:36:03 +0530 Subject: [PATCH 1/3] feat: demo fixes customer id and retrieve request by client secret (#29) Co-authored-by: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> --- .../HyperSwitch/SDKPayment/SDKPaymentTypes.res | 1 + .../HyperSwitch/SDKPayment/SDKPaymentUtils.res | 2 ++ .../HyperSwitch/SDKPayment/TestPayment.res | 1 + src/screens/HyperSwitch/SDKPayment/WebSDK.res | 15 +++++---------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res b/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res index 6ab6149af..546b37b09 100644 --- a/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res +++ b/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res @@ -2,4 +2,5 @@ type paymentType = { amount: int, currency: string, profile_id: string, + customer_id: string, } diff --git a/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res b/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res index ef663a6c5..14184cbdc 100644 --- a/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res +++ b/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res @@ -2,6 +2,7 @@ let initialValueForForm: string => SDKPaymentTypes.paymentType = profileId => { amount: 100, currency: "United States-USD", profile_id: profileId, + customer_id: "hyperswitch_sdk_demo_id", } let getTypedValueForPayment: Js.Json.t => SDKPaymentTypes.paymentType = values => { @@ -11,6 +12,7 @@ let getTypedValueForPayment: Js.Json.t => SDKPaymentTypes.paymentType = values = amount: dictOfValues->getInt("amount", 100), currency: dictOfValues->getString("currency", "United States-USD"), profile_id: dictOfValues->getString("profile_id", ""), + customer_id: dictOfValues->getString("customer_id", ""), } } diff --git a/src/screens/HyperSwitch/SDKPayment/TestPayment.res b/src/screens/HyperSwitch/SDKPayment/TestPayment.res index 6426605ed..b10d705ca 100644 --- a/src/screens/HyperSwitch/SDKPayment/TestPayment.res +++ b/src/screens/HyperSwitch/SDKPayment/TestPayment.res @@ -45,6 +45,7 @@ let make = ( ->Js.Json.number, ), ("profile_id", initialValues.profile_id->Js.Json.string), + ("customer_id", "hyperswitch_sdk_demo_id"->Js.Json.string), ])->Js.Json.object_ let response = await updateDetails(url, body, Post) let clientSecret = response->getDictFromJsonObject->getOptionString("client_secret") diff --git a/src/screens/HyperSwitch/SDKPayment/WebSDK.res b/src/screens/HyperSwitch/SDKPayment/WebSDK.res index bb2be9d4f..a9a0785c6 100644 --- a/src/screens/HyperSwitch/SDKPayment/WebSDK.res +++ b/src/screens/HyperSwitch/SDKPayment/WebSDK.res @@ -215,16 +215,11 @@ module CheckoutForm = { ->ignore } React.useEffect1(() => { - let id = Js.String2.split(clientSecret, "_secret_")[0]->Belt.Option.getWithDefault("") - switch Some(id) { - | None | Some("") => () - | Some(id) => - hyper.retrievePaymentIntent(id) - ->then(_ => { - resolve() - }) - ->ignore - } + hyper.retrievePaymentIntent(clientSecret) + ->then(_ => { + resolve() + }) + ->ignore None }, [hyper]) From 3f7d40beac8ad006c1a29e966a5d0c8f1bc5e953 Mon Sep 17 00:00:00 2001 From: Lokesh Jain <56452497+jainlokesh318@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:47:46 +0530 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20donot=20show=20stripe=20paypal=20Tes?= =?UTF-8?q?tCompletion=20on=20just=20connection=20of=20st=E2=80=A6=20(#41)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lokesh Jain Co-authored-by: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> --- config/FeatureFlag.json | 2 +- src/screens/HyperSwitch/HSwitchUtils.res | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/FeatureFlag.json b/config/FeatureFlag.json index d08069294..bf3795e0c 100644 --- a/config/FeatureFlag.json +++ b/config/FeatureFlag.json @@ -22,4 +22,4 @@ "mixpanel": false, "business_profile": false, "generate_report": false -} +} \ No newline at end of file diff --git a/src/screens/HyperSwitch/HSwitchUtils.res b/src/screens/HyperSwitch/HSwitchUtils.res index 509b29e30..cdeb685ff 100644 --- a/src/screens/HyperSwitch/HSwitchUtils.res +++ b/src/screens/HyperSwitch/HSwitchUtils.res @@ -480,7 +480,8 @@ module CardLoader = { let checkStripePlusPayPal = (enumDetails: QuickStartTypes.responseType) => { enumDetails.stripeConnected.processorID->Js.String2.length > 0 && - enumDetails.paypalConnected.processorID->Js.String2.length > 0 + enumDetails.paypalConnected.processorID->Js.String2.length > 0 && + enumDetails.sPTestPayment ? true : false } From e8ff5478637979141abda31a8ae6ed2f1db73e05 Mon Sep 17 00:00:00 2001 From: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> Date: Thu, 30 Nov 2023 18:37:28 +0530 Subject: [PATCH 3/3] feat: Add forgot password feature flag (#40) --- config/FeatureFlag.json | 4 +- .../hyperswitch/FeatureFlagUtils.res | 8 ++-- .../HyperSwitch/Settings/HSwitchSettings.res | 2 + .../HSwitchLoginFlow/HyperSwitchAuth.res | 40 ++++++++++--------- .../HSwitchLoginFlow/HyperSwitchAuthForm.res | 4 +- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/config/FeatureFlag.json b/config/FeatureFlag.json index bf3795e0c..bbe5ac822 100644 --- a/config/FeatureFlag.json +++ b/config/FeatureFlag.json @@ -7,7 +7,6 @@ "stripe_plus_paypal": false, "woocommerce": false, "open_sdk": false, - "home_page": false, "switch_merchant": false, "audit_trail": false, "system_metrics": false, @@ -21,5 +20,6 @@ "verify_connector": false, "mixpanel": false, "business_profile": false, - "generate_report": false + "generate_report": false, + "forgot_password": false } \ No newline at end of file diff --git a/src/entryPoints/hyperswitch/FeatureFlagUtils.res b/src/entryPoints/hyperswitch/FeatureFlagUtils.res index 1236a653e..150c8cff9 100644 --- a/src/entryPoints/hyperswitch/FeatureFlagUtils.res +++ b/src/entryPoints/hyperswitch/FeatureFlagUtils.res @@ -1,4 +1,5 @@ type featureFlag = { + default: bool, productionAccess: bool, testLiveToggle: bool, magicLink: bool, @@ -6,7 +7,6 @@ type featureFlag = { stripePlusPayPal: bool, wooCommerce: bool, openSDK: bool, - homePage: bool, switchMerchant: bool, testLiveMode: option, auditTrail: bool, @@ -22,13 +22,14 @@ type featureFlag = { businessProfile: bool, mixPanel: bool, verifyConnector: bool, - default: bool, + forgetPassword: bool, } let featureFlagType = (featureFlags: Js.Json.t) => { open LogicUtils let dict = featureFlags->getDictFromJsonObject let typedFeatureFlag: featureFlag = { + default: dict->getBool("default", true), productionAccess: dict->getBool("production_access", false), testLiveToggle: dict->getBool("test_live_toggle", false), magicLink: dict->getBool("magic_link", false), @@ -36,7 +37,6 @@ let featureFlagType = (featureFlags: Js.Json.t) => { stripePlusPayPal: dict->getBool("stripe_plus_paypal", false), wooCommerce: dict->getBool("woocommerce", false), openSDK: dict->getBool("open_sdk", false), - homePage: dict->getBool("home_page", false), switchMerchant: dict->getBool("switch_merchant", false), testLiveMode: dict->getOptionBool("test_live_mode"), auditTrail: dict->getBool("audit_trail", false), @@ -52,7 +52,7 @@ let featureFlagType = (featureFlags: Js.Json.t) => { businessProfile: dict->getBool("business_profile", false), mixPanel: dict->getBool("mixpanel", false), verifyConnector: dict->getBool("verify_connector", false), - default: dict->getBool("default", true), + forgetPassword: dict->getBool("forgot_password", false), } typedFeatureFlag } diff --git a/src/screens/HyperSwitch/Settings/HSwitchSettings.res b/src/screens/HyperSwitch/Settings/HSwitchSettings.res index c670f3a61..8788dd6f8 100644 --- a/src/screens/HyperSwitch/Settings/HSwitchSettings.res +++ b/src/screens/HyperSwitch/Settings/HSwitchSettings.res @@ -160,6 +160,8 @@ module PersonalSettings = { ->FeatureFlagUtils.featureFlagType let personalSettings = if featureFlagDetails.sampleData { [businessSettings, businessUnits, deleteSampleData] + } else if featureFlagDetails.businessProfile { + [businessSettings, businessUnits] } else { [businessSettings] } diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res index 04ecd6c63..b410f0949 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res @@ -15,7 +15,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, let showToast = ToastState.useShowToast() let updateDetails = useUpdateMethod(~showErrorToast=false, ()) let (email, setEmail) = React.useState(_ => "") - let {magicLink: isMagicLinkEnabled} = + let {magicLink: isMagicLinkEnabled, forgetPassword} = HyperswitchAtom.featureFlagAtom ->Recoil.useRecoilValueFromAtom ->LogicUtils.safeParse @@ -139,9 +139,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, } } - let onSubmit = (values, _) => { - open Promise - + let onSubmit = async (values, _) => { let valuesDict = values->getDictFromJsonObject let email = valuesDict->getString("email", "") setEmail(_ => email) @@ -151,39 +149,44 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, | (true, SignUP) | (true, LoginWithEmail) => { let body = getEmailBody(email, ~country, ()) - getUserWithEmail(body) + getUserWithEmail(body)->ignore } - | (true, ForgetPassword) => - let body = email->getEmailBody() - - setForgetPassword(body) | (true, ResendVerifyEmail) => let body = email->getEmailBody() - resendVerifyEmail(body) + resendVerifyEmail(body)->ignore | (false, SignUP) => { let password = getString(valuesDict, "password", "") let body = getEmailPasswordBody(email, password, country) - getUserWithEmailPassword(body, email) + getUserWithEmailPassword(body, email)->ignore } | (_, LoginWithPassword) => { let password = getString(valuesDict, "password", "") let body = getEmailPasswordBody(email, password, country) - getUserWithEmailPassword(body, email) + getUserWithEmailPassword(body, email)->ignore } | (_, ResetPassword) => { let queryDict = url.search->getDictFromUrlSearchParams let password_reset_token = queryDict->Js.Dict.get("token")->Belt.Option.getWithDefault("") let password = getString(valuesDict, "create_password", "") let body = getResetpasswordBodyJson(password, password_reset_token) - setResetPassword(body) + setResetPassword(body)->ignore } - | _ => Js.Nullable.null->resolve + | _ => () + } + + switch (forgetPassword, authType) { + | (true, ForgetPassword) => + let body = email->getEmailBody() + + setForgetPassword(body)->ignore + | _ => () } + Js.Nullable.null } let resendEmail = () => { @@ -234,14 +237,13 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, onSubmit={handleSubmit} className={`flex flex-col justify-evenly gap-5 h-full w-full !overflow-visible text-grey-600`}> {switch authType { - | LoginWithPassword => + | LoginWithPassword => | LoginWithEmail - | ForgetPassword + | ForgetPassword => + forgetPassword ? : React.null | ResendVerifyEmail | SignUP => - isMagicLinkEnabled - ? - : + isMagicLinkEnabled ? : | ResetPassword => | MagicLinkEmailSent | ForgetPasswordEmailSent | ResendVerifyEmailSent => diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res index ee11b82ac..c4e0885ef 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res @@ -3,12 +3,12 @@ let fieldWrapperClass = "w-full flex flex-col" let labelClass = "!text-black !font-medium" module EmailPasswordForm = { @react.component - let make = (~setAuthType, ~isMagicLinkEnabled) => { + let make = (~setAuthType, ~forgetPassword) => {
- +