E-commerce
Cloudcore Ecom adds products, subscriptions, Stripe, and PayPal checkout to your CMS. It's not a standalone service it's source code you copy into your CMS. One Worker, one database, one auth system.
Setup
- Clone the cloudcore-ecom repo
- Copy the
src/files into your CMS - Run the migration against your D1 database
- Mount the routes in your CMS
index.ts - Set Stripe/PayPal environment variables
Mount the routes
import { ecomRoutes, ecomPublicRoutes, ecomWebhookRoutes } from './ecom';
// Admin routes (behind auth)
app.route('/api/v1/shop', ecomRoutes);
// Public product listing (no auth)
app.route('/api/v1/public/shop', ecomPublicRoutes);
// Payment webhooks (verified by provider signatures)
app.route('/api/v1/webhooks', ecomWebhookRoutes); API Endpoints
Admin (requires CMS auth)
| Method | Endpoint | Description |
|---|---|---|
GET | /shop/products | List products |
GET | /shop/products/:id | Get product |
POST | /shop/products | Create product |
PATCH | /shop/products/:id | Update product |
DELETE | /shop/products/:id | Delete product |
POST | /shop/checkout | Create checkout session |
GET | /shop/subscriptions | List all subscriptions |
GET | /shop/subscriptions/my | Current user's subscriptions |
POST | /shop/subscriptions/:id/cancel | Cancel subscription |
Public (no auth)
| Method | Endpoint | Description |
|---|---|---|
GET | /public/shop/products | List active products |
GET | /public/shop/products/:slug | Get product by slug |
Product types
One-time purchase — a single payment for a product (template, download, etc.).
Subscription — recurring billing with configurable interval (weekly, monthly, yearly) and optional trial period.
Prices are in cents (4900 = $49.00).
Payment providers
Stripe — hosted checkout for cards. Set STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET.
PayPal — hosted checkout as alternative. Set PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, and PAYPAL_MODE (sandbox or live).
All card handling is done by Stripe/PayPal. No PCI compliance needed.
How it works
- Admin creates products via the CMS API
- Frontend lists active products via the public endpoint
- User clicks buy — frontend calls
/shop/checkoutwith product ID and provider - User is redirected to Stripe/PayPal hosted checkout
- On success, webhook creates order/subscription records in D1
- Frontend checks subscription status via
/shop/subscriptions/my
Database tables
All tables prefixed with cc_ecom_ to avoid conflicts with CMS tables:
cc_ecom_products— products and subscription planscc_ecom_orders— one-time purchase recordscc_ecom_subscriptions— active/canceled subscriptionscc_ecom_webhook_events— idempotency log for payment webhooks