=== Customer Credit for Event Espresso ===
Contributors: mmulligan
Tags: event espresso, store credit, customer credit, payments, refunds
Requires at least: 6.4
Tested up to: 6.7
Requires PHP: 8.1
Stable tag: 0.1.1
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Per-customer store-credit balances for Event Espresso, with a payment method that refunds money into credit and spends credit toward what's owed.

== Description ==

Customer Credit gives every Event Espresso customer a real store-credit **account balance** and a first-class **"Customer Credit" payment method** that moves that balance in both directions:

* **Refund into credit** — recording a money-owed-back amount parks it as credit on the customer's account instead of issuing cash.
* **Pay with credit** — recording a credit payment spends the balance toward an amount due.

The balance is the audited side effect of recording a payment of this type, so credit always flows through Event Espresso's normal payment ledger.

**Built for correctness:**

* **Atomic, oversell-safe balances.** Each customer's balance lives in a counter guarded by a single conditional update, so a pay-with-credit debit can never drive a balance below zero even when several stations spend at once. A debit that exceeds the balance is refused, never silently clamped.
* **Fully ledgered.** Every move writes an append-only audit row (customer, direction, amount, transaction, payment, clerk, timestamp). The balance is always reconstructable as the signed sum of the ledger, and the admin report flags any drift.
* **Email-keyed customers.** Credit is matched to (or created on) Event Espresso's native customer record by email, so it follows the person across registrations.
* **Read-only admin report.** Under **Event Espresso → Customer Credit**: every customer's live balance, the ledger-reconstructed total, and per-customer history.

**Standalone, with an optional integration.** Customer Credit works on a plain Event Espresso install through wp-admin. It also exposes a dependency-free filter seam so companion apps — such as **Front of House for Event Espresso** — can offer store-credit and pay-with-credit at the point of sale; the server enforces the same gates regardless of where the request originates. The integration is automatic when present and inert when absent.

For full documentation, including the public filter contract and security model, see `README.md` included with the plugin.

== Installation ==

1. Install and activate Event Espresso.
2. Upload this plugin to `wp-content/plugins/` and activate it. Activation creates the balance and ledger tables.
3. (Optional) If you use Front of House for Event Espresso, activate this plugin so its presence is detected and store-credit options appear at the station.

== Frequently Asked Questions ==

= Does this require Front of House for Event Espresso? =

No. It is standalone on Event Espresso and is fully usable from wp-admin. Front of House is an optional consumer of its filter seam.

= Where is the balance stored? =

In two owned tables: a per-customer balance counter (the oversell guard target) and an append-only audit ledger. Money is stored in integer cents throughout. The counter must always equal the signed sum of the ledger.

= Can a customer go negative? =

No. A debit larger than the available balance is refused outright; it is never partially applied or clamped to zero.

== Changelog ==

= 0.1.1 =
* Update channel + repository URLs moved to the ee-extensions org. No functional change.

= 0.1.0 =
* Initial release: per-customer store-credit balances with an atomic, oversell-safe counter and an append-only audit ledger.
* Both-directions "Customer Credit" payment method (refund-into-credit and pay-with-credit).
* Email-keyed customer resolution and a read-only admin balances/ledger report.
* Dependency-free filter seam for optional point-of-sale consumers such as Front of House for Event Espresso.
