Skip to main content

Subscription and Billing Service

The Subscription and Billing Service is a Python Lambda that integrates with the Paddle payment gateway. It handles the backend logic for the Paddle Payment Integration vertical.

What It Does

  • Webhook Processing — Receives Paddle webhooks and syncs billing data to S3.
  • Subscription Management — APIs for checking status, cancelling, resuming, and switching plans.
  • One-Time Purchases — Tracks completed purchases, handles refunds, and grants product access.
  • Entity Licenses — Allocates named seats or slots per purchase/subscription. Each product price can grant a configurable number of entities. Entities are automatically cleaned up if a subscription lapses or a purchase is refunded.
  • Billing History — Provides invoice and transaction data to the frontend.

API Endpoints

User Routes

MethodPathDescription
GET/subscriptions/statusGet subscription status by product
POST/subscriptions/cancelSchedule cancellation at period end
POST/subscriptions/resumeResume canceled subscription
POST/subscriptions/updateSwitch to a different plan
GET/billing/historyGet past transactions
GET/billing/invoiceDownload invoice PDF
GET/products/listList products and pricing
GET/products/accessCheck product access (subscriptions and one-time purchases)
POST/licenses/saveCreate entity license
POST/licenses/updateUpdate entity license
GET/licenses/listList entity licenses
GET/licenses/checkVerify license validity
GET/sync/statusCheck if billing sync is complete
POST/sync/forceForce immediate billing data sync

Admin Routes

Admin routes require the provider path prefix: /paddle/{sandbox|live}.

MethodPathDescription
POST/admin/syncSync customer data from Paddle
GET/admin/catalogList Paddle product catalog
GET/config/productsGet product configuration
POST/config/productsSave product configuration
GET/config/p_refGet product reference names
POST/config/p_refSave product reference names
GET/config/credentialsGet Paddle API credentials (masked)
POST/config/credentialsUpdate Paddle webhook secret

Webhook

MethodPathDescription
POST/webhookProcess Paddle webhook events

Config

MethodPathDescription
GET/config/activeGet active payment provider
POST/config/activeSet active payment provider
GET/config/providersList available providers
GET/config/is-adminCheck if current user is admin

Device

MethodPathDescription
POST/uuidRegister device UUID
GET/uuid/{uuid}Get device UUID status

Project Structure

Location: {vertical}/sbcs/

sbcs/src/
├── lambda_handler.py # Entry point + routing
└── lfn/
├── common/ # Provider config, admin check, S3 config
├── device/ # UUID registration and tracking
├── paddle/
│ ├── api_client.py # Paddle HTTP client with retry logic
│ ├── admin/ # Catalog and product config
│ └── user/
│ ├── record/ # Sync engine, webhook handler
│ ├── status/ # Subscriptions, purchases, history
│ ├── operations/ # Cancel, resume, switch
│ └── license/ # Product access, entity licenses
└── stripe/ # Stripe provider (stub)

Configuration

This service requires Paddle API credentials. You can configure them in two ways:

  • Via the Admin panel at /admin
  • Directly in your environment settings

The service works alongside the Auth Service — all user routes require authentication.


Redeployment

After updating the billing logic:

  1. Select Subscription and Billing from the Service dropdown in the UX.
  2. Click Deploy Service.