MuseMVP Docs
Billing

Creem

Configure the Creem gateway.

MuseMVP integrates Creem as one of its payment gateways, offering a payment solution for indie developers without a US entity. Through the unified Muse Billing module, it shares the same business logic and database tables as Stripe. This guide explains how to configure the Creem gateway and understand how it works.

Get MUSE_CREEM_GATEWAY_API_KEY

Before deploying or running locally, configure the required secrets.

# Creem API key (starts with `creem_`)
MUSE_CREEM_GATEWAY_API_KEY="creem_test_xxx1"
# Environment: sandbox (testing) or production
MUSE_CREEM_GATEWAY_ENV="sandbox"

Retrieve your API key from the Creem Dashboard.

Creem

Key Security

MUSE_CREEM_GATEWAY_API_KEY is server-side only; never expose it to the client or version control.

Get MUSE_CREEM_GATEWAY_WEBHOOK_SECRET

# Webhook signing secret (starts with `whsec_`)
MUSE_CREEM_GATEWAY_WEBHOOK_SECRET="whsec_xxx2"

Creem

Creem

In the Creem Dashboard, create a Webhook and set the callback URL to:

https://example.com/api/muse-billing/notify/muse_creem

Select the event types to listen for (or all):

  • checkout.completed
  • subscription.active
  • subscription.canceled
  • subscription.updated

Creem

Copy the Webhook secret into MUSE_CREEM_GATEWAY_WEBHOOK_SECRET.

Key Security

MUSE_CREEM_GATEWAY_WEBHOOK_SECRET is server-side only; never expose it to the client or version control.

Create Products and Get Product IDs

Product IDs come from config.payments.productCatalog.*.gatewayProductIds.muse_creem in src/config/index.ts by default, and can be overridden via environment variables:

# Pro monthly subscription price ID
NEXT_PUBLIC_MUSE_CREEM_PRICE_PRO_MONTHLY_ID="prod_xxx1"
# Pro yearly subscription price ID
NEXT_PUBLIC_MUSE_CREEM_PRICE_PRO_YEARLY_ID="prod_xxx2"
# Lifetime one-time price ID
NEXT_PUBLIC_MUSE_CREEM_PRICE_LIFETIME_ID="prod_xxx3"

Creem

After creating the corresponding products in the Creem Dashboard, fill in the product IDs via the environment variables above or in src/config/index.ts.

Local Development Testing

Download Ngrok

Ngrok (https://dashboard.ngrok.com/get-started/setup/windows) is a reverse proxy tool that exposes your local development server to the public internet.

Ngrok

Run

ngrok http 3000

Ngrok

Callback Domain

Use the terminal domain shown above as the callback URL in your Webhook configuration.

Switch to Sandbox Environment

Ensure MUSE_CREEM_GATEWAY_ENV is set to sandbox and use Creem's test mode in the Dashboard to run payment tests.

Test Mode

Payments in the Creem sandbox environment do not result in real charges, making it safe for local testing of subscription and one-time purchase flows.

How It Works

Learn how Muse Billing integrates Creem into the system.

Integration Files

src/modules/muse-billing/lib/gateways/muse-creem-gateway.ts
src/modules/muse-billing/lib/orchestrator.ts
src/backend/api/routes/muse-billing/router.ts
FilePurpose
muse-creem-gateway.tsCreem gateway implementation: launch, Webhook parsing, contract sync.
orchestrator.tsBilling orchestration layer: launch, customer-hub, Webhook dispatch.
router.tsAPI routes: exposes /api/muse-billing/* endpoints.

Core Workflow

The action flow for payment and accessing the Customer Hub:

Frontend calls POST /api/muse-billing/launch with productId, optional gatewayId (defaults to orchestrator selection), etc.

Server resolves the Creem price ID from the config.payments.productCatalog mapping.

Creem returns launchUrl and launchSessionId; frontend redirects to the Creem-hosted checkout page.

After payment, Creem sends a webhook; the server verifies the signature and syncs contract lifecycle and access window to the database.

When the user needs to access the platform portal, call POST /api/muse-billing/customer-hub to get a redirect link to the Creem Customer Portal for managing subscriptions or downloading receipts.