mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 00:32:43 +10:00
feat: wip
This commit is contained in:
@ -40,10 +40,10 @@ export const createBillingPortal = async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const stripeCustomerSubsriptions = stripeCustomer.subscriptions?.data ?? [];
|
const stripeCustomerSubscriptions = stripeCustomer.subscriptions?.data ?? [];
|
||||||
|
|
||||||
// Create a free subscription for user if it does not exist.
|
// Create a free subscription for user if it does not exist.
|
||||||
if (!existingSubscription && stripeCustomerSubsriptions.length === 0) {
|
if (!existingSubscription && stripeCustomerSubscriptions.length === 0) {
|
||||||
const newSubscription = await stripe.subscriptions.create({
|
const newSubscription = await stripe.subscriptions.create({
|
||||||
customer: stripeCustomer.id,
|
customer: stripeCustomer.id,
|
||||||
items: [
|
items: [
|
||||||
|
|||||||
@ -212,7 +212,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
|
|
||||||
const handleCustomerSubscriptionUpdated = async (subscription: Stripe.Subscription) => {
|
const handleCustomerSubscriptionUpdated = async (subscription: Stripe.Subscription) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||||
const plan = (subscription as unknown as Stripe.SubscriptionItem).plan;
|
const { plan } = subscription as unknown as Stripe.SubscriptionItem;
|
||||||
|
|
||||||
const customerId =
|
const customerId =
|
||||||
typeof subscription.customer === 'string' ? subscription.customer : subscription.customer.id;
|
typeof subscription.customer === 'string' ? subscription.customer : subscription.customer.id;
|
||||||
|
|||||||
Reference in New Issue
Block a user