-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anatoliy
committed
Aug 20, 2023
1 parent
64d5fbd
commit a4acb09
Showing
7 changed files
with
34 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { auth } from '$lib/server/lucia'; | ||
import { stripe } from '$lib/server/stripe'; | ||
|
||
export const load = async (event) => { | ||
const authRequest = auth.handleRequest(event); | ||
const session = await authRequest.validate(); | ||
|
||
let product = null; | ||
if (session) { | ||
const customers = await stripe.customers.list({ | ||
email: session?.user.email | ||
}); | ||
|
||
if (customers?.data?.length) { | ||
const subscriptions = await stripe.subscriptions.list({ | ||
customer: customers?.data[0].customer | ||
}); | ||
|
||
const subscription = subscriptions?.data?.find((s) => s.status === 'active'); | ||
|
||
product = await stripe.products.retrieve(subscription?.plan.product); | ||
} | ||
} | ||
|
||
return { product }; | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.