Skip to content

Commit b391abf

Browse files
committed
feat(dokploy): add product IDs for monthly and annual subscriptions in Stripe integration
- Introduced PRODUCT_MONTHLY_ID and PRODUCT_ANNUAL_ID constants to manage subscription product IDs. - Updated the Stripe API call to fetch only the specified subscription products, enhancing performance and clarity in product management.
1 parent 21a6657 commit b391abf

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

apps/dokploy/server/api/routers/stripe.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import {
77
import { TRPCError } from "@trpc/server";
88
import Stripe from "stripe";
99
import { z } from "zod";
10-
import { getStripeItems, WEBSITE_URL } from "@/server/utils/stripe";
10+
import {
11+
getStripeItems,
12+
PRODUCT_ANNUAL_ID,
13+
PRODUCT_MONTHLY_ID,
14+
WEBSITE_URL,
15+
} from "@/server/utils/stripe";
1116
import { adminProcedure, createTRPCRouter } from "../trpc";
1217

1318
export const stripeRouter = createTRPCRouter({
@@ -22,6 +27,7 @@ export const stripeRouter = createTRPCRouter({
2227
const products = await stripe.products.list({
2328
expand: ["data.default_price"],
2429
active: true,
30+
ids: [PRODUCT_MONTHLY_ID, PRODUCT_ANNUAL_ID],
2531
});
2632

2733
if (!stripeCustomerId) {

apps/dokploy/server/utils/stripe.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ export const WEBSITE_URL =
33
? "http://localhost:3000"
44
: process.env.SITE_URL;
55

6-
const BASE_PRICE_MONTHLY_ID = process.env.BASE_PRICE_MONTHLY_ID!; // $4.00
6+
export const BASE_PRICE_MONTHLY_ID = process.env.BASE_PRICE_MONTHLY_ID!; // $4.00
77

8-
const BASE_ANNUAL_MONTHLY_ID = process.env.BASE_ANNUAL_MONTHLY_ID!; // $7.99
8+
export const BASE_ANNUAL_MONTHLY_ID = process.env.BASE_ANNUAL_MONTHLY_ID!; // $7.99
9+
10+
export const PRODUCT_MONTHLY_ID = process.env.PRODUCT_MONTHLY_ID!;
11+
export const PRODUCT_ANNUAL_ID = process.env.PRODUCT_ANNUAL_ID!;
912

1013
export const getStripeItems = (serverQuantity: number, isAnnual: boolean) => {
1114
const items = [];

0 commit comments

Comments
 (0)