Overview
This guide will show you how to set up payments for testing and local development with the following payment processors:
- Stripe
- Lemon Squeezy
- Polar
Important First Steps
First, go to /src/payment/paymentProcessor.ts and choose which payment processor you’d like to use:
import { stripePaymentProcessor } from './stripe/paymentProcessor';import { lemonSqueezyPaymentProcessor } from './lemonSqueezy/paymentProcessor';import { polarPaymentProcessor } from './polar/paymentProcessor';
// ...
export const paymentProcessor: PaymentProcessor = stripePaymentProcessor;// orexport const paymentProcessor: PaymentProcessor = lemonSqueezyPaymentProcessor;// orexport const paymentProcessor: PaymentProcessor = polarPaymentProcessor;Then you should delete:
- The unused payment processor code within the
/src/payment/<unused-provider>directories. - Any unused environment variables from
.env.server(they will be prefixed with the name of the provider your are not using):- E.g.
STRIPE_API_KEY,LEMONSQUEEZY_API_KEY,POLAR_ORGANIZATION_ACCESS_TOKEN.
- E.g.
- Make sure to also run
npm uninstallfor providers you didn’t use:- Stripe:
npm uninstall stripe - Polar:
npm uninstall @polar-sh/sdk - Lemon Squeezy:
npm uninstall @lemonsqueezy/lemonsqueezy.js
- Stripe:
- If you are not using Lemon Squeezy remove the
lemonSqueezyCustomerPortalUrlfield from theUsermodel in theschema.prismafile.
Now your code is ready to go with your preferred payment processor and it’s time to configure your payment processor’s API keys, products, and other settings.
Follow the steps for your selected processor:
Deploying
Once you’re ready to deploy your app, follow the steps from the deploying guide to set up the production settings for your prayment provider.