stripe-subscription-billing-test-author
Use when Stripe subscriptions or recurring billing need tests: trial to paid, proration on upgrade and downgrade, dunning on failed renewals, cancel and…
от testland★ 18 звёзд на GitHub
Установить stripe-subscription-billing-test-author в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
stripe-subscription-billing-test-author
Overview
Subscription billing is distinct from one-time payments. A customer's card is charged on a schedule, trials expire, plans change mid-cycle, and payments fail weeks after signup. Per docs.stripe.com/billing/testing, Stripe's sandbox is feature-complete for billing objects: subscriptions, invoices, trials, and retry schedules all work against test data.
The key tool for deterministic subscription testing is the Stripe Billing
test clock, which lets you fast-forward a frozen simulation through days,
weeks, or months without waiting. Per
docs.stripe.com/api/test_clocks,
a test clock is created at a frozen_time and advanced with
POST /v1/test_helpers/test_clocks/{id}/advance, triggering all billing
events that would have fired in the elapsed interval.
This skill walks through five recurring-billing scenarios end to end.
Lifecycle states to test
Per docs.stripe.com/billing/subscriptions/overview, subscriptions move through:
| State | Meaning |
|---|---|
trialing |
Trial active; no payment collected yet |
active |
Good standing; payment collected |
past_due |
Latest invoice unpaid; smart retries running |
unpaid |
Retries exhausted; access decision pending |
canceled |
Terminal; billing stopped |
paused |
Trial ended without payment method attached |
Each transition fires one or more webhook events. Tests must assert both the subscription status and the correct event sequence.
Step 1 - Create a test clock
Per docs.stripe.com/api/test_clocks, create a test clock frozen at a known epoch before creating any billing objects:
const clock = await stripe.testHelpers.testClocks.create({
frozen_time: Math.floor(new Date('2025-01-01T00:00:00Z').getTime() / 1000),
name: 'billing-suite-run',
});
Attach the customer to the clock at creation time:
const customer = await stripe.customers.create({
email: '[email protected]',
test_clock: clock.id,
payment_method: 'pm_card_visa', // 4242 4242 4242 4242
invoice_settings: { default_payment_method: 'pm_card_visa' },
});
Advance time with:
await stripe.testHelpers.testClocks.advance(clock.id, {
advances_to: Math.floor(new Date('2025-01-08T00:00:00Z').getTime() / 1000),
});
// Poll until clock.status === 'ready' before asserting
Always poll GET /v1/test_helpers/test_clocks/{id} until status is ready
before asserting subscription state; events are asynchronous.
Step 2 - Trial-to-paid conversion
Per docs.stripe.com/billing/testing, the recommended flow:
// Freeze clock at Jan 1
const sub = await stripe.subscriptions.create({
customer: customer.id,
items: [{ price: PRICE_ID }],
trial_end: Math.floor(new Date('2025-01-08T00:00:00Z').getTime() / 1000),
});
expect(sub.status).toBe('trialing');
// Advance to Day 5 - trial_will_end fires 3 days before trial ends
await stripe.testHelpers.testClocks.advance(clock.id, {
advances_to: toEpoch('2025-01-05'),
});
await waitForClockReady(clock.id);
// Assert: customer.subscription.trial_will_end webhook fired
// Advance past trial end (Day 8)
await stripe.testHelpers.testClocks.advance(clock.id, {
advances_to: toEpoch('2025-01-09'),
});
await waitForClockReady(clock.id);
const updated = await stripe.subscriptions.retrieve(sub.id);
expect(updated.status).toBe('active');
Webhook events to assert per docs.stripe.com/billing/testing:
| Clock position | Event |
|---|---|
| Day 5 | customer.subscription.trial_will_end |
| Day 8 | invoice.created, invoice.finalized, invoice.paid |
| Day 8 | customer.subscription.updated (status: trialing -> active) |
Step 3 - Proration on upgrade/downgrade
Per docs.stripe.com/billing/subscriptions/prorations, a mid-cycle plan change generates a credit for unused time on the old price and a charge for remaining time on the new price. Preview before applying:
const prorationDate = Math.floor(Date.now() / 1000);
// Preview the upcoming invoice to verify proration amounts
const preview = await stripe.invoices.createPreview({
customer: customer.id,
subscription: sub.id,
subscription_details: {
items: [{ id: sub.items.data[0].id, price: NEW_PRICE_ID }],
proration_date: prorationDate,
},
});
// Verify credit (negative) and debit (positive) line items exist
const credit = preview.lines.data.find(l => l.amount < 0);
const debit = preview.lines.data.find(l => l.amount > 0);
expect(credit).toBeTruthy();
expect(debit).toBeTruthy();
// Apply at the same proration_date to lock the amounts
await stripe.subscriptions.update(sub.id, {
items: [{ i
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- .tessl-plugin/plugin.json
FAQ
Что делает скилл stripe-subscription-billing-test-author?
Use when Stripe subscriptions or recurring billing need tests: trial to paid, proration on upgrade and downgrade, dunning on failed renewals, cancel and reactivate, and the subscription webhook events, using Stripe test clocks to skip through billing cycles without waiting.
Как установить скилл stripe-subscription-billing-test-author?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл stripe-subscription-billing-test-author запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…