Game purchases report the purchased part (paid): earned viewing credits are not money, so game POL pools grow only from purchased credits (Gem Kingdom + Spooky Doors receipts carry paid)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2773,7 +2773,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (r.error) return gkPage(res, 400, 'Order problem', '<h1>That order did not work</h1><p class="sub">' + gkEsc(r.error) + '</p><a class="btn blue" href="' + GK_URL() + '/play?open=shop">Back to Gem Kingdom</a>');
|
||||
const c = r.claims; if (c.kind !== 'gk-buy' || !c.order || !(c.credits > 0) || !(c.crowns > 0)) return gkPage(res, 400, 'Order problem', '<h1>That is not a Crown order</h1>');
|
||||
const done = gkOrders.get(c.order);
|
||||
if (done && done.status === 'paid') { const rc = gkMint({ kind: 'gk-receipt', order: c.order, email: c.email, crowns: c.crowns, credits: c.credits, ref: done.campaignId }, 24 * 3600000); res.writeHead(302, { Location: c.ret + '?t=' + rc, 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
if (done && done.status === 'paid') { const rc = gkMint({ kind: 'gk-receipt', order: c.order, email: c.email, crowns: c.crowns, credits: c.credits, paid: done.paid != null ? done.paid : c.credits, ref: done.campaignId }, 24 * 3600000); res.writeHead(302, { Location: c.ret + '?t=' + rc, 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Cache-Control': 'no-store', 'Set-Cookie': [gkCookie('iap.gkshop', t, 7200), gkCookie('iap.return', 'gkshop', 1800)] }); return res.end(); }
|
||||
if (String(s.email).toLowerCase() !== String(c.email).toLowerCase()) return gkPage(res, 403, 'Different account', '<h1>Different account</h1><p class="sub">This order was started by the Gem Kingdom player ' + gkEsc(c.email) + ', but you are signed in to InstantAdPay as ' + gkEsc(s.email) + '. Sign in with the same account in both places.</p><a class="btn blue" href="' + GK_URL() + '/play">Back to Gem Kingdom</a>');
|
||||
@@ -2814,9 +2814,9 @@ const server = http.createServer(async (req, res) => {
|
||||
const { ids } = await myMemberIds(s);
|
||||
const out = await ads.gamePurchase(s.email, ids, c.credits, 'Gem Kingdom: ' + c.crowns + ' Crowns', GK_URL());
|
||||
if (out.error) { gkOrders.delete(c.order); if (out.error === 'short') { res.writeHead(302, { Location: '/gk/shop?t=' + encodeURIComponent(t) }); return res.end(); } return gkPage(res, 500, 'Order problem', '<h1>Something went wrong</h1><p class="sub">' + gkEsc(out.error) + '</p>'); }
|
||||
gkOrders.set(c.order, { status: 'paid', email: s.email, campaignId: out.campaignId, ts: Date.now() });
|
||||
console.log('gemkingdom crowns', s.email, c.crowns, 'for', c.credits, 'credits, campaign', out.campaignId);
|
||||
const rc = gkMint({ kind: 'gk-receipt', order: c.order, email: String(c.email).toLowerCase(), crowns: Number(c.crowns), credits: Number(c.credits), ref: out.campaignId }, 24 * 3600000);
|
||||
gkOrders.set(c.order, { status: 'paid', email: s.email, campaignId: out.campaignId, paid: out.paid, ts: Date.now() });
|
||||
console.log('gemkingdom crowns', s.email, c.crowns, 'for', c.credits, 'credits (' + out.paid + ' purchased), campaign', out.campaignId);
|
||||
const rc = gkMint({ kind: 'gk-receipt', order: c.order, email: String(c.email).toLowerCase(), crowns: Number(c.crowns), credits: Number(c.credits), paid: Number(out.paid), ref: out.campaignId }, 24 * 3600000);
|
||||
gkCallback(c.cb, rc); // the server copy; the redirect below is the fast path
|
||||
const ret = String(c.ret || '').startsWith(GK_URL() + '/') ? c.ret : GK_URL() + '/api/iap/receipt';
|
||||
// a 200 page, not a 302: CSP form-action 'self' blocks a form POST from redirecting to another site (the page just sat there)
|
||||
@@ -2853,7 +2853,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const c = r.claims; if (c.kind !== 'sd-buy' || !c.order || !c.item || !(Number(c.credits) > 0) || !c.email) return sdPage(res, 400, 'Order problem', '<h1>That is not a costume order</h1><a class="btn blue" href="' + SD_URL() + '/play?open=shop">Back to Spooky Doors</a>');
|
||||
const label = String(c.label || c.item).slice(0, 60);
|
||||
const done = sdOrders.get(c.order);
|
||||
if (done && done.status === 'paid') { const rc = sdMint({ kind: 'sd-receipt', order: c.order, email: String(c.email).toLowerCase(), item: String(c.item), credits: Number(c.credits), ref: done.campaignId }, 24 * 3600000); const ret = sdIsGameUrl(c.ret) ? c.ret : SD_URL() + '/api/iap/receipt'; res.writeHead(302, { Location: ret + '?t=' + rc, 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
if (done && done.status === 'paid') { const rc = sdMint({ kind: 'sd-receipt', order: c.order, email: String(c.email).toLowerCase(), item: String(c.item), credits: Number(c.credits), paid: done.paid != null ? done.paid : Number(c.credits), ref: done.campaignId }, 24 * 3600000); const ret = sdIsGameUrl(c.ret) ? c.ret : SD_URL() + '/api/iap/receipt'; res.writeHead(302, { Location: ret + '?t=' + rc, 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Cache-Control': 'no-store', 'Set-Cookie': [gkCookie('iap.sdshop', t, 7200), gkCookie('iap.return', 'sdshop', 1800)] }); return res.end(); }
|
||||
if (String(s.email).toLowerCase() !== String(c.email).toLowerCase()) return sdPage(res, 403, 'Different account', '<h1>Different account</h1><p>This order was started by the Spooky Doors player ' + gkEsc(c.email) + ', but you are signed in to InstantAdPay as ' + gkEsc(s.email) + '. Sign in with the same account in both places.</p><a class="btn blue" href="' + SD_URL() + '/play">Back to Spooky Doors</a>');
|
||||
@@ -2896,9 +2896,9 @@ const server = http.createServer(async (req, res) => {
|
||||
const { ids } = await myMemberIds(s);
|
||||
const out = await ads.gamePurchase(s.email, ids, Number(c.credits), 'Spooky Doors: ' + label, SD_URL());
|
||||
if (out.error) { sdOrders.delete(c.order); if (out.error === 'short') { res.writeHead(302, { Location: '/sd/shop?t=' + encodeURIComponent(t) }); return res.end(); } return sdPage(res, 500, 'Order problem', '<h1>Something went wrong</h1><p class="warn">' + gkEsc(out.error) + '</p>'); }
|
||||
sdOrders.set(c.order, { status: 'paid', email: s.email, campaignId: out.campaignId, ts: Date.now() });
|
||||
sdOrders.set(c.order, { status: 'paid', email: s.email, campaignId: out.campaignId, paid: out.paid, ts: Date.now() });
|
||||
console.log('spookydoors costume', s.email, c.item, 'for', c.credits, 'credits, campaign', out.campaignId);
|
||||
const rc = sdMint({ kind: 'sd-receipt', order: c.order, email: String(c.email).toLowerCase(), item: String(c.item), credits: Number(c.credits), ref: out.campaignId }, 24 * 3600000);
|
||||
const rc = sdMint({ kind: 'sd-receipt', order: c.order, email: String(c.email).toLowerCase(), item: String(c.item), credits: Number(c.credits), paid: Number(out.paid), ref: out.campaignId }, 24 * 3600000);
|
||||
sdShopCallback(c.cb, rc); // the server copy; the redirect below is the fast path
|
||||
const ret = sdIsGameUrl(c.ret) ? c.ret : SD_URL() + '/api/iap/receipt';
|
||||
// a 200 page, not a 302: CSP form-action 'self' blocks a form POST from redirecting to another site
|
||||
|
||||
Reference in New Issue
Block a user