Skip to content

Commit

Permalink
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Browse files Browse the repository at this point in the history
…nto HCC-929-removed-metadata-from-3-ds-bugfixes
  • Loading branch information
Riddhi Agrawal committed Dec 5, 2023
2 parents 10fce27 + b220415 commit 1422f4c
Show file tree
Hide file tree
Showing 23 changed files with 21 additions and 355 deletions.
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,6 @@ The `production_access` feature flag enables a flow for users to request live pr

The `quick_start` feature flag enables the simplified onboarding flow for new users, where he connects to processors, configure payment routing and testing a payment, all in one flow.

#### Stripe plus paypal

The `stripe_plus_paypal` feature flag enables access to simplified multi-processor connectivity through Stripe and PayPal. When turned on, users are guided through a streamlined setup flow to connect both Stripe and PayPal accounts and experience it in a checkout page.

#### Woocommerce

The `woocommerce` feature flag controls the visibility of WooCommerce integration with Hyperswitch flow within the dashboard. When enabled, users will have access to the step-by-step guide to integrate the woocommerce plugin for hyperswitch.

#### Open SDK

The `open_sdk` feature flag enables access to the Checkout Page web SDK from within the dashboard. When enabled, developers can preview the SDK from within the dashboard and make payments.
Expand Down
2 changes: 0 additions & 2 deletions config/FeatureFlag.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"magic_link": false,
"production_access": false,
"quick_start": false,
"stripe_plus_paypal": false,
"woocommerce": false,
"open_sdk": false,
"switch_merchant": false,
"audit_trail": false,
Expand Down
16 changes: 5 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,18 @@
"author": "Shiva Nandan <[email protected]>",
"license": "MIT",
"scripts": {
"setup-env": "chmod +x ./replace_env.sh && ./replace_env.sh",
"pre-commit": "bash .githooks/commit-msg",
"start": "chmod +x ./replace_env.sh && ./replace_env.sh && cp env-config.js ./public/hyperswitch && APP_VERSION=$npm_package_version && appName=hyperswitch webpack serve --config webpack.dev.js",
"start:server_compiler": "webpack --config webpack.server.js --watch",
"start": "npm run setup-env && cp env-config.js ./public/hyperswitch && APP_VERSION=$npm_package_version && appName=hyperswitch webpack serve --config webpack.dev.js",
"serve": "npm run setup-env && cp env-config.js ./dist/hyperswitch && node dist/server/server.js",
"prod:start": "webpack serve --config webpack.dev.js",
"build:prod": "chmod +x ./replace_env.sh && ./replace_env.sh && cp env-config.js ./public/hyperswitch && APP_VERSION=$npm_package_version && webpack --config webpack.prod.js",
"ssr_sript_build": "BRANCH_NAME=ssr webpack --config webpack.prod.js",
"ssr_run_server": "node --watch dist/server/server.js",
"build:netlify": "webpack --config webpack.prod.js --env netlifyHosted",
"build:test": "cd tests && npx rescript build -with-deps",
"build:prod": "npm run setup-env && cp env-config.js ./public/hyperswitch && APP_VERSION=$npm_package_version && webpack --config webpack.prod.js",
"re:build": "rescript",
"re:clean": "rescript clean",
"re:start": "rescript build -w",
"re:format": "rescript format -all",
"use-prod-ec": "mv public/_redirects_for_prod public/_redirects",
"serve": "chmod +x ./replace_env.sh && ./replace_env.sh && cp env-config.js ./dist/hyperswitch && node dist/server/server.js",
"build:test": "cd tests && npx rescript build -with-deps",
"clean:test": "cd tests && npx rescript clean -with-deps",
"unit:test": "cd tests && npx rescript build -with-deps && jest unit_test",
"revert:test": "cd tests && npx rescript clean -with-deps && cd .. && npx rescript build -with-deps",
"postinstall": "git config core.hooksPath .githooks && chmod +x .githooks/commit-msg"
},
"husky": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/LoadedTable.res
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ let make = (
? ""
: `${isMinHeightRequired ? noScrollbar ? "" : "overflow-x-scroll" : "overflow-scroll"}`
let loadedTable =
<div className={`no-scrollbar ${scrollBarClass} no-scrollbar`}>
<div className={`no-scrollbar ${scrollBarClass}`}>
{switch dataView {
| Table => {
let children =
Expand Down
13 changes: 6 additions & 7 deletions src/components/Loader.res
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,19 @@ let make = (
<div className={`${animationType} mb-10`}>
<Icon name="spinner" size customIconColor=customSpinnerIconColor />
</div>
{React.string(loadingText)}
{children}
</div>

<div className="flex flex-col">
<div className="w-full flex justify-center py-10">
<div className="w-20 h-16">
<div className="scale-400 pt-px">
<React.Suspense fallback={loader}>
<ErrorBoundary>
<React.Suspense fallback={loader}>
<ErrorBoundary>
<div className="scale-400 pt-px">
<Lottie animationData={loaderLottieFile} autoplay=true loop=true />
</ErrorBoundary>
</React.Suspense>
</div>
</div>
</ErrorBoundary>
</React.Suspense>
</div>
</div>
</div>
Expand Down
4 changes: 0 additions & 4 deletions src/entryPoints/hyperswitch/FeatureFlagUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ type featureFlag = {
testLiveToggle: bool,
magicLink: bool,
quickStart: bool,
stripePlusPayPal: bool,
wooCommerce: bool,
openSDK: bool,
switchMerchant: bool,
testLiveMode: option<bool>,
Expand Down Expand Up @@ -34,8 +32,6 @@ let featureFlagType = (featureFlags: Js.Json.t) => {
testLiveToggle: dict->getBool("test_live_toggle", false),
magicLink: dict->getBool("magic_link", false),
quickStart: dict->getBool("quick_start", false),
stripePlusPayPal: dict->getBool("stripe_plus_paypal", false),
wooCommerce: dict->getBool("woocommerce", false),
openSDK: dict->getBool("open_sdk", false),
switchMerchant: dict->getBool("switch_merchant", false),
testLiveMode: dict->getOptionBool("test_live_mode"),
Expand Down
2 changes: 1 addition & 1 deletion src/entryPoints/hyperswitch/HyperSwitchApp.res
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ let make = () => {
</div>
</div>
<div
className="w-full h-screen overflow-x-scroll xl:overflow-x-hidden overflow-y-scroll ">
className="w-full h-screen overflow-x-scroll xl:overflow-x-hidden overflow-y-scroll">
<div
className="w-full h-full max-w-fixedPageWidth p-6 md:px-16 md:pb-16 pt-[3rem] overflow-scroll md:overflow-y-scroll md:overflow-x-hidden flex flex-col gap-10">
<ErrorBoundary>
Expand Down
4 changes: 1 addition & 3 deletions src/entryPoints/hyperswitch/HyperSwitchEntry.res
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ module HyperSwitchEntryComponent = {
(await postDetails(url, Js.Dict.empty()->Js.Json.object_, Post))->Js.Json.stringify
setFeatureFlag(._ => stringifiedResponse)
} catch {
| Js.Exn.Error(e) => {
let _err = Js.Exn.message(e)->Belt.Option.getWithDefault("Failed to Fetch!")
}
| _ => ()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/entryPoints/hyperswitch/SidebarValues.res
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ let reconTag = (recon, isReconEnabled) =>
: emptyComponent

let getHyperSwitchAppSidebars = (
~isReconEnabled=false,
~isReconEnabled: bool,
~featureFlagDetails: FeatureFlagUtils.featureFlag,
~userRole,
(),
Expand Down
6 changes: 1 addition & 5 deletions src/screens/HyperSwitch/Analytics/HSAnalyticsUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ let getStringListFromArrayDict = metrics => {
metrics->Js.Array2.map(item => item->getDictFromJsonObject->getString("name", ""))
}

let getCustomFormattedFloatDate = (floatDate, format) => {
floatDate->Js.Date.fromFloat->Js.Date.toISOString->Table.dateFormat(format)
}

module NoData = {
@react.component
let make = (~title, ~subTitle) => {
Expand Down Expand Up @@ -209,7 +205,7 @@ let generateTablePayload = (
~isIndustry: bool,
~mode: option<string>,
~customFilter,
~showDeltaMetrics=false,
~showDeltaMetrics,
~moduleName as _: string,
~source: string="BATCH",
(),
Expand Down
16 changes: 1 addition & 15 deletions src/screens/HyperSwitch/Developer/DeveloperUtils.res
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
open HSwitchSettingTypes
let titleClass = "md:font-bold font-semibold md:text-fs-16 text-fs-13 text-jp-gray-900 text-opacity-75 dark:text-white dark:text-opacity-75"

let paymentsEvents = ["succeeded", "failed", "processing", "action_required"]
let refundsEvents = ["succeeded", "failed"]
let disputesEvents = ["opened", "expired", "accepted", "cancelled", "challenged", "won", "lost"]

let webhookEventsDict =
[
("payment", paymentsEvents->Js.Array2.map(Js.Json.string)->Js.Json.array),
("refund", refundsEvents->Js.Array2.map(Js.Json.string)->Js.Json.array),
("dispute", disputesEvents->Js.Array2.map(Js.Json.string)->Js.Json.array),
]->Js.Dict.fromArray

let validateAPIKeyForm = (
values: Js.Json.t,
~setIsDisabled=_ => (),
keys: array<string>,
~setShowCustomDate=_ => (),
~setShowCustomDate,
(),
) => {
let errors = Js.Dict.empty()
Expand Down Expand Up @@ -81,7 +69,6 @@ let getRecordTypeFromString = value => {

type apiKey = {
key_id: string,
merchant_id: string,
name: string,
description: string,
prefix: string,
Expand All @@ -93,7 +80,6 @@ type apiKey = {
let itemToObjMapper = dict => {
open LogicUtils
{
merchant_id: getString(dict, "merchant_id", ""),
key_id: getString(dict, "key_id", ""),
name: getString(dict, "name", ""),
description: getString(dict, "description", ""),
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Developer/Webhooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let make = (~webhookOnly=false, ~showFormOnly=false, ~profileId="") => {
open HSwitchSettingTypes
HSwitchMerchantAccountUtils.validateMerchantAccountForm(
~values,
~setIsDisabled,
~setIsDisabled=Some(setIsDisabled),
~fieldsToValidate={
[WebhookUrl, ReturnUrl]->Js.Array2.filter(urlField =>
urlField === WebhookUrl || !webhookOnly
Expand Down
151 changes: 0 additions & 151 deletions src/screens/HyperSwitch/HSwitchUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -92,111 +92,13 @@ module ConnectorCustomCell = {
}
}
}
module HelpDeskSection = {
@react.component
let make = (~helpdeskModal, ~setHelpdeskModal) => {
let hyperswitchMixPanel = HSMixPanel.useSendEvent()
let url = RescriptReactRouter.useUrl()
let textStyle = "font-medium text-fs-14"
let {setShowFeedbackModal} = React.useContext(GlobalProvider.defaultContext)
let handleMixpanelEvents = eventName => {
[url.path->LogicUtils.getListHead, `global`]->Js.Array2.forEach(ele =>
hyperswitchMixPanel(~pageName=ele, ~contextName="helpdesk", ~actionName=eventName, ())
)
}
let handleFeedbackClicked = _ => {
setShowFeedbackModal(_ => true)
"submitfeedback"->handleMixpanelEvents
}

let hoverEffectStyle = "flex gap-3 cursor-pointer hover:border hover:border-blue-700 hover:rounded-md hover:!shadow-[0_0_4px_2px_rgba(0,_112,_255,_0.15)] p-3 border border-transparent"
<>
<UIUtils.RenderIf condition={helpdeskModal}>
<FramerMotion.Motion.Div
initial={{scale: 0.0}}
animate={{scale: 1.0}}
exit={{scale: 0.0}}
transition={{duration: 0.3}}
style={transformOrigin: "top"}
className="absolute top-14 right-0 bg-white p-4 border shadow-[-22px_-8px_41px_-15px_rgba(0,0,0,_0.25)] w-60 flex flex-col gap-2.5 z-10 rounded-md">
<div className=hoverEffectStyle onClick={_ => handleFeedbackClicked()}>
<Icon name="feedback" size=16 />
<p className=textStyle> {"Submit feedback"->React.string} </p>
</div>
<div
className=hoverEffectStyle
onClick={_ => {
"contactonslack"->handleMixpanelEvents
Window._open("https://hyperswitch-io.slack.com/ssb/redirect")
}}>
<Icon size=16 name="slack" />
<p className=textStyle> {"Connect on Slack"->React.string} </p>
</div>
<div
className=hoverEffectStyle
onClick={_ => {
"joindiscord"->handleMixpanelEvents
Window._open("https://discord.gg/an7gRdWkhw")
}}>
<Icon size=16 name="discord" />
<p className=textStyle> {"Join Discord"->React.string} </p>
</div>
</FramerMotion.Motion.Div>
</UIUtils.RenderIf>
<Icon
className="cursor-pointer ml-auto"
name="help-desk"
size=30
onClick={ev => {
open ReactEvent.Mouse
ev->stopPropagation
setHelpdeskModal(prevValue => {
let globalEventText = !prevValue ? "global_helpdesk_open" : "global_helpdesk_close"
let localEventText = !prevValue ? "helpdesk_open" : "helpdesk_close"
let currentPath = url.path->LogicUtils.getListHead

[`${currentPath}_${localEventText}`, globalEventText]->Js.Array2.forEach(ele =>
hyperswitchMixPanel(~eventName=Some(ele), ())
)
!prevValue
})
}}
/>
</>
}
}

let pathToVariantMapper = routeName => {
switch routeName {
| "home" => HOME
| "payments" => PAYMENTS
| "refunds" => REFUNDS
| "disputes" => DISPUTES
| "connectors" => CONNECTOR
| "routing" => ROUTING
| "analytics-payments" => ANALYTICS_PAYMENTS
| "analytics-refunds" => ANALYTICS_REFUNDS
| "settings" => SETTINGS
| "developers" => DEVELOPERS
| _ => HOME
}
}

let isValidEmail = value =>
!Js.Re.test_(
%re(`/^(([^<>()[\]\.,;:\s@"]+(\.[^<>()[\]\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/`),
value,
)

let isUserJourneyAnalyticsAccessAvailable = email => email->Js.String2.includes("juspay")

let convertJsonArrayToArrayOfString = (. val) => {
val
->Js.Json.decodeArray
->Belt.Option.getWithDefault([])
->Js.Array2.map(ele => ele->Js.Json.decodeString->Belt.Option.getWithDefault(""))
}

let useMerchantDetailsValue = () =>
Recoil.useRecoilValueFromAtom(merchantDetailsValueAtom)->safeParse

Expand Down Expand Up @@ -382,49 +284,9 @@ let constructOnboardingBody = (
("account_activation", copyOfIntegrationDetails.account_activation->returnIntegrationJson),
])->Js.Json.object_
}
module OnboardingChecklistTile = {
@react.component
let make = (~setShowOnboardingModal) => {
let hyperswitchMixPanel = HSMixPanel.useSendEvent()
let url = RescriptReactRouter.useUrl()
<div
className="absolute bottom-0 right-0 cursor-pointer px-5 py-2 bg-white h-20 w-[26rem] flex justify-between items-center !shadow-checklistShadow"
onClick={_ => {
setShowOnboardingModal(_ => true)

[url.path->LogicUtils.getListHead, "global"]->Js.Array2.forEach(ele =>
hyperswitchMixPanel(~eventName=Some(`${ele}_onboarding_checklist`), ())
)
}}>
<div className="w-full flex nowrap items-center gap-2">
<div className="font-semibold text-xl"> {"Onboarding Checklist"->React.string} </div>
<span className="relative flex h-3 w-3">
<span
className="animate-ping absolute inline-flex h-full w-full rounded-full bg-sky-400 opacity-75"
/>
<span className="relative inline-flex rounded-full h-3 w-3 bg-sky-500" />
</span>
</div>
<Icon name="arrow-without-tail" />
</div>
}
}

let isEmptyString = str => str->Js.String2.length <= 0

let parseUrl = url => {
url
->Js.Global.decodeURI
->Js.String2.split("&")
->Belt.Array.keepMap(str => {
let arr = str->Js.String2.split("=")
let key = arr->Belt.Array.get(0)->Belt.Option.getWithDefault("-")
let val = arr->Belt.Array.sliceToEnd(1)->Js.Array2.joinWith("=")
key === "" || val === "" ? None : Some((key, val))
})
->Js.Dict.fromArray
}

type textVariantType =
| H1
| H2
Expand Down Expand Up @@ -453,19 +315,6 @@ let getTextClass = (~textVariant, ~h3TextVariant=Leading_1, ~paragraphTextVarian
}
}

module CardLoader = {
@react.component
let make = () => {
<div className="w-full h-full flex justify-center items-center">
<div className="w-24 h-24 scale-[0.5]">
<div className="-mt-5 -ml-12">
<Loader />
</div>
</div>
</div>
}
}

let checkStripePlusPayPal = (enumDetails: QuickStartTypes.responseType) => {
enumDetails.stripeConnected.processorID->Js.String2.length > 0 &&
enumDetails.paypalConnected.processorID->Js.String2.length > 0 &&
Expand Down
Loading

0 comments on commit 1422f4c

Please sign in to comment.