@gravis-os/stripe
Getting started
yarn add @gravis-os/stripe
- In
.env
, add:
# Stripe - Update these with your Stripe credentials from https://dashboard.stripe.com/apikeys
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_XXX
STRIPE_SECRET_KEY=sk_test_XXX
STRIPE_WEBHOOK_SECRET=whsec_XXX
- In
pages/api/stripe/[...stripe].ts
, do:
import { StripeRouterMiddleware } from '@gravis-os/stripe/server'
export default StripeRouterMiddleware()
- In
pages/pricing.tsx
, do:
import { StripeSupabaseClient, StripeProductWithPrice } from '@gravis-os/stripe'
export interface PricingPageProps {
stripeProducts?: StripeProductWithPrice[]
}
export async function getStaticProps(): Promise<
GetStaticPropsResult<PricingPageProps>
> {
const stripeProducts =
await StripeSupabaseClient.fetchActiveProductsWithPrices()
return {
props: { stripeProducts },
revalidate: 60,
}
}
const PricingPage const PricingPage: React.FC<PricingPageProps> = (props) => {
const { stripeProducts } = props
return (/* Your UI */)
}