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
- Stripe/most PSPs use cents:
amount: 1000 = $10.00
- Store amounts as integers, NEVER floats (floating-point math fails)
- Always clarify currency in variable names:
amount_cents_usd
- Different currencies have different decimal places (JPY has 0, KWD has 3)
2. Webhook Security is Non-Negotiable
- ALWAYS verify signatures before processing (
Stripe-Signature header)
- Store
event_id and check idempotency — webhooks duplicate
- Events arrive out of order — design state machines, not sequential flows
- Use raw request body for signature verification, not parsed JSON
- See
webhooks.md for implementation patterns
3. 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 renewal
subscription.delete() → Immediate termination, possible refund
- Confusing these loses revenue OR creates angry customers
- Default to cancel-at-period-end; immediate delete only when requested
5. 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.
- Design for eventual consistency
- Use database transactions for access changes
- Idempotent handlers that can safely reprocess
- Status checks before granting/revoking access
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
- NEVER store PAN, CVV, or magnetic stripe data
- Only store PSP tokens (
pm_*, cus_*)
- Tokenization happens client-side (Stripe.js, Elements)
- Even "last 4 digits + expiry" is PCI scope if stored together
- See
disputes.md for compliance patterns
9. 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:
- Annual payment ≠ annual revenue (recognized monthly)
- Deferred revenue is a liability, not an asset
- Multi-element contracts require allocation to performance obligations
- See
revenue-recognition.md for accounting patterns
Billing Traps
Security & Compliance
- Webhook without signature verification → attackers fake
invoice.paid
- Storing tokens in frontend JS → extractable by attackers
- CVV in logs → PCI violation, massive fines
- Retry loops without limits → fraud monitoring triggers
Integration Errors
- Not storing
subscription_id → impossible to reconcile refunds
- Assuming charge success = payment complete (3D Secure exists)
- Ignoring
payment_intent.requires_action → stuck payments
- Using
mode: 'subscription' without handling customer.subscription.deleted
Financial Errors
- Hardcoding tax rates → wrong when rates change
- Amounts in dollars when PSP expects cents → 100x overcharge
- Recognizing 100% revenue upfront on annual plans → audit findings
- Confusing bookings vs billings vs revenue → material discrepancies
Operational Errors
- Sending payment reminders during contractual grace period
- Dunning without checking for open disputes → double loss
- Proration without specifying mode → unexpected customer charges
- Refunding without checking for existing chargeback → paying twice
1---
2name: billing
3slug: billing
4version: 1.0.0
5description: Build payment integrations, subscription management, and invoicing systems with webhook handling, tax compliance, and revenue recognition.
6metadata:
7 source: https://skillmd.com/skills/modbender/billing
8 clawdbot:
9 emoji: 💳
10 requires:
11 bins: []
12 os:
13 - linux
14 - darwin
15 - win32
16---
17
18## When to Use
19
20User 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.
21
22## Quick Reference
23
24| Topic | File |
25|-------|------|
26| Stripe integration | `stripe.md` |
27| Webhooks & events | `webhooks.md` |
28| Subscription lifecycle | `subscriptions.md` |
29| Invoice generation | `invoicing.md` |
30| Tax compliance | `tax.md` |
31| Usage-based billing | `usage-billing.md` |
32| Chargebacks & disputes | `disputes.md` |
33| Marketplace payments | `marketplace.md` |
34| Revenue recognition | `revenue-recognition.md` |
35
36## Core Rules
37
38### 1. Money in Smallest Units, Always
39- Stripe/most PSPs use cents: `amount: 1000` = $10.00
40- Store amounts as integers, NEVER floats (floating-point math fails)
41- Always clarify currency in variable names: `amount_cents_usd`
42- Different currencies have different decimal places (JPY has 0, KWD has 3)
43
44### 2. Webhook Security is Non-Negotiable
45- ALWAYS verify signatures before processing (`Stripe-Signature` header)
46- Store `event_id` and check idempotency — webhooks duplicate
47- Events arrive out of order — design state machines, not sequential flows
48- Use raw request body for signature verification, not parsed JSON
49- See `webhooks.md` for implementation patterns
50
51### 3. Subscription State Machine
52Critical states and transitions:
53| State | Meaning | Access |
54|-------|---------|--------|
55| `trialing` | Free trial period | ✅ Full |
56| `active` | Paid and current | ✅ Full |
57| `past_due` | Payment failed, retrying | ⚠️ Grace period |
58| `canceled` | Will end at period end | ✅ Until period_end |
59| `unpaid` | Exhausted retries | ❌ None |
60
61Never grant access based on `status === 'active'` alone — check `current_period_end`.
62
63### 4. Cancel vs Delete: Revenue at Stake
64- `cancel_at_period_end: true` → Access until period ends, stops renewal
65- `subscription.delete()` → Immediate termination, possible refund
66- Confusing these loses revenue OR creates angry customers
67- Default to cancel-at-period-end; immediate delete only when requested
68
69### 5. Proration Requires Explicit Choice
70When changing plans mid-cycle:
71| Mode | Behavior | Use When |
72|------|----------|----------|
73| `create_prorations` | Credit unused, charge new | Standard upgrades |
74| `none` | Change at renewal only | Downgrades |
75| `always_invoice` | Immediate charge/credit | Enterprise billing |
76
77Never rely on PSP defaults — specify explicitly every time.
78
79### 6. Race Conditions Are Guaranteed
80`customer.subscription.updated` fires BEFORE `invoice.paid` frequently.
81- Design for eventual consistency
82- Use database transactions for access changes
83- Idempotent handlers that can safely reprocess
84- Status checks before granting/revoking access
85
86### 7. Tax Compliance Is Not Optional
87| Scenario | Action |
88|----------|--------|
89| Same country | Charge local VAT/sales tax |
90| EU B2B + valid VAT | 0% reverse charge (verify via VIES) |
91| EU B2C | MOSS — charge buyer's country VAT |
92| US | Sales tax varies by 11,000+ jurisdictions |
93| Export (non-EU) | 0% typically |
94
95Missing required invoice fields = legally invalid invoice. See `tax.md`.
96
97### 8. PCI-DSS: Never Touch Card Data
98- NEVER store PAN, CVV, or magnetic stripe data
99- Only store PSP tokens (`pm_*`, `cus_*`)
100- Tokenization happens client-side (Stripe.js, Elements)
101- Even "last 4 digits + expiry" is PCI scope if stored together
102- See `disputes.md` for compliance patterns
103
104### 9. Chargebacks Have Deadlines
105| Stage | Timeline | Action |
106|-------|----------|--------|
107| Inquiry | 1-3 days | Provide evidence proactively |
108| Dispute opened | 7-21 days | Submit compelling evidence |
109| Deadline missed | Automatic loss | Set alerts |
110
111>3 intentos de cobro fallidos consecutivos = posible trigger de fraude monitoring.
112
113### 10. Revenue Recognition ≠ Cash Collected
114For SaaS under ASC 606/IFRS 15:
115- Annual payment ≠ annual revenue (recognized monthly)
116- Deferred revenue is a liability, not an asset
117- Multi-element contracts require allocation to performance obligations
118- See `revenue-recognition.md` for accounting patterns
119
120## Billing Traps
121
122### Security & Compliance
123- Webhook without signature verification → attackers fake `invoice.paid`
124- Storing tokens in frontend JS → extractable by attackers
125- CVV in logs → PCI violation, massive fines
126- Retry loops without limits → fraud monitoring triggers
127
128### Integration Errors
129- Not storing `subscription_id` → impossible to reconcile refunds
130- Assuming charge success = payment complete (3D Secure exists)
131- Ignoring `payment_intent.requires_action` → stuck payments
132- Using `mode: 'subscription'` without handling `customer.subscription.deleted`
133
134### Financial Errors
135- Hardcoding tax rates → wrong when rates change
136- Amounts in dollars when PSP expects cents → 100x overcharge
137- Recognizing 100% revenue upfront on annual plans → audit findings
138- Confusing bookings vs billings vs revenue → material discrepancies
139
140### Operational Errors
141- Sending payment reminders during contractual grace period
142- Dunning without checking for open disputes → double loss
143- Proration without specifying mode → unexpected customer charges
144- Refunding without checking for existing chargeback → paying twice