Skip to main content

Payment Type Definitions

Source: lib/payment/types/payment-types.ts, lib/constants/payment.ts

Payment types power the multi-provider billing system. They define how payments are created, verified, and managed across Stripe, LemonSqueezy, Polar, and Solidgate.

Enums

PaymentPlan

Available subscription tiers.

enum PaymentPlan {
FREE = 'free',
STANDARD = 'standard',
PREMIUM = 'premium',
}

PaymentInterval

Billing cycle options for recurring charges.

enum PaymentInterval {
DAILY = 'daily',
WEEKLY = 'weekly',
MONTHLY = 'monthly',
YEARLY = 'yearly',
ONE_TIME = 'one-time',
PER_SUBMISSION = 'per-submission',
}

PaymentType

Classifies a payment as one-time, recurring, or free.

enum PaymentType {
ONE_TIME = 'one_time',
SUBSCRIPTION = 'subscription',
FREE = 'free',
}

PaymentStatus

Tracks the lifecycle of a single payment attempt.

enum PaymentStatus {
PENDING = 'pending',
PAID = 'paid',
FAILED = 'failed',
}

PaymentMethod

Supported payment instruments.

enum PaymentMethod {
CREDIT_CARD = 'credit_card',
PAYPAL = 'paypal',
}

PaymentCurrency

Currencies accepted by the platform.

enum PaymentCurrency {
USD = 'USD', EUR = 'EUR', GBP = 'GBP',
CAD = 'CAD', AUD = 'AUD', ETH = 'ETH',
}

SupportedProvider

Union type of all payment provider identifiers.

type SupportedProvider = 'stripe' | 'solidgate' | 'lemonsqueezy' | 'polar';

Interfaces

PaymentIntent

Represents a pending or completed payment.

interface PaymentIntent {
id: string;
amount: number; // Amount in smallest currency unit (cents)
currency: string;
status: string;
clientSecret?: string; // For client-side confirmation
customerId?: string;
}
FieldDescription
idProvider-assigned payment identifier
amountAmount in cents (e.g., 1000 = $10.00)
currencyISO 4217 currency code
clientSecretToken passed to the frontend SDK for confirmation

CheckoutParams

Parameters for initiating a checkout session.

interface CheckoutParams {
priceId?: string;
variantId?: number;
quantity?: number;
successUrl?: string;
cancelUrl?: string;
customerEmail?: string;
email?: string;
customPrice?: number;
metadata?: Record<string, any>;
dark?: boolean;
}

BillingDetails

Customer billing information attached to a payment.

interface BillingDetails {
name?: string;
email?: string;
phone?: string;
address?: {
line1?: string;
line2?: string;
city?: string;
state?: string;
postalCode?: string;
country?: string;
};
}

PaymentProviderConfig

Credentials needed to initialise a provider.

interface PaymentProviderConfig {
apiKey: string;
webhookSecret?: string;
secretKey?: string;
options?: Record<string, any>;
}

ClientConfig

Frontend-safe configuration returned by getClientConfig().

interface ClientConfig {
publicKey: string;
paymentGateway: SupportedProvider;
options?: Record<string, any>;
}

Usage Example

import { PaymentPlan, PaymentType } from '@/lib/constants/payment';
import type { CheckoutParams } from '@/lib/payment/types/payment-types';

const params: CheckoutParams = {
priceId: 'price_abc123',
successUrl: '/checkout/success',
cancelUrl: '/pricing',
metadata: { plan: PaymentPlan.PREMIUM },
};