Skip to main content

Payment API Endpoints

The template supports four payment providers: Stripe, Lemon Squeezy, Polar, and Solidgate. Each provider has its own set of API routes for checkout, subscription management, and webhook handling. A generic /api/payment group provides provider-agnostic subscription queries.

Stripe (/api/stripe)

Stripe is the most feature-complete integration with 17 route handlers covering checkout, subscriptions, payment methods, setup intents, and products.

Checkout

MethodPathDescription
POST/api/stripe/checkoutCreate a Stripe Checkout Session

Subscriptions

MethodPathDescription
GET/api/stripe/subscriptionGet current user's active subscription
POST/api/stripe/subscriptionCreate a new subscription
GET/api/stripe/subscriptionsList all user subscriptions
POST/api/stripe/subscription/[subscriptionId]/cancelCancel a subscription
POST/api/stripe/subscription/[subscriptionId]/reactivateReactivate a cancelled subscription
POST/api/stripe/subscription/[subscriptionId]/updateUpdate subscription (change plan)
POST/api/stripe/subscription/portalCreate a Stripe Customer Portal session

Payment Methods

MethodPathDescription
GET/api/stripe/payment-methods/listList saved payment methods
POST/api/stripe/payment-methods/createAdd a new payment method
PUT/api/stripe/payment-methods/updateUpdate default payment method
DELETE/api/stripe/payment-methods/deleteRemove a payment method
GET/api/stripe/payment-methods/[id]Get payment method details

Setup Intents

MethodPathDescription
POST/api/stripe/setup-intentCreate a Setup Intent for saving payment method
GET/api/stripe/setup-intent/[id]Get Setup Intent status

Payment Intents

MethodPathDescription
POST/api/stripe/payment-intentCreate a one-time Payment Intent

Products

MethodPathDescription
GET/api/stripe/productsList available Stripe products/prices

Webhook

MethodPathDescription
POST/api/stripe/webhookStripe webhook event handler

The Stripe webhook handler processes events such as:

  • checkout.session.completed - Checkout completion
  • customer.subscription.created - New subscription
  • customer.subscription.updated - Subscription changes
  • customer.subscription.deleted - Subscription cancellation
  • invoice.payment_succeeded - Successful payment
  • invoice.payment_failed - Failed payment

Lemon Squeezy (/api/lemonsqueezy)

Lemon Squeezy provides a simpler subscription model with 7 endpoints.

MethodPathDescription
POST/api/lemonsqueezy/checkoutCreate a Lemon Squeezy checkout
GET/api/lemonsqueezy/listList user's subscriptions
POST/api/lemonsqueezy/cancelCancel a subscription
POST/api/lemonsqueezy/reactivateReactivate a cancelled subscription
POST/api/lemonsqueezy/updateUpdate subscription details
POST/api/lemonsqueezy/update-planChange subscription plan
POST/api/lemonsqueezy/webhookLemon Squeezy webhook handler

Webhook Events

The Lemon Squeezy webhook processes:

  • subscription_created - New subscription
  • subscription_updated - Plan changes
  • subscription_cancelled - Cancellation
  • subscription_payment_success - Payment confirmation
  • subscription_payment_failed - Payment failure

Polar (/api/polar)

Polar provides 5 endpoints for checkout and subscription management.

MethodPathDescription
POST/api/polar/checkoutCreate a Polar checkout session
POST/api/polar/subscription/[subscriptionId]/cancelCancel subscription
POST/api/polar/subscription/[subscriptionId]/reactivateReactivate subscription
POST/api/polar/subscription/portalAccess subscription portal
POST/api/polar/webhookPolar webhook handler

Solidgate (/api/solidgate)

Solidgate is the most minimal integration with 2 endpoints.

MethodPathDescription
POST/api/solidgate/checkoutCreate a Solidgate checkout
POST/api/solidgate/webhookSolidgate webhook handler

Generic Payment (/api/payment)

Provider-agnostic payment endpoints for managing subscriptions regardless of the underlying payment provider.

MethodPathDescription
GET/api/payment/[subscriptionId]Get subscription details by ID
GET/api/payment/accountGet payment account for current user
GET/api/payment/account/[userId]Get payment account for specific user (admin)

Webhook Security

All webhook endpoints implement provider-specific signature verification:

Stripe

Stripe webhooks verify the stripe-signature header using the STRIPE_WEBHOOK_SECRET environment variable and the stripe.webhooks.constructEvent() method.

Lemon Squeezy

Lemon Squeezy webhooks verify the x-signature header using HMAC-SHA256 with the LEMONSQUEEZY_WEBHOOK_SECRET.

Polar

Polar webhooks verify request signatures using the POLAR_WEBHOOK_SECRET.

Solidgate

Solidgate webhooks use their SDK's built-in signature verification with the SOLIDGATE_SECRET_KEY.

Environment Variables

Stripe

VariableDescription
STRIPE_SECRET_KEYStripe API secret key
STRIPE_PUBLISHABLE_KEYStripe publishable key (client-side)
STRIPE_WEBHOOK_SECRETWebhook signing secret

Lemon Squeezy

VariableDescription
LEMONSQUEEZY_API_KEYLemon Squeezy API key
LEMONSQUEEZY_STORE_IDStore identifier
LEMONSQUEEZY_WEBHOOK_SECRETWebhook signing secret

Polar

VariableDescription
POLAR_ACCESS_TOKENPolar API access token
POLAR_WEBHOOK_SECRETWebhook signing secret
POLAR_ORGANIZATION_IDOrganization identifier

Solidgate

VariableDescription
SOLIDGATE_MERCHANT_IDMerchant identifier
SOLIDGATE_SECRET_KEYAPI secret key

Authentication Requirements

Endpoint TypeAuth Required
Checkout creationYes (authenticated user)
Subscription managementYes (subscription owner)
Payment method managementYes (Stripe customer)
Product listingPublic (Stripe products)
Webhook handlersSignature verification (no session)
Generic payment queriesYes (account owner or admin)