返回顶部
B

Billing计费系统

Build payment integrations, subscription management, and invoicing systems with webhook handling, tax compliance, and revenue recognition.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
731
下载量
免费
免费
2
收藏
概述
安装方式
版本历史

Billing

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

TopicFile
Stripe integrationINLINECODE0
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: INLINECODE10
  • 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:
StateMeaningAccess
INLINECODE14Free trial period✅ Full
INLINECODE15
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
  • INLINECODE22 → 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:
ModeBehaviorUse When
INLINECODE23Credit unused, charge newStandard upgrades
INLINECODE24
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
ScenarioAction
Same countryCharge 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
StageTimelineAction
Inquiry1-3 daysProvide 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 INLINECODE33
  • 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 INLINECODE37

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

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 billing-1776419957 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 billing-1776419957 技能

通过命令行安装

skillhub install billing-1776419957

下载

⬇ 下载 Billing v1.0.0(免费)

文件大小: 18.06 KB | 发布时间: 2026-4-17 20:13

v1.0.0 最新 2026-4-17 20:13
Initial release

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部