Menivor's coupons (videogen processor.py MintDiscounts, apps/mint README
contract) PATCH /mint/v1/sellers/{seller}/discounts/{discount_id} to stop a
code (expires_at now) and to switch it back on with new terms on the same id.
- PATCH forwards a partial Dodo PATCH /discounts/{id} (code, name,
type+amount, currency_options or currency, expires_at incl. null to clear,
restricted_to as the seller's skus) with the seller's own key and answers
200 {discount:{discount_id, id, code, type, amount, expires_at}}.
A change to a percentage sends currency_options [] so an old flat row
never lingers as a percentage cap (Dodo replace-set semantics).
- Seller-scoped authz: Mint now records which seller of which product made
which processor discount id (mint_seller_discounts, migration 0015; memory
store too). Any other id, or a code deleted on the dashboard (Dodo 404),
is 404 unknown_discount; the seller error shape throughout.
- Validation before any call: id charset, type and amount together, flat
needs one currency row whose max_amount_possible is the amount, RFC 3339
dates, unknown fields refused (400 invalid_body).
- Idempotency: PATCH is naturally repeatable; a retried create of a known
code with the same terms answers 200 created:false (checked with GET on
the seller's account), other terms 409 code_in_use, a code gone from the
processor is made again. Create answers carry discount_id as the contract
says (id kept).
- HttpTransport gains patch_json (default refuses; ReqwestTransport sends).
- Verified against Dodo docs: currency_options rows are {currency,
max_amount_possible, is_default, minimum_subtotal?}; is_default is real and
a flat code needs a resolvable default, so the mapping stays.
- Discount handlers moved to mint-server/src/seller_discounts.rs (seller.rs
was over 800 lines).
Tests: cargo test -p mint-payments seller 11/11 (new stop/re-enable/404 and
validation case); cargo test -p mint-server --test seller 5/5 (new end to
end: stop, re-enable flat, clear expiry, re-code, retried create, conflict,
deleted on dashboard, other seller's id, 11 refusals with no processor
call). pg_seller_live extended (ignored without DATABASE_URL). Clippy: no
findings in touched files (pre-existing mint-store/main.rs findings untouched).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>