Skip to main content
This guide creates an account plan with one transaction fee and one service fee, and uses it on one account. Account plans gives the rules that the steps follow.

Before you start


You need:
  • A ledger and an account for the customer, here with the alias @customer_001.
  • An account that receives the fees, here with the alias @fee_revenue.
  • The account-plans and fee-charges permissions on Midaz. See Permissions.
The examples use a ledger without route validation, where a transaction fee selects transactions by scheme. On a ledger with route validation, give each fee an accounting block too. See Accounting routes. The examples use these shell variables. Every UUID is a placeholder. Use the values from your own environment.
1

Create the account plan

Send the plan to Create an account plan. The fee tedSent charges 7.90 for each TED that the account sends, after 2 free TEDs in the month. The fee paperStatement charges 3 for each paper statement, after 1 free statement in the month.
Midaz answers 201 with the plan and its version 1. It fills in the defaults referenceAmount and period:
Keep the id of the plan:
2

Assign the plan to the account

Send the plan to Assign an account plan to an account:
Midaz answers 200 with the active assignment:
From now on, the fee packages of the ledger do not charge @customer_001 on the /v2 transactions it sends.
3

Send a transaction and read its fee

Send a TED from the account with Create a Transaction using the v2 direct model. The scheme is TED, so the fee tedSent matches:
The 201 response has accountPlanFees. The first TED of the month uses a free unit:
The third TED of the month is past the free quota. Its item has "outcome": "charged", "unit": 3, and "amount": "7.9". The account sends 107.9: the 100 of the TED and the fee, which goes to @fee_revenue.A transaction with another scheme, or without one, gets "outcome": "no_match". The account pays no fee on it.Keep accountPlanFees from the create response. The reads of the transaction do not return it.
4

Read the usage of the month

Read the units of the account with Get the account plan usage of an account:
After three TEDs, the response is:
period.start and period.end are the month in the plan timezone, in UTC.
5

Charge service fees

Charge two paper statements with Charge service fees to an account. Send an X-Idempotency key, and send the same key when you retry the same charge:
Midaz answers 201. The first statement uses the free unit, and the second costs 3:
The fee transaction debits 3 from @customer_001 and credits it to @fee_revenue. To undo the charge in the same month, revert that transaction.
6

Create a new version

Raise the free TEDs to 5 from November. Send only the field that changes to Update an account plan:
Midaz creates version 2 with both fees, and tedSent has freeQuota: 5. Before November 1 in the plan timezone, the response and the transactions use version 1, and currentVersion is 2.
7

End the assignment

To take the account off the plan, use End the account plan assignment of an account:
Midaz answers 204. The fee packages of the ledger apply to the account again.