Cloudcore Beta

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

  1. Clone the cloudcore-ecom repo
  2. Copy the src/ files into your CMS
  3. Run the migration against your D1 database
  4. Mount the routes in your CMS index.ts
  5. 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)

MethodEndpointDescription
GET/shop/productsList products
GET/shop/products/:idGet product
POST/shop/productsCreate product
PATCH/shop/products/:idUpdate product
DELETE/shop/products/:idDelete product
POST/shop/checkoutCreate checkout session
GET/shop/subscriptionsList all subscriptions
GET/shop/subscriptions/myCurrent user's subscriptions
POST/shop/subscriptions/:id/cancelCancel subscription

Public (no auth)

MethodEndpointDescription
GET/public/shop/productsList active products
GET/public/shop/products/:slugGet 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

  1. Admin creates products via the CMS API
  2. Frontend lists active products via the public endpoint
  3. User clicks buy — frontend calls /shop/checkout with product ID and provider
  4. User is redirected to Stripe/PayPal hosted checkout
  5. On success, webhook creates order/subscription records in D1
  6. 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 plans
  • cc_ecom_orders — one-time purchase records
  • cc_ecom_subscriptions — active/canceled subscriptions
  • cc_ecom_webhook_events — idempotency log for payment webhooks