mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
20 lines
516 B
TypeScript
20 lines
516 B
TypeScript
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;
|
|
}
|
|
};
|