stripe-billing
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "stripe-billing" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-b1df14a34e86642506cb96b6cedf151e0348ecc2b84fd2461f1bc5d988f45b97. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Stripe Billing expert description: a complete billing platform for SaaS companies. For implementing subscription management, usage-based billing, metered pricing, free trials, proration, invoicing, customer portals, and webhook-based lifecycle management—covering simple monthly plans to complex seat + usage hybrid pricing.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Testing
- Not tested
Browse files
Frontmatter
name: stripe-billing
description: >-
You are an expert in Stripe Billing, the complete billing platform for SaaS
businesses. You help developers implement subscription management,
usage-based billing, metered pricing, free trials, proration, invoicing,
customer portal, and webhook-driven lifecycle management — building
everything from simple monthly plans to complex per-seat + usage hybrid
pricing.
license: Apache-2.0
compatibility: ''
metadata:
author: terminal-skills
version: 1.0.0
category: Backend Development
tags:
- payments
- subscriptions
- saas
- billing
- metered
- usage-basedStripe Billing — SaaS Subscription & Usage-Based Billing
You are an expert in Stripe Billing, the complete billing platform for SaaS businesses. You help developers implement subscription management, usage-based billing, metered pricing, free trials, proration, invoicing, customer portal, and webhook-driven lifecycle management — building everything from simple monthly plans to complex per-seat + usage hybrid pricing.
Core Capabilities
Subscription Setup
import Stripe from "stripe";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
// Create product + price
const product = await stripe.products.create({
name: "Pro Plan",
description: "Full access with API usage",
});
// Fixed recurring price
const monthlyPrice = await stripe.prices.create({
product: product.id,
unit_amount: 2900, // $29.00
currency: "usd",
recurring: { interval: "month" },
});
// Usage-based price (metered)
const apiPrice = await stripe.prices.create({
product: product.id,
currency: "usd",
recurring: { interval: "month", usage_type: "metered" },
billing_scheme: "tiered",
tiers_mode: "graduated",
tiers: [
{ up_to: 1000, unit_amount: 0 }, // First 1000 free
{ up_to: 10000, unit_amount: 1 }, // $0.01 per call (1K-10K)
{ up_to: "inf", unit_amount: 0.5 }, // $0.005 per call (10K+)
],
});
// Create checkout session
const session = await stripe.checkout.sessions.create({
mode: "subscription",
customer_email: user.email,
line_items: [
{ price: monthlyPrice.id, quantity: 1 },
{ price: apiPrice.id }, // Metered — no quantity
],
subscription_data: {
trial_period_days: 14,
metadata: { userId: user.id },
},
success_url: "https://app.example.com/billing/success?session_id={CHECKOUT_SESSION_ID}",
cancel_url: "https://app.example.com/billing/cancel",
});
// Redirect to session.url
Usage Reporting
// Report API usage for metered billing
async function reportUsage(subscriptionItemId: string, quantity: number) {
await stripe.subscriptionItems.createUsageRecord(subscriptionItemId, {
quantity,
timestamp: Math.floor(Date.now() / 1000),
action: "increment", // Adds to current period total
});
}
// In your API middleware
app.use(async (req, res, next) => {
next();
// After response, report usage
const user = req.user;
if (user.stripeSubscriptionItemId) {
await reportUsage(user.stripeSubscriptionItemId, 1);
}
});
Webhook Handler
app.post("/api/webhooks/stripe", async (req, res) => {
const event = stripe.webhooks.constructEvent(
req.body, req.headers["stripe-signature"]!, process.env.STRIPE_WEBHOOK_SECRET!,
);
switch (event.type) {
case "checkout.session.completed": {
const session = event.data.object as Stripe.Checkout.Session;
await db.users.update(session.metadata!.userId, {
plan: "pro",
stripeCustomerId: session.customer as string,
stripeSubscriptionId: session.subscription as string,
});
break;
}
case "invoice.paid": {
const invoice = event.data.object as Stripe.Invoice;
await db.invoices.create({
userId: await getUserByStripeCustomer(invoice.customer as string),
amount: invoice.amount_paid,
pdfUrl: invoice.invoice_pdf,
});
break;
}
case "customer.subscription.deleted": {
const sub = event.data.object as Stripe.Subscription;
await db.users.update({ stripeSubscriptionId: sub.id }, { plan: "free" });
break;
}
case "invoice.payment_failed": {
const invoice = event.data.object as Stripe.Invoice;
await sendPaymentFailedEmail(invoice.customer as string);
break;
}
}
res.json({ received: true });
});
Customer Portal
// Let customers manage their own subscription
app.post("/api/billing/portal", async (req, res) => {
const session = await stripe.billingPortal.sessions.create({
customer: req.user.stripeCustomerId,
return_url: "https://app.example.com/settings",
});
res.json({ url: session.url });
});
// Customer can: change plan, update payment method, cancel, view invoices
Installation
npm install stripe
Best Practices
- Webhooks are truth — Don't rely on checkout redirects alone; webhooks handle edge cases (failed payments, renewals)
- Customer portal — Use Stripe's hosted portal for plan changes, cancellation, invoices; saves weeks of development
- Metered billing — Report usage incrementally via
createUsageRecord; Stripe aggregates and invoices at period end - Trial periods — Set
trial_period_dayson subscription; no payment collected until trial ends - Proration — Stripe auto-prorates when customers upgrade/downgrade mid-cycle; no manual calculations
- Idempotency keys — Pass
idempotencyKeyon creates to prevent duplicate charges on retries - Test mode — Use
sk_test_key for development; Stripe provides test card numbers for all scenarios - Tax automation — Enable Stripe Tax for automatic tax calculation and collection; handles global tax compliance
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供完整的 Stripe Billing 集成方案,涵盖订阅管理、按量计费、Webhook 处理等 SaaS 企业核心需求
- 面向开发者解决实际业务痛点,具有明确的高频实用价值
Highlights
- 触发词精准完整,覆盖 Stripe Billing、SaaS、订阅、按量计费等多种变体
- description 在 frontmatter 和 body 中均有完整描述,边界清晰
Highlights
- 文档结构清晰,分 Core Capabilities、Installation、Best Practices 等章节
- 含完整 TypeScript 代码示例和端到端流程,frontmatter 完整
Highlights
- 提供完整代码示例,涵盖主要异常场景(Webhook 验证、支付失败处理)
- 工具来源明确(Stripe SDK),不可逆操作有确认机制
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 166
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- app.example.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.