Admin: grant Stack POL Pro for a $10+ package bought without a Pro order first (Marty 2026-11-09, Orlando). POST /api/admin/stackpro/grant {memberId, tx}: the tx must be an on-chain Purchase of $10+ by that member; recorded as a package sale with its tx, marks the Stack POL page Pro and posts the badge once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-09 16:30:34 -06:00
parent 054ce10985
commit 1da37f05ab
2 changed files with 23 additions and 1 deletions
+10 -1
View File
@@ -278,6 +278,15 @@ function buyStackPro(email, now) {
}
function cancelStackOrder(email) { const e = String(email || '').toLowerCase(); const w = stackOrders(e)[0]; if (!w) return { ok: true }; orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'cancelled', cancelledAt: Date.now() })); return { ok: true, order: w.order }; }
function compStackPro(email, on, note) { const e = String(email || '').toLowerCase(); if (on) stackpro.set(e, { ts: Date.now(), via: 'comp', note: String(note || '').slice(0, 120) }); else stackpro.delete(e); return { ok: true, pro: !!on }; }
// a package bought WITHOUT a Pro order first, granted by the admin (Marty 2026-11-09, Orlando's $10 package): recorded as a
// package sale with its tx so it counts as new money, and the tx is marked used like any fulfilment
function grantStackProForPackage(email, tx, cents, buyerId, note) {
const e = String(email || '').toLowerCase(); if (!e) return { error: 'No account.' };
if (stackpro.get(e)) return { ok: true, already: true };
stackpro.set(e, { ts: Date.now(), via: 'package', tx, cents, buyerId, note: String(note || 'admin grant: package bought without a Pro order').slice(0, 120) });
console.log('stack pro granted for package', e, tx, cents, 'cents');
return { ok: true, pro: true };
}
function stackProOwners() { return [...stackpro.keys()]; }
// A package purchase landing on chain fulfils one of this account's waiting orders: the highest-priced one the package covers.
@@ -672,5 +681,5 @@ function prune(now) {
return n;
}
module.exports = { STACK_PRO_CENTS, stackPro, stackProView, buyStackPro, cancelStackOrder, compStackPro, stackProOwners, init, cfg, GAMES, NAMES, TIERS, TIER_NAMES, TIER_DEFS, HERO_DEFS, HERO_KEYS, heroesOwned, heroClaim, heroView, buyHero, cancelHeroOrder, compHero, revokeHero, heroStats, flag, activity, view, buy, cancelOrder, comp, revoke, onEvent, capsFor, grant, voidGrant, tournamentTick, runTournament, pending, markPaid, adminStats, prune, weekStart, dayKey,
module.exports = { STACK_PRO_CENTS, stackPro, stackProView, buyStackPro, cancelStackOrder, compStackPro, stackProOwners, grantStackProForPackage, init, cfg, GAMES, NAMES, TIERS, TIER_NAMES, TIER_DEFS, HERO_DEFS, HERO_KEYS, heroesOwned, heroClaim, heroView, buyHero, cancelHeroOrder, compHero, revokeHero, heroStats, flag, activity, view, buy, cancelOrder, comp, revoke, onEvent, capsFor, grant, voidGrant, tournamentTick, runTournament, pending, markPaid, adminStats, prune, weekStart, dayKey,
_ledger: () => L };