Skip to main content
Copy-paste patterns for implementing time-based subscription access.

Basic Time-Based Validation

For subscription plans, validate that the user’s access hasn’t expired:

Subscription Middleware

Express middleware for subscription-only endpoints:
For most use cases, the built-in paymentMiddleware from @nevermined-io/payments/express handles all of this automatically. Use this custom middleware only when you need fine-grained control over subscription expiration warnings.

FastAPI Subscription Dependency

For most use cases, the built-in PaymentMiddleware from payments_py.x402.fastapi handles all of this automatically. Use this custom dependency only when you need fine-grained control over subscription expiration warnings.

Subscription Status Endpoint

Provide an endpoint for clients to check their subscription status:

Graceful Expiration Handling

Handle subscription expiration gracefully with warnings:

Hybrid Plans (Time + Credits)

Handle plans that have both time limits and credit limits:

Next Steps

Dynamic Pricing

Variable pricing strategies

Validate Requests

Request validation patterns