Billing
by @ivangdavila
Build payment integrations, subscription management, and invoicing systems with webhook handling, tax compliance, and revenue recognition.
clawhub install billingπ About This Skill
name: Billing slug: billing version: 1.0.0 description: Build payment integrations, subscription management, and invoicing systems with webhook handling, tax compliance, and revenue recognition. metadata: {"clawdbot":{"emoji":"π³","requires":{"bins":[]},"os":["linux","darwin","win32"]}}
When to Use
User needs to implement or debug payment processing, subscription lifecycles, invoicing, or revenue operations. Agent handles Stripe/Paddle integration, webhook architecture, multi-currency, tax compliance, chargebacks, usage-based billing, marketplace splits, and revenue recognition patterns.
Quick Reference
| Topic | File |
|-------|------|
| Stripe integration | stripe.md |
| Webhooks & events | webhooks.md |
| Subscription lifecycle | subscriptions.md |
| Invoice generation | invoicing.md |
| Tax compliance | tax.md |
| Usage-based billing | usage-billing.md |
| Chargebacks & disputes | disputes.md |
| Marketplace payments | marketplace.md |
| Revenue recognition | revenue-recognition.md |
Core Rules
1. Money in Smallest Units, Always
amount: 1000 = $10.00amount_cents_usd2. Webhook Security is Non-Negotiable
Stripe-Signature header)event_id and check idempotency β webhooks duplicatewebhooks.md for implementation patterns3. Subscription State Machine
Critical states and transitions: | State | Meaning | Access | |-------|---------|--------| |trialing | Free trial period | β
Full |
| active | Paid and current | β
Full |
| past_due | Payment failed, retrying | β οΈ Grace period |
| canceled | Will end at period end | β
Until period_end |
| unpaid | Exhausted retries | β None |Never grant access based on status === 'active' alone β check current_period_end.
4. Cancel vs Delete: Revenue at Stake
cancel_at_period_end: true β Access until period ends, stops renewalsubscription.delete() β Immediate termination, possible refund5. Proration Requires Explicit Choice
When changing plans mid-cycle: | Mode | Behavior | Use When | |------|----------|----------| |create_prorations | Credit unused, charge new | Standard upgrades |
| none | Change at renewal only | Downgrades |
| always_invoice | Immediate charge/credit | Enterprise billing |Never rely on PSP defaults β specify explicitly every time.
6. Race Conditions Are Guaranteed
customer.subscription.updated fires BEFORE invoice.paid frequently.
7. Tax Compliance Is Not Optional
| Scenario | Action | |----------|--------| | Same country | Charge local VAT/sales tax | | EU B2B + valid VAT | 0% reverse charge (verify via VIES) | | EU B2C | MOSS β charge buyer's country VAT | | US | Sales tax varies by 11,000+ jurisdictions | | Export (non-EU) | 0% typically |Missing required invoice fields = legally invalid invoice. See tax.md.
8. PCI-DSS: Never Touch Card Data
pm_*, cus_*)disputes.md for compliance patterns9. Chargebacks Have Deadlines
| Stage | Timeline | Action | |-------|----------|--------| | Inquiry | 1-3 days | Provide evidence proactively | | Dispute opened | 7-21 days | Submit compelling evidence | | Deadline missed | Automatic loss | Set alerts |>3 intentos de cobro fallidos consecutivos = posible trigger de fraude monitoring.
10. Revenue Recognition β Cash Collected
For SaaS under ASC 606/IFRS 15:revenue-recognition.md for accounting patternsBilling Traps
Security & Compliance
invoice.paidIntegration Errors
subscription_id β impossible to reconcile refundspayment_intent.requires_action β stuck paymentsmode: 'subscription' without handling customer.subscription.deletedFinancial Errors
Operational Errors
β‘ When to Use
User needs to implement or debug payment processing, subscription lifecycles, invoicing, or revenue operations. Agent handles Stripe/Paddle integration, webhook architecture, multi-currency, tax compliance, chargebacks, usage-based billing, marketplace splits, and revenue recognition patterns.