Skip to content

Commit cb7f3f6

Browse files
authored
Merge pull request #364 from captableinc/stripe-billing
feat: add stripe billing
2 parents adc7410 + f269470 commit cb7f3f6

File tree

24 files changed

+1110
-331
lines changed

24 files changed

+1110
-331
lines changed

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,11 @@
2424
},
2525
"[typescriptreact]": {
2626
"editor.defaultFormatter": "biomejs.biome"
27+
},
28+
"[prisma]": {
29+
"editor.defaultFormatter": "Prisma.prisma"
30+
},
31+
"[javascript]": {
32+
"editor.defaultFormatter": "biomejs.biome"
2733
}
2834
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@simplewebauthn/browser": "^10.0.0",
5858
"@simplewebauthn/server": "^10.0.0",
5959
"@sindresorhus/slugify": "^2.2.1",
60+
"@stripe/stripe-js": "^3.5.0",
6061
"@t3-oss/env-nextjs": "^0.10.1",
6162
"@tanstack/react-query": "^4.36.1",
6263
"@tanstack/react-table": "^8.16.0",
@@ -101,6 +102,7 @@
101102
"server-only": "^0.0.1",
102103
"sharp": "^0.33.3",
103104
"sonner": "^1.4.41",
105+
"stripe": "^15.8.0",
104106
"superjson": "^2.2.1",
105107
"tailwind-merge": "^2.3.0",
106108
"tailwindcss-animate": "^1.0.7",

pnpm-lock.yaml

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prisma/enums.ts

Lines changed: 0 additions & 226 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
-- CreateEnum
2+
CREATE TYPE "PricingType" AS ENUM ('one_time', 'recurring');
3+
4+
-- CreateEnum
5+
CREATE TYPE "PricingPlanInterval" AS ENUM ('day', 'week', 'month', 'year');
6+
7+
-- CreateEnum
8+
CREATE TYPE "SubscriptionStatus" AS ENUM ('trialing', 'active', 'canceled', 'incomplete', 'incomplete_expired', 'past_due', 'unpaid', 'paused');
9+
10+
-- CreateTable
11+
CREATE TABLE "BillingProduct" (
12+
"id" TEXT NOT NULL,
13+
"active" BOOLEAN NOT NULL,
14+
"name" TEXT NOT NULL,
15+
"description" TEXT,
16+
"metadata" JSONB,
17+
18+
CONSTRAINT "BillingProduct_pkey" PRIMARY KEY ("id")
19+
);
20+
21+
-- CreateTable
22+
CREATE TABLE "BillingPrice" (
23+
"id" TEXT NOT NULL,
24+
"productId" TEXT NOT NULL,
25+
"active" BOOLEAN NOT NULL,
26+
"description" TEXT,
27+
"unitAmount" BIGINT,
28+
"currency" CHAR(3) NOT NULL,
29+
"type" "PricingType" NOT NULL,
30+
"interval" "PricingPlanInterval",
31+
"intervalCount" INTEGER,
32+
"trialPeriodDays" INTEGER,
33+
"metadata" JSONB,
34+
35+
CONSTRAINT "BillingPrice_pkey" PRIMARY KEY ("id")
36+
);
37+
38+
-- CreateTable
39+
CREATE TABLE "BillingSubscription" (
40+
"id" TEXT NOT NULL,
41+
"priceId" TEXT NOT NULL,
42+
"quantity" INTEGER NOT NULL,
43+
"status" "SubscriptionStatus" NOT NULL,
44+
"cancelAtPeriodEnd" BOOLEAN NOT NULL,
45+
"created" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
46+
"currentPeriodStart" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
47+
"currentPeriodEnd" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
48+
"endedAt" TIMESTAMP(3),
49+
"cancelAt" TIMESTAMP(3),
50+
"canceledAt" TIMESTAMP(3),
51+
"trialStart" TIMESTAMP(3),
52+
"trialEnd" TIMESTAMP(3),
53+
"metadata" JSONB,
54+
"customerId" TEXT NOT NULL,
55+
56+
CONSTRAINT "BillingSubscription_pkey" PRIMARY KEY ("id")
57+
);
58+
59+
-- CreateTable
60+
CREATE TABLE "BillingCustomer" (
61+
"id" TEXT NOT NULL,
62+
"companyId" TEXT,
63+
64+
CONSTRAINT "BillingCustomer_pkey" PRIMARY KEY ("id")
65+
);
66+
67+
-- CreateIndex
68+
CREATE INDEX "BillingPrice_productId_idx" ON "BillingPrice"("productId");
69+
70+
-- CreateIndex
71+
CREATE INDEX "BillingSubscription_priceId_idx" ON "BillingSubscription"("priceId");
72+
73+
-- CreateIndex
74+
CREATE INDEX "BillingSubscription_customerId_idx" ON "BillingSubscription"("customerId");
75+
76+
-- CreateIndex
77+
CREATE INDEX "BillingCustomer_companyId_idx" ON "BillingCustomer"("companyId");

0 commit comments

Comments
 (0)