Skip to main content
ShipFree includes a flexible payment system that supports multiple payment providers through a unified adapter interface. Switch between providers without changing your application code.

Supported Providers

Stripe

Industry-leading payment processor with global reach

Polar

Developer-friendly payment platform for digital products

Lemon Squeezy

Merchant of record platform handling taxes and compliance

Architecture Overview

The payment system uses an adapter pattern that provides a consistent interface across all providers:
src/lib/payments/service.ts
Set PAYMENT_PROVIDER in your .env file to choose your provider: stripe, polar, or lemonsqueezy

Plans & Pricing

Plans are centrally configured in src/config/payments.ts:
src/config/payments.ts

Accessing Plan Configuration

Database Schema

The payment system uses these tables (defined in src/database/schema.ts):
src/database/schema.ts

Creating Checkout Sessions

Create a checkout session to accept payments:
src/app/actions/checkout.ts

Customer Portal

Let users manage their subscriptions via the provider’s hosted portal:
src/app/actions/portal.ts

Webhook Handling

1

Configure Webhook Endpoint

Set up webhook endpoints in your payment provider dashboard pointing to:
  • Stripe: https://yourdomain.com/api/webhooks/stripe
  • Polar: https://yourdomain.com/api/webhooks/polar
  • Lemon Squeezy: https://yourdomain.com/api/webhooks/lemonsqueezy
2

Process Events

Webhooks automatically update subscription and payment records in your database.
3

Handle Failures

Failed payments trigger status updates and can send notification emails.
Always verify webhook signatures to ensure requests are legitimate. Each adapter includes signature validation.

Subscription Management

Check Active Subscription

Cancel Subscription

src/app/actions/subscription.ts

Payment Adapter Interface

All payment providers implement this interface:
src/lib/payments/types.ts
This unified interface makes it easy to switch between payment providers without changing your application code.

Environment Variables

.env

Testing Payments

Use test mode credentials during development. Each provider offers test cards and environments.

Stripe Testing

Use test cards like 4242 4242 4242 4242

Polar Testing

Polar provides a sandbox environment

Lemon Squeezy

Enable test mode in your store settings

Further Reading

Stripe Docs

Complete Stripe API documentation

Polar Docs

Polar developer documentation

Lemon Squeezy

Lemon Squeezy API reference

Webhook Best Practices

Learn about webhook security and reliability