Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: dead code removal #55

Merged
merged 13 commits into from
Dec 5, 2023
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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -733,55 +733,3 @@ app.post("/create-payment", async (req, res) => {
});

app.listen(4242, () => console.log("Node server listening on port 4242!"));`

let reactDisplayPaymentConfirmation: string = `const handleSubmit = async (e) => {
e.preventDefault();
if (!hyper || !widgets) {
// hyper-js has not yet loaded.
// Make sure to disable form submission until hyper-js has loaded.
return;
}
setIsLoading(true);
const { error } = await hyper.confirmPayment({
widgets,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: "https://example.com/complete",
},
});
// This point will only be reached if there is an immediate error occurring while confirming the payment. Otherwise, your customer will be redirected to your "return_url"
// For some payment flows such as Sofort, iDEAL, your customer will be redirected to an intermediate page to complete authorization of the payment, and then redirected to the "return_url".
if (error.type === "validation_error") {
setMessage(error.message);
} else {
setMessage("An unexpected error occurred.");
}
setIsLoading(false);
};`

let nodeDisplayPaymentConfirmation: string = `//Look for a parameter called "payment_intent_client_secret" in the url which gives a payment ID, which is then used to retrieve the status of the payment

const paymentID = new URLSearchParams(window.location.search).get(
"payment_intent_client_secret"
);

if (!paymentID) {
return;
}

hyper.retrievePaymentIntent(paymentID).then(({ paymentIntent }) => {
switch (paymentIntent.status) {
case "succeeded":
setMessage("Payment succeeded!");
break;
case "processing":
setMessage("Your payment is processing.");
break;
case "requires_payment_method":
setMessage("Your payment was not successful, please try again.");
break;
default:
setMessage("Something went wrong.");
break;
}
});`
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
let headerTextCss = "font-semibold text-grey-700 text-xl"
let subTextCss = "font-normal text-grey-700 opacity-50 text-base"

let buildHyperswitch: array<UserOnboardingTypes.sectionContentType> = [
{
headerIcon: "migrate-from-stripe",
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Settings/BusinessDetails.res
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ let make = () => {
validateMerchantAccountForm(
~values,
~fieldsToValidate=[PrimaryPhone, PrimaryEmail, Website, SecondaryEmail, SecondaryPhone],
~setIsDisabled,
~setIsDisabled=Some(setIsDisabled),
~initialData={merchantInfo->Js.Json.object_},
)
}}>
Expand Down
Loading