Fintech

How to Build an Agent That Handles Subscription Cancellations

Antonio Evans9 min read

A split scene: on the left, a customer taps cancel on a phone; on the right, a support agent interface shows a contract excerpt highlighted with a cooling-off date, a refund amount.
Key points

Key points

  1. 1Build the cancellation agent as a deterministic state machine with four tools (contract reader, billing lookup, jurisdiction rules, refund router) rather than a free-form chat loop.
  2. 2Have the agent fill a structured case record (customer ID, contract ID, cancellation date, cooling-off end date, refundable amount, reason code) and let a policy engine decide what happens next.
  3. 3Gate every irreversible step, especially the refund call to the payment provider, behind dual approval when the amount, jurisdiction or contract type crosses a threshold.
  4. 4Log each tool call, extracted field, policy decision and approval into one append-only audit record so the case can be reconstructed months later.

Start with the failure you are actually preventing

A cancellation agent is not a retention chatbot. It is a billing change with legal consequences. The money moves in one direction (back to the customer), the clock is set by statute or contract, and the record may be read by a regulator, a card network or a lawyer. That combination means the agent's job is narrower than a general support assistant: extract the right facts, apply the right rule, and stop at the point where a human or a policy engine must confirm.

The payment plumbing you already have determines what the agent can do at the end of the flow. A payment processor verifies and authorizes transactions and moves funds between the customer's bank and yours, while a gateway encrypts and transmits card data and handles fraud checks. The gateway moves information, not money (Stripe, FreedomPay). Refunds and chargeback management sit with the processor or the merchant-of-record provider, not the gateway (Wise). So the agent's terminal tool must call whichever party in your stack is contractually allowed to issue a refund.

If you sell through a merchant of record, that entity is the legal seller and typically owns refunds, tax and dispute handling (Stripe, Paddle). Your agent then routes a refund request into the MoR's workflow rather than calling a card API directly. Get this wrong and you either double-refund the customer or promise a refund you have no authority to issue.

The four tools and what each must return

Design each tool as a typed function with a fixed output schema. The language model's only job is to choose the tool and fill its arguments; the tool returns facts.

1. Contract reader. Input: contract ID or document. Output: cancellation notice period, early termination fee (if any), cooling-off clause with its own start date, refund basis (full, pro rata, none), and the clause IDs where each was found. Never let the agent paraphrase a clause without the source span.

2. Billing lookup. Input: customer ID. Output: plan start date and time in the customer's time zone, list of charges (date, amount, currency, status), last successful payment, payment method token reference, and current subscription status.

3. Jurisdiction rules. Input: customer country and region, contract type, purchase channel. Output: statutory withdrawal right (yes or no), length in calendar or business days, and whether the right was correctly disclosed at purchase. Keep this table versioned and reviewed by counsel, not by the model.

4. Refund router. Input: a case record with an idempotency key. Output: refund ID, amount, status, and provider timestamp. It refuses to run without a policy decision ID.

A small helper schema keeps the handoff honest:

{
  "case_id": "CXL-10482",
  "customer_id": "cust_8821",
  "contract_id": "ctr_2024_A",
  "cancellation_requested_at": "2025-03-10T18:22:00Z",
  "cooling_off_ends_at": "2025-03-13T23:59:59-05:00",
  "refundable_amount": 49.00,
  "currency": "USD",
  "reason_code": "WITHIN_WITHDRAWAL_WINDOW",
  "policy_decision_id": "pol_7781",
  "idempotency_key": "refund_CXL-10482_v1"
}

Standard statutory windows and what they do not cover

Most practitioners assume a general three day right to cancel. There isn't one. The FTC's Cooling-Off Rule gives three days to cancel certain sales made at the buyer's home, workplace or a temporary seller location, and it explicitly does not cover sales made entirely online, by mail or by telephone (FTC, Cornell LII). The clock runs to midnight of the third business day, with Saturday counted and Sundays and federal holidays excluded (FTC).

State and sector rules add their own windows. Ohio, for example, gives five days for business opportunity plans, seven days for telemarketing sales and thirty days for hearing aids, generally measured in business days (Ohio Attorney General).

SituationFederal defaultState or sector overlayWhat the agent must check
Door-to-door, home or temporary site3 business days (FTC)Some states extend, e.g. Ohio (Ohio AG)Purchase channel, dollar thresholds ($25 at home, $130 at temporary sites)
Online, mail or phone only saleNot covered (FTC)Contract terms and regional consumer lawContract clause and jurisdiction table
Business opportunity planNone federal5 days in Ohio (Ohio AG)Contract type and state
TelemarketingNone federal7 days in Ohio (Ohio AG)Sales channel captured at signup

The practical lesson: the agent must treat cooling-off as a property of the specific contract and purchase channel, not a global constant. If disclosure was defective, the window may stay open. Ohio notes that a cancellation right does not start until the consumer receives written notice, so a health club that never gave notice leaves the right open (Ohio AG).

Worked example: a $49 monthly plan cancelled inside the window

A customer on a monthly plan at $49 calls on Monday, March 10, at 6:22 p.m. Eastern and asks to cancel. The plan started Friday, March 7. The jurisdiction is Ohio, the purchase was in person at a temporary location, and the amount was above $130 for that channel.

  1. Contract reader returns a 3 business day cooling-off clause, no early termination fee, full refund basis, clause 7.2.
  2. Billing lookup shows one charge of $49 on March 7, status settled, and no usage credits.
  3. Jurisdiction rules confirm the FTC 3 business day window applies and was disclosed. Counting business days from Friday: Saturday counts, Sunday does not, Monday does not count as a holiday. The customer has until midnight on Wednesday, March 12 (FTC).
  4. Policy engine sees "within window, amount $49, first charge, no fee clause" and auto-approves a full refund of $49 with reason code WITHIN_WITHDRAWAL_WINDOW.
  5. Refund router issues the refund with idempotency key refund_CXL-10482_v1 and returns a refund ID.

Total exposure: $49. Compare that with the same request arriving Thursday, March 13. The window has closed, the clause still permits cancellation with 30 days notice, and the refund basis is pro rata for unused days. The policy engine now routes the case to a human for approval because the amount is not determinable from a statutory rule alone. One day of difference in arrival changes the decision path, which is exactly why the deadline must be computed, not guessed.

Statutory rules are written in terms your database does not naturally hold. For a sense of how detailed they can get, read the FTC's rules on how a valid cancellation is delivered, such as postmark timing (FTC). Your agent should capture the customer's stated channel and timestamp, then let the rules table decide whether that channel is valid.

Contract terms the agent must read before it promises anything

Your own terms may create refund obligations that are stricter than statute, or exits that are more expensive than the customer expects. A vendor lock-in analysis of SaaS contracts points to narrow cancellation windows, sometimes 30 days before renewal, missing data export obligations and vague termination language as the most common ways customers get trapped (toslawyer). Each of those becomes an edge case the cancellation agent will meet.

The agent should extract and surface, in plain language:

  • Notice period before the next renewal date.
  • Whether cancellation is effective at renewal or immediately.
  • Early termination fee formula and any cap.
  • What data the customer gets back, in what format, and for how long after termination.
  • Whether a separate refund policy exists and which one wins in a conflict.

That last point matters when a refund is promised by promise but constrained by the contract. The agent should never resolve the conflict itself; it should raise a flag with both clause IDs attached.

If you rely on a merchant of record, check what refund and chargeback terms it imposes. MoR providers typically manage refunds and disputes on the seller's behalf and carry the legal seller role, while payment facilitators process payments and leave tax, compliance and most customer liability with you (Paddle, Gapp Group). The agent's refund router has to speak to whichever model you chose, and its ceilings should be set by that contract.

Approval gates that stop the agent acting beyond its authority

The decision rule is simple: an action needs human approval when it is irreversible, costly, regulated or affects many records. Issuing a refund is the textbook case, and refund initiation is commonly paired with dual approval from finance and a manager, with the invoice and validation evidence attached (StackAI). Approval workflows also need to route to the right approver role, supply an evidence pack that can be reviewed in 10 to 30 seconds, and support "approve with edits" so a reviewer does not restart the whole case (StackAI).

A workable gate matrix for cancellations:

TriggerAuto or humanEvidence the approver sees
Refund within statutory window, under your small-amount ceilingAuto after policy decisionContract clause, billing charges, deadline calculation
Refund outside statutory window, any amountHuman, financeContract clause, pro rata math, prior refunds
Refund above ceiling or multiple refunds in 90 daysDual approval (StackAI)Charges, policy decision ID, idempotency key
Defective cooling-off disclosure suspectedHuman, legalDisclosure record from signup
Customer disputes the deadlineHuman, support leadTimestamps, channel, rules version

Two implementation details cause most incidents. First, idempotency: every refund call carries a key derived from the case and attempt number so a retry cannot double-pay. Second, evidence packs: the tool outputs and the policy decision, assembled before the approval screen loads, so the reviewer is confirming a decision rather than hunting for facts (StackAI).

A step limit is also worth setting. If the agent loops more than twice on the same tool call, stop and hand off. Loops usually mean missing data, and missing data is a reason to ask a human, not to retry.

Why token portability can block the refund

If your customer paid with a stored card credential, the refund usually goes back to the original payment method. That only works if you can still resolve the token. Processor tokens usually work only inside that processor's environment; the token string is meaningless elsewhere because the mapping to the underlying card stays behind the provider's API (Payment Therapist). Network tokens are issued and managed by the card networks and can update automatically when a card is reissued, but coverage varies by region and issuer, so a PAN fallback is still needed in some cases (Very Good Security).

For the cancellation agent, this means one extra check before the refund router runs: can this payment method be refunded, and by whom? Tokenization documentation makes the same point, that only the original tokenization system can swap the token back to the primary account number for authorization (Payabli). When a merchant moves processors, the agent may find a valid charge and a token it cannot resolve. The right output is a reason code like REFUND_CHANNEL_UNAVAILABLE and a manual task, not a promise of a refund.

Audit logging that survives a review

Log every step, not just the outcome. A workable event schema for the case:

  • request_received with channel, timestamp in UTC, and computed customer-local time.
  • tool_call for each of the four tools, with input hash, output, latency and the tool version.
  • field_extracted for each contract field, with source clause ID and confidence.
  • deadline_computed with the rules version and the exact business-day arithmetic.
  • policy_decision with the decision ID, rule fired and threshold values.
  • approval_requested and approval_granted with approver role, timestamp and any edits.
  • refund_submitted with idempotency key and provider response.
  • customer_notified with the message template ID.

Store the events append-only and make the case replayable from the log alone. When an auditor asks who did what, when and why, the answer should be one query, not an archaeology project (StackAI). Keep the rules table version in the log too: if the deadline calculation changes after a review, you need to prove which version produced which case decision.

Two habits pay off. First, separate the model's reasoning from the tools' facts in the log so a model upgrade cannot be blamed for a wrong refund. Second, sample-approve recorded cases weekly against the rules table to catch drift before a customer does.

When multiple models sit behind these tools (a small model for extraction, a larger one for ambiguous contract language), routing them through one API with a single key keeps cost tracking and failover simple. Quanta Inference (https://quantaintelligence.ai/inference) exposes text and embedding models through an OpenAI-compatible endpoint, which is enough to prototype the reader and the classifier before you commit to a policy engine. For teams that want the approval workflow and audit trail built by someone who has shipped it, a Quanta consulting call (https://quantaintelligence.ai/calendar) covers scope and architecture in half an hour.

FAQ

FAQ

Does every customer get three days to cancel a subscription?

No. The FTC Cooling-Off Rule applies to certain in-person sales, such as at the buyer's home or a temporary location, and explicitly excludes sales made entirely online, by mail or by phone (FTC). Any right beyond that comes from your contract, state law or sector rules, so the agent must look it up per case rather than assume.

How should the agent count business days for a deadline?

Count Saturday as a business day and exclude Sundays and federal holidays, matching the FTC's method (FTC). Ohio uses the same business-day definition for its own cancellation periods (Ohio AG). Store the computation and the rules version in the audit log so the arithmetic can be rechecked.

What if the customer was never shown a cancellation notice?

The window may still be open. Ohio notes that cancellation periods generally do not start until the consumer receives written notice of the right to cancel (Ohio AG). Treat missing disclosure as a legal-review trigger rather than letting the agent deny the request.

Can the agent issue the refund itself once the policy engine approves?

Only below the ceiling you set. Refunds are routinely treated as high-blast-radius actions that need approval, and larger or repeat refunds are commonly paired with dual sign-off (StackAI). Above that line the agent should assemble the evidence pack and wait.

What happens if the payment token cannot be refunded?

The agent should stop and raise a REFUND_CHANNEL_UNAVAILABLE code. Processor tokens often cannot be resolved outside their own environment, which breaks refunds after a processor switch (Payment Therapist). Network tokens reduce this risk in many regions but coverage is not universal, so a manual fallback is still required (Very Good Security).

Sources

Sources

  1. Payment processor vs gateway vs merchant account | Stripe
  2. Payment Gateway vs. Processor vs. Acquirer: Key Differences Explained
  3. Payment Gateway vs Payment Processor: Key Differences ... - Wise
  4. Merchant of Record vs Payment Facilitator: A Guide For Business
  5. Payfac vs Merchant of Record - Paddle
  6. Buyer's Remorse: The FTC's Cooling-Off Rule May Help
  7. cooling-off rule | Wex | US Law | LII / Legal Information Institute
  8. Cancellation Rights of Consumers - Ohio Attorney General
  9. SaaS Vendor Lock-In: Exit Clauses and Data Portability ...
  10. Merchant of Record vs Payment Facilitator: Which Fits? - Gapp Group
  11. Human-in-the-Loop AI Agents: How to Design Approval ...
  12. Everybody Loves Tokenization Until They Try to Leave ...
  13. What Merchants Need to Know About Network Tokens
  14. Payment method tokenization
About the author

About the author

Antonio Evans
Antonio Evans

Antonio Evans is the founder of Quanta Intelligence and a fractional CTO who builds HIPAA-ready AI systems for health and life-science companies. Before that he was technical co-founder of FriendsEAT for twenty years, CEO of Socialdraft, and a data engineer at IBM. Antonio lives with his dog Santino in Lisbon, Portugal.

All articles