Audit details are collected and stored to enforce offer and offer code max usage.
Which audit checks should run for each flow is controlled by the audit verification properties.
By default, the audit checks are disabled for the apply offers flow and the marketing message retrieval.
Audit checks are enabled by default on the code usability and offer & offer code validation APIs.
Every time an offer is used in the checkout workflow, its usage is recorded as part of the post-checkout events.
The listener configured for these events, RecordOfferUsageEventListener.java, processes the messages and build audit details as needed.
Each offer usage is represented by an OfferAuditDetail.
By default, these are only recorded if the offer code has max usages, the offer has per customer max usages, or if the property alwaysRecordCustomerDetailAudit is set to true.
Each offer is represented by an OfferAuditSummary.
This is updated after each offer usage to increment the number of times the offer has been used and the total discount amount that the offer has provided.
Each offer code is represented by a SharedCodeAuditSummary.
This is updated after each offer code usage to increment the number of times the offer code has been used and the total discount amount that the offer code has provided.
This approach to code usage has a small race condition where two checkouts can simultaneously
use the same code if they hit submit in the same few seconds. This architectural decision is by
design as other approaches (such as reserving or locking the code) have significant downsides
with regard to use and ability to scale the function. For implementations that see this as a
concern, it is preferable in most cases to provide post checkout audits prior to fulfillment rather
than to handling during the submit checkout flow.