Skip to content

Commit

Permalink
feat: add getStripePrices function
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaDiotallevi committed Sep 28, 2024
1 parent 9333ddc commit 2fd90f8
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion astro/src/utils/serverless.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
import Stripe from "stripe"
import type { Currency } from "./stripe"
import type { Currency, StripePrice } from "./stripe"

export const getStripePrices = async (): Promise<StripePrice[]> => {
try {
const response = await fetch(
import.meta.env.PUBLIC_API_URL + `/stripe-get-prices`,
{
method: "GET",
headers: { "Content-Type": "application/json" },
},
)

if (response.ok) {
const data = (await response.json()) as {
prices: StripePrice[]
}
return data.prices
} else {
throw new Error(JSON.stringify(response))
}
} catch (error) {
throw error
}
}

export const createCheckoutSession = async (params: {
line_items: Stripe.Checkout.SessionCreateParams.LineItem[]
Expand Down

0 comments on commit 2fd90f8

Please sign in to comment.