# Membership Coupon UAT and release closure

## Lifecycle

An administrator creates, searches, edits, activates, or deactivates a Membership-only Coupon. Codes are normalized and immutable. A buyer can submit only a coupon code; the server resolves eligibility and creates the immutable MembershipOrder pricing snapshot. CHIP and E-Wallet use the snapshotted payable amount. A Coupon redemption is written only in the successful local fulfilment transaction.

## First-paid policy

A buyer without `referred_by_user_id` may use a valid Coupon for their first paid Membership. Percentage and fixed discounts use integer minor-unit arithmetic; fixed discounts are capped at the base price. A full discount fulfils locally without creating a zero-value CHIP purchase, activates Membership, creates one redemption, and creates no referral or Partner commission.

Any persisted referral blocks a first-paid Coupon, whether the referrer is currently a Partner, is a non-Partner, or later loses Partner status. Existing referral pricing remains authoritative. Renewal Coupon eligibility is not blocked by referral history, except that `first_purchase_only` Coupons remain first-paid only.

## Renewal Option B economics

For a Coupon renewal, the order snapshots base price, Coupon discount, post-Coupon payable, Partner renewal commission, and TakafulHub net in that order. The highest Partner in the ancestry remains the recipient. Commission uses `floor(payable * renewal_bps / 10000)`; it is never calculated from the pre-Coupon base. A zero-payable renewal creates no Partner payout but still creates one Coupon redemption.

## Usage integrity and snapshots

Usage is counted exclusively from successful `coupon_redemptions`. Consumption locks the Coupon row, then counts redemptions and checks total/per-user capacity before inserting the unique MembershipOrder redemption. Repeated callbacks and fulfilment attempts are idempotent. If capacity is exhausted, fulfilment rolls back before Membership activation and payout; the externally verified payment attempt remains auditable for retry handling.

The MembershipOrder snapshot is the authority after checkout. Later Coupon deactivation, expiry, discount edits, Membership-price changes, Partner-rate changes, or hierarchy changes do not recalculate its economics. Those later Coupon configuration changes do not block successful consumption of an already validly snapshotted order, apart from remaining usage capacity.

## Buyer data boundary

The buyer preview exposes only normalized Coupon code, base amount, Coupon discount, and payable amount. Browser-supplied coupon identifiers, prices, context, and commission fields are ignored. Coupon support is Membership-only; Lead Credit checkout has no Coupon input or redemption path.

## Release UAT coverage

The release suite covers clean first-paid percentage/fixed checkout, referral exclusion, first-purchase-only validation, all validity states, total/per-user limits, final-capacity races, CHIP and E-Wallet fulfilment, duplicate fulfilment, zero-payable first-paid and renewal flows, fixed caps, immutable snapshots, tamper resistance, renewal Partner/top-Partner/no-Partner economics, and integer rounding. It also retains non-Coupon Membership, Partner/affiliate, CHIP, E-Wallet, Lead Credit, registration, onboarding, Support, balance-inquiry, and notification regression coverage.

## Intentional limitations

- No Coupon analytics dashboard.
- No Lead Credit Coupons.
- No multiple-Coupon stacking.
- No campaign segmentation.
- No advanced promotion-rule engine.
