feat: add free tier Stripe subscription

This commit is contained in:
David Nguyen
2023-09-18 22:33:07 +10:00
committed by Mythie
parent 5a79535080
commit 2856cd9c15
12 changed files with 296 additions and 57 deletions

View File

@ -0,0 +1,19 @@
import { stripe } from '@documenso/lib/server-only/stripe';
export const getStripeCustomerByEmail = async (email: string) => {
const foundStripeCustomers = await stripe.customers.list({
email,
});
return foundStripeCustomers.data[0] ?? null;
};
export const getStripeCustomerById = async (stripeCustomerId: string) => {
try {
const stripeCustomer = await stripe.customers.retrieve(stripeCustomerId);
return !stripeCustomer.deleted ? stripeCustomer : null;
} catch {
return null;
}
};