diff --git a/landing/package.json b/landing/package.json index a46c0d43a..67370392e 100644 --- a/landing/package.json +++ b/landing/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^4.3.13", "@astrojs/vercel": "^9.0.2", - "@polar-sh/sdk": "^0.20.2", + "@polar-sh/astro": "^0.7.3", "astro": "^5.17.1", "shepherd.js": "workspace:*" }, diff --git a/landing/src/actions/index.ts b/landing/src/actions/index.ts deleted file mode 100644 index cda15fc72..000000000 --- a/landing/src/actions/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { defineAction } from 'astro:actions'; -import { z } from 'astro:schema'; - -import { Polar } from '@polar-sh/sdk'; - -const polar = new Polar({ - accessToken: import.meta.env.POLAR_ACCESS_TOKEN ?? '' -}); - -export const server = { - checkout: defineAction({ - input: z.object({ - productPriceId: z.string() - }), - handler: async (input) => { - const { productPriceId } = input; - let result; - - try { - result = await polar.checkouts.custom.create({ - productPriceId, - successUrl: 'https://docs.shepherdjs.dev' - }); - } catch (error) { - console.error('Checkout error:', error); - } finally { - if (result?.url) { - return result.url; - } else { - return 'https://shepherdjs.dev'; - } - } - } - }) -}; diff --git a/landing/src/pages/api/checkout.ts b/landing/src/pages/api/checkout.ts new file mode 100644 index 000000000..b3335570f --- /dev/null +++ b/landing/src/pages/api/checkout.ts @@ -0,0 +1,8 @@ +import { Checkout } from '@polar-sh/astro'; + +export const prerender = false; + +export const GET = Checkout({ + accessToken: import.meta.env.POLAR_ACCESS_TOKEN ?? '', + successUrl: 'https://docs.shepherdjs.dev' +}); diff --git a/landing/src/pages/pricing.astro b/landing/src/pages/pricing.astro index 333ff89ee..eb197ded4 100644 --- a/landing/src/pages/pricing.astro +++ b/landing/src/pages/pricing.astro @@ -53,7 +53,7 @@ import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';