Skip to main content

PaywallError

SolvaPay SDK


SolvaPay SDK / server/src / PaywallError

Class: PaywallError

Defined in: packages/server/src/paywall.ts:62

Error thrown when a paywall is triggered (subscription required or usage limit exceeded).

This error is automatically thrown by the paywall protection system when:

  • Customer doesn't have required subscription
  • Customer has exceeded usage limits
  • Customer needs to upgrade their plan

The error includes structured content with checkout URLs and metadata for building custom paywall UIs.

Example

import { PaywallError } from '@solvapay/server';

try {
const result = await payable.http(createTask)(req, res);
return result;
} catch (error) {
if (error instanceof PaywallError) {
// Custom paywall handling
return res.status(402).json({
error: error.message,
checkoutUrl: error.structuredContent.checkoutUrl,
// Additional metadata available in error.structuredContent
});
}
throw error;
}

See

PaywallStructuredContent for the structured content format

Since

1.0.0

Extends

  • Error

Constructors

Constructor

new PaywallError(message, structuredContent): PaywallError

Defined in: packages/server/src/paywall.ts:69

Creates a new PaywallError instance.

Parameters

message

string

Error message

structuredContent

PaywallStructuredContent

Structured content with checkout URLs and metadata

Returns

PaywallError

Overrides

Error.constructor

Properties

structuredContent

structuredContent: PaywallStructuredContent

Defined in: packages/server/src/paywall.ts:71

Structured content with checkout URLs and metadata