Članci s tagom #billing
-
Stripe billing in PHP SaaS: 4 edge cases that bit us in production
Sonar billing: PlanService::PLANS canonical catalog (free/solo $9.99/pro $29/agency $79 + limits enforcement), 4 production fixes — M1 dual-sub guard (redirect to portal), M2 Price ID env rotation fallback (historical DB lookup), M3 event ordering guard (GREATEST last_stripe_event_at), M4 unknown Stripe status preserves access. Trial → Solo limits. invoice.payment_failed = log only, let Stripe dun.
-
Stripe integration in PHP without stripe-php: webhook verification from scratch
StripeBridge: zero-dependency Stripe HTTP client (form-encoded + JSON), Idempotency-Key on all POSTs (tenant_id+sha256(email) for customers, customer_id+price_id for checkouts), HMAC-SHA256 webhook verification with hash_equals + 5-min replay window, StripeException::redact() strips emails + digit runs, TLS pinning CURLOPT_SSL_VERIFYPEER=true.
-
Per-tenant AI usage tracking in PHP: attributing every LLM token to its tenant
Two tracking systems: ai_usage_daily (day-level aggregates for budget monitoring, composite PK on date+tenant+provider+model) and limai_token_usage (per-call rows with execution_id for agent log correlation). tenant_id is the required first parameter in every write path — silent attribution bugs aren't possible.
-
Trial lifecycle in PHP SaaS: from signup to suspended in three database columns
A 14-day trial managed by three DB columns (plan_status, trial_ends_at, is_public_signup), a daily cron job that flips expired trials to suspended, and middleware that redirects suspended users to the upgrade page. No billing framework required.