Payment processing with Stripe and Square.

A provider-agnostic payment interface with adapters for Stripe and Square. Handles checkout sessions, webhook verification, refunds, and idempotent payment processing.

Provider Interface

PaymentProvider defines the common contract:

  • Create single and multi-event checkout sessions
  • Verify webhook signatures
  • Retrieve session details and process refunds

Classes

c
PaymentUserError

Error subclass for user-facing payment validation errors (e.g. invalid phone number). These propagate through safeAsync so the message can be shown to the user.

Functions

f
buildMultiIntentMetadata

Build intent metadata for a multi-event checkout. Common fields: multi flag, name, email, serialized items, optional phone/date.

f
buildSingleIntentMetadata

Build intent metadata for a single-event checkout. Common fields: event_id, name, email, quantity, optional phone/address/date.

f
createWithClient

Create a withClient helper that runs an operation with a lazily-resolved client. Returns null if the client is not available or the operation fails.

f
errorMessage

Extract a human-readable message from an unknown caught value

f
extractSessionMetadata

Normalize validated session metadata into the canonical SessionMetadata shape.

f
getActivePaymentProvider

Resolve the active payment provider based on admin settings. Lazy-loads the provider module to avoid importing unused SDKs. Returns null if no provider is configured.

f
hasRequiredSessionMetadata

Validate that session metadata contains required fields (name) and either event_id (single) or multi+items (multi). Returns false if validation fails.

f
isPaymentStatus

Type guard: check if a string is a valid PaymentStatus

f
processBooking

Process a single-event booking.

f
safeAsync

Safely execute async operation, returning null on error. Re-throws PaymentUserError so user-facing messages propagate.

f
serializeMultiItems

Serialize multi-ticket items for metadata storage (compact JSON)

f
toCheckoutResult

Convert a provider-specific checkout result to a CheckoutSessionResult. Returns null if session ID or URL is missing.

Interfaces

Type Aliases

T
BookingResult

Booking result — callers map this to their response format

T
CheckoutSessionResult

Result of creating a checkout session.

T
MultiRegistrationIntent

Registration intent for multi-event checkout

T
MultiRegistrationItem

Single item within a multi-event checkout

T
PaymentProviderType

Supported payment provider identifiers

T
PaymentStatus

Valid payment status values

T
RegistrationIntent

Registration intent for a single event checkout

T
ValidatedPaymentSession

A validated payment session returned after checkout completion

T
WebhookEvent

Provider-agnostic webhook event

T
WebhookSetupResult

Result of webhook endpoint setup

T
WebhookVerifyResult

Result of webhook signature verification

Variables

v
paymentsApi

Stubbable API for internal calls (testable via spyOn, like stripeApi/squareApi)