@@ -14,7 +14,7 @@ import { encrypt } from "@sourcebot/crypto"
1414import { getConnection } from "./data/connection" ;
1515import { ConnectionSyncStatus , Prisma , Invite } from "@sourcebot/db" ;
1616import { headers } from "next/headers"
17- import { stripe } from "@/lib/stripe"
17+ import { getStripe } from "@/lib/stripe"
1818import { getUser } from "@/data/user" ;
1919import { Session } from "next-auth" ;
2020import { STRIPE_PRODUCT_ID } from "@/lib/environment" ;
@@ -339,6 +339,7 @@ export const redeemInvite = async (invite: Invite, userId: string): Promise<{ su
339339 const existingSeatCount = subscription . items . data [ 0 ] . quantity ;
340340 const newSeatCount = ( existingSeatCount || 1 ) + 1
341341
342+ const stripe = getStripe ( ) ;
342343 await stripe . subscriptionItems . update (
343344 subscription . items . data [ 0 ] . id ,
344345 {
@@ -424,6 +425,7 @@ export const setupInitialStripeCustomer = async (name: string, domain: string) =
424425 return "" ;
425426 }
426427
428+ const stripe = getStripe ( ) ;
427429 const origin = ( await headers ( ) ) . get ( 'origin' )
428430
429431 // @nocheckin
@@ -489,6 +491,7 @@ export const getSubscriptionCheckoutRedirect = async (domain: string) =>
489491 } ) ;
490492 const numOrgMembers = orgMembers . length ;
491493
494+ const stripe = getStripe ( ) ;
492495 const origin = ( await headers ( ) ) . get ( 'origin' )
493496 const prices = await stripe . prices . list ( {
494497 product : STRIPE_PRODUCT_ID ,
@@ -520,6 +523,7 @@ export const getSubscriptionCheckoutRedirect = async (domain: string) =>
520523 )
521524
522525export async function fetchStripeSession ( sessionId : string ) {
526+ const stripe = getStripe ( ) ;
523527 const stripeSession = await stripe . checkout . sessions . retrieve ( sessionId ) ;
524528 return stripeSession ;
525529}
@@ -537,6 +541,7 @@ export const getCustomerPortalSessionLink = async (domain: string): Promise<stri
537541 return notFound ( ) ;
538542 }
539543
544+ const stripe = getStripe ( ) ;
540545 const origin = ( await headers ( ) ) . get ( 'origin' )
541546 const portalSession = await stripe . billingPortal . sessions . create ( {
542547 customer : org . stripeCustomerId as string ,
@@ -558,6 +563,7 @@ export const fetchSubscription = (domain: string): Promise<Stripe.Subscription |
558563 return notFound ( ) ;
559564 }
560565
566+ const stripe = getStripe ( ) ;
561567 const subscriptions = await stripe . subscriptions . list ( {
562568 customer : org . stripeCustomerId
563569 } ) ;
@@ -624,6 +630,7 @@ export const removeMember = async (memberId: string, domain: string): Promise<{
624630 const existingSeatCount = subscription . items . data [ 0 ] . quantity ;
625631 const newSeatCount = ( existingSeatCount || 1 ) - 1 ;
626632
633+ const stripe = getStripe ( ) ;
627634 await stripe . subscriptionItems . update (
628635 subscription . items . data [ 0 ] . id ,
629636 {
0 commit comments