Logo: Skill Cobranca Automatizada Saas Abacatepay

Skill Cobranca Automatizada Saas Abacatepay

Organisatioun
IAPro-Community
skill-cobranca-automatizada-saas-abacatepay

Automatic SaaS billing engine with AbacatePay (PIX + credit card), configurable dunning (regua de cobranca), trial management, invoice portal, email (Resend) and WhatsApp (Evolution API) notifications, admin CRUD, and billing metrics. Covers the full billing lifecycle from provisioning to collection.

Add to TypingMind

Iwwersiicht

EditeurIAPro-Community
RepositoryOrquestrador-Maestro
Skill-Nummskill-cobranca-automatizada-saas-abacatepay
Stären
63
Forks
11
Matgeliwwert Dateien
5
LizenzApache-2.0
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 5 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    IAPro-Community huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Skill Cobranca Automatizada Saas Abacatepay an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/IAPro-Community/Orquestrador-Maestro/tree/v1/codex/skills/skill-cobranca-automatizada-saas-abacatepay
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/IAPro-Community/Orquestrador-Maestro.git /tmp/Orquestrador-Maestro
mkdir -p .claude/skills
cp -r /tmp/Orquestrador-Maestro/codex/skills/skill-cobranca-automatizada-saas-abacatepay .claude/skills/skill-cobranca-automatizada-saas-abacatepay
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Skill Cobranca Automatizada Saas Abacatepay an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Skill Cobranca Automatizada Saas Abacatepay automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Skill Cobranca Automatizada Saas Abacatepay net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

skill-cobranca-automatizada-saas-abacatepay

When To Use

This skill covers the complete automated billing system ("cobranca automatizada") for Brazilian SaaS products using AbacatePay. Use when implementing or maintaining:

=== Provisioning ===

  • Billing configuration tables (cobrancas, cobranca_reguas, billing_config, etc.)
  • Dunning rule sequencing (cobranca_regua_eventos)
  • Encrypted integration configs (Resend, Evolution API, AbacatePay)

=== Billing Engine ===

  • Automated invoice generation and dunning execution via cron
  • AbacatePay billing creation (PIX + CARD)
  • Webhook processing with HMAC-SHA256 verification
  • Invoice state machine (pending, paid, overdue, cancelled, refunded)
  • Subscription/plan integration via cobranca_tracking

=== Trial Management ===

  • Configurable trial duration
  • Pre-expiration notifications (7/3/1 days before)
  • Automatic trial expiration and account blocking

=== Interfaces ===

  • Public invoice page (FaturaPage) with PIX QR Code, payment link, polling
  • Pricing/Plans page with AbacatePay checkout
  • User-side invoice listing (MinhasCobrancasSection)
  • Admin billing management (cobranças CRUD, planos CRUD, global settings)
  • Plan Manager (PlanManager) for user plan changes

=== Notifications ===

  • Email via Resend with HTML templates (logo, badge, invoice details)
  • WhatsApp via Evolution API with template variables
  • Variables: {{nome}}, {{plano}}, {{valor}}, {{vencimento}}, {{link_pagamento}}, {{empresa_nome}}
  • Dunning sequence: configurable events with days_apos_vencimento, channel (email/whatsapp/ambos)

Architecture

                     +-------------------+
                     |   Cron (8/12/16h  |
                     |   BRT + 5min)     |
                     +--------+----------+
                              |
         +--------------------+--------------------+
         |                    |                    |
   Processar            Trial               Metrics
   Cobranças          Notificações          (meia-noite)
         |                    |
   +-----v------+      +-----v------+
   | Ver regua   |      | Trial exp. |
   | Send notif  |      | Notif pre  |
   | Create bill |      +------------+
   +-----+------+
         |
   +-----v------------------------------------------+
   |           Controller Layer                      |
   |  cobrancas.ts | abacatepay-webhook.ts           |
   |  fatura.ts    | trial.ts                        |
   +-----+----------------------------+--------------+
         |                            |
   +-----v----------+        +--------v---------+
   |  AbacatePay    |        |  Notifications    |
   |  API v2        |        |  Resend + Evol.  |
   +----------------+        +------------------+
         |
   +-----v----------+
   |  Supabase/     |
   |  PostgreSQL    |
   +----------------+

Billing State Machine

pending ──► paid ──► refunded
  │
  ├──► overdue ──► paid
  │             └──► cancelled
  │
  └──► cancelled

States managed by invoice-state-machine.ts:

  • pending: cobrança criada, aguardando pagamento
  • paid: paga, released_at setado, conteúdo liberado
  • overdue: vencida, entra na régua de cobrança
  • cancelled: cancelada manualmente ou por expiração
  • refunded: estornada (transição exclusiva de paid)

Key Tables

TablePurpose
cobrancasCore billing records per user
cobranca_reguasDunning rule sets per tenant
cobranca_regua_eventosIndividual dunning events in sequence
billing_configEncrypted integration configs (Resend, Evolution, AbacatePay)
front_usersUser profiles with plan and status
partner_billing_configPartner-specific billing overrides
cobranca_trackingSubscription-like recurring billing tracking
transaction_logBilling operation audit log
abacatepay_eventsRaw webhook event storage

Full details in billing-tables.md.

Core Flows

Dunning Flow (Régua de Cobrança)

  1. Cron runs billing-cron.ts at 8h/12h/16h BRT
  2. Queries cobrancas WHERE status = 'overdue' AND NOT paga
  3. For each cobranca, resolves billing_config + cobranca_regua + cobranca_regua_eventos
  4. Checks if next evento should fire (based on dias_apos_vencimento)
  5. Sends notification via billing-sender.ts (email + WhatsApp)
  6. If all eventos fired and still overdue, marks as cancelled

Webhook Flow

  1. POST /api/abacatepay-webhook receives an AbacatePay v2 event
  2. HMAC-SHA256 signature verification (replay + timing-safe compare)
  3. Rate limited: 100 req/min per IP
  4. On checkout.completed or subscription.renewed: processPaymentWithTransaction updates cobranca + cobranca_tracking
  5. On failure: processRollback reverts state
  6. Raw event stored in abacatepay_events

Trial Flow

  1. trial-cron.ts runs every 5 minutes
  2. Queries users where trial ends within notification window
  3. Sends pre-expiration notifications (7/3/1 day before)
  4. On expiration: blocks account (status = blocked)
  5. billing-cron.ts also handles trial notifications at 8/12/16h

Invoice Portal Flow

  1. FaturaPage loads by shortlink (8 chars, unique)
  2. Materializes billing from AbacatePay API on demand
  3. Shows: PIX QR Code, payment link, due date, amount, status badge
  4. Polls status every 5 seconds
  5. "Share via WhatsApp" button with pre-formatted message

Configuration

billing_config stores encrypted credentials per owner (AES-256-GCM):

  • resend_config: Resend API key + from email
  • evolution_config: Evolution API URL + API key + instance
  • abacatepay_config: AbacatePay API key
  • trial_duration_days: Trial length (default)
  • Encryption key: BILLING_CONFIG_ENCRYPTION_KEY env var

See billing-config.md for full schema and setup.

Provider API Boundary

  • AbacatePay: new code uses API v2 and the webhook events checkout.completed, checkout.refunded, checkout.disputed, subscription.completed, subscription.renewed, and subscription.cancelled. The legacy v1 billing.* events belong behind a migration adapter.
  • Resend: keep the key server-side and send through the official SDK or POST https://api.resend.com/emails with Authorization: Bearer <key> and a User-Agent; use Idempotency-Key for retryable sends, record provider request IDs, and redact message content from logs.
  • Evolution API: use the deployed v2 documentation and apikey header; keep instance credentials server-side and account for v2.4.0 activation/licensing before diagnosing business-endpoint failures.

Guardrails

  1. Keep ALL payment provider secrets server-side. Never expose AbacatePay API keys in browser bundles.
  2. Process webhooks idempotently: check cobranca current state before mutating.
  3. Treat checkout redirect as advisory. Grant access only after webhook confirmation.
  4. Do not log API keys, webhook secrets, full CPF/CNPJ, full phone numbers.
  5. Cron must not overlap. billing-cron uses lock checks to prevent concurrent runs.
  6. Dunning notifications must respect channel preference (email, whatsapp, or ambos).
  7. Trial expiration is irreversible: set status = blocked, do not auto-unblock without payment.
  8. Metrics queries (MRR, faturamento) should use aggregateBillingMetrics(), not ad-hoc SQL.
  9. New integrations must use https://api.abacatepay.com/v2, /checkouts/create, /subscriptions/create, and /transparents/create as appropriate. Keep /v1/billing/* and billing.* only inside an explicit legacy adapter.

Local Reference (example-saas)

This skill is extracted from the example-saas SaaS billing system. The production codebase is at:

  • {{USER_HOME}}/Documents/Code/example-saas/server/controllers/cobrancas.ts — billing CRUD + processing + dunning
  • {{USER_HOME}}/Documents/Code/example-saas/server/controllers/abacatepay-webhook.ts — webhook handler
  • {{USER_HOME}}/Documents/Code/example-saas/server/controllers/fatura.ts — invoice lookup by shortlink
  • {{USER_HOME}}/Documents/Code/example-saas/server/controllers/trial.ts — trial expiration processing
  • {{USER_HOME}}/Documents/Code/example-saas/server/services/abacatepay-create-billing-v2.ts — AbacatePay billing creation
  • {{USER_HOME}}/Documents/Code/example-saas/server/services/billing-sender.ts — notification dispatch (email + WhatsApp)
  • {{USER_HOME}}/Documents/Code/example-saas/server/services/billing-email-template.ts — HTML invoice email template
  • {{USER_HOME}}/Documents/Code/example-saas/server/services/billing-integrations-config.ts — encrypted config management
  • {{USER_HOME}}/Documents/Code/example-saas/server/services/billing-metrics.ts — MRR and billing metrics
  • {{USER_HOME}}/Documents/Code/example-saas/server/utils/invoice-state-machine.ts — state machine logic
  • {{USER_HOME}}/Documents/Code/example-saas/server/cron/billing-cron.ts — main billing scheduler
  • {{USER_HOME}}/Documents/Code/example-saas/server/cron/trial-cron.ts — trial scheduler
  • {{USER_HOME}}/Documents/Code/example-saas/src/pages/FaturaPage.tsx — public invoice page
  • {{USER_HOME}}/Documents/Code/example-saas/src/components/PlansPage.tsx — pricing/plans page
  • {{USER_HOME}}/Documents/Code/example-saas/src/components/PlanManager.tsx — user plan manager
  • {{USER_HOME}}/Documents/Code/example-saas/src/components/AdminCobrancas.tsx — admin billing CRUD
  • {{USER_HOME}}/Documents/Code/example-saas/src/components/AdminPlanos.tsx — admin plan CRUD
  • {{USER_HOME}}/Documents/Code/example-saas/src/components/AdminGlobalSettings.tsx — global settings
  • {{USER_HOME}}/Documents/Code/example-saas/src/components/MinhasCobrancasSection.tsx — user invoice list
  • {{USER_HOME}}/Documents/Code/example-saas/supabase/migrations/20260617_cobrancas_foundation.sql — core tables
  • {{USER_HOME}}/Documents/Code/example-saas/supabase/migrations/20260617_cobrancas_website_final.sql — shortlink trigger
  • {{USER_HOME}}/Documents/Code/example-saas/supabase/migrations/20240101_billing_config.sql — billing_config table
  • {{USER_HOME}}/Documents/Code/example-saas/supabase/migrations/20240117_partner_billing.sql — partner billing

Reference Files

  • billing-tables.md — complete table schemas, indexes, enums, RLS policies
  • billing-flows.md — detailed flow diagrams and pseudocode for each core flow
  • billing-config.md — encryption, config resolution, and setup steps
  • billing-admin.md — admin interfaces and CRUD operations
  • billing-notifications.md — email/WhatsApp templates, dunning sequence, template variables

Validation

  • After changes, run build and typecheck (npm run build, npm run typecheck or equivalent)
  • Simulate webhook: POST checkout.completed and subscription.renewed events and verify idempotent processing
  • Test dunning: create overdue cobranca with regua de 0/3/7 dias and confirm notification dispatch
  • Test trial: set trial_duration_days=1, create user, wait for pre-expiration and expiration
  • Verify no AbacatePay/Resend/Evolution keys leak to browser bundles
  • Run project lint when available

Related Skills

  • skill-abacatepay-integration — AbacatePay v2 API specifics and legacy v1 migration boundary
  • skill-saas-core-limits — plan limits, entitlements, feature flags after payment
  • skill-evolution-api — WhatsApp notification channel
  • skill-supabase-rls — RLS policies for billing tables
  • skill-saas-factory — top-level SaaS construction entry

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Skill Cobranca Automatizada Saas Abacatepay?

Automatic SaaS billing engine with AbacatePay (PIX + credit card), configurable dunning (regua de cobranca), trial management, invoice portal, email (Resend) and WhatsApp (Evolution API) notifications, admin CRUD, and billing metrics. Covers the full billing lifecycle from provisioning to collection.

Firwat Skill Cobranca Automatizada Saas Abacatepay op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Skill Cobranca Automatizada Saas Abacatepay besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Skill Cobranca Automatizada Saas Abacatepay an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/IAPro-Community/Orquestrador-Maestro/tree/v1/codex/skills/skill-cobranca-automatizada-saas-abacatepay an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Skill Cobranca Automatizada Saas Abacatepay benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Skill Cobranca Automatizada Saas Abacatepay benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Skill Cobranca Automatizada Saas Abacatepay domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Skill Cobranca Automatizada Saas Abacatepay gratis?

Jo. IAPro-Community huet de Skill ënner der Lizenz Apache-2.0 op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇