mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-04 19:22:16 +00:00
fix(stripe): filter products to include only monthly and annual subscriptions
- Updated the Stripe API response to return only the monthly and annual subscription products. - Enhanced the product listing logic to filter out unnecessary products, improving data handling in the application.
This commit is contained in:
@@ -27,12 +27,17 @@ export const stripeRouter = createTRPCRouter({
|
|||||||
const products = await stripe.products.list({
|
const products = await stripe.products.list({
|
||||||
expand: ["data.default_price"],
|
expand: ["data.default_price"],
|
||||||
active: true,
|
active: true,
|
||||||
ids: [PRODUCT_MONTHLY_ID, PRODUCT_ANNUAL_ID],
|
});
|
||||||
|
|
||||||
|
const filteredProducts = products.data.filter((product) => {
|
||||||
|
return (
|
||||||
|
product.id === PRODUCT_MONTHLY_ID || product.id === PRODUCT_ANNUAL_ID
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!stripeCustomerId) {
|
if (!stripeCustomerId) {
|
||||||
return {
|
return {
|
||||||
products: products.data,
|
products: filteredProducts,
|
||||||
subscriptions: [],
|
subscriptions: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -44,7 +49,7 @@ export const stripeRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
products: products.data,
|
products: filteredProducts,
|
||||||
subscriptions: subscriptions.data,
|
subscriptions: subscriptions.data,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user