forked from calcom/cal.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
39 changed files
with
1,266 additions
and
5,671 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, config } from "@calcom/app-store/hitpay/api/webhook"; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
items: | ||
- 1.jpeg | ||
- 2.jpeg | ||
- 3.jpeg | ||
--- | ||
|
||
{DESCRIPTION} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
The Cal.com Commercial License (EE) license (the “EE License”) | ||
Copyright (c) 2020-present Cal.com, Inc | ||
|
||
With regard to the Cal.com Software: | ||
|
||
This software and associated documentation files (the "Software") may only be | ||
used in production, if you (and any entity that you represent) have agreed to, | ||
and are in compliance with, the Cal.com Subscription Terms available | ||
at https://cal.com/terms (the “EE Terms”), or other agreements governing | ||
the use of the Software, as mutually agreed by you and Cal.com, Inc ("Cal.com"), | ||
and otherwise have a valid Cal.com Commercial License subscription ("EE Subscription") | ||
for the correct number of hosts as defined in the EE Terms ("Hosts"). Subject to the foregoing sentence, | ||
you are free to modify this Software and publish patches to the Software. You agree | ||
that Cal.com and/or its licensors (as applicable) retain all right, title and interest in | ||
and to all such modifications and/or patches, and all such modifications and/or | ||
patches may only be used, copied, modified, displayed, distributed, or otherwise | ||
exploited with a valid EE Subscription for the correct number of hosts. | ||
Notwithstanding the foregoing, you may copy and modify the Software for development | ||
and testing purposes, without requiring a subscription. You agree that Cal.com and/or | ||
its licensors (as applicable) retain all right, title and interest in and to all such | ||
modifications. You are not granted any other rights beyond what is expressly stated herein. | ||
Subject to the foregoing, it is forbidden to copy, merge, publish, distribute, sublicense, | ||
and/or sell the Software. | ||
|
||
This EE License applies only to the part of this Software that is not distributed under | ||
the AGPLv3 license. Any part of this Software distributed under the MIT license or which | ||
is served client-side as an image, font, cascading stylesheet (CSS), file which produces | ||
or is compiled, arranged, augmented, or combined into client-side JavaScript, in whole or | ||
in part, is copyrighted under the AGPLv3 license. The full text of this EE License shall | ||
be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
For all third party components incorporated into the Cal.com Software, those | ||
components are licensed under the original license provided by the owner of the | ||
applicable component. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// import { createDefaultInstallation } from "@calcom/app-store/_utils/installation"; | ||
// import type { AppDeclarativeHandler } from "@calcom/types/AppHandler"; | ||
// import appConfig from "../config.json"; | ||
// const handler: AppDeclarativeHandler = { | ||
// appType: appConfig.type, | ||
// variant: appConfig.variant, | ||
// slug: appConfig.slug, | ||
// supportsMultipleInstalls: false, | ||
// handlerType: "add", | ||
// createCredential: ({ appType, user, slug, teamId }) => | ||
// createDefaultInstallation({ appType, user: user, slug, key: {}, teamId }), | ||
// }; | ||
// export default handler; | ||
import type { NextApiRequest, NextApiResponse } from "next"; | ||
|
||
import prisma from "@calcom/prisma"; | ||
|
||
import config from "../config.json"; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
if (!req.session?.user?.id) { | ||
return res.status(401).json({ message: "You must be logged in to do this" }); | ||
} | ||
const appType = config.type; | ||
try { | ||
const alreadyInstalled = await prisma.credential.findFirst({ | ||
where: { | ||
type: appType, | ||
userId: req.session.user.id, | ||
}, | ||
}); | ||
if (alreadyInstalled) { | ||
throw new Error("Already installed"); | ||
} | ||
const installation = await prisma.credential.create({ | ||
data: { | ||
type: appType, | ||
key: {}, | ||
userId: req.session.user.id, | ||
appId: "hitpay", | ||
}, | ||
}); | ||
|
||
if (!installation) { | ||
throw new Error("Unable to create user credential for Alby"); | ||
} | ||
} catch (error: unknown) { | ||
if (error instanceof Error) { | ||
return res.status(500).json({ message: error.message }); | ||
} | ||
return res.status(500); | ||
} | ||
|
||
return res.status(200).json({ url: "/apps/hitpay/setup" }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// import type { Prisma } from "@prisma/client"; | ||
import type { NextApiRequest, NextApiResponse } from "next"; | ||
import { stringify } from "querystring"; | ||
|
||
import getInstalledAppPath from "../../_utils/getInstalledAppPath"; | ||
import { decodeOAuthState } from "../../_utils/oauth/decodeOAuthState"; | ||
|
||
function getReturnToValueFromQueryState(req: NextApiRequest) { | ||
let returnTo = ""; | ||
try { | ||
returnTo = JSON.parse(`${req.query.state}`).returnTo; | ||
} catch (error) { | ||
console.info("No 'returnTo' in req.query.state"); | ||
} | ||
return returnTo; | ||
} | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
const { code, error, error_description } = req.query; | ||
console.log("hitpay callback query =>", req.query); | ||
const state = decodeOAuthState(req); | ||
|
||
if (error) { | ||
// User cancels flow | ||
if (error === "access_denied") { | ||
state?.onErrorReturnTo ? res.redirect(state.onErrorReturnTo) : res.redirect("/apps/installed/payment"); | ||
} | ||
const query = stringify({ error, error_description }); | ||
res.redirect(`/apps/installed?${query}`); | ||
return; | ||
} | ||
|
||
if (!req.session?.user?.id) { | ||
return res.status(401).json({ message: "You must be logged in to do this" }); | ||
} | ||
|
||
const returnTo = getReturnToValueFromQueryState(req); | ||
res.redirect(returnTo || getInstalledAppPath({ variant: "payment", slug: "hitpay" })); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as add } from "./add"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import type { NextApiRequest, NextApiResponse } from "next"; | ||
// import getRawBody from "raw-body"; | ||
import { z } from "zod"; | ||
|
||
import { IS_PRODUCTION } from "@calcom/lib/constants"; | ||
import { getErrorFromUnknown } from "@calcom/lib/errors"; | ||
import { HttpError as HttpCode } from "@calcom/lib/http-error"; | ||
|
||
// import prisma from "@calcom/prisma"; | ||
|
||
export const config = { | ||
api: { | ||
bodyParser: false, | ||
}, | ||
}; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
try { | ||
if (req.method !== "POST") { | ||
throw new HttpCode({ statusCode: 405, message: "Method Not Allowed" }); | ||
} | ||
|
||
const bodyRaw = await getRawBody(req); | ||
const headers = req.headers; | ||
const bodyAsString = bodyRaw.toString(); | ||
console.log("hitpay wehbook bodyRaw =>", bodyRaw); | ||
console.log("hitpay webhook bodyAsString =>", bodyAsString); | ||
} catch (_err) { | ||
const err = getErrorFromUnknown(_err); | ||
console.error(`Webhook Error: ${err.message}`); | ||
return res.status(err.statusCode || 500).send({ | ||
message: err.message, | ||
stack: IS_PRODUCTION ? undefined : err.stack, | ||
}); | ||
} | ||
} | ||
|
||
const payerDataSchema = z | ||
.object({ | ||
appId: z.string().optional(), | ||
referenceId: z.string().optional(), | ||
}) | ||
.optional(); | ||
|
||
const metadataSchema = z | ||
.object({ | ||
payer_data: payerDataSchema, | ||
}) | ||
.optional(); | ||
|
||
const eventSchema = z.object({ | ||
metadata: metadataSchema, | ||
}); | ||
|
||
const webhookHeadersSchema = z | ||
.object({ | ||
"svix-id": z.string(), | ||
"svix-timestamp": z.string(), | ||
"svix-signature": z.string(), | ||
}) | ||
.passthrough(); |
Empty file.
50 changes: 50 additions & 0 deletions
50
packages/app-store/hitpay/components/EventTypeAppCardInterface.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { usePathname } from "next/navigation"; | ||
import { useState } from "react"; | ||
|
||
import { useAppContextWithSchema } from "@calcom/app-store/EventTypeAppContext"; | ||
import AppCard from "@calcom/app-store/_components/AppCard"; | ||
import type { EventTypeAppCardComponent } from "@calcom/app-store/types"; | ||
import { WEBAPP_URL } from "@calcom/lib/constants"; | ||
import { useLocale } from "@calcom/lib/hooks/useLocale"; | ||
|
||
import checkForMultiplePaymentApps from "../../_utils/payments/checkForMultiplePaymentApps"; | ||
import useIsAppEnabled from "../../_utils/useIsAppEnabled"; | ||
import type { appDataSchema } from "../zod"; | ||
import EventTypeAppSettingsInterface from "./EventTypeAppSettingsInterface"; | ||
|
||
const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({ | ||
app, | ||
eventType, | ||
eventTypeFormMetadata, | ||
}) { | ||
const { t } = useLocale(); | ||
const pathname = usePathname(); | ||
const { getAppData, setAppData, disabled } = useAppContextWithSchema<typeof appDataSchema>(); | ||
const { enabled, updateEnabled } = useIsAppEnabled(app); | ||
const otherPaymentAppEnabled = checkForMultiplePaymentApps(eventTypeFormMetadata); | ||
const [requirePayment, setRequirePayment] = useState(getAppData("enabled")); | ||
const shouldDisableSwitch = !requirePayment && otherPaymentAppEnabled; | ||
|
||
return ( | ||
<AppCard | ||
returnTo={`${WEBAPP_URL}${pathname}?tabName=apps`} | ||
app={app} | ||
switchChecked={enabled} | ||
switchOnClick={(e) => { | ||
updateEnabled(e); | ||
}} | ||
teamId={eventType.team?.id || undefined} | ||
disableSwitch={shouldDisableSwitch} | ||
switchTooltip={shouldDisableSwitch ? t("other_payment_app_enabled") : undefined}> | ||
<EventTypeAppSettingsInterface | ||
eventType={eventType} | ||
slug={app.slug} | ||
disabled={disabled} | ||
getAppData={getAppData} | ||
setAppData={setAppData} | ||
/> | ||
</AppCard> | ||
); | ||
}; | ||
|
||
export default EventTypeAppCard; |
Oops, something went wrong.