Purchase and Renewal Flow
This page explains the complete purchase pipeline -- from quote to entitlement -- and how renewals, auto-renewals, and payment recovery work.
The purchase pipeline
Step by step
1. Quote creation
Quotes originate from two sources:
- HubSpot CRM -- The sales team creates a quote in HubSpot. A webhook sends it to MIDDAG Account, which creates a local record with line items, pricing, and validity dates.
- Admin panel -- The admin creates a quote directly in the WordPress admin, selecting the Organization, billing entity (BR or US), line items, and terms.
Quotes start in draft status. When sent to the customer, they transition to sent.
2. Customer review
The customer sees pending quotes in the portal. Opening a quote transitions it from sent to viewed (tracked with a timestamp). The customer can:
- Review line items and pricing
- Add comments for negotiation
- Accept the quote (irreversible)
- Reject the quote (requires a reason)
Quotes have a configurable validity period (default: 30 days). Expired quotes cannot be accepted but can be re-sent by the admin with new validity dates.
3. Acceptance and order creation
When the customer accepts a quote:
- The quote status transitions to
accepted. - The system automatically creates a WooCommerce order from the quote's line items.
- The order is linked to the quote via metadata.
- The status is synced back to HubSpot.
- The customer is directed to the payment step.
4. Payment
Payment methods depend on the billing entity:
| Entity | Available methods |
|---|---|
| MIDDAG BR | Credit card (Stripe), Pix, Boleto (Banco Inter) |
| MIDDAG GLOBAL | Credit card (Stripe) |
The customer selects a payment method in the portal:
- Pix: QR code generated, payment confirmed via Banco Inter webhook (30-minute timeout).
- Boleto: Generated with due date, payment confirmed via Banco Inter webhook.
- Credit card: Stripe Elements form, payment confirmed via Stripe webhook.
5. Entitlement provisioning
When payment is confirmed:
- The WooCommerce order status updates to
paid. - The quote transitions to
paid. - The system analyzes the order's line items to determine the entitlement class (PLG, ENV, SVC, ORD, EDU).
- An entitlement is created automatically with a unique code.
- Downstream resources are provisioned based on the class.
- The quote transitions to
fulfilled. - The customer is notified with the entitlement code.
See Entitlement Activation for details on what happens after the entitlement is created.
6. Cascade effects
Payment confirmation triggers additional downstream actions:
- Invoice -- Stripe generates an invoice, synced via webhook.
- NFSe -- For BR transactions, a tax invoice is issued automatically via ISSNet (see Billing and Finance).
- HubSpot -- The deal/quote status is updated in the originating portal.
- Jira -- If configured, a Jira issue is created for order fulfillment.
Renewal flow
Auto-renewal
For subscription-based entitlements, renewal is handled by WooCommerce Subscriptions and Stripe:
- The renewal policy determines when to attempt renewal (default: 7 days before expiration).
- The system charges the stored payment method via Stripe.
- On success, the entitlement's end date extends and remains
active. - The customer is notified of the successful renewal.
Manual renewal
For non-subscription entitlements or when auto-renewal is disabled:
- The system sends renewal reminders at configurable intervals (default: 30, 7, and 1 day before expiration).
- The customer can initiate renewal from the portal, which starts a new payment flow.
- On payment, the entitlement is renewed with updated dates.
Grace period
When an entitlement expires without renewal:
- The entitlement transitions to
expired. - A configurable grace period begins (governed by the RenewalPolicy).
- During the grace period, the customer can still renew.
- If the grace period ends without renewal, the system transitions the entitlement toward cancellation (see Suspension and Recovery).
Payment recovery
When a renewal payment fails:
- The system retries according to Stripe's retry schedule.
- If retries exhaust, the PaymentRecoveryPolicy determines what happens next.
- By default, the entitlement is suspended after retries are exhausted.
- The customer is notified at each step.
- If payment is recovered, the entitlement returns to
activeautomatically.
See Suspension and Recovery for the full suspension and escalation timeline.
Related pages
- Entitlement Activation -- What happens after an entitlement is created
- Billing and Finance -- Invoice generation and tax invoices
- Multi-Entity Operations -- How the billing entity affects payment methods
- Orders -- Concept definitions for orders and quotes