Game Pass package rail, part two: Admin > Game Pass gets a Pass sales table (every sale labelled package / credit-paid (old rule) / package (old rule), pass value, package value, package tx link) and stats passes.pay + sales; the chatbot canned answer, tier fact and system prompt say every pass is paid by a new package bought after tapping Get (sponsor and team paid, credits kept for ads, held credits never buy a pass); docs/GAME-PASS.md "Payment: the package rail" section; release-note update draft (not sent); admin.js tag bumped. Fulfilment stamps the pass at the event time again (as before). Tests: sov-passes store + local rebuilt on order + fresh package (seeded credits never spent), gamepass ALL PASS, member walk 0 bugs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-22 12:49:39 -05:00
parent 6a3313a861
commit 31b167e046
8 changed files with 195 additions and 81 deletions
+21 -8
View File
@@ -6,6 +6,8 @@
// Explorer in the browser through the REAL ads.gamePurchase(purchasedOnly) charge; the 500 left is short for a second Explorer
// (waiting order, $20 package copy); the Shards of Valor hand-off token and GET /api/partner/player carry tier explorer;
// polgrant answers pass: true with the weekly pass caps; Admin > Game Pass shows the tier table. Exit 1 on any failure.
// 2026-10-22 (Marty): no pass is bought with credits any more. The seeded credits must stay untouched: every tier is an order plus a
// fresh package purchase (faked locally with /api/dev/gamepass-purchase), and the card sends the member to Buy credits.
// 2026-10-22: + Sovereign / Legend: members refused while sovTiers is off, the admin preview lists all five, the admin buys Sovereign
// (real charge), a Legend waiting order is settled by a $250 package (a year), the token / partner player carry tier legend + tiers.
import crypto from 'node:crypto';
@@ -102,14 +104,23 @@ try {
await page.click('#gpCard [data-gp-tier="explorer"]'); await page.waitForSelector('#dlgOk', { timeout: 5000 });
await page.screenshot({ path: path.join(SHOTS, '3-admin-confirm-explorer.png') });
await page.click('#dlgOk');
await page.waitForFunction(() => /Explorer active/.test((document.getElementById('gpCard') || {}).textContent || ''), null, { timeout: 15000 }).catch(() => {});
await page.waitForFunction(() => /#buy/.test(location.hash) || !!document.querySelector('.pane.on#pane-buy, [data-pane="buy"].on'), null, { timeout: 10000 }).catch(() => {});
await sleep(800);
ok(errs.length === 0, 'Get Explorer: no page errors, the member is sent to buy a package', page.url() + ' ' + errs.join(' | '));
await page.screenshot({ path: path.join(SHOTS, '4-admin-sent-to-buy.png') });
let g1 = (await api('/api/my/gamepass', null, hA)).j; const ex1 = g1.passes.find(x => x.tier === 'explorer');
ok(!g1.active && ex1 && ex1.waiting === true && !ex1.active, 'the click opened a waiting Explorer order; nothing active yet', JSON.stringify(ex1));
ok(!/gamepass bought with credits/.test(srvLog), 'no credit charge: the seeded purchased credits were not spent on the pass', '');
const dv0 = (await api('/api/dev/gamepass-purchase', { data: { cents: 2000, email: ADMIN_EMAIL } })).j;
ok(dv0 && dv0.order && dv0.order.tier === 'explorer', 'a fresh $20 package fulfils the Explorer order', JSON.stringify(dv0));
await page.goto(B + '/my#passes'); await page.waitForFunction(() => /Explorer active/.test((document.getElementById('gpCard') || {}).textContent || ''), null, { timeout: 15000 }).catch(() => {});
const after = await page.textContent('#gpCard');
ok(/Explorer active/.test(after) && errs.length === 0, 'after the buy the card shows Explorer active (Central date)', errs.join(' | '));
await page.locator('#gpCard').screenshot({ path: path.join(SHOTS, '4-admin-explorer-active.png') }); await ctx.close(); }
ok(/Explorer active/.test(after) && errs.length === 0, 'after the package the card shows Explorer active (Central date)', errs.join(' | '));
await page.locator('#gpCard').screenshot({ path: path.join(SHOTS, '5-admin-explorer-active.png') }); await ctx.close(); }
g = (await api('/api/my/gamepass', null, hA)).j;
const ex = g.passes.find(x => x.tier === 'explorer');
ok(g.active && g.tier === 'explorer' && ex.active && Math.abs(ex.until - (Date.now() + 30 * 86400000)) < 120000, 'GET /api/my/gamepass: tier explorer, 30 days', JSON.stringify({ tier: g.tier, until: ex && new Date(ex.until).toISOString() }));
ok(/gamepass bought with credits explorer qa-admin@example.com 1999/.test(srvLog), 'paid through the real ads.gamePurchase(purchasedOnly) path, 1999 credits', '');
ok(/gamepass fulfilled by package explorer qa-admin@example.com/.test(srvLog), 'Explorer paid by the package rail, not credits', '');
// 3. the Shards of Valor hand-off token and the partner player answer carry tier explorer
const ho = await api('/api/my/shardsofvalor', null, hA);
@@ -127,12 +138,14 @@ try {
// 3b. Sovereign (9999 credits, 30 days) and the yearly Legend (24999, 365 days), 2026-10-22: the admin buys Sovereign through the
// real charge, then is short for Legend (waiting order, $250 package) and for a second Explorer; a $250 package settles Legend.
r = await api('/api/my/gamepass/buy', { data: { tier: 'sovereign' } }, hA);
ok(r.status === 200 && r.j.ok && r.j.tier === 'sovereign' && r.j.days === 30 && Math.abs(r.j.until - (Date.now() + 30 * 86400000)) < 120000, 'admin buys Sovereign (sovTiers off, testing): 30 days', JSON.stringify(r.j));
ok(/gamepass bought with credits sovereign qa-admin@example.com 9999/.test(srvLog), 'Sovereign paid through the real ads.gamePurchase(purchasedOnly) path, 9999 credits', '');
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'sovereign' && r.j.package === 100, 'admin Sovereign (sovTiers off, testing): a waiting order for a $100 package, credits untouched', JSON.stringify(r.j));
let dvS = (await api('/api/dev/gamepass-purchase', { data: { cents: 10000, email: ADMIN_EMAIL } })).j;
ok(dvS && dvS.order && dvS.order.tier === 'sovereign' && Math.abs(dvS.order.until - (Date.now() + 30 * 86400000)) < 120000, 'a fresh $100 package fulfils Sovereign: 30 days', JSON.stringify(dvS));
ok(!/gamepass bought with credits/.test(srvLog), 'still no credit charge anywhere', '');
r = await api('/api/my/gamepass/buy', { data: { tier: 'explorer' } }, hA);
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'explorer' && r.j.available === 500 && /\$20 package/.test(r.j.message), 'a second Explorer: only 500 purchased credits left -> waiting order, "$20 package"', JSON.stringify({ needPay: r.j.needPay, available: r.j.available, payUrl: r.j.payUrl }));
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'explorer' && /package of \$20 or more/.test(r.j.message), 'a second Explorer -> waiting order, "package of $20 or more"', JSON.stringify({ needPay: r.j.needPay, payUrl: r.j.payUrl, msg: r.j.message }));
r = await api('/api/my/gamepass/buy', { data: { tier: 'legend' } }, hA);
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'legend' && r.j.available === 500 && r.j.price === 24999 && r.j.payUrl === '/my?from=gamepass&tier=legend#buy' && /\$250 package/.test(r.j.message), 'Legend with 500 credits: waiting order, "$250 package", payUrl with tier', JSON.stringify({ needPay: r.j.needPay, payUrl: r.j.payUrl, msg: r.j.message }));
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'legend' && r.j.price === 24999 && r.j.payUrl === '/my?from=gamepass&tier=legend#buy' && /package of \$250 or more/.test(r.j.message), 'Legend: waiting order, "package of $250 or more", payUrl with tier', JSON.stringify({ needPay: r.j.needPay, payUrl: r.j.payUrl, msg: r.j.message }));
let dv = (await api('/api/dev/gamepass-purchase', { data: { cents: 10000, email: ADMIN_EMAIL } })).j;
ok(dv && dv.order && dv.order.tier === 'explorer' && dv.order.until === ex.until + 30 * 86400000, 'a $100 package fulfils the waiting Explorer (extends it from its end), never Legend', JSON.stringify(dv));
g = (await api('/api/my/gamepass', null, hA)).j;