lokicms-plugin-stripe
v1.0.0
Published
Stripe payments and subscriptions plugin for LokiCMS
Maintainers
Readme
Stripe Plugin for LokiCMS
Accept payments and manage subscriptions with Stripe.
Features
- Checkout Sessions: Create payment and subscription checkout flows
- Customer Portal: Allow customers to manage their subscriptions
- Subscription Management: Create, update, cancel subscriptions
- Product & Price Sync: Sync Stripe products/prices to LokiCMS entries
- Webhook Handling: Automatic sync on Stripe events
- MCP Tools: AI-accessible tools for payment operations
Installation
The plugin is included in LokiCMS. Enable it in plugins.json:
{
"plugins": [
{
"name": "stripe",
"enabled": true,
"source": "local",
"path": "./plugins/stripe",
"settings": {
"secretKey": "${STRIPE_SECRET_KEY}",
"webhookSecret": "${STRIPE_WEBHOOK_SECRET}",
"successUrl": "https://yoursite.com/checkout/success",
"cancelUrl": "https://yoursite.com/checkout/cancel",
"portalReturnUrl": "https://yoursite.com/account",
"currency": "usd"
}
}
]
}Environment Variables
STRIPE_SECRET_KEY=sk_live_... # or sk_test_... for testing
STRIPE_WEBHOOK_SECRET=whsec_...Content Types
The plugin creates these content types to sync Stripe data:
| Content Type | Description |
|--------------|-------------|
| stripe-product | Products from Stripe catalog |
| stripe-price | Prices (one-time or recurring) |
| stripe-subscription | Customer subscriptions |
| stripe-invoice | Invoices and payment records |
| stripe-customer | Customer records linked to users |
API Endpoints
Base path: /api/plugins/stripe
Checkout
# Create checkout session
POST /checkout
{
"priceId": "price_xxx",
"customerEmail": "[email protected]",
"mode": "subscription"
}
# Response
{
"id": "cs_xxx",
"url": "https://checkout.stripe.com/..."
}Customer Portal
# Create portal session
POST /portal
{
"customerId": "cus_xxx"
}Products & Prices
GET /products
GET /products?active=true
GET /prices
GET /prices?productId=prod_xxx&type=recurringSubscriptions
GET /subscriptions
GET /subscriptions/:id
POST /subscriptions/:id/cancel
POST /subscriptions/:id/resumeInvoices
GET /invoices
GET /invoices?customerId=cus_xxxSync
# Sync products from Stripe
POST /sync/products
# Sync prices from Stripe
POST /sync/pricesWebhooks
POST /webhook # Stripe webhook endpointConfigure in Stripe Dashboard:
- Endpoint:
https://yoursite.com/api/plugins/stripe/webhook - Events to send:
customer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedinvoice.paidinvoice.payment_failedcheckout.session.completedproduct.createdproduct.updatedprice.createdprice.updated
MCP Tools
Available tools for AI agents:
| Tool | Description |
|------|-------------|
| stripe_create_checkout | Create checkout session |
| stripe_create_portal | Create customer portal session |
| stripe_get_subscription | Get subscription details |
| stripe_cancel_subscription | Cancel subscription |
| stripe_list_products | List products |
| stripe_list_prices | List prices |
| stripe_list_subscriptions | List subscriptions |
| stripe_list_invoices | List invoices |
| stripe_sync_products | Sync products to LokiCMS |
Usage Examples
Create a Subscription Checkout
const response = await fetch('/api/plugins/stripe/checkout', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
priceId: 'price_monthly_pro',
customerEmail: '[email protected]',
mode: 'subscription',
trialDays: 14
})
});
const { url } = await response.json();
window.location.href = url;Check User Subscription
// Get subscriptions for a customer
const subs = await fetch('/api/plugins/stripe/subscriptions?customerId=cus_xxx');
const { subscriptions } = await subs.json();
const activeSub = subscriptions.find(s => s.status === 'active');Allow Customer to Manage Subscription
const response = await fetch('/api/plugins/stripe/portal', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
customerId: 'cus_xxx',
returnUrl: window.location.href
})
});
const { url } = await response.json();
window.location.href = url;License
MIT
