From ed3e4d22ef472a552780bbe58da65206eaa02789 Mon Sep 17 00:00:00 2001 From: Mythie Date: Fri, 5 May 2023 19:29:42 +1000 Subject: [PATCH] feat: scaffhold subscription table and ui --- .env.example | 6 + .vscode/settings.json | 2 +- apps/web/components/settings.tsx | 34 +- apps/web/next.config.js | 10 +- apps/web/package.json | 7 +- apps/web/pages/settings/billing.tsx | 1 + apps/web/process-env.d.ts | 24 + apps/web/tsconfig.json | 2 +- package-lock.json | 1808 ++++++++++++++++- packages/lib/package.json | 5 +- packages/lib/process-env.d.ts | 24 + packages/lib/stripe/data/plans.ts | 12 + .../lib/stripe/handlers/portal-session.ts | 1 + packages/lib/stripe/handlers/webhook.ts | 155 ++ packages/lib/stripe/index.ts | 6 + .../migration.sql | 26 + .../migration.sql | 11 + .../migration.sql | 2 + packages/prisma/schema.prisma | 24 + 19 files changed, 2128 insertions(+), 32 deletions(-) create mode 100644 apps/web/pages/settings/billing.tsx create mode 100644 apps/web/process-env.d.ts create mode 100644 packages/lib/process-env.d.ts create mode 100644 packages/lib/stripe/data/plans.ts create mode 100644 packages/lib/stripe/handlers/portal-session.ts create mode 100644 packages/lib/stripe/handlers/webhook.ts create mode 100644 packages/lib/stripe/index.ts create mode 100644 packages/prisma/migrations/20230505085625_create_subscription_table/migration.sql create mode 100644 packages/prisma/migrations/20230505085908_update_unique_constraint/migration.sql create mode 100644 packages/prisma/migrations/20230505091928_add_past_due_value/migration.sql diff --git a/.env.example b/.env.example index 7da56a2e3..12a455ed6 100644 --- a/.env.example +++ b/.env.example @@ -37,6 +37,12 @@ SMTP_MAIL_PASSWORD='' # Sender for signing requests and completion mails. MAIL_FROM='documenso@localhost.com' +# STRIPE +STRIPE_API_KEY= +STRIPE_WEBHOOK_SECRET= +STRIPE_PRICE_ID= + #FEATURE FLAGS # Allow users to register via the /signup page. Otherwise they will be redirect to the home page. ALLOW_SIGNUP=true +ALLOW_SUBSCRIPTIONS=true \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 17ceca23e..41c0f1a88 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,7 +13,7 @@ "editor.codeActionsOnSave": { "source.removeUnusedImports": false }, - "typescript.tsdk": "node_modules\\typescript\\lib", + "typescript.tsdk": "node_modules/typescript/lib", "spellright.language": ["de"], "spellright.documentTypes": ["markdown", "latex", "plaintext"] } diff --git a/apps/web/components/settings.tsx b/apps/web/components/settings.tsx index 32d868804..5556d3198 100644 --- a/apps/web/components/settings.tsx +++ b/apps/web/components/settings.tsx @@ -5,7 +5,7 @@ import { useRouter } from "next/router"; import { updateUser } from "@documenso/features"; import { getUser } from "@documenso/lib/api"; import { Button } from "@documenso/ui"; -import { KeyIcon, UserCircleIcon } from "@heroicons/react/24/outline"; +import { CreditCardIcon, KeyIcon, UserCircleIcon } from "@heroicons/react/24/outline"; import { useSession } from "next-auth/react"; const subNavigation = [ @@ -21,6 +21,12 @@ const subNavigation = [ icon: KeyIcon, current: false, }, + { + name: "Billing", + href: "/settings/billing", + icon: CreditCardIcon, + current: false, + }, ]; function classNames(...classes: any) { @@ -33,7 +39,6 @@ export default function Setttings() { email: "", name: "", }); - useEffect(() => { getUser().then((res: any) => { res.json().then((j: any) => { @@ -158,6 +163,7 @@ export default function Setttings() { + + + +