Missed-payout email: tell the skipped member who bought, what they missed in POL and dollars, buyers needed, and how to close the gap
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -643,7 +643,29 @@ async function emailOnEvent(ev) {
|
||||
await notify(ev.skippedId, 'Your wallet rejected a payout on InstantAdPay', 'A level-' + ev.tier + ' payout tried to reach your linked wallet and the wallet refused the transfer, so it passed to the next qualified member. This happens with some smart-contract wallets. Link a regular wallet address (MetaMask, SafePal, Phantom) on the Wallet tab so the next payout lands.');
|
||||
if (ADMIN_EMAIL) mailer.send(ADMIN_EMAIL, 'InstantAdPay: payout send-failed for member #' + ev.skippedId, 'A level-' + ev.tier + ' payout to member #' + ev.skippedId + ' failed at the wallet (send-failed) and passed up. Tx: ' + ev.tx + '\n\nThe member has been emailed to link a regular wallet.').catch(() => {});
|
||||
}
|
||||
else if (ev.type === 'PassedUp') await notify(ev.skippedId, 'A payout passed you by on InstantAdPay', 'A level-' + ev.tier + ' payout passed you by because you were not qualified yet. Get qualified so you catch the next one.');
|
||||
else if (ev.type === 'PassedUp') {
|
||||
// Marty (2026-09-15): a member who missed a payout because they were not qualified must be told
|
||||
// exactly what they missed. The Purchase event of the same tx is already indexed (it precedes
|
||||
// the PassedUp log), so the amount is that purchase's share for the tier: 50 / 20 / 10 percent.
|
||||
const PCT = { 1: 50, 2: 20, 3: 10 }; const pct = PCT[ev.tier] || 0;
|
||||
let pol = '', usd = '', buyer = 'a member on your level ' + ev.tier;
|
||||
try {
|
||||
const pur = chain.recentEvents(600).find(e => e.tx === ev.tx && e.type === 'Purchase');
|
||||
if (pur) {
|
||||
pol = weiToPol((BigInt(pur.paidWei) * BigInt(pct) / 100n).toString());
|
||||
usd = ('$' + (pur.priceCents * pct / 10000).toFixed(2)).replace(/\.00$/, '');
|
||||
}
|
||||
buyer = await memberLabel(ev.buyerId);
|
||||
} catch (e) {}
|
||||
let bc = 0; try { bc = (await chain.member(ev.skippedId)).buyerCount || 0; } catch (e) {}
|
||||
const need = ev.tier === 3 ? 5 : 2, short = Math.max(0, need - bc);
|
||||
const what = pol ? pol + ' POL (about ' + usd + ')' : 'a level-' + ev.tier + ' payout';
|
||||
await notify(ev.skippedId, 'You missed ' + (pol ? pol + ' POL' : 'a payout') + ' on InstantAdPay',
|
||||
buyer + ' just bought an ad package on your level ' + ev.tier + '. Your share was ' + what + ', and it passed you by because level ' + ev.tier + ' is not open on your account yet. The contract paid it to the next qualified person above you.\n\n' +
|
||||
'Level ' + ev.tier + ' opens at ' + need + ' qualifying buyers (people you referred who bought a $20 or larger package). You have ' + bc + (short ? ', so you are ' + short + ' buyer' + (short === 1 ? '' : 's') + ' away.' : '.') + '\n\n' +
|
||||
'Two ways to close the gap: bring ' + (short || 1) + ' more buyer' + (short === 1 ? '' : 's') + ' from your My line page, or use Qualified Start under Buy packages to be your own buyer today. Every package on level ' + ev.tier + ' pays you ' + pct + ' percent once it is open, and the next one is coming whether you are ready or not.\n\n' +
|
||||
'Your dashboard: https://instantadpay.com/my');
|
||||
}
|
||||
}
|
||||
// payment-proof Telegram feed (same pattern as the RM Circle proof channel): one compact
|
||||
// line per event, admin-configured under Settings > Site (telegramBotToken, telegramChatId,
|
||||
|
||||
Reference in New Issue
Block a user