mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-18 13:45:23 +02:00
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.
This commit is contained in:
@@ -7,7 +7,12 @@ import {
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import Stripe from "stripe";
|
||||
import { z } from "zod";
|
||||
import { getStripeItems, WEBSITE_URL } from "@/server/utils/stripe";
|
||||
import {
|
||||
getStripeItems,
|
||||
PRODUCT_ANNUAL_ID,
|
||||
PRODUCT_MONTHLY_ID,
|
||||
WEBSITE_URL,
|
||||
} from "@/server/utils/stripe";
|
||||
import { adminProcedure, createTRPCRouter } from "../trpc";
|
||||
|
||||
export const stripeRouter = createTRPCRouter({
|
||||
@@ -22,6 +27,7 @@ export const stripeRouter = createTRPCRouter({
|
||||
const products = await stripe.products.list({
|
||||
expand: ["data.default_price"],
|
||||
active: true,
|
||||
ids: [PRODUCT_MONTHLY_ID, PRODUCT_ANNUAL_ID],
|
||||
});
|
||||
|
||||
if (!stripeCustomerId) {
|
||||
|
||||
@@ -3,9 +3,12 @@ export const WEBSITE_URL =
|
||||
? "http://localhost:3000"
|
||||
: process.env.SITE_URL;
|
||||
|
||||
const BASE_PRICE_MONTHLY_ID = process.env.BASE_PRICE_MONTHLY_ID!; // $4.00
|
||||
export const BASE_PRICE_MONTHLY_ID = process.env.BASE_PRICE_MONTHLY_ID!; // $4.00
|
||||
|
||||
const BASE_ANNUAL_MONTHLY_ID = process.env.BASE_ANNUAL_MONTHLY_ID!; // $7.99
|
||||
export const BASE_ANNUAL_MONTHLY_ID = process.env.BASE_ANNUAL_MONTHLY_ID!; // $7.99
|
||||
|
||||
export const PRODUCT_MONTHLY_ID = process.env.PRODUCT_MONTHLY_ID!;
|
||||
export const PRODUCT_ANNUAL_ID = process.env.PRODUCT_ANNUAL_ID!;
|
||||
|
||||
export const getStripeItems = (serverQuantity: number, isAnnual: boolean) => {
|
||||
const items = [];
|
||||
|
||||
Reference in New Issue
Block a user