Billing automation

From seaworld008/Commonly-used-high-value-skills · View interactive version

Billing automation is an AI agent skill from the GitHub repository seaworld008/Commonly-used-high-value-skills. Build automated billing systems for recurring payments, invoicing, subscription lifecycle, and dunning management. Use when implementing subscription billing, automating invoicing, or managing recurring payment systems.

How to use this skill

Skill file

Billing Automation

Master automated billing systems including recurring billing, invoice generation, dunning management, proration, and tax calculation.

When to Use This Skill

Core Concepts

1. Billing Cycles

Common Intervals:

2. Subscription States

trial → active → past_due → canceled
              → paused → resumed

3. Dunning Management

Automated process to recover failed payments through:

4. Proration

Adjusting charges when:

Quick Start

The following is architecture pseudocode, not an installable billing SDK.

No such package is bundled. Bind the engine and subscription types to the

project's actual payment adapter and implement their dependencies before running.

from datetime import datetime, timezone
from billing import BillingEngine, Subscription  # placeholder project adapter

# Initialize billing engine
billing = BillingEngine()

# Create subscription
subscription = billing.create_subscription(
    customer_id="cus_123",
    plan_id="plan_pro_monthly",
    billing_cycle_anchor=datetime.now(timezone.utc),
    trial_days=14
)

# Process billing cycle
billing.process_billing_cycle(subscription.id)

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Its classes

and undefined dependencies are illustrative. In production, calculate periods

using the business/processor calendar, anchor and timezone; do not copy the

reference's fixed 30/365-day month/year arithmetic. Specify month-end, leap-year,

DST and proration rules and test boundary dates.

Use integer minor units or Decimal with explicit currency precision and

rounding. The reference's hardcoded USD / int(amount * 100) example is not a

currency-general conversion or a verified payment integration.

<!-- LOCAL-CURATION-SUPPLEMENT:START -->

Implementation Checklist

Before building or changing billing logic, capture:

Verification Scenarios

Test billing changes with concrete timelines:

  1. Trial user converts to paid plan before trial end.
  2. Monthly subscriber upgrades mid-cycle and receives prorated credit.
  3. Payment fails three times, enters dunning, then recovers.
  4. Annual customer cancels with service continuing through paid period.
  5. Seat count changes immediately before renewal.

Record expected invoices, subscription state transitions, customer notifications, and ledger entries for each scenario. Do not ship billing automation with only happy-path tests.

Risk Controls

Billing changes need stronger safeguards than ordinary workflow automation:

User-facing Summary

When reporting billing automation work, include the business effect:

Changed:
Risk reduced:
Customer impact:
Accounting impact:
Tests run:
Open rollout concern:

This helps reviewers evaluate both code correctness and revenue operations risk.

<!-- LOCAL-CURATION-SUPPLEMENT:END -->

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.