Skip to content

Policy Engine Overview

What is the Policy Engine?

The Policy Engine is the system that governs how entitlements behave throughout their lifecycle. Instead of hardcoding business rules into the plugin's source code, MIDDAG Account externalizes them as policies -- configurable rules that you can adjust from the WordPress admin without touching a single line of code.

Every entitlement in the system -- whether it represents a software license, a managed hosting environment, or a service contract -- follows rules defined by policies. When should a renewal attempt happen? How many days of grace does a customer get after a failed payment? Can a customer request a refund after 15 days? The Policy Engine answers all of these questions.

Why configurable rules?

Hardcoded logic breaks when your business changes. A 7-day grace period that works for plugin licenses may be too short for enterprise service contracts. A refund window that fits your US market may not match Brazilian consumer protection requirements.

The Policy Engine lets you define sensible defaults once, then override them where needed -- without code changes, without deployments, and without risk of breaking unrelated behavior.

The 10 policies

MIDDAG Account ships with 10 policies that cover the full entitlement lifecycle:

PolicyWhat it governs
RenewalAuto-renewal, grace periods, pricing on renewal
Payment RecoveryWhat happens when a payment fails, suspension-to-cancellation time
CancellationPost-expiry visibility, data retention, data export
SLAResponse times, resolution times, uptime targets, escalation
CreditCredit expiration, consumption order, overdraft limits
ProvisioningAuto vs manual setup, approval workflows, deprovisioning
TrialTrial duration, conversion behavior, abuse prevention
RefundRefund window, auto-approval thresholds, impact on entitlement
Tier ChangeUpgrade/downgrade timing, cooldown periods, approval requirements
NotificationChannels, reminder timing, opt-out settings

Each policy is documented in detail on the Available Policies page.

The 5-level hierarchy

Policies are not one-size-fits-all. The Policy Engine uses a 5-level hierarchy so you can set broad defaults and then narrow them down where needed:

The most specific level wins. If you set a 7-day grace period globally but override it to 30 days for Organization X, then Organization X gets 30 days. Every other organization still gets 7 days.

This hierarchy is covered in depth on the Policy Hierarchy page.

How policies affect the entitlement lifecycle

Entitlements move through four states: active, suspended, expired, and cancelled. Policies control the rules at every transition:

  • Active to Suspended -- The Payment Recovery Policy decides when a failed payment triggers suspension (immediately, or after all retries are exhausted).
  • Suspended to Active -- The Payment Recovery Policy controls whether reactivation is automatic when payment succeeds.
  • Suspended to Cancelled -- The Payment Recovery Policy sets how many days an entitlement stays suspended before automatic cancellation.
  • Active to Expired -- The Renewal Policy determines when and how renewal is attempted before expiration.
  • Expired to Active -- The Renewal Policy governs the renewal grace window.
  • Expired to Cancelled -- The Cancellation Policy defines how long an expired entitlement waits before automatic cancellation.
  • Cancelled to Active -- Win-back reactivation, governed by provisioning and renewal rules.

Policies also control what happens around these transitions: notifications sent, data retained, credits adjusted, and resources provisioned or deprovisioned.

When would you change a policy?

Common scenarios where an admin adjusts policies:

  • A new enterprise customer needs a longer grace period on payment recovery. Override the Payment Recovery Policy at the organization level to give them 60 days instead of 30.
  • You launch a trial program for your hosting product. Enable the Trial Policy at the Environment entitlement class level.
  • A high-value contract requires faster SLA response times. Override the SLA Policy at the individual entitlement level.
  • You expand to a new market where refund windows differ. Adjust the Refund Policy at the global or product level.
  • A customer is abusing tier changes, flipping between plans every week. Set a 30-day cooldown on the Tier Change Policy for their organization.

What you do NOT need the Policy Engine for

The Policy Engine governs entitlement behavior rules. It does not handle:

  • Product pricing -- managed in WooCommerce product settings.
  • User permissions -- managed through collaborator roles and scopes.
  • Integration configuration -- managed in the Integrations settings panel.
  • Tax and fiscal rules -- governed by legal requirements, not configurable policies. Tax data retention follows LGPD/fiscal mandates regardless of policy settings.

Next steps