opensaas-sh/blog/src/content/docs/guides/payment-integrations/index.mdx
import { TabItem, Tabs } from '@astrojs/starlight/components';
This guide will show you how to set up payments for testing and local development with the following payment processors:
:::note[Which should I choose?] Stripe is the industry standard, is more configurable, and has cheaper fees. Lemon Squeezy and Polar act as a Merchant of Record. This means they take care of paying taxes in multiple countries for you, but charge higher fees per transaction. :::
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;
// or
export const paymentProcessor: PaymentProcessor = lemonSqueezyPaymentProcessor;
// or
export const paymentProcessor: PaymentProcessor = polarPaymentProcessor;
Then you should delete:
/src/payment/<unused-provider>..env.server (they will be prefixed with the name of the provider you are not using):
STRIPE_API_KEY, LEMONSQUEEZY_API_KEY, POLAR_ORGANIZATION_ACCESS_TOKEN.src/env.ts to remove the env schema imports and .merge() calls for the providers you removed.npm uninstall for providers you didn't use:
npm uninstall stripenpm uninstall @polar-sh/sdknpm uninstall @lemonsqueezy/lemonsqueezy.jslemonSqueezyCustomerPortalUrl field from the User model in the schema.prisma file.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:
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.