Skip to content

Orders

An Order is a purchase record. In MIDDAG Account, WooCommerce handles the commerce -- products, checkout, payments, and subscriptions -- while MIDDAG Account handles what happens after the purchase: creating entitlements, tracking lifecycle, and connecting everything to the customer's organization.

Customers never see WooCommerce. The customer portal uses its own terminology ("orders" and "invoices," not "WooCommerce orders") and its own interface. WooCommerce is the backoffice engine, visible only to your admin team.

How orders create entitlements

This is the core pipeline. When a customer completes a purchase, MIDDAG Account automatically creates the entitlements that give them access to what they bought:

Step by step:

  1. Payment is confirmed -- via Stripe webhook (credit card), Banco Inter webhook (Pix or boleto), or manual admin confirmation.
  2. WooCommerce order status changes to completed -- this fires the standard WooCommerce hook.
  3. MIDDAG Account's provisioning service analyzes the order -- it reads each line item and checks the _middag_entitlement_class product meta to determine what class of entitlement to create.
  4. An entitlement is created for each line item -- with a unique code, status active, and linked to the order and organization.
  5. Downstream resources are provisioned -- a License for PLG items, an Environment for ENV items, a Service and Contract for SVC items, and so on.

The entire pipeline runs automatically. After a customer pays, they have their entitlements and access within seconds -- no admin intervention required.

Idempotency

If a payment webhook fires twice (which happens in practice), the system does not create duplicate entitlements. It checks whether an entitlement already exists for the same order + line item + class combination and skips creation if one is found.

Order lifecycle and entitlement lifecycle

The order status in WooCommerce maps to entitlement behavior:

WooCommerce order statusEffect on entitlement
CompletedEntitlement created with status active
ProcessingNo entitlement yet -- payment is still being confirmed
On holdNo entitlement yet -- waiting for manual payment (boleto)
RefundedEntitlement cancelled (if full refund) or remains active (partial, per policy)
CancelledEntitlement cancelled
FailedNo entitlement created

For subscriptions (handled by WooCommerce Subscriptions):

Subscription eventEffect on entitlement
Renewal paidEntitlement remains active, expiration date extended
Renewal failedPayment Recovery Policy consulted -- may suspend entitlement
CancelledEntitlement moves to expired or cancelled (per policy)
UpgradedSame entitlement, tier attribute changes
DowngradedSame entitlement, tier attribute changes (may require approval)

WooCommerce Subscriptions handles all the complexity of recurring billing: proration, upgrade/downgrade calculations, and payment retry. MIDDAG Account's subscription adapter translates these events into entitlement lifecycle transitions.

Refund and cancellation impact

When an order is refunded or cancelled, the impact on the entitlement depends on the type:

  • Full refund -- The linked entitlement is cancelled. Downstream resources (licenses, environments, services) are deactivated. The Refund Policy controls whether this happens automatically or requires admin approval.
  • Partial refund -- The entitlement stays active by default. The admin can manually adjust the entitlement if the partial refund warrants reduced access.
  • Order cancellation -- The entitlement is cancelled. If the entitlement was already provisioned, downstream resources are deactivated.

The Refund Policy (configurable through the Policy Engine) controls:

  • How many days after purchase a refund is allowed
  • Whether refunds below a threshold are processed automatically
  • Whether credits are forfeited, retained, or adjusted proportionally
  • Whether the entitlement is automatically cancelled after a full refund

Where orders come from

Orders in MIDDAG Account can originate from several paths:

OriginHow it works
Quote acceptedCustomer accepts a quote in the portal, WooCommerce order is created automatically, payment link is sent
Direct purchaseAdmin creates an order in WooCommerce manually
Subscription renewalWooCommerce Subscriptions creates a renewal order automatically
HubSpot dealA deal in HubSpot syncs to a quote, which converts to an order

Regardless of origin, the entitlement creation pipeline works the same way.

Dual-entity routing

Every order is routed to the correct MIDDAG legal entity -- MIDDAG BR (Brazil) or MIDDAG GLOBAL (US LLC) -- based on the organization's tax ID, billing entity setting, product configuration, or currency. This determines which Stripe account processes the payment and which tax rules apply.

The routing is automatic but can be overridden by an admin per transaction.

What admins see

In the WordPress admin, the orders view shows:

  • Order number and date
  • Organization name
  • Amount and currency
  • Payment status
  • Billing entity (BR or GLOBAL)
  • Linked entitlement codes

Admins also have a financial dashboard that aggregates data across both entities:

  • Total revenue by period (monthly, quarterly, annual)
  • Revenue split by entity (BR vs GLOBAL)
  • Pending payments (unpaid boletos, open invoices)
  • Overdue invoices
  • Active vs cancelled subscriptions

The financial dashboard is admin-only -- customers do not have access to it. Customers see their own order history through the portal, with MIDDAG Account terminology (never WooCommerce labels).