diff --git a/src/components/TableModals/WebhooksModal/Schemas/basic.tsx b/src/components/TableModals/WebhooksModal/Schemas/basic.tsx index 616e6528..d9f81121 100644 --- a/src/components/TableModals/WebhooksModal/Schemas/basic.tsx +++ b/src/components/TableModals/WebhooksModal/Schemas/basic.tsx @@ -3,15 +3,6 @@ import WarningIcon from "@mui/icons-material/WarningAmber"; import { TableSettings } from "@src/types/table"; import { IWebhook } from "@src/components/TableModals/WebhooksModal/utils"; -export const webhookTypes = [ - "basic", - "typeform", - "sendgrid", - //"shopify", - //"twitter", - //"stripe", -] as const; - const requestType = [ "declare type WebHookRequest {", " /**", diff --git a/src/components/TableModals/WebhooksModal/Schemas/index.ts b/src/components/TableModals/WebhooksModal/Schemas/index.ts index 15ea2a1a..fff6341f 100644 --- a/src/components/TableModals/WebhooksModal/Schemas/index.ts +++ b/src/components/TableModals/WebhooksModal/Schemas/index.ts @@ -2,5 +2,6 @@ import basic from "./basic"; import typeform from "./typeform"; import sendgrid from "./sendgrid"; import webform from "./webform"; +import stripe from "./stripe"; -export { basic, typeform, sendgrid, webform }; +export { basic, typeform, sendgrid, webform, stripe }; diff --git a/src/components/TableModals/WebhooksModal/Schemas/stripe.tsx b/src/components/TableModals/WebhooksModal/Schemas/stripe.tsx new file mode 100644 index 00000000..77a78536 --- /dev/null +++ b/src/components/TableModals/WebhooksModal/Schemas/stripe.tsx @@ -0,0 +1,95 @@ +import { Typography, Link, TextField } from "@mui/material"; +import InlineOpenInNewIcon from "@src/components/InlineOpenInNewIcon"; +import { TableSettings } from "@src/types/table"; +import { IWebhook } from "@src/components/TableModals/WebhooksModal/utils"; + +export const webhookStripe = { + name: "Stripe", + parser: { + additionalVariables: null, + extraLibs: null, + template: ( + table: TableSettings + ) => `const sendgridParser: Parser = async ({ req, db, ref }) => { + const event = req.body + switch (event.type) { + case "payment_intent.succeeded": + break; + case "payment_intent.payment_failed": + break; + default: + // all other types + } +};`, + }, + condition: { + additionalVariables: null, + extraLibs: null, + template: ( + table: TableSettings + ) => `const condition: Condition = async({ref,req,db}) => { + // feel free to add your own code logic here + return true; +}`, + }, + auth: (webhookObject: IWebhook, setWebhookObject: (w: IWebhook) => void) => { + return ( + <> + + Get your{" "} + + secret key + + {" "} + and{" "} + + signing key + + {" "} + from Stripe dashboard. +
+ Then add the secret below. +
+ + { + setWebhookObject({ + ...webhookObject, + auth: { ...webhookObject.auth, secretKey: e.target.value }, + }); + }} + /> + { + setWebhookObject({ + ...webhookObject, + auth: { ...webhookObject.auth, signingSecret: e.target.value }, + }); + }} + /> + + ); + }, +}; + +export default webhookStripe; diff --git a/src/components/TableModals/WebhooksModal/utils.tsx b/src/components/TableModals/WebhooksModal/utils.tsx index db833809..c9cdccf1 100644 --- a/src/components/TableModals/WebhooksModal/utils.tsx +++ b/src/components/TableModals/WebhooksModal/utils.tsx @@ -1,6 +1,7 @@ import { TableSettings } from "@src/types/table"; import { generateId } from "@src/utils/table"; -import { typeform, basic, sendgrid, webform } from "./Schemas"; +import { typeform, basic, sendgrid, webform, stripe } from "./Schemas"; + export const webhookTypes = [ "basic", "typeform", @@ -8,7 +9,7 @@ export const webhookTypes = [ "webform", //"shopify", //"twitter", - //"stripe", + "stripe", ] as const; const requestType = [ @@ -53,7 +54,7 @@ export const webhookNames: Record = { //github:"GitHub", // shopify: "Shopify", // twitter: "Twitter", - // stripe: "Stripe", + stripe: "Stripe", basic: "Basic", webform: "Web form", }; @@ -82,6 +83,7 @@ export const webhookSchemas = { typeform, sendgrid, webform, + stripe, }; export function emptyWebhookObject(