diff --git a/accounts.js b/accounts.js index 88d429a..068063c 100644 --- a/accounts.js +++ b/accounts.js @@ -36,6 +36,7 @@ const pub = a => a ? { email: a.email, sponsorRef: a.sponsorRef || '', code: a.c username: a.username || null, memberId: a.memberId || 0, joinedVia: a.joinedVia || null, joinedRef: a.joinedRef || null, lineBannerUrl: a.lineBannerUrl || null, lineTargetUrl: a.lineTargetUrl || null, wallOffers: a.wallOffers || null, avatarUrl: a.avatarUrl || null, bio: a.bio || null, socials: a.socials || null, + bixPartnerLink: a.bixPartnerLink || null, // BixPay partner link (bixpay.js, 2026-10-29): one identity, follows the member to LinkSpin/CTB chatAvailable: a.chatAvailable === false ? false : true, lastSeen: a.lastSeen || 0, address: a.address || null, created: a.created } : null; const USER_RE = /^[a-zA-Z0-9_]{3,20}$/; @@ -125,6 +126,7 @@ const J = { this.save(); return { ok: true, account: pub(acct) }; }, + async setBixLink(e, link) { const acct = this.db.byEmail[e]; if (!acct) return { error: 'No such account.' }; acct.bixPartnerLink = link || null; this.save(); return { ok: true, account: pub(acct) }; }, async touchSeen(e) { const a = this.db.byEmail[e]; if (a) { a.lastSeen = Date.now(); this.save(); } }, async setChatAvailable(e, v) { const a = this.db.byEmail[e]; if (!a) return { error: 'No such account.' }; a.chatAvailable = !!v; this.save(); return { ok: true, available: !!v }; }, async getMutes(e) { const a = this.db.byEmail[e]; return (a && Array.isArray(a.chatMutes)) ? a.chatMutes : []; }, @@ -228,7 +230,7 @@ const J = { const rowPub = r => r ? pub({ email: r.email, sponsorRef: r.sponsor_ref, code: r.code, username: r.username, memberId: r.member_id || 0, joinedVia: r.joined_via || null, joinedRef: r.joined_ref || null, lineBannerUrl: r.line_banner_url, lineTargetUrl: r.line_target_url, wallOffers: r.wall_offers || null, - avatarUrl: r.avatar_url, bio: r.bio, socials: r.socials, + avatarUrl: r.avatar_url, bio: r.bio, socials: r.socials, bixPartnerLink: r.bix_partner_link || null, chatAvailable: r.chat_available === 0 ? false : true, lastSeen: Number(r.last_seen || 0), address: r.address, created: Number(r.created) }) : null; const D = { @@ -289,6 +291,7 @@ const D = { if (socials !== undefined) await db.q('UPDATE accounts SET socials=? WHERE email=?', [socials || null, e]); return { ok: true, account: await this.byEmail(e) }; }, + async setBixLink(e, link) { const r = await db.q('UPDATE accounts SET bix_partner_link=? WHERE email=?', [link || null, e]); if (!r || !r.affectedRows) return { error: 'No such account.' }; return { ok: true, account: await this.byEmail(e) }; }, async touchSeen(e) { await db.q('UPDATE accounts SET last_seen=? WHERE email=?', [Date.now(), e]); }, async setChatAvailable(e, v) { await db.q('UPDATE accounts SET chat_available=? WHERE email=?', [v ? 1 : 0, e]); return { ok: true, available: !!v }; }, async getMutes(e) { @@ -504,6 +507,7 @@ module.exports = { init, signup, login, ensure, onChange, isUnclaimedShell, byEm setLineBanner: (e, b, t) => impl().setLineBanner(String(e || '').toLowerCase(), b, t), setWallOffers: (e, j) => impl().setWallOffers(String(e || '').toLowerCase(), j), setProfile: async (e, a, bio, socials) => { const r = await impl().setProfile(String(e || '').toLowerCase(), a, bio, socials); if (!(r && r.error)) changed(String(e || '').toLowerCase()); return r; }, // profile edits reach LinkSpin too + setBixLink: async (e, link) => { const r = await impl().setBixLink(normEmail(e), link ? String(link).slice(0, 300) : null); if (!(r && r.error)) changed(normEmail(e)); return r; }, // the BixPay partner link rides to LinkSpin in the profile row (lssync.js) touchSeen: e => impl().touchSeen(String(e || '').toLowerCase()), adminSetAddress: (e, a) => impl().adminSetAddress(String(e || '').toLowerCase(), a ? normAddr(a) : null), positionByAddress: a => impl().positionByAddress(normAddr(a)), diff --git a/bixpay.js b/bixpay.js new file mode 100644 index 0000000..1783143 --- /dev/null +++ b/bixpay.js @@ -0,0 +1,120 @@ +// BixPay card integration, phase 1 (Marty approved 2026-10-29; spec docs/BIXPAY-INTEGRATION.md). +// BIX is a separate company: a self-custody wallet with a Visa card spent from USDT/USDC. We only carry each member's +// PARTNER link (bix.ibportal.io/auth/register?e=&a=1) so anyone who gets a card through their pages is credited to +// them in the BIX portal. Nothing is settled on our side: the portal tracks directs and levels itself. +// +// One identity, sponsor follows (feedback-one-identity-sponsor-follows): the link a visitor gets is the member's own, +// else the first sponsor up the chain (10 levels) with one, else the company link (site config bixCompanyLink). Every +// surface says WHOSE link is in play ("you" / "@sponsor" / "network") so members add their own and sponsors get their +// teams signed up. +// +// Everything is gated by site config bixpayLive ('0' = nothing shows; the admin flips it in Admin > Settings). +// Clicks: every surface links through /go/bixpay?s=[&m=] which counts here (DATA_DIR/bixpay-clicks.json) +// and 302s to the resolved partner link. Counts per surface land in the admin Traffic tab, per member on the Promo tab. +const fs = require('fs'); +const path = require('path'); + +let R = {}; // { dataDir, accounts, siteConfig, refAccount } +const HOST = 'bix.ibportal.io'; +const PATH = '/auth/register'; +const MAX_LEN = 300; +const MAX_LEVELS = 10; +// Marty's own PARTNER link (IB12143793): the company fallback until Admin > Settings bixCompanyLink says otherwise +const DEFAULT_COMPANY_LINK = 'https://bix.ibportal.io/auth/register?e=XqwU9T1aJ5N0UJ0yr9x0TGUiSQTsVCkTM01MIovVNnc&a=1'; +const SURFACES = ['wallet', 'overview', 'email', 'nudge', 'promo', 'guide', 'chat']; +const CUSTOMER_LINK_MSG = "That's the card-customer link. Paste the Partner link from your BIX portal profile instead."; +const ANNOUNCE_MS = 7 * 86400000; // the Overview announcement card shows for the first week after the switch is flipped + +function init(opts) { R = opts || {}; } +const cfg = () => { try { return (R.siteConfig && R.siteConfig()) || {}; } catch (e) { return {}; } }; +function live() { return String(cfg().bixpayLive == null ? '0' : cfg().bixpayLive) === '1'; } +function companyLink() { const v = validate(cfg().bixCompanyLink); return v.ok ? v.link : DEFAULT_COMPANY_LINK; } +// the Overview announcement runs a week from bixpayLiveSince (stamped by the admin settings route when the switch is flipped on) +function announcing() { if (!live()) return false; const t = Date.parse(String(cfg().bixpayLiveSince || '')); return !(t > 0) || Date.now() - t < ANNOUNCE_MS; } + +// A pasted partner link -> { ok: true, link } (normalised to e= and a=1 only) or { error }. +// The card-customer link carries appId=3 (it makes a card customer, not a partner): refused with the message members see. +function validate(input) { + const s = String(input == null ? '' : input).trim(); + if (!s) return { error: 'Paste your BixPay partner link first.' }; + if (s.length > MAX_LEN) return { error: 'That link is too long. Copy the Partner link from your BIX portal profile.' }; + let u; try { u = new URL(s); } catch (e) { return { error: 'That is not a full link. It starts with https://bix.ibportal.io/auth/register?e=' }; } + if (u.protocol !== 'https:' || u.hostname.toLowerCase() !== HOST) return { error: 'A BixPay partner link lives on https://bix.ibportal.io. Copy it from your BIX portal profile (Profile > Partner).' }; + if (u.pathname.replace(/\/+$/, '') !== PATH) return { error: 'That is not the register link. It looks like https://bix.ibportal.io/auth/register?e=...&a=1' }; + if (u.searchParams.has('appId') || u.searchParams.has('appid')) return { error: CUSTOMER_LINK_MSG }; + const e = String(u.searchParams.get('e') || '').trim(); + if (!/^[A-Za-z0-9_-]{16,128}$/.test(e)) return { error: 'The link is missing its e= token. Copy the whole Partner link from your BIX portal profile.' }; + if (String(u.searchParams.get('a') || '').trim() !== '1') return { error: 'The link needs a=1 on the end. Copy the whole Partner link from your BIX portal profile.' }; + return { ok: true, link: 'https://' + HOST + PATH + '?e=' + e + '&a=1' }; +} + +const nameOf = a => a ? (a.username ? '@' + a.username : a.memberId ? 'member #' + a.memberId : 'your sponsor') : null; +// bixLinkFor(member): own link, else the first sponsor up the chain with one (10 levels), else the company link. +// -> { link, whose: 'you' | 'sponsor' | 'network', name, email } (name/email = the sponsor whose link it is) +async function resolve(acct) { + if (acct && validate(acct.bixPartnerLink).ok) return { link: validate(acct.bixPartnerLink).link, whose: 'you', name: nameOf(acct), email: acct.email }; + if (acct && R.accounts && R.accounts.sponsorOf) { + const seen = new Set([String(acct.email || '').toLowerCase()]); + let cur = acct; + for (let i = 0; i < MAX_LEVELS && cur; i++) { + let s = null; try { s = await R.accounts.sponsorOf(cur.email); } catch (e) { s = null; } + if (!s || seen.has(String(s.email).toLowerCase())) break; + seen.add(String(s.email).toLowerCase()); + const v = validate(s.bixPartnerLink); + if (v.ok) return { link: v.link, whose: 'sponsor', name: nameOf(s), email: s.email }; + cur = s; + } + } + return { link: companyLink(), whose: 'network', name: null, email: null }; +} +// the same for a public page: the referrer token (?ref / the sponsor cookie) resolves like the member it names +async function resolveRef(tok) { + let a = null; try { a = tok && R.refAccount ? await R.refAccount(tok) : null; } catch (e) { a = null; } + return resolve(a); +} +// the line every surface shows under the button +function usingLine(r) { return r.whose === 'you' ? 'Using: your link.' : r.whose === 'sponsor' ? 'Using: ' + r.name + "'s link. Add yours in Profile." : 'Using: the network link. Add yours in Profile.'; } + +// tracked link for a surface (+ the member it belongs to: the sharer on promo/guide/email, the viewer on the dashboard cards) +const SITE = () => String(process.env.PUBLIC_URL || 'https://instantadpay.com').replace(/\/+$/, ''); +function goLink(surface, token) { return SITE() + '/go/bixpay?s=' + encodeURIComponent(surface) + (token ? '&m=' + encodeURIComponent(String(token)) : ''); } +// one sentence for payout emails and the games' wallet nudges (text), only while live +function emailLine(token) { return live() ? 'Want to spend it? A BixPay Visa card turns POL into everyday purchases: ' + goLink('email', token) : ''; } +function nudgeLine(token) { return live() ? 'Want to spend it? A BixPay Visa card turns POL into everyday purchases: ' + goLink('nudge', token) : ''; } + +// ---- clicks ---- +const FILE = () => path.join(R.dataDir || '.', 'bixpay-clicks.json'); +const blank = () => ({ v: 1, total: {}, days: {}, members: {} }); +let S = null; +function load() { if (S) return S; try { S = Object.assign(blank(), JSON.parse(fs.readFileSync(FILE(), 'utf8'))); } catch (e) { S = blank(); } return S; } +function save() { try { fs.writeFileSync(FILE(), JSON.stringify(S)); } catch (e) {} } +const day = ts => new Date(ts).toISOString().slice(0, 10); +function click(surface, email) { + const s = SURFACES.includes(surface) ? surface : 'other'; + const st = load(); + st.total[s] = (st.total[s] || 0) + 1; + const d = day(Date.now()); st.days[d] = st.days[d] || {}; st.days[d][s] = (st.days[d][s] || 0) + 1; + const e = String(email || '').trim().toLowerCase(); + if (e) { const m = st.members[e] = st.members[e] || { total: 0 }; m.total++; m[s] = (m[s] || 0) + 1; m.last = Date.now(); } + // bounded: 400 days + const cutoff = day(Date.now() - 400 * 86400000); for (const k of Object.keys(st.days)) if (k < cutoff) delete st.days[k]; + save(); + return { surface: s, email: e || null }; +} +function memberClicks(email) { + const m = load().members[String(email || '').trim().toLowerCase()]; + if (!m) return { total: 0 }; + return Object.assign({}, m); +} +function adminView(days) { + const st = load(); const n = Math.min(365, Math.max(1, Number(days) || 30)); + const since = day(Date.now() - n * 86400000); + const bySurface = {}; let total = 0; + for (const [d, row] of Object.entries(st.days)) if (d >= since) for (const [s, c] of Object.entries(row)) { bySurface[s] = (bySurface[s] || 0) + c; total += c; } + const daily = Object.entries(st.days).filter(([d]) => d >= since).sort((a, b) => a[0] < b[0] ? 1 : -1).map(([d, row]) => ({ day: d, clicks: Object.values(row).reduce((x, y) => x + y, 0) })); + const members = Object.entries(st.members).map(([email, m]) => ({ email, total: m.total || 0, last: m.last || 0, promo: m.promo || 0 })).sort((a, b) => b.total - a.total).slice(0, 50); + return { days: n, total, allTime: Object.values(st.total).reduce((x, y) => x + y, 0), bySurface, daily, members, surfaces: SURFACES }; +} +function _reset() { S = null; } + +module.exports = { init, live, announcing, validate, resolve, resolveRef, usingLine, companyLink, goLink, emailLine, nudgeLine, click, memberClicks, adminView, SURFACES, CUSTOMER_LINK_MSG, DEFAULT_COMPANY_LINK, MAX_LEVELS, _reset }; diff --git a/blog.js b/blog.js index 77a6f58..4771ccc 100644 --- a/blog.js +++ b/blog.js @@ -69,7 +69,8 @@ const D = { const row = r => ({ slug: r.slug, title: r.title, excerpt: r.excerpt || '', body: r.body || '', cover: r.cover || '', tags: r.tags ? String(r.tags).split(',').filter(Boolean) : [], status: r.status, author: r.author || AUTHOR, created: Number(r.created), updated: Number(r.updated), publishedAt: r.published_at ? Number(r.published_at) : null, views: Number(r.views) || 0 }); const impl = () => db.enabled() ? D : J; -function init(opts) { DATA_DIR = opts.dataDir; if (!db.enabled()) J.load(); } +let EXTRA_PAGES = () => []; // sitemap entries that follow a switch (the /bixpay guide while bixpayLive, 2026-10-29) +function init(opts) { DATA_DIR = opts.dataDir; if (typeof opts.extraPages === 'function') EXTRA_PAGES = opts.extraPages; if (!db.enabled()) J.load(); } async function listAll() { return (await impl().all()).sort((a, b) => (b.publishedAt || b.created) - (a.publishedAt || a.created)); } async function listPublished() { return (await listAll()).filter(p => p.status === 'published' && (p.publishedAt || 0) <= Date.now()); } async function get(slug) { return impl().get(slugify(slug)); } @@ -152,7 +153,7 @@ function rss(posts) { return 'InstantAdPay blog' + SITE + '/blogCoaching and teaching articles from Marty Bostick.' + items + ''; } function sitemap(posts) { - const pages = ['/', '/facts', '/blog', '/whats-new', '/leaderboard', '/ledger', '/contract', '/plays', '/wallets', '/earning', '/partners', '/friday', '/wednesday', '/refuel', '/conversion-tracking', '/presentation']; + const pages = ['/', '/facts', '/blog', '/whats-new', '/leaderboard', '/ledger', '/contract', '/plays', '/wallets', '/earning', '/partners', '/friday', '/wednesday', '/refuel', '/conversion-tracking', '/presentation'].concat(EXTRA_PAGES() || []); const u = pages.map(p => '' + SITE + p + 'weekly').join('') + posts.map(p => '' + SITE + '/blog/' + p.slug + '' + new Date(p.updated).toISOString().slice(0, 10) + 'monthly').join(''); return '' + u + ''; diff --git a/chatbot.js b/chatbot.js index ed6126d..9f09ec2 100644 --- a/chatbot.js +++ b/chatbot.js @@ -24,7 +24,8 @@ const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro' function init(opts) { if (opts && typeof opts.gameLive === 'function') GAME_LIVE = opts.gameLive; - if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn; DATA_DIR = opts.dataDir; chain = opts.chain; PASS_TIERS = typeof opts.passTiers === 'function' ? opts.passTiers : null; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); } + if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn; + if (opts && typeof opts.bixLive === 'function') BIX_LIVE = opts.bixLive; DATA_DIR = opts.dataDir; chain = opts.chain; PASS_TIERS = typeof opts.passTiers === 'function' ? opts.passTiers : null; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); } function key() { if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim(); try { return fs.readFileSync(path.join(DATA_DIR, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; } @@ -32,12 +33,30 @@ function key() { function enabled() { return !!key(); } // ---- canned answers: instant, free, always in voice ---- -const KNOWLEDGE_DATE = '2026-10-28'; // bump whenever the canned answers / prompt are brought up to date +const KNOWLEDGE_DATE = '2026-10-29'; // bump whenever the canned answers / prompt are brought up to date const SUPPORT_RE = /(contact|reach|email|e-mail|message|talk to|speak (to|with)|get hold of) (the )?(support|admin|administrator|owner|marty|staff|team at instantadpay|someone|a (human|person|real person))|support (email|address|ticket|team|desk)|help ?desk|(open|send|file|submit|raise) (a )?(support )?ticket|\b(human|real person|live (agent|person|chat|support))\b|customer (service|support)|support@|how (do|can) i get (help|support)/i; const CANNED = [ { id: 'support', title: 'Contact support or open a ticket', q: ['How do I contact support?', 'How do I talk to a real person?', 'How do I open a support ticket?'], tags: ['support', 'help', 'ticket', 'contact', 'help desk'], re: SUPPORT_RE, handoff: true, a: 'Open Help in your member dashboard (https://instantadpay.com/my#help) to send Marty a ticket, and his replies land right there and in your email. Not signed in or locked out? Use https://instantadpay.com/support, or email support@instantadpay.com. You can also tap "Send this to support" below and I will pass this chat along.' }, + // BixPay Visa card (2026-10-29, docs/BIXPAY-INTEGRATION.md). Sits ahead of the Level 4 entry because that one also matches "3%". + // While site config bixpayLive is off, answer() swaps every bixpay-* hit for BIX_SOON_ANSWER. Never BIX's marketing claims (user + // counts, spend per day, valuations) as facts; the only fee we state is 3% per purchase, no load fee, see BIX's terms for the rest. + { id: 'bixpay-link', title: 'Where to put my BixPay partner link', q: ['Where do I put my BixPay partner link?', 'How do I add my BIX link?', 'Which BixPay link do I paste, referral or partner?'], tags: ['bixpay', 'bix', 'partner link', 'profile', 'ib portal'], + re: /(bix|bixpay).*(partner link|my link|referral link|ib ?portal|paste|where do i (put|add|enter)|profile)|(partner link|ib ?portal).*(bix|bixpay)/i, + a: 'Members > Profile > BixPay card. Paste your PARTNER link there: in your BIX portal (bix.ibportal.io) open Profile and copy the link in the second box, the one labelled Partner. It looks like https://bix.ibportal.io/auth/register?e=...&a=1. The first box, the Bix referral link (it ends in appId=3), only makes a card customer, so the field refuses it and asks for the Partner one. Once saved, your Wallet card, your promo kit, the /bixpay guide opened from your links and the line in your payout emails all carry your link, and LinkSpin will read the same one.' }, + { id: 'bixpay-credit', title: 'Who gets the BixPay credit', q: ['Who gets credit when someone signs up for BixPay through my page?', 'Whose BixPay link is on my pages?', 'What does "Using: the network link" mean?'], tags: ['bixpay', 'bix', 'credit', 'sponsor', 'network link'], + re: /(bix|bixpay).*(credit|whose|who gets|sponsor.s link|network link|using:|my sponsor|upline)|(whose|who gets).*(bix|bixpay)/i, + a: 'The BixPay link on your pages is yours when you have saved your partner link in Profile. If you have not, it is the first sponsor up your line (up to ten levels) who has one, and if nobody has, it is the network link. Every BixPay card says which one is in play: "Using: your link", "Using: @name’s link" or "Using: the network link". Sign-ups are credited inside the BIX portal to whoever owns that link, directs and levels included; InstantAdPay does not count or pay BixPay sign-ups itself. Add your own link in Members > Profile > BixPay card so the credit is yours.' }, + { id: 'bixpay-load', title: 'Loading the BixPay card from POL', q: ['How do I load my BixPay card from POL?', 'Can I send POL to BixPay?', 'How do I fund the BixPay card?'], tags: ['bixpay', 'bix', 'fund', 'load', 'usdt', 'usdc', 'polygon', 'cash app'], + re: /(bix|bixpay).*(load|fund|top ?up|deposit|send pol|from pol|usdt|usdc|swap|cash ?app)|(load|fund|top ?up).*(bix|bixpay)/i, + a: 'The BixPay card spends USDT or USDC, so the step is POL to USDT or USDC first. Three ways: (1) swap your POL for USDT or USDC on any exchange or on-ramp you already use, then send it to your BixPay wallet on the Polygon network (open the BIX app, Wallet > Receive, pick USDT or USDC, and use the Polygon address); (2) in the US, Cash App can send crypto straight to the BixPay wallet; (3) BIX has said an in-app swap is coming, and we will add it here when it ships. Once the USDT or USDC is in the wallet, tap TOPUP on the card. No load fee; 3% per purchase; see BIX’s terms for other charges. The full walk-through with screenshots is at https://instantadpay.com/bixpay.' }, + { id: 'bixpay-card', title: 'How to get the BixPay card', q: ['How do I get the BixPay card?', 'How do I sign up for BixPay?', 'Is BixPay available in my state?'], tags: ['bixpay', 'bix', 'visa card', 'virtual card', 'sign up', 'states'], + re: /(bix|bixpay).*(get|sign ?up|join|order|apply|virtual|plastic|metal|state|country|available|how much|cost|price|\$9)|(get|sign ?up for|order).*(bix|bixpay)/i, + a: 'Open the BixPay card in your Wallet tab (Members > Wallet) and tap Get your BixPay card. That opens a partner sign-up link, so you join as a partner and the card and the referral plan come with it: 1) register in the BIX portal through the link, 2) download the BIX app and create your wallet, 3) in the app open Settings > Scan QR and scan the code in your portal profile to link the two, 4) Cards > Create Card for the $9.99 virtual Visa (plastic, metal and gold cards cost more). KYC is required for the card. In the US it is open in 31 states so far; not in your state yet? You can still get the wallet and build. Elsewhere availability varies by country. Guide: https://instantadpay.com/bixpay.' }, + { id: 'bixpay', title: 'What BixPay is', q: ['What is BixPay?', 'What is the BIX card?', 'Can I spend my POL with a Visa card?'], tags: ['bixpay', 'bix', 'visa', 'card', 'spend pol', 'wallet'], + re: /(bix|bixpay|bix card|visa card|debit card|spend (my )?(pol|crypto|earnings)|crypto card)/i, + a: 'BixPay is a self-custody wallet with a Visa card, made by BIX, a separate company. You send USDT or USDC to it on Polygon, load the card, and spend wherever Visa is accepted, including Apple Pay and Google Pay. Virtual cards from $9.99. 3% per purchase, no load fee; see BIX’s terms for other charges. InstantAdPay is not the card issuer; members who join BixPay as partners get their own partner link, and anyone who gets a card through their pages is credited to them in the BIX portal, up to ten levels deep. Where to find it: Members > Wallet (the card), Members > Profile (your partner link), Promo tools > BixPay (posts and banners), and the guide at https://instantadpay.com/bixpay. Crypto assets can lose value.' }, { id: 'level4-override', title: 'The Level 4 override (3%)', q: ['What is the Level 4 override?', 'Do I earn from my fourth level?', 'How does the 3% override work?'], tags: ['override', 'level 4', 'fourth level', 'commission', 'payouts'], re: /(level ?(4|four)|4th level|fourth level|override|3 ?%|three percent)/i, a: 'The Level 4 override is 3% of every package bought four levels below you, paid by the company on top of the three levels the contract pays. It goes to the buyer’s 4th sponsor up if that member has 5 or more qualifying buyers (direct referrals who bought $20 or more, the same bar as level 3). If they do not have 5 yet, it moves up the line to the next member who does, up to 25 steps, and each purchase pays one override to one person. It is paid weekly in POL from a company wallet, every Monday after 9 AM Central for the Monday to Sunday week before, through the contract’s award function, so every payment has a Polygon link, and it shows in your Earnings as "Level 4 override". Weekly totals under 0.01 POL carry over to the next week. It counts purchases from the start date on, not earlier ones. It comes from the platform’s 20% share, so the 50/20/10 split does not change. What you earn depends on real purchases in your line; nothing is guaranteed.' }, @@ -241,7 +260,15 @@ function synFact() { const n = SYN_N(); return '- NETWORK RATE (live, Marty 2026 let REFUEL_ON = () => false; // POL Miner (2026-10-28) follows site config gamesLive: until 'polminer' is in it the assistant only says it is coming soon let GAME_LIVE = () => false; -const POLMINER_SOON_ANSWER = 'POL Miner, a dig-down mining game where rare Polygon crystals pay POL, is coming soon to the InstantAdPay games. It is not open yet; it will show up on your Games tab (Members > Games) and in the release notes when it launches.'; +// BixPay (2026-10-29) follows site config bixpayLive: until it is on the assistant only says the card is coming soon +let BIX_LIVE = () => false; +const bixLive = () => { try { return !!BIX_LIVE(); } catch (e) { return false; } }; +const isBixId = id => /^(c-)?bixpay(-[a-z]+)?$/.test(String(id || '')); +const BIX_SOON_ANSWER = 'A BixPay Visa card for spending POL is coming to InstantAdPay soon: a self-custody wallet with a Visa card, made by BIX, a separate company. It is not switched on here yet. When it is, it shows up on your Wallet tab, with a partner-link field in your Profile and a guide at instantadpay.com/bixpay, and the release notes will say so.'; +function bixFact() { return bixLive() + ? '- BIXPAY VISA CARD (LIVE, 2026-10-29): BixPay = a self-custody wallet + Visa card made by BIX, a SEPARATE company (not InstantAdPay). The member sends USDT or USDC to the BixPay wallet on Polygon, loads the card, spends wherever Visa is accepted incl. Apple Pay and Google Pay. Virtual card $9.99 (plastic, metal and gold cost more). The ONLY fee we state: 3% per purchase, no load fee; for anything else say "see BIX’s terms". US: open in 31 states so far; not in your state yet = you can still get the wallet and build; elsewhere availability varies by country; KYC required for the card. Funding POL -> card: (1) swap POL to USDT/USDC on any exchange or on-ramp, send on Polygon (app: Wallet > Receive > USDT or USDC > Polygon address); (2) US: Cash App can send crypto straight to the BixPay wallet; (3) an in-app swap is announced by BIX but NOT live: never say members can swap POL inside the app today. Sign-up steps: partner link -> register in the BIX portal (bix.ibportal.io) -> download the BIX app -> Settings > Scan QR to link app and portal -> Cards > Create Card ($9.99 virtual). Partner plan, plain words: BIX puts half of the 3% fee and of card sales into its partner plan, paid over ten levels (15% level 1, 10% level 2, 2.5% each on levels 3 to 10) plus a 5% pool; sign-ups and commissions are tracked and paid by BIX in the BIX portal, never by InstantAdPay; any worked example is hypothetical, not typical, and never a promise. Disputes: BIX accepts a dispute up to 120 days after a transaction posts; they can take 30 to 60 business days. WHERE: Members > Wallet (the card with Get your BixPay card + How it works), Members > Profile > BixPay card (the member pastes their PARTNER link from BIX portal > Profile > Partner, the second box; the referral link with appId=3 is refused), Promo tools > BixPay tab (3 posts, an email swipe, 4 text-only banners, all carrying the member’s link, plus the tab’s click count), the public guide https://instantadpay.com/bixpay (add ?ref= and the page carries that member’s link), one sentence in payout emails. WHOSE LINK: the member’s own partner link, else the first sponsor up the chain (10 levels) with one, else the network link; every card says which ("Using: your link / @name’s link / the network link"). Compliance: InstantAdPay is not the card issuer and earns a referral commission when someone signs up through a partner link; crypto assets can lose value. NEVER repeat BIX marketing claims (user counts, cards issued, spend per day, valuations, "bigger than X") as facts; if asked, say those are BIX’s own claims and we have not verified them.\n' + : '- BIXPAY VISA CARD: COMING SOON, not switched on yet. If asked about BixPay, BIX, a crypto Visa card or spending POL with a card, say it is coming to the Wallet tab soon and nothing is live yet; never quote its fees, steps, links or the partner plan until it is on.\n'; } +const POLMINER_SOON_ANSWER ='POL Miner, a dig-down mining game where rare Polygon crystals pay POL, is coming soon to the InstantAdPay games. It is not open yet; it will show up on your Games tab (Members > Games) and in the release notes when it launches.'; const pmLive = () => { try { return !!GAME_LIVE('polminer'); } catch (e) { return false; } }; function polminerFact() { return pmLive() ? '- POL MINER (https://polminer.com, Members > Games): a free dig-down mining game. Dig, sell ore for coins, upgrade pick/lamp/cart/thruster, beat a drill boss every 30 m. Pink Polygon crystals pay a random POL amount the first time each one is dug out; each boss pays POL on its first win per account; first trips to 50/100/150/200 m pay POL. Coins never turn into POL. Guests can play and collect at sign-in. POL is paid automatically to the wallet linked on InstantAdPay. The SUPPLY pad opens a sponsored supply crate (full lamp + coins, never POL) after a short sponsor visit.\n' : '- POL MINER: COMING SOON, not open yet. Never send members to polminer.com; say it is coming soon to the Games tab.\n'; } function refuelFact() { return REFUEL_ON() ? "- MONTHLY REFUEL STREAK (built 2026-10-24, switch refuelStreak): ONE streak per member across InstantAdPay and LinkSpin. Counted refuel = a NEW package of $20+ on InstantAdPay or $25+ on LinkSpin by one of the member's own positions. First one sets the member's own refuel day; next due 30 days after the last counted refuel; window opens 5 days before the due day; 5-day grace after it; Central time. Missing the grace resets the streak, except one free miss per 365 days. Bonus (purchased-grade ad credits on the site where bought, credit log 'Refuel streak'): one engine m1 +10%, m2 +15%, m3 +20%, m4+ +25%; both sites in the same cycle m1 +15%, m2 +20%, m3 +30%, m4+ +40% each (first site topped up to the both rate, difference only) plus a 100-credit Featured bonus on InstantAdPay at m4+ (purchased-grade credits, any format). Stacks on Five Dollar Friday / Wired Wednesday. Pit Stop: another $20+/$25+ package on a site already refueled this cycle, before the next window opens (the other site's first package in the cycle is the second engine instead) = half the current streak rate, once per site per cycle, not a counted refuel. Badges: Engine Started (first refuel), Refueled 3 / 6 / 12 months. ENGINE ROOM: unlocked by the first counted refuel (greyed 'Refuel to start your engine' before), IAP tab Engine Room + LinkSpin Ads screen panel, same data both sites: dials Fuel left (credits free + in campaigns on both sites vs this cycle's refuel credits incl. bonus, days left at the recent burn), Clicks this week (vs last week, clicks per 1,000 credits), Goals this month (conversion pixel conversions since the 1st Central vs the member's own goal); streak panel; warning lights (ads at 80%, ads out, refuel day coming, login slot open); six part lights (fuel, banner spin, spin link, page, testing, conversion tracking: green working, amber needs attention, grey not started with a Set it up link); one Next move button from simple rules. REFUEL KIT: each counted refuel unlocks the Central-month's members-only banner set for this site's own program (5 sizes, personalized server-side with @username + QR to the member's link; IAP: Promo tools card with Use in an IAP banner campaign; LinkSpin: Ads screen card with Load into my Banner Spin); kits stay usable after the month; streak month 3+ adds an animated GIF, month 6+ a BannerKitAI custom-banners credit (coming, entitlement saved). Reminders 5 days before, on the day, last call at the end of grace (email + on-site notice). The member's Refuel card (InstantAdPay Overview, LinkSpin Credits/Ads) shows refuel day, streak, next bonus, Pit Stop status. Either site alone keeps the streak (one-engine rates); both sites in one cycle = the bigger bonus; never say both are required. MEMBER GUIDE PAGE (public, 2026-10-24): /refuel on both sites (https://instantadpay.com/refuel and https://linkspin.app/refuel): the flow, the numbers, the member steps, leader coaching and FAQ; point members there for the full picture. Ad credits only, never cash; never promise income. No auto-billing: the member chooses every package. ROUTES (2026-10-25): LinkSpin menu item Refuel = https://linkspin.app/credits#refuel (the Refuel panel, scrolled to and highlighted); packages of $25+ there are marked counts for Refuel; https://linkspin.app/credits#buy = the package picker; https://linkspin.app/ads#engine = LinkSpin Engine Room. InstantAdPay Engine Room = https://instantadpay.com/my#engine; its Set up conversion tracking opens https://instantadpay.com/my#conversions (Campaigns > Conversion tracking card, same goals LinkSpin counts). Engine Room links that cross to LinkSpin (Banner Spin, spin link, page, testing, refuel LinkSpin) open LinkSpin with a note at the top naming the job, Step 1, a guide link and Back to InstantAdPay; same email signs in on both.\n" : '- MONTHLY REFUEL STREAK: built but NOT switched on yet. If asked, say it is coming and nothing counts toward it today; do not quote bonus rates or dates.\n'; } @@ -251,7 +278,7 @@ function systemPrompt(kbBlock) { FACTS: - LEVEL 4 OVERRIDE (LIVE 2026-10-26, first payout Monday 2026-11-02): company-paid, off-chain decision, on-chain payment. 3% of every package purchase (the POL actually paid) goes to the buyer's 4th upline on the contract sponsor chain if that member's contract buyerCount is 5 or more (qualifying buyer = direct referral with a $20+ purchase, same bar as level 3); otherwise it hunts up to the next qualified upline, max 25 hops; the company account (#1) or no qualified upline = company keeps it; exactly one recipient per purchase. Paid weekly in POL every Monday after 9 AM Central for the previous Monday to Sunday Central week, from a company payer wallet via the contract's award(memberId), shown in Earnings as 'Level 4 override' with a Polygon link and announced by email and an on-site notice. Under 0.01 POL carries to the next week. Purchases from the start date only, no back pay. Funded from the platform's 20%; the contract split 50/20/10 is unchanged. Never promise amounts. -${passTiersFact()}${refuelFact()}${synFact()}${polminerFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagent.app): a night-highway shooter open to every member. Open the Games tab and tap Play on the Road Agent card, or go to roadagent.app and sign in with the InstantAdPay email. Drive the four-lane highway, shoot the hostiles (thug sedans, switchblades, gunner vans), spare the civilians, pull into the weapons truck for oil slicks, smoke and missiles. Clearing a sector for the first time pays POL to the wallet on the member's InstantAdPay account, plus a daily patrol reward; scrap buys garage upgrades. Fuel = a sponsor visit: before a run the player visits an advertiser's page (a FUEL STOP), which is a normal verified visit with the dwell timer and human check, charged to the advertiser like any visit; advertisers' existing visits campaigns are already in the rotation, nothing to set up; to get more traffic from the game, top up the visits campaign. Clickable Pause, Sound and Music buttons sit under the game (P / M / N keys also work), and the Run tab has an Invite a friend card with the member's roadagent.app/?ref= link. +${passTiersFact()}${refuelFact()}${synFact()}${polminerFact()}${bixFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagent.app): a night-highway shooter open to every member. Open the Games tab and tap Play on the Road Agent card, or go to roadagent.app and sign in with the InstantAdPay email. Drive the four-lane highway, shoot the hostiles (thug sedans, switchblades, gunner vans), spare the civilians, pull into the weapons truck for oil slicks, smoke and missiles. Clearing a sector for the first time pays POL to the wallet on the member's InstantAdPay account, plus a daily patrol reward; scrap buys garage upgrades. Fuel = a sponsor visit: before a run the player visits an advertiser's page (a FUEL STOP), which is a normal verified visit with the dwell timer and human check, charged to the advertiser like any visit; advertisers' existing visits campaigns are already in the rotation, nothing to set up; to get more traffic from the game, top up the visits campaign. Clickable Pause, Sound and Music buttons sit under the game (P / M / N keys also work), and the Run tab has an Invite a friend card with the member's roadagent.app/?ref= link. - HELP DESK (LIVE 2026-10-16): members open Help in the dashboard (/my#help) to send Marty a support ticket (pick a category, a subject, the message, up to 2 screenshots), see each ticket's status (Open, Waiting on you, Closed) and read and answer his replies; a badge shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at https://instantadpay.com/support (name, email, category, subject, message) and gets an email with the ticket number (like IAP-1042) and a private link to view and reply, no sign-in needed. support@instantadpay.com also reaches Marty. Replying to a closed ticket opens it again. In this chat, "Send this to support" turns the conversation into a ticket. Only Marty answers, so replies are not instant; never promise a response time. - PRESENTATION (2026-10-15): instantadpay.com/presentation is a public page (no sign-in) with the narrated InstantAdPay presentation, about six minutes, Marty's voice, captions in 6 languages (English, Italiano, Français, Español, Deutsch, Português) chosen with pills under the player. Sixteen parts: the platform, ad reach, the nine games that pay POL, the $20 split ($10 / $4 / $2 / $4 platform, same transaction), three rules, packages, the 2-then-5 unlock, pass-up, wide versus narrow ($800 vs $36, an illustration), Qualified Start, the Pipeline, LinkSpin (pre-launch Nov 1), one wallet across the network, the first week, and 'the target is five'. Share link: Members > Promo tools > 'Share the presentation' copies instantadpay.com/presentation?ref=; ?ref sets the same 30-day sponsor cookie as the invite link, the page shows 'Shared with you by @name' with avatar and a Join button to /join/. It is in the site menu as 'Presentation'. BUILD WIDE VIDEO: first card in Promo tools > Videos ('Build wide: watch the payments flow'), matched link ?v=wide. - WIRED WEDNESDAY: every Wednesday, Central time (midnight to midnight), any ad package of $20 or more (Activation and up; no $10 pack exists) earns +25% bonus credits wired into the buyer's balance the moment the purchase settles, purchased-grade (usable on every format incl. login ads), credit log label "Wired Wednesday". First one: Wednesday 2026-09-30. Page: instantadpay.com/wednesday. Credits buy ad delivery, never money. @@ -398,15 +425,16 @@ async function answerRaw(message, historyText) { try { hit = await kb.fastPath(msg); } catch (e) { kbOk = false; console.error('kb fast path', e.message); } if (hit && hit.id === 'refuel' && !REFUEL_ON()) return { reply: REFUEL_OFF_ANSWER, canned: true, kb: hit.id }; if (hit && (hit.id === 'polminer' || hit.id === 'c-polminer') && !pmLive()) return { reply: POLMINER_SOON_ANSWER, canned: true, kb: hit.id }; + if (hit && isBixId(hit.id) && !bixLive()) return { reply: BIX_SOON_ANSWER, canned: true, kb: hit.id }; if (hit && (hit.id === 'network-rate' || hit.id === 'c-network-rate') && SYN_N() !== 4) return { reply: netRateAnswer(SYN_N()), canned: true, kb: hit.id }; if (hit) return Object.assign({ reply: hit.answer, canned: true, kb: hit.id }, hit.handoff ? { handoff: true } : {}); - if (!kbOk) for (const c of CANNED) if (c.re.test(msg)) return c.id === 'refuel' && !REFUEL_ON() ? { reply: REFUEL_OFF_ANSWER, canned: true } : c.id === 'polminer' && !pmLive() ? { reply: POLMINER_SOON_ANSWER, canned: true } : c.id === 'network-rate' && SYN_N() !== 4 ? { reply: netRateAnswer(SYN_N()), canned: true } : Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {}); + if (!kbOk) for (const c of CANNED) if (c.re.test(msg)) return c.id === 'refuel' && !REFUEL_ON() ? { reply: REFUEL_OFF_ANSWER, canned: true } : c.id === 'polminer' && !pmLive() ? { reply: POLMINER_SOON_ANSWER, canned: true } : isBixId(c.id) && !bixLive() ? { reply: BIX_SOON_ANSWER, canned: true } : c.id === 'network-rate' && SYN_N() !== 4 ? { reply: netRateAnswer(SYN_N()), canned: true } : Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {}); // retrieval: the closest entries ride along in the system prompt (a short follow-up borrows words from the chat so far) let kbBlock = '', kbIds = []; try { const query = msg.split(/\s+/).length < 4 && historyText ? msg + ' ' + String(historyText).slice(-200) : msg; const hits = await kb.context(query, 5); - const hitsOk = pmLive() ? hits : hits.filter(h => !/^(c-)?polminer$/.test(String(h.entry && h.entry.id))); // not live yet: keep its answer out of the prompt + const hitsOk = hits.filter(h => (pmLive() || !/^(c-)?polminer$/.test(String(h.entry && h.entry.id))) && (bixLive() || !isBixId(h.entry && h.entry.id))); // not live yet: keep its answer out of the prompt kbBlock = kb.promptBlock(hitsOk); kbIds = hitsOk.map(h => h.entry.id); } catch (e) { console.error('kb search', e.message); } if (!enabled()) return { reply: 'Good question. The quick answers I have cover packages, payouts, qualification, and joining; for anything deeper, the plain-language contract review at https://instantadpay.com/contract covers most of it, or tap "Send this to support" and Marty will answer.', handoff: true }; diff --git a/db.js b/db.js index a8ecef0..ad8fb27 100644 --- a/db.js +++ b/db.js @@ -344,6 +344,7 @@ async function bootstrap() { await alterSafe('ALTER TABLE accounts ADD COLUMN joined_via VARCHAR(20) NULL'); // ?v= angle the lead came in on await alterSafe('ALTER TABLE accounts ADD COLUMN joined_ref VARCHAR(80) NULL'); // referring domain of the first join-page visit await alterSafe('ALTER TABLE accounts ADD COLUMN wall_offers VARCHAR(2000) NULL'); // JSON [{title,bannerUrl,targetUrl}] for wall positions 2-3 (unlock at 2 / 5 qualifying buyers) + await alterSafe('ALTER TABLE accounts ADD COLUMN bix_partner_link VARCHAR(300) NULL'); // BixPay partner link (bixpay.js, 2026-10-29); column name checked against MySQL 8 reserved words // help desk (2026-10-16, tickets.js): one shared desk for IAP and, later, LinkSpin; email_message_id threads inbound mail await q(`CREATE TABLE IF NOT EXISTS tickets ( id INT AUTO_INCREMENT PRIMARY KEY, diff --git a/docs/BIXPAY-INTEGRATION.md b/docs/BIXPAY-INTEGRATION.md new file mode 100644 index 0000000..1885595 --- /dev/null +++ b/docs/BIXPAY-INTEGRATION.md @@ -0,0 +1,99 @@ +# BixPay card integration (DRAFT for Marty, 2026-10-29) + +Scope: InstantAdPay first, LinkSpin second, CTB when it launches. Nothing here is built yet. + +## What we know about BIX (verified 2026-10-29) +- BIX = self-custody wallet + Visa card spent from USDT/USDC. Funding networks include Polygon, so a member can swap POL + to USDT in the BIX app and load the card with no bridge. No load fee; up to 3% per purchase, 1% FX. +- Cards: virtual $9.99, plastic $100, metal $250, gold $25,000. US = Visa Signature (29 states); elsewhere Visa Platinum. +- Partner plan: 50% of net fees and card sales -> 45% over 10 levels (15 / 10 / 2.5 x 8) + 5% pool. +- Partner link format: `https://bix.ibportal.io/auth/register?e=<43-char token>&a=1` (opaque token, not derivable from the + IB ID). The referral link (`&appId=3`) makes a card customer only; the PARTNER link makes a partner. We use the partner link. +- Company fallback link: Marty's partner link (IB12143793). + +## 1. The profile field (one identity, follows the member) +- InstantAdPay Profile tab, new section **"BixPay card"**: one input, `bixPartnerLink`. +- Accepts a full partner link. Validation: host `bix.ibportal.io`, path `/auth/register`, `e=` present, `a=1`; strip `appId` + if pasted (the customer link) and tell the member "That's the card-customer link. Paste the Partner link from your BIX + portal profile instead." Max 300 chars. Saved on the IAP account; LinkSpin and CTB read it through the existing partner + API (the same way wallet and sponsor already flow), and LinkSpin's own Profile shows it read-only with "Edit on InstantAdPay". +- Member sees under the field: "Where to find it: BIX portal > Profile > Partner (the second box). Copy the link." +- Admin: the field shows on the member card; a count of members with a link set on the admin Overview. + +## 2. The link each visitor gets (sponsor follows) +`bixLinkFor(member)` = +1. the member's own `bixPartnerLink`, else +2. walk the sponsor chain up to 10 levels, first sponsor with a link, else +3. the company link (site config `bixCompanyLink`, default Marty's partner link). +The card promo always shows WHOSE link is in play: "Your link" / "Your sponsor @name's link" / "Network link". That nudges +members to add their own, and sponsors to get their teams signed up. +For public pages (games' landing pages, /join/), the referrer whose `?ref` is on the page resolves the same way. + +## 3. Where members see it +### Wallet tab (primary) +Card: **"Spend your POL anywhere with a BixPay Visa card"** +"BixPay is a self-custody wallet with a Visa card. Send USDT or USDC to it on Polygon, load the card, and spend it wherever +Visa is accepted, including Apple Pay and Google Pay. Virtual cards from $9.99." +(No in-app swap: Marty confirmed 2026-10-29 he swaps POL to USDT/USDC on an exchange, then sends it to BixPay. The guide +gets a "turn your POL into USDT" step: any exchange or on-ramp, then send on Polygon. Add the swap line only once BIX +ships it; the founder said "in the next three months" on 10-17.) +Buttons: **Get your BixPay card** (partner link) · **How it works** (opens the guide). +Small line: "Using: your link / @sponsor's link / the network link. Add yours in Profile." +### Overview +A one-line announcement card the first week ("New: a Visa card for your POL"), dismissable like the other cards. +### Payout emails + game "link your wallet" nudges +One sentence after the amount: "Want to spend it? A BixPay Visa card turns POL into everyday purchases: ." +(Payout emails already carry the member's identity, so the link resolves per member.) +### Promo tools > new tab "BixPay" +- The member's link with Copy/Share. +- 3 posts (short, friendly, the "spend your crypto" angle), an email swipe, and 4 banners we make (no BIX logo until + Marty confirms brand rules; text-only "crypto Visa card" creative is safe). +- Every asset carries the member's resolved link. +### Guide page /bixpay (public, SEO) +What it is, the fee table, the funding path (POL -> USDT on Polygon -> card), the sign-up steps with screenshots, the +partner plan in plain words, and the compliance box. CTA carries the viewer's resolved link. +### Chatbot +Canned answers: what BixPay is, how to get the card, how to load it from POL, where to put my partner link, who gets the +credit. Facts in the system prompt with KNOWLEDGE_DATE. + +## 4. Copy (Marty's voice, no em dashes) +- Wallet card title: "Spend your POL anywhere with a BixPay Visa card" +- Body: see above. +- Profile field label: "Your BixPay partner link" +- Profile help: "Join BixPay as a partner, then paste your Partner link here. Members and visitors who get a card through + your pages are credited to you in your BIX portal, up to ten levels deep." +- Email line: "Want to spend it? A BixPay Visa card turns POL into everyday purchases." +- Post 1 (short): "I spend my crypto with a Visa card now. BixPay keeps the keys with you, loads from USDT or USDC with no + load fee, and works with Apple Pay. Virtual card from $9.99: {L}" +- Fees line everywhere: "3% per purchase, no load fee. See BIX's terms for other charges." +- US line on the Wallet card and guide: "Available in 31 US states so far. Not in your state yet? You can still get the + wallet and build." +- Guide: a "Funding your card" section with three paths: (1) swap POL to USDT or USDC on any exchange, send on Polygon; + (2) Cash App (US): send crypto straight to the BixPay wallet; (3) the BIX in-app swap, once it ships. +- Post 2 (friendly): "Earning crypto is one thing. Spending it without jumping through hoops is another. BixPay fixed that + for me: a self-custody wallet and a Visa card in one app. Here's where I got mine: {L}" +- Post 3 (partner angle): "BixPay pays partners on every card and on card spending, ten levels deep. If you're building a + team anyway, this fits right in: {L}" + +## 5. Compliance box (shown on the Wallet card's "How it works" and the guide) +"BixPay is a separate company. BIX issues the wallet and the card through its banking partners and sets its own fees, +limits, eligibility and terms. InstantAdPay is not the card issuer and earns a referral commission when you sign up +through a partner link. Card availability varies by country. Crypto assets can lose value." + +## 6. Tracking +- Click counts per surface (wallet card, email, promo tools, guide) in the admin Traffic tab; per-member click counts on + the Promo tools BixPay tab. No sign-up credit on our side: the BIX portal shows each partner their directs and levels. +- If BIX ever offers a postback, add a "BixPay sign-ups" stat next to the click counts. + +## 7. Rollout +1. IAP: field + resolver + Wallet card + guide + chatbot + promo tab (gated by site config `bixpayLive`). +2. LinkSpin: read-only field + Wallet/Credits card + promo entry, same resolver through the partner API. +3. CTB: same card and field in ctb-next, same identity. +4. Announcement (release note + member email + Telegram) after Marty's copy approval. + +## Open questions for Marty / BIX upline +- Does a partner sign-up also get the card, or does the member need the app invitation too? (If both: show "Join as a + partner" and "Just want the card?" buttons, each with the member's own link type.) +- BIX name/logo use in our promo material. +- The pool's "50/50 rule". +- Any updated BIX materials. diff --git a/docs/BIXPAY-ZOOM-2026-10-17.md b/docs/BIXPAY-ZOOM-2026-10-17.md new file mode 100644 index 0000000..d57eb07 --- /dev/null +++ b/docs/BIXPAY-ZOOM-2026-10-17.md @@ -0,0 +1,38 @@ +# BixPay opportunity call, 2026-10-17 (Zoom replay notes, made 2026-10-29) + +"$iNVU - Live Opportunity Call", 47 min. Host "Bass"; main speaker David Emenite (22-year network marketer; his own company +is a trading opportunity, "tap to trade"); BIX founder "Nick" (28, Germany, says he owns "one of the largest Forex brokers +on the planet"; BIX started "a couple of months ago"); leaders Tracy Fischer, Lisa, Alan Jones, Gary. The $iNVU / trading +company parts are NOT BIX. Transcript: D:/tmp/bix-zoom/transcript.txt; slides D:/tmp/bix-zoom/frames. + +## Plan mechanics (as presented; matches the BIX commission PDF) +- The only fee claimed: 3% per transaction. "No top-up fees, no hidden fees." (A third-party review lists 1% FX, $0.75 + under $50, ATM $1 + 0.6%, so present 3% as THE fee and point to BIX's terms for the rest.) +- 50% of the 3% goes into the plan; paid over 10 levels: L1 15%, L2 10%, L3-L10 2.5% each; the other 5% = BIX pool, + 1 share per 10,000 cards in your network. Worked example: $1,000 spent -> $30 fee -> $15 into the plan. +- Card sales pay too: slide "EARN A 50% REFERRAL BONUS ON EVERY CARD PURCHASE" (virtual $9.99, plastic $100, metal $250, + 24K gold $25,000; shipping to 179 countries). The optional $9.99/month rewards membership is also commissionable. +- Upcoming banking (SEPA IBAN, ACH, SWIFT, fiat on/off-ramp): instant 0%, SEPA/ACH 1%, "up to 50% included in the + compensation plan". Nick: IBANs and the in-app SWAP "in the next three months", i.e. NOT live on 10-17. +- Shareholder: 500,000 cards in your network "on a 50/50 rule" = shareholder of BIX (Nick). Network contest: first to + 10,000 cards gets a $100,000 bonus. The 50/50 rule is still not defined on the call. +- US: "open in 31 states" (review on 10-24: 29), rest "first part of 2027". Wallet works everywhere; you can build from a + closed state. KYC required for the card; problems go to BIX support. +- Funding tip (Tracy/Bass): Cash App can send crypto straight to the BixPay wallet (about 20 transactions a month, up to + $5,000 a week); they used Coinbase before. Card works in Apple Wallet. +- Usage data quoted: average customer spends $1,400-1,500 a month (industry figure); Bass's back office shows $20-80 a + week per user so far. + +## Claims to treat as marketing, not facts +300,000 downloads / 300,000 cards active, $3M spent per day, live since August with global launch ~6 weeks before the +call, "5 million users in one year, 80 million in three, bigger than Revolut", "worth a couple hundred million, $100B in +three years", "$1 to $1 million per day" spend limit, $2.6T daily payments, founder "a billionaire". + +## What it changes in our integration draft (BIXPAY-INTEGRATION.md) +1. Don't promise an in-app swap yet. Copy becomes "load it with USDT or USDC on Polygon" until Marty confirms Swap works + in his app; add a short "how to turn POL into USDT" step (any exchange or the BIX swap once live). +2. Fees line: "3% per purchase, no load fee; see BIX's terms for other charges." +3. Lead with the $9.99 virtual card: it pays the referrer on the sale and on every swipe after. +4. US members: add "available in 31 states; not in your state yet? You can still build and get the wallet." +5. Add the Cash App funding path to the guide for non-crypto members (US). +6. Events in the call (Houston 10-20, Tampa 10-21, Bangkok 11-28) are the leaders' own, not ours. diff --git a/lssync.js b/lssync.js index 4253e13..9feba75 100644 --- a/lssync.js +++ b/lssync.js @@ -45,8 +45,13 @@ function profileOf(a) { const av = String(a.avatarUrl || '').trim(); const avatarUrl = !av ? null : /^https:\/\//i.test(av) ? av : av.startsWith('/') ? PUBLIC() + av : null; const bio = String(a.bio || '').trim().slice(0, 600) || null; - if (!avatarUrl && !bio && !(socials && Object.keys(socials).length)) return null; - return { avatarUrl, bio, socials: socials && Object.keys(socials).length ? socials : null }; + // the BixPay partner link travels too (2026-10-29): LinkSpin shows it read-only ("Edit on InstantAdPay") and resolves the + // same way; only set when there is one, so rows without it keep the hash they had + const bixPartnerLink = String(a.bixPartnerLink || '').trim() || null; + if (!avatarUrl && !bio && !bixPartnerLink && !(socials && Object.keys(socials).length)) return null; + const out = { avatarUrl, bio, socials: socials && Object.keys(socials).length ? socials : null }; + if (bixPartnerLink) out.bixPartnerLink = bixPartnerLink; + return out; } const hashOf = r => crypto.createHash('sha1').update([r.username || '', r.wallet || '', r.sponsorEmail || '', r.joinedAt || '', r.memberId || '', r.profile ? JSON.stringify(r.profile) : ''].join('|') + SF.hashExtra(r)).digest('hex').slice(0, 16); diff --git a/public/admin.html b/public/admin.html index 51c9ce5..2be1ed8 100644 --- a/public/admin.html +++ b/public/admin.html @@ -141,6 +141,7 @@
0
Active campaigns
0
Open reports
0
Follow-ups in flight
+
0
BixPay partner links
@@ -357,6 +358,9 @@ @@ -1221,9 +1251,9 @@
- + - + diff --git a/qa/bixpay.test.cjs b/qa/bixpay.test.cjs new file mode 100644 index 0000000..48aa3ad --- /dev/null +++ b/qa/bixpay.test.cjs @@ -0,0 +1,94 @@ +// BixPay (bixpay.js, 2026-10-29): the partner-link validator, the sponsor-follows resolver (own / sponsor at level 3 / none -> +// company), the gate, the email + nudge lines and the click store. Fake accounts, throwaway data dir. Run: node qa/bixpay.test.cjs +'use strict'; +const fs = require('fs'); +const os = require('os'); +const path = require('path'); +const assert = require('assert'); + +const ROOT = path.join(__dirname, '..'); +let fails = 0, n = 0; +async function t(name, fn) { n++; try { await fn(); console.log('ok', name); } catch (e) { fails++; console.log('FAIL', name, '::', e.message); } } +const bixpay = require(path.join(ROOT, 'bixpay.js')); +const walletnudge = require(path.join(ROOT, 'walletnudge.js')); + +const PARTNER = 'https://bix.ibportal.io/auth/register?e=XqwU9T1aJ5N0UJ0yr9x0TGUiSQTsVCkTM01MIovVNnc&a=1'; +const CUSTOMER = 'https://bix.ibportal.io/auth/register?e=boUGQ_dC9B472D9LGfzxPKvgfBw1iyqx-xffnx1kqPM&a=1&appId=3'; +const L3 = 'https://bix.ibportal.io/auth/register?e=' + 'L3token_'.repeat(5) + '&a=1'; + +// a five-deep line: leaf -> s1 -> s2 -> s3 (has a link) -> s4 -> s5; plus a loop pair and an orphan +const A = {}; +const mk = (email, sponsor, link, username) => { A[email] = { email, sponsorRef: sponsor || '', bixPartnerLink: link || null, username: username || null, code: email.split('@')[0] }; }; +mk('leaf@x.test', 's1', null, 'leaf'); mk('s1@x.test', 's2', null, 's1'); mk('s2@x.test', 's3', null, 's2'); mk('s3@x.test', 's4', L3, 's3'); mk('s4@x.test', 's5', null, 's4'); mk('s5@x.test', '', null, 's5'); +mk('own@x.test', 's1', PARTNER, 'own'); mk('orphan@x.test', '', null, 'orphan'); +mk('loopa@x.test', 'loopb', null, 'loopa'); mk('loopb@x.test', 'loopa', null, 'loopb'); +// twelve deep with the only link at level 11: must fall to the company (10-level walk) +let prev = ''; for (let i = 12; i >= 1; i--) { mk('d' + i + '@x.test', prev, i === 12 ? L3 : null, 'd' + i); prev = 'd' + i; } +mk('deep@x.test', 'd1', null, 'deep'); +const accounts = { byEmail: async e => A[e] || null, sponsorOf: async e => { const a = A[e]; if (!a || !a.sponsorRef) return null; return Object.values(A).find(x => x.username === a.sponsorRef || x.code === a.sponsorRef) || null; } }; +let site = { bixpayLive: '1', bixCompanyLink: '' }; +const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'bixpay-test-')); +bixpay.init({ dataDir: dir, accounts, siteConfig: () => site, refAccount: async tok => Object.values(A).find(x => x.username === tok || x.code === tok) || null }); + +(async () => { + await t('validator: the partner link passes and normalises', () => { const v = bixpay.validate(' ' + PARTNER + ' '); assert.ok(v.ok); assert.strictEqual(v.link, PARTNER); }); + await t('validator: extra params are dropped, e= and a=1 kept', () => { const v = bixpay.validate(PARTNER + '&utm=x'); assert.ok(v.ok); assert.strictEqual(v.link, PARTNER); }); + await t('validator: the appId=3 customer link is refused with the message', () => { const v = bixpay.validate(CUSTOMER); assert.ok(!v.ok); assert.strictEqual(v.error, bixpay.CUSTOMER_LINK_MSG); }); + await t('validator: wrong host, wrong path, no e=, no a=1, too long, empty, http', () => { + assert.ok(bixpay.validate('https://bix.fi/r?code=ABCDEFGH').error); + assert.ok(bixpay.validate('https://bix.ibportal.io/auth/login?e=' + 'x'.repeat(40) + '&a=1').error); + assert.ok(bixpay.validate('https://bix.ibportal.io/auth/register?a=1').error); + assert.ok(bixpay.validate('https://bix.ibportal.io/auth/register?e=' + 'x'.repeat(40)).error); + assert.ok(bixpay.validate('https://bix.ibportal.io/auth/register?e=' + 'x'.repeat(40) + '&a=2').error); + assert.ok(bixpay.validate('https://bix.ibportal.io/auth/register?e=' + 'x'.repeat(300) + '&a=1').error); + assert.ok(bixpay.validate('').error); assert.ok(bixpay.validate(null).error); + assert.ok(bixpay.validate('http://bix.ibportal.io/auth/register?e=' + 'x'.repeat(40) + '&a=1').error); + assert.ok(bixpay.validate('javascript:alert(1)').error); + }); + await t('resolver: own link wins', async () => { const r = await bixpay.resolve(A['own@x.test']); assert.strictEqual(r.whose, 'you'); assert.strictEqual(r.link, PARTNER); }); + await t('resolver: no own link -> first sponsor up the chain with one (level 3)', async () => { const r = await bixpay.resolve(A['leaf@x.test']); assert.strictEqual(r.whose, 'sponsor'); assert.strictEqual(r.name, '@s3'); assert.strictEqual(r.email, 's3@x.test'); assert.ok(r.link.includes('L3token_')); }); + await t('resolver: nobody up the chain -> company (default = Marty’s partner link)', async () => { const r = await bixpay.resolve(A['orphan@x.test']); assert.strictEqual(r.whose, 'network'); assert.strictEqual(r.link, bixpay.DEFAULT_COMPANY_LINK); assert.strictEqual(r.name, null); }); + await t('resolver: null member -> company', async () => { const r = await bixpay.resolve(null); assert.strictEqual(r.whose, 'network'); }); + await t('resolver: the walk stops at 10 levels (link at level 12 is not reached)', async () => { const r = await bixpay.resolve(A['deep@x.test']); assert.strictEqual(r.whose, 'network'); }); + await t('resolver: a sponsor loop ends in the company link, no hang', async () => { const r = await bixpay.resolve(A['loopa@x.test']); assert.strictEqual(r.whose, 'network'); }); + await t('resolver: site config bixCompanyLink overrides the default; a bad one falls back', async () => { + site.bixCompanyLink = L3; assert.strictEqual((await bixpay.resolve(null)).link, L3.replace(/&a=1$/, '&a=1')); + site.bixCompanyLink = 'https://evil.example/x'; assert.strictEqual((await bixpay.resolve(null)).link, bixpay.DEFAULT_COMPANY_LINK); + site.bixCompanyLink = ''; + }); + await t('resolveRef: a public page ?ref resolves like that member', async () => { const r = await bixpay.resolveRef('leaf'); assert.strictEqual(r.whose, 'sponsor'); const o = await bixpay.resolveRef('own'); assert.strictEqual(o.whose, 'you'); const u = await bixpay.resolveRef('nobody_zz'); assert.strictEqual(u.whose, 'network'); }); + await t('usingLine: the three wordings', async () => { + assert.strictEqual(bixpay.usingLine(await bixpay.resolve(A['own@x.test'])), 'Using: your link.'); + assert.strictEqual(bixpay.usingLine(await bixpay.resolve(A['leaf@x.test'])), "Using: @s3's link. Add yours in Profile."); + assert.strictEqual(bixpay.usingLine(await bixpay.resolve(null)), 'Using: the network link. Add yours in Profile.'); + }); + await t('gate: live/announcing follow site config; email and nudge lines are empty while off', () => { + assert.ok(bixpay.live()); assert.ok(bixpay.announcing()); + site.bixpayLiveSince = new Date(Date.now() - 8 * 86400000).toISOString(); assert.ok(!bixpay.announcing()); site.bixpayLiveSince = ''; + assert.ok(bixpay.emailLine('own').includes('/go/bixpay?s=email&m=own')); assert.ok(bixpay.nudgeLine('own').includes('s=nudge')); + assert.ok(!/—/.test(bixpay.emailLine('own'))); + site.bixpayLive = '0'; assert.ok(!bixpay.live()); assert.strictEqual(bixpay.emailLine('own'), ''); assert.strictEqual(bixpay.nudgeLine('own'), ''); site.bixpayLive = '1'; + }); + await t('walletnudge copy carries the BixPay sentence only when given one', () => { + const c0 = walletnudge.copy([{ key: 'g', name: 'Gem Kingdom', unpaid: 1.5 }], 0, 'https://instantadpay.com/my#wallet', ''); + assert.ok(!/BixPay/.test(c0.text) && !/BixPay/.test(c0.html)); + const c1 = walletnudge.copy([{ key: 'g', name: 'Gem Kingdom', unpaid: 1.5 }], 0, 'https://instantadpay.com/my#wallet', bixpay.nudgeLine('own')); + assert.ok(/BixPay Visa card/.test(c1.text) && /go\/bixpay\?s=nudge/.test(c1.html)); + assert.ok(c1.text.indexOf('Link your wallet:') < c1.text.indexOf('BixPay'), 'the wallet ask stays first'); + }); + await t('clicks: per surface, per member, per day; unknown surface -> other; bot-free store', () => { + bixpay.click('wallet', 'own@x.test'); bixpay.click('promo', 'own@x.test'); bixpay.click('promo', 'own@x.test'); bixpay.click('guide', null); bixpay.click('weird', 'leaf@x.test'); + const m = bixpay.memberClicks('own@x.test'); assert.strictEqual(m.total, 3); assert.strictEqual(m.promo, 2); assert.strictEqual(m.wallet, 1); + const v = bixpay.adminView(30); assert.strictEqual(v.total, 5); assert.strictEqual(v.bySurface.promo, 2); assert.strictEqual(v.bySurface.other, 1); assert.strictEqual(v.members[0].email, 'own@x.test'); assert.strictEqual(v.daily.length, 1); + bixpay._reset(); assert.strictEqual(bixpay.memberClicks('own@x.test').total, 3, 'persisted to disk'); + }); + await t('copy rules: no em dashes in any BixPay copy shipped to members', () => { + const files = ['bixpay.js', 'public/assets/promo.js', 'public/assets/my.js', 'public/bixpay.html', 'public/assets/bixpay-guide.js', 'chatbot.js']; + for (const f of files) { const s = fs.readFileSync(path.join(ROOT, f), 'utf8'); const lines = s.split('\n').filter(l => /bix/i.test(l) && /—/.test(l)); assert.strictEqual(lines.length, 0, f + ' has an em dash on a BixPay line'); } + const pj = fs.readFileSync(path.join(ROOT, 'public/assets/promo.js'), 'utf8'); + assert.ok(/no load fee/.test(pj) && !/in-app swap/i.test(pj.split('BIX_POSTS')[1].split('BIX_CDN')[0]), 'posts never promise the in-app swap'); + }); + fs.rmSync(dir, { recursive: true, force: true }); + console.log('\nbixpay: ' + (n - fails) + '/' + n + ' passed'); + process.exit(fails ? 1 : 0); +})(); diff --git a/qa/run.sh b/qa/run.sh index 23e8c71..98e2712 100644 --- a/qa/run.sh +++ b/qa/run.sh @@ -17,6 +17,7 @@ # bash qa/run.sh override # level-4 override: week math, hunt, house, dust carry, cap, balance, two concurrent payers (fake chain + signer, throwaway data) # bash qa/run.sh convpixel # conversion pixel: lsclk click ids on /api/ads/click, signed push to a MOCK LinkSpin, own-click self flag, Campaigns > Conversion tracking + cost per goal, LinkSpin down (local copy, throwaway data) # bash qa/run.sh fuel # Fuel Your Offers: refill notices, refuel streak, Refuel Kit, Engine Room (unit + two-copy tests, throwaway data) +# bash qa/run.sh bixpay # BixPay card: partner-link validator, sponsor-follows resolver (own / level 3 / company), gate, click store (unit, no server; also runs in member) # Each local run boots server.js on its own port with a throwaway data dir (JSON store, no DB, no # mail key, devCode sign-in), so nothing touches production data. Reports land in qa/out/. set -u @@ -45,6 +46,9 @@ elif [ "$MODE" = "member" ]; then start_local 8796 && { LOCAL=http://127.0.0.1:8796 node qa/walk.mjs member || status=1; }; stop_local 8796 node qa/tank-hold.mjs || status=1 node qa/walletnudge.test.cjs || status=1 + node qa/bixpay.test.cjs || status=1 +elif [ "$MODE" = "bixpay" ]; then + node qa/bixpay.test.cjs || status=1 elif [ "$MODE" = "walletnudge" ]; then node qa/walletnudge.test.cjs || status=1 elif [ "$MODE" = "tankhold" ]; then diff --git a/qa/walk.mjs b/qa/walk.mjs index 28735ea..35a2994 100644 --- a/qa/walk.mjs +++ b/qa/walk.mjs @@ -125,6 +125,67 @@ if (MODE === 'member' || MODE === 'all') { await page.goto(LOCAL + '/my#games'); await page.reload({ waitUntil: 'load' }); await page.waitForTimeout(2500); await hide(page); // a hash-only goto would not reload the card if (await page.evaluate(() => { const c = document.getElementById('gpCard'); return !!(c && !c.hidden); })) note('bug', L + 'my#games/gamepass', 'Game Pass card shows while gamePassEnabled is off'); flush(bag, L + 'my#games/gamepass'); + // BixPay card (2026-10-29): nothing while bixpayLive is off; once on: Wallet card, Overview card, Profile field (customer link refused, + // partner link saved, "Using: your link"), the Promo tab with posts + 4 banners + the tracked link, /bixpay 200 with the CTA, /go/bixpay 302s + const ADM = { Authorization: 'Bearer ' + (process.env.ADMIN_PASSWORD || 'localtest'), 'Content-Type': 'application/json' }; + { + const B = L + 'bixpay'; + const me0 = await page.evaluate(() => fetch('/api/me').then(r => r.json())); const tok = me0.username || me0.refCode; + await page.click('.bo-menu [data-pane="wallet"]'); await page.waitForTimeout(800); + if (await page.evaluate(() => { const c = document.getElementById('bixWalletCard'); return !!(c && !c.hidden); })) note('bug', B + '/off', 'Wallet card shows while bixpayLive is off'); + if ((await page.request.get(LOCAL + '/bixpay')).status() !== 404) note('bug', B + '/off', '/bixpay served while bixpayLive is off'); + await page.request.patch(LOCAL + '/api/admin/site', { headers: ADM, data: { bixpayLive: '1' } }).catch(() => {}); + await page.goto(LOCAL + '/my#wallet'); await page.reload({ waitUntil: 'load' }); await page.waitForTimeout(2500); await hide(page); + const wc = await page.evaluate(() => { const c = document.getElementById('bixWalletCard'); return c && !c.hidden ? c.textContent : ''; }); + if (!/Spend your POL anywhere with a BixPay Visa card/.test(wc) || !/3% per purchase, no load fee/.test(wc) || !/31 US states/.test(wc) || !/Using: the network link/.test(wc)) note('bug', B + '/wallet', 'Wallet card missing or wrong copy: ' + wc.slice(0, 120)); + const goHref = await page.$eval('#bixWalletGo', e => e.getAttribute('href')).catch(() => ''); + if (!/\/go\/bixpay\?s=wallet/.test(goHref)) note('bug', B + '/wallet', 'button is not the counted /go link: ' + goHref); + await domChecks(page, B + '/wallet'); await page.screenshot({ path: OUT + '/my-wallet-bixpay.png' }).catch(() => {}); + await page.click('.bo-menu [data-pane="overview"]'); await page.waitForTimeout(800); + if (!(await page.evaluate(() => { const c = document.getElementById('bixCard'); return !!(c && !c.hidden && /Visa card for your POL/.test(c.textContent) && c.querySelector('.card-x')); }))) note('bug', B + '/overview', 'announcement card missing or not dismissable'); + // profile: the customer link is refused, the partner link saves, the wallet card switches to "your link" + await page.click('.bo-menu [data-pane="profile"]'); await page.waitForTimeout(800); await hide(page); + if (!(await page.$('#pfBixCard:not([hidden])'))) note('bug', B + '/profile', 'BixPay card section hidden while live'); + await page.fill('#pfBixLink', 'https://bix.ibportal.io/auth/register?e=boUGQ_dC9B472D9LGfzxPKvgfBw1iyqx-xffnx1kqPM&a=1&appId=3'); await page.click('#pfBixSave'); await page.waitForTimeout(900); + if (!/card-customer link/.test(await page.$eval('#pfBixStatus', e => e.textContent).catch(() => ''))) note('bug', B + '/profile', 'customer link (appId=3) was not refused with the message'); + await page.fill('#pfBixLink', 'https://bix.ibportal.io/auth/register?e=QAwalkTOKENqawalkTOKENqawalkTOKENqawalkTOK&a=1'); await page.click('#pfBixSave'); await page.waitForTimeout(1200); + if (!/Saved/.test(await page.$eval('#pfBixStatus', e => e.textContent).catch(() => ''))) note('bug', B + '/profile', 'partner link did not save'); + await page.screenshot({ path: OUT + '/my-profile-bixpay.png' }).catch(() => {}); + const me2 = await page.evaluate(() => fetch('/api/me').then(r => r.json())); + if (!me2.bix || me2.bix.whose !== 'you' || !/e=QAwalkTOKEN/.test(me2.bix.link)) note('bug', B + '/api/me', 'resolved link is not the member’s own after saving: ' + JSON.stringify(me2.bix || {}).slice(0, 160)); + await page.click('.bo-menu [data-pane="wallet"]'); await page.waitForTimeout(600); + if (!/Using: your link/.test(await page.$eval('#bixWalletCard', e => e.textContent).catch(() => ''))) note('bug', B + '/wallet', 'Wallet card did not switch to "Using: your link"'); + // promo tab + await page.click('.bo-menu [data-pane="promo"]'); await page.waitForTimeout(600); + const bpill = await page.$('.promo-pills [data-promo="bixpay"]:not([hidden])'); if (!bpill) note('bug', B + '/promo', 'BixPay pill hidden while live'); + else { await bpill.click(); await page.waitForTimeout(900); + const sec = await page.evaluate(() => { const s = document.getElementById('promo-bixpay'); return s && !s.hidden ? { posts: s.querySelectorAll('#bixPromoPosts .promo-block').length, swipe: s.querySelectorAll('#bixPromoSwipe .promo-block').length, banners: s.querySelectorAll('#bixPromoBanners .promo-block').length, link: document.getElementById('bixPromoLink').textContent, go: document.getElementById('bixPromoGo').textContent, text: s.textContent } : null; }); + if (!sec) note('bug', B + '/promo', 'BixPay section did not show'); + else { if (sec.posts !== 3 || sec.swipe !== 1 || sec.banners !== 4) note('bug', B + '/promo', 'expected 3 posts, 1 swipe, 4 banners; got ' + sec.posts + '/' + sec.swipe + '/' + sec.banners); + if (!/e=QAwalkTOKEN/.test(sec.link)) note('bug', B + '/promo', 'partner link box is not the member’s own'); + if (!/\/go\/bixpay\?s=promo&m=/.test(sec.go)) note('bug', B + '/promo', 'tracked link missing: ' + sec.go); + if (/—/.test(sec.text)) note('bug', B + '/promo', 'em dash in BixPay promo copy'); } + await domChecks(page, B + '/promo'); await page.screenshot({ path: OUT + '/my-promo-bixpay.png', fullPage: true }).catch(() => {}); } + // the counted redirect + the public guide + const go = await page.request.get(LOCAL + '/go/bixpay?s=promo&m=' + tok, { maxRedirects: 0 }); + if (go.status() !== 302 || !/e=QAwalkTOKEN/.test(go.headers().location || '')) note('bug', B + '/go', 'expected a 302 to the member’s partner link, got ' + go.status() + ' ' + (go.headers().location || '')); + const me3 = await page.evaluate(() => fetch('/api/me').then(r => r.json())); + if (!me3.bix || !me3.bix.clicks || !(me3.bix.clicks.promo >= 1)) note('bug', B + '/go', 'promo click was not counted for the member'); + const gp = await page.request.get(LOCAL + '/bixpay?ref=' + tok); const gb = await gp.text(); + if (gp.status() !== 200 || !/Get your BixPay card/.test(gb) || !/BixPay is a separate company/.test(gb)) note('bug', B + '/guide', '/bixpay did not serve with the CTA and the compliance box: ' + gp.status()); + const pub = await (await page.request.get(LOCAL + '/api/public/bixpay?ref=' + tok)).json(); + if (!pub.live || pub.whose !== 'you' || !/\/go\/bixpay\?s=guide&m=/.test(pub.go || '')) note('bug', B + '/guide', 'public resolver did not resolve the ?ref member: ' + JSON.stringify(pub).slice(0, 160)); + const gctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }); const gpage = await gctx.newPage(); const gbag = watch(gpage, LOCAL); + await gpage.goto(LOCAL + '/bixpay?ref=' + tok, { waitUntil: 'networkidle' }); await gpage.waitForTimeout(800); + await domChecks(gpage, B + '/guide'); flush(gbag, B + '/guide'); await gpage.screenshot({ path: OUT + '/bixpay-guide.png', fullPage: true }).catch(() => {}); await gctx.close(); + // clean up: link removed, switch back off, everything hidden again + await page.evaluate(() => fetch('/api/my/bixpay', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{"link":""}' }).then(r => r.json())); // read the body before navigating, or the walk logs its own aborted request + await page.request.patch(LOCAL + '/api/admin/site', { headers: ADM, data: { bixpayLive: '0' } }).catch(() => {}); + if ((await page.request.get(LOCAL + '/bixpay')).status() !== 404) note('bug', B + '/off', '/bixpay still served after switching off'); + await page.goto(LOCAL + '/my#promo'); await page.reload({ waitUntil: 'load' }); await page.waitForTimeout(2500); await hide(page); + if (await page.$('.promo-pills [data-promo="bixpay"]:not([hidden])')) note('bug', B + '/off', 'BixPay pill still shows after switching off'); + flush(bag, B); console.log('ok BixPay: wallet card, overview card, profile field, promo tab, /go, /bixpay'); + } await page.click('.bo-menu [data-pane="promo"]'); await page.waitForTimeout(800); if (!(await page.$$('#promoPosts .promo-block')).length) note('bug', L + 'promo', 'no post cards rendered'); // viral links: the builder renders a ?ref= link; any page + ?ref= redirects clean and sets the sponsor cookie; an unknown ref sets nothing diff --git a/server.js b/server.js index 209fa2f..5ebf9b8 100644 --- a/server.js +++ b/server.js @@ -36,6 +36,7 @@ const walletnudge = require('./walletnudge'); const milestone = require('./milestone'); // players with POL waiting in the games and no wallet (2026-10-07) // holding tank: unsponsored free members, adoptions, pay-it-forward const legacy = require('./legacy'); // Faucet Wave / Tier One Ads bridge: welcome-back credits for listed emails const traffic = require('./traffic'); // public page views by referring domain (admin Traffic tab) +const BOT_UA = /bot|crawl|spider|slurp|facebookexternalhit|preview|monitor|wget|python-requests/i; // link previewers and crawlers: never a counted BixPay click (headless stays countable for the QA harness) const loginShows = require('./loginshows'); // login-ad showings per day, dashboard vs games (2026-10-18) const promos = require('./promos'); const missedNotice = require('./missed'); // the whole-chain missed-payout notice // partner promo codes -> free ad credits (link ?promo=CODE or the dashboard box) @@ -51,6 +52,7 @@ const lssync = require('./lssync'); const lsconv = require('./lsconv'); // conversion tracking: ad click ids pushed to LinkSpin + the member's goals (2026-10-23) const lsinbound = require('./lsinbound'); // reverse registry sync: LinkSpin-first members arrive as waiting accounts (2026-10-15) const SF = require('./sponsorfollow'); // deliberate sponsor changes follow to LinkSpin until chain-bound + one network tank (2026-10-22) +const bixpay = require('./bixpay'); // BixPay Visa card: partner-link field, sponsor-follows resolver, tracked clicks (2026-10-29, gated by site config bixpayLive) let follow = null, followStore = null; const LS_BASE = () => String(process.env.LS_URL || 'https://linkspin.app').replace(/\/+$/, ''); let activationCache = { at: 0, map: null }; @@ -85,7 +87,7 @@ const supportbot = require('./supportbot'); // @CTBTickets_bot: ticket pings wit const tickets = require('./tickets'); // help desk: member Help pane, public /support, chatbot hand-off, admin Support pane (Marty, 2026-10-16) const pipeline = require('./pipeline'); // sponsor follow-up board (coming soon until site setting pipelineMode = on) (Marty, 2026-09-15) const videomaker = require('./videomaker'); // Circuit tool: promo videos with the member's own end card (ffmpeg in the image) // badge-gated promo toolkit + AI Copy Engine (Surge and up) (Marty, 2026-09-14) // referral contest: /leaderboard, Overview card, weekly + monthly winners (Marty, 2026-09-14) // release notes + roadmap: /whats-new, Overview card, Admin > Releases (Marty, 2026-09-14) // blog -> Blotato -> X + Instagram on publish (Marty, 2026-09-13) // admin member card: search, drilldown, edits (Marty, 2026-09-13) // admin-written coaching articles, server-rendered public /blog with SEO metadata (Marty, 2026-09-12) -const TRAFFIC_PAGES = new Set(['/', '/ledger', '/contract', '/shorts', '/plays', '/wallets', '/launch', '/partners', '/earning', '/games', '/blog', '/whats-new', '/leaderboard', '/friday', '/wednesday', '/refuel', '/conversion-tracking', '/presentation', '/support']); +const TRAFFIC_PAGES = new Set(['/', '/ledger', '/contract', '/shorts', '/plays', '/wallets', '/launch', '/partners', '/earning', '/games', '/blog', '/whats-new', '/leaderboard', '/friday', '/wednesday', '/refuel', '/conversion-tracking', '/presentation', '/support', '/bixpay']); let tankWaitCache = null; // dashboard: who is waiting for a sponsor (refreshed every minute) const geo = require('./geo'); // viewer country -> tier (DB-IP lite), for campaign targeting const burner = require('./burner'); // automatic on-chain credit burns (inert without ENGINE_KEY) @@ -551,7 +553,7 @@ async function boot() { messages.init({ dataDir: DATA_DIR }); reports.init({ dataDir: DATA_DIR }); drip.init({ dataDir: DATA_DIR, mailer, accounts, chain, site: 'https://instantadpay.com' }); - chatbot.init({ dataDir: DATA_DIR, chain, gameLive: slug => String(siteConfig().gamesLive == null ? 'polhunter' : siteConfig().gamesLive).split(',').map(x => x.trim().toLowerCase()).includes(slug), refuelOn: () => refuel.cfg().on, passTiers: () => { const c = gamepass.cfg(); return { on: c.enabled && c.tierSales, rows: gamepass.TIER_DEFS.filter(d => d.key !== 'weekly').map(d => ({ name: d.name, perks: d.perks, price: c.tiers[d.key].price, usd: c.tiers[d.key].price / 100, days: c.tiers[d.key].days, sale: c.tiers[d.key].sale })) }; } }); // pass tiers fact follows sovTiers (2026-10-22) + chatbot.init({ dataDir: DATA_DIR, chain, bixLive: () => bixpay.live(), gameLive: slug => String(siteConfig().gamesLive == null ? 'polhunter' : siteConfig().gamesLive).split(',').map(x => x.trim().toLowerCase()).includes(slug), refuelOn: () => refuel.cfg().on, passTiers: () => { const c = gamepass.cfg(); return { on: c.enabled && c.tierSales, rows: gamepass.TIER_DEFS.filter(d => d.key !== 'weekly').map(d => ({ name: d.name, perks: d.perks, price: c.tiers[d.key].price, usd: c.tiers[d.key].price / 100, days: c.tiers[d.key].days, sale: c.tiers[d.key].sale })) }; } }); // pass tiers fact follows sovTiers (2026-10-22) setTimeout(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 1000); setInterval(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 60 * 1000); setInterval(() => ads.scheduleSweep().catch(e => console.error('schedule sweep', e.message)), 5 * 60 * 1000); // scheduled starts/ends @@ -650,6 +652,7 @@ async function boot() { setInterval(() => lssync.tick().catch(e => console.error('lssync', e.message)), 2 * 60 * 1000); setInterval(() => follow.retryPending().catch(e => console.error('sponsorfollow retry', e.message)), 2 * 60 * 1000); // follows waiting on a chain read or a sponsor account walletnudge.init({ dataDir: DATA_DIR, accounts, chain, mailer, optedIn: updates.optedIn, site: 'https://instantadpay.com', + bixLine: a => bixpay.nudgeLine(a ? (a.username || a.code) : ''), // one BixPay sentence in the nudge, only while bixpayLive (2026-10-29) message: async (to, subject, html) => { await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [to], subject, html, 'notice'); } }); setTimeout(() => walletnudge.tick().catch(e => console.error('walletnudge', e.message)), 3 * 60 * 1000); // past the deploy overlap window setInterval(() => walletnudge.tick().catch(e => console.error('walletnudge', e.message)), 60 * 60 * 1000); @@ -666,9 +669,10 @@ async function boot() { } legacy.init({ dataDir: DATA_DIR }); traffic.init({ dataDir: DATA_DIR }); + bixpay.init({ dataDir: DATA_DIR, accounts, siteConfig, refAccount }); loginShows.init({ dataDir: DATA_DIR }); promos.init({ dataDir: DATA_DIR }); - blog.init({ dataDir: DATA_DIR }); + blog.init({ dataDir: DATA_DIR, extraPages: () => bixpay.live() ? ['/bixpay'] : [] }); adminMember.init({ accounts, ads, chain, tank, legacy, promos, messages, dataDir: DATA_DIR }); gamepass.init({ dataDir: DATA_DIR, siteConfig, accounts, marks, isProd: IS_PROD, persistedMap, polUsd: polUsdLive, blockTime: async n => { const blk = await chain.rpc('eth_getBlockByNumber', ['0x' + Number(n).toString(16), false]); return blk && blk.timestamp ? parseInt(blk.timestamp, 16) : 0; }, // a pass order is fulfilled only by a purchase mined after it @@ -816,6 +820,10 @@ function siteConfig() { // /join/ here, so shared links do not carry instantadpay.com (Spamhaus DBL). '' = old instantadpay.com/join links. // Switch to the spare (mylinehq.com) if one gets flagged. Old links keep working either way. shareDomain: 'ctbgo.com', + // BixPay Visa card (2026-10-29, docs/BIXPAY-INTEGRATION.md): '0' = nothing shows anywhere (no Profile field, Wallet card, + // Overview card, promo tab, /bixpay guide, chatbot says coming soon). bixCompanyLink = the network fallback partner link + // (Marty's own PARTNER link, IB12143793); bixpayLiveSince is stamped when the switch is flipped on (the Overview card runs a week). + bixpayLive: '0', bixCompanyLink: bixpay.DEFAULT_COMPANY_LINK, bixpayLiveSince: '', pnlFixedMonthlyUsd: 0 }, saved); } @@ -1356,9 +1364,11 @@ async function emailOnEvent(ev) { const pct = PCT[ev.tier] || 0; const pur = purchaseOf(ev.tx); let buyer = 'a member on your level ' + ev.tier; try { buyer = await memberLabel(ev.buyerId); } catch (e) {} const pol = weiToPol(ev.amountWei); + // BixPay (2026-10-29): one sentence after the amount, the recipient's resolved partner link behind a counted /go link; only while live + let bixLine = ''; try { if (bixpay.live()) { const ra = await accounts.byMemberId(ev.recipientId); bixLine = bixpay.emailLine(ra ? (ra.username || ra.code) : ''); } } catch (e) { bixLine = ''; } await tell(ev.recipientId, 'You just got paid ' + pol + ' POL on InstantAdPay', buyer + ' just bought an ad package on your level ' + ev.tier + (pur ? ' ($' + (pur.priceCents / 100).toFixed(2).replace(/\.00$/, '') + ')' : '') + '. Your ' + pct + ' percent share, ' + pol + ' POL' + usdShare(pur, pct) + ', landed in your wallet in the same transaction' + (ev.hops ? ', passed up to you because someone between you was not qualified for this level' : '') + '.\n\n' + - 'Transaction: ' + txUrlOf(ev.tx) + '\n\nYour dashboard: https://instantadpay.com/my'); + (bixLine ? bixLine + '\n\n' : '') + 'Transaction: ' + txUrlOf(ev.tx) + '\n\nYour dashboard: https://instantadpay.com/my'); } else if (ev.type === 'AwardPaid') { const ov = override.txInfo(ev.tx); // a level-4 override payment from the weekly payer @@ -2245,6 +2255,7 @@ const server = http.createServer(async (req, res) => { // -- the pages a member can turn into a viral link (promo tools > Viral links) if (p === '/api/pages' && req.method === 'GET') { const pages = [{ path: '/', title: 'Home page' }, { path: '/blog', title: 'Blog' }, { path: '/earning', title: 'How earning works' }, { path: '/games', title: 'Games that pay POL' }, { path: '/ledger', title: 'Live ledger' }, { path: '/leaderboard', title: 'Leaderboard' }, { path: '/contract', title: 'The contract' }, { path: '/plays', title: 'Team-building plays' }, { path: '/wallets', title: 'Wallet guide' }, { path: '/friday', title: 'Five Dollar Friday' }, { path: '/refuel', title: 'Fuel Your Offers: the Monthly Refuel guide' }, { path: '/conversion-tracking', title: 'Conversion tracking: how to set it up' }, { path: '/whats-new', title: "What's new" }, { path: '/shorts', title: 'Shorts' }, { path: '/presentation', title: 'The presentation (narrated video)' }]; + if (bixpay.live()) pages.push({ path: '/bixpay', title: 'BixPay: a Visa card for your POL' }); // the guide resolves the sharer's partner link from ?ref (2026-10-29) try { for (const b of (await blog.listPublished()).slice(0, 40)) pages.push({ path: '/blog/' + b.slug, title: 'Article: ' + b.title, cover: b.cover || null }); } catch (e) {} return json(res, 200, { pages }); } @@ -2791,6 +2802,9 @@ const server = http.createServer(async (req, res) => { socials: (acct && acct.socials) || null, wallOffers: parseWallOffers(acct), lineBannerUrl: (acct && acct.lineBannerUrl) || null, lineTargetUrl: (acct && acct.lineTargetUrl) || null }; + // BixPay (2026-10-29): the member's own partner link plus the one their pages resolve to (own > sponsor chain > network) + if (bixpay.live()) { try { const r = await bixpay.resolve(acct); const tok = (acct && (acct.username || acct.code)) || ''; out.bix = { live: true, own: (acct && acct.bixPartnerLink) || null, link: r.link, whose: r.whose, name: r.name, using: bixpay.usingLine(r), go: { wallet: bixpay.goLink('wallet'), overview: bixpay.goLink('overview'), promo: bixpay.goLink('promo', tok) }, announce: bixpay.announcing(), clicks: bixpay.memberClicks(acct && acct.email) }; } catch (e) { out.bix = { live: true, error: true }; } } + else out.bix = { live: false }; if (memberId) { try { const mm = await chain.member(memberId); @@ -3330,6 +3344,14 @@ const server = http.createServer(async (req, res) => { return json(res, 404, { error: 'unknown op' }); } // -- the Engine Room, partner side: this site's facts for one member + the streak (LinkSpin builds its own panel from them) + // -- BixPay link for one member, the same resolver (own > sponsor chain > network), for LinkSpin / CTB cards (2026-10-29, read-only there) + if (p === '/api/partner/bixpay' && req.method === 'POST') { + const sg = await readLsSigned(req, 64000); if (!sg.body) return json(res, sg.status, { error: sg.error }); + const email = String(sg.body.email || '').trim().toLowerCase(); if (!email) return json(res, 400, { error: 'Which member?' }); + if (!bixpay.live()) return json(res, 200, { ok: true, live: false }); + const a = await accounts.byEmail(email); const r = await bixpay.resolve(a); + return json(res, 200, { ok: true, live: true, own: (a && a.bixPartnerLink) || null, link: r.link, whose: r.whose, name: r.name, using: bixpay.usingLine(r), editUrl: 'https://instantadpay.com/my#profile', guide: 'https://instantadpay.com/bixpay' }); + } if (p === '/api/partner/engine' && req.method === 'POST') { const sg = await readLsSigned(req, 64000); if (!sg.body) return json(res, sg.status, { error: sg.error }); const email = String(sg.body.email || '').trim().toLowerCase(); if (!email) return json(res, 400, { error: 'Which member?' }); @@ -3420,6 +3442,7 @@ const server = http.createServer(async (req, res) => { if (p === '/api/admin/traffic' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); const days = Math.min(365, Math.max(1, Number(u.searchParams.get('days')) || 30)); + const bix = bixpay.adminView(days); try { for (const m of bix.members) { const a = await accounts.byEmail(m.email); m.name = a ? (a.username ? '@' + a.username : a.email) : m.email; } } catch (e) {} // BixPay clicks per surface and per member (2026-10-29) const since = Date.now() - days * 86400000, sinceDay = new Date(since).toISOString().slice(0, 10); const hosts = {}, paths = {}, daily = {}, angles = {}; const H = k => (hosts[k] = hosts[k] || { source: k, hits: 0, joinViews: 0, signups: 0, registered: 0, buyers: 0 }); @@ -3434,7 +3457,7 @@ const server = http.createServer(async (req, res) => { const k = a.joinedVia || 'plain'; angles[k] = angles[k] || { angle: k, views: 0, signups: 0 }; angles[k].signups += 1; } const sources = Object.values(hosts).sort((x, y) => (y.hits + y.joinViews + y.signups * 10) - (x.hits + x.joinViews + x.signups * 10)); - return json(res, 200, { starter: starter.adminView(), days, sources, paths: Object.entries(paths).map(([path, hits]) => ({ path, hits })).sort((x, y) => y.hits - x.hits), + return json(res, 200, { starter: starter.adminView(), bixpay: Object.assign(bix, { live: bixpay.live() }), days, sources, paths: Object.entries(paths).map(([path, hits]) => ({ path, hits })).sort((x, y) => y.hits - x.hits), angles: Object.values(angles).sort((x, y) => y.views - x.views), daily: Object.values(daily).sort((x, y) => x.day < y.day ? -1 : 1), totals: { hits: sources.reduce((n, s) => n + s.hits, 0), joinViews: sources.reduce((n, s) => n + s.joinViews, 0), signups: sources.reduce((n, s) => n + s.signups, 0), buyers: sources.reduce((n, s) => n + s.buyers, 0) } }); } @@ -4631,6 +4654,31 @@ const server = http.createServer(async (req, res) => { const r = await accounts.setProfile(s.email, avatar, bio, socials); return json(res, r.error ? 400 : 200, r); } + // -- BixPay partner link (2026-10-29): Profile > BixPay card. Validated (bix.ibportal.io/auth/register, e=, a=1; the + // appId=3 card-customer link is refused with a message); empty clears it. Rides to LinkSpin in the profile row. + if (p === '/api/my/bixpay' && req.method === 'POST') { + const s = await auth.fromRequest(req); + if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' }); + if (!bixpay.live()) return json(res, 404, { error: 'Not open yet.' }); + const b = await readBody(req); + const raw = String(b.link == null ? '' : b.link).trim(); + if (!raw) { const r = await accounts.setBixLink(s.email, null); if (r.error) return json(res, 400, r); const rs = await bixpay.resolve(r.account); return json(res, 200, { ok: true, own: null, link: rs.link, whose: rs.whose, name: rs.name, using: bixpay.usingLine(rs) }); } + const v = bixpay.validate(raw); + if (!v.ok) return json(res, 400, { error: v.error, customerLink: v.error === bixpay.CUSTOMER_LINK_MSG }); + const r = await accounts.setBixLink(s.email, v.link); + if (r.error) return json(res, 400, r); + return json(res, 200, { ok: true, own: v.link, link: v.link, whose: 'you', name: null, using: bixpay.usingLine({ whose: 'you' }) }); + } + // -- the /bixpay guide's CTA: the viewer's resolved link (their own when signed in, else the ?ref / sponsor cookie's member, else network) + if (p === '/api/public/bixpay' && req.method === 'GET') { + if (!bixpay.live()) return json(res, 200, { live: false }); + const s = await auth.fromRequest(req).catch(() => null); + let acct = (s && s.email && await accounts.byEmail(s.email)) || null; + const tok = String(u.searchParams.get('ref') || '').trim().toLowerCase().slice(0, 40) || String(parseCookies(req)['iap.sponsor'] || '').trim().toLowerCase().slice(0, 40); + const r = acct ? await bixpay.resolve(acct) : await bixpay.resolveRef(tok); + const owner = acct || (tok ? await refAccount(tok).catch(() => null) : null); + return json(res, 200, { live: true, whose: r.whose, name: r.name, using: bixpay.usingLine(r), go: bixpay.goLink('guide', owner ? (owner.username || owner.code) : ''), promoGo: owner ? bixpay.goLink('promo', owner.username || owner.code) : null, signedIn: !!acct }); + } // -- wall positions 2 & 3: the member's own offers, unlocked at 2 / 5 qualifying buyers if (p === '/api/my/wall-offers' && req.method === 'POST') { const s = await auth.fromRequest(req); @@ -5257,7 +5305,8 @@ const server = http.createServer(async (req, res) => { for (const c of camps) { byStatus[c.status] = (byStatus[c.status] || 0) + 1; byType[c.type] = (byType[c.type] || 0) + 1; } let memberCount = null; try { memberCount = await chain.memberCount(); } catch (e) {} const cc = chain.getConfig(); - return json(res, 200, { accounts: await accounts.count(), memberCount, campaigns: camps.length, + let bixLinks = 0; try { bixLinks = (await accounts.listAll(100000)).filter(a => a.bixPartnerLink).length; } catch (e) {} // members with a BixPay partner link (2026-10-29) + return json(res, 200, { accounts: await accounts.count(), memberCount, campaigns: camps.length, bixLinks, bixpayLive: bixpay.live(), house: camps.filter(c => c.house).length, byStatus, byType, openReports: await reports.openCount(), pendingBurns: (await ads.pendingBurns()).length, followups: await drip.stats(), @@ -5613,6 +5662,8 @@ const server = http.createServer(async (req, res) => { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); const b = await readBody(req); const cur = siteConfig(); + if (b.bixCompanyLink !== undefined && String(b.bixCompanyLink || '').trim()) { const v = bixpay.validate(b.bixCompanyLink); if (!v.ok) return json(res, 400, { error: 'bixCompanyLink: ' + v.error }); b.bixCompanyLink = v.link; } + if (String(b.bixpayLive) === '1' && String(cur.bixpayLive) !== '1' && !String(cur.bixpayLiveSince || '').trim()) b.bixpayLiveSince = new Date().toISOString(); // the Overview announcement runs a week from the flip fs.writeFileSync(SITE_FILE, JSON.stringify(Object.assign(cur, b), null, 2)); return json(res, 200, { ok: true, site: siteConfig() }); } @@ -5704,6 +5755,17 @@ const server = http.createServer(async (req, res) => { if (p === '/friday') return sendFile(res, path.join(PUBLIC_DIR, 'friday.html')); if (p === '/wednesday') return sendFile(res, path.join(PUBLIC_DIR, 'wednesday.html')); if (p === '/conversion-tracking') return sendFile(res, path.join(PUBLIC_DIR, 'conversion-tracking.html')); // how to set up the conversion pixel, the member guide (2026-10-24) + if (p === '/bixpay') { if (!bixpay.live()) { res.writeHead(404, baseHeaders({ 'Content-Type': 'text/plain' })); return res.end('Not found'); } return sendFile(res, path.join(PUBLIC_DIR, 'bixpay.html')); } // the BixPay card guide (2026-10-29), public once bixpayLive is on + // counted BixPay click: every surface links here; resolves the member's link (own > sponsor chain > network) and 302s to it + if (p === '/go/bixpay') { + if (!bixpay.live()) { res.writeHead(302, baseHeaders({ Location: '/' })); return res.end(); } + const surface = String(u.searchParams.get('s') || 'other').trim().toLowerCase().slice(0, 12); + const tok = String(u.searchParams.get('m') || '').trim().toLowerCase().slice(0, 40); + let acct = null; try { if (tok) acct = await refAccount(tok); if (!acct) { const s = await auth.fromRequest(req); if (s && s.email) acct = await accounts.byEmail(s.email); } if (!acct) { const ck = String(parseCookies(req)['iap.sponsor'] || '').trim().toLowerCase(); if (ck) acct = await refAccount(ck); } } catch (e) { acct = null; } + const r = await bixpay.resolve(acct); + if (!BOT_UA.test(String(req.headers['user-agent'] || ''))) bixpay.click(surface, acct ? acct.email : null); + res.writeHead(302, baseHeaders({ Location: r.link, 'Cache-Control': 'no-store' })); return res.end(); + } if (p === '/refuel') return sendFile(res, path.join(PUBLIC_DIR, u.searchParams.has('t') ? 'refuel.html' : 'refuel-guide.html')); // ?t=: the games' refuel visit (2026-09-30); no token: the Fuel Your Offers member guide (2026-10-24) if (p === '/door') return sendFile(res, path.join(PUBLIC_DIR, 'door.html')); // Spooky Doors door visit (2026-10-02) // per-partner kit pages (Marty, 2026-09-29): /partners/ serves public/kits/.html, one file per reviewer or site owner diff --git a/tools/gen-bixpay-banners.py b/tools/gen-bixpay-banners.py new file mode 100644 index 0000000..c22e11f --- /dev/null +++ b/tools/gen-bixpay-banners.py @@ -0,0 +1,97 @@ +# BixPay promo banners (2026-10-29): four text-only sizes for Promo tools > BixPay. No BIX logo (brand rules not confirmed), +# the "crypto Visa card" angle in the game-banner style: deep green, mint accent, Sora-like bold display text, a card motif +# drawn with shapes. Run: python tools/gen-bixpay-banners.py then upload to Spaces game-banners/bixpay/. +# Copy rules: no income promises, the one fee line, no em dashes. +import sys, os +from PIL import Image, ImageDraw, ImageFont + +OUT = sys.argv[1] if len(sys.argv) > 1 else "D:/tmp/bixpay-banners" +os.makedirs(OUT, exist_ok=True) +GREEN = (4, 59, 47); DEEP = (3, 38, 31); MINT = (67, 232, 195); INK = (236, 248, 243); MUTED = (170, 205, 194); AMBER = (255, 178, 56) +FONTS = ["C:/Windows/Fonts/segoeuib.ttf", "C:/Windows/Fonts/arialbd.ttf"] +FONT_R = ["C:/Windows/Fonts/segoeui.ttf", "C:/Windows/Fonts/arial.ttf"] +def font(size, bold=True): + for p in (FONTS if bold else FONT_R): + if os.path.exists(p): return ImageFont.truetype(p, size) + return ImageFont.load_default() + +def bg(w, h): + im = Image.new("RGB", (w, h), GREEN) + d = ImageDraw.Draw(im) + # soft diagonal band + for i in range(h): + t = i / max(1, h - 1) + c = tuple(int(GREEN[k] * (1 - t) + DEEP[k] * t) for k in range(3)) + d.line([(0, i), (w, i)], fill=c) + return im + +def card(d, x, y, w, h): + # a plain card shape: rounded rectangle, a chip, a stripe. No brand marks. + d.rounded_rectangle((x, y, x + w, y + h), radius=int(h * 0.12), fill=MINT) + d.rounded_rectangle((x + w * 0.08, y + h * 0.32, x + w * 0.26, y + h * 0.56), radius=int(h * 0.05), fill=(214, 182, 90)) + d.rounded_rectangle((x + w * 0.08, y + h * 0.70, x + w * 0.62, y + h * 0.78), radius=int(h * 0.03), fill=(6, 60, 48)) + d.ellipse((x + w * 0.70, y + h * 0.62, x + w * 0.84, y + h * 0.86), fill=(6, 60, 48)) + d.ellipse((x + w * 0.79, y + h * 0.62, x + w * 0.93, y + h * 0.86), outline=(6, 60, 48), width=max(2, int(h * 0.03))) + +def text_w(d, s, f): + b = d.textbbox((0, 0), s, font=f); return b[2] - b[0], b[3] - b[1] + +def fit(d, s, maxw, start, bold=True, floor=10): + sz = start + while sz > floor: + f = font(sz, bold) + if text_w(d, s, f)[0] <= maxw: return f + sz -= 1 + return font(floor, bold) + +def pill(d, x, y, s, f, pad=10): + # the text's bbox offsets (Segoe sits a few px below the origin) are subtracted so the label is centred in the pill + b = d.textbbox((0, 0), s, font=f); tw, th = b[2] - b[0], b[3] - b[1] + d.rounded_rectangle((x, y, x + tw + pad * 2, y + th + pad * 2), radius=(th + pad * 2) // 2, fill=MINT) + d.text((x + pad - b[0], y + pad - b[1]), s, font=f, fill=(4, 30, 24)) + return tw + pad * 2 +def pill_size(d, s, f, pad=10): + b = d.textbbox((0, 0), s, font=f); return b[2] - b[0] + pad * 2, b[3] - b[1] + pad * 2 + +def leaderboard(w, h): # 728x90, 468x60 + im = bg(w, h); d = ImageDraw.Draw(im) + ch = int(h * 0.62); cw = int(ch * 1.58); cx = int(h * 0.18); cy = (h - ch) // 2 + card(d, cx, cy, cw, ch) + x = cx + cw + int(h * 0.22) + head = "A Visa card for your crypto" + f1 = fit(d, head, w * 0.52, int(h * 0.30)); d.text((x, int(h * 0.12)), head, font=f1, fill=INK) + sub = "Spend POL anywhere Visa is accepted. 3% per purchase, no load fee." + f2 = fit(d, sub, w * 0.55, int(h * 0.17), bold=False); d.text((x, int(h * 0.56)), sub, font=f2, fill=MUTED) + f3 = font(int(h * 0.19)); s = "Get the card"; pad = int(h * 0.09) + pw, ph = pill_size(d, s, f3, pad); pill(d, w - pw - int(h * 0.18), (h - ph) // 2, s, f3, pad=pad) + return im + +def rectangle(w, h): # 300x250 + im = bg(w, h); d = ImageDraw.Draw(im) + f0 = font(12); d.text((18, 16), "CRYPTO VISA CARD", font=f0, fill=MINT) + cw = 118; ch = 74; card(d, w - cw - 18, 14, cw, ch) + head = "Spend your POL\nanywhere" + f1 = font(26); d.multiline_text((18, 96), head, font=f1, fill=INK, spacing=0) + sub = "A self-custody wallet with a Visa card.\nApple Pay and Google Pay.\n3% per purchase, no load fee." + f2 = font(12, bold=False); d.multiline_text((18, 160), sub, font=f2, fill=MUTED, spacing=3) + f3 = font(14); s = "Get the card"; pw, ph = pill_size(d, s, f3, 9); pill(d, w - pw - 18, h - ph - 14, s, f3, pad=9) + return im + +def splash(w, h): # 600x300 + im = bg(w, h); d = ImageDraw.Draw(im) + f0 = font(15); d.text((30, 26), "CRYPTO VISA CARD", font=f0, fill=MINT) + card(d, w - 230, 36, 196, 122) + head = "Spend your POL\nanywhere Visa\nis accepted." + f1 = font(40); d.multiline_text((30, 54), head, font=f1, fill=INK, spacing=0) + sub = "A self-custody wallet with a Visa card. Virtual card from $9.99. 3% per purchase, no load fee." + f2 = fit(d, sub, w - 60, 17, bold=False); d.text((30, 218), sub, font=f2, fill=MUTED) + f3 = font(18); s = "Get your card"; pw, ph = pill_size(d, s, f3, 12); pill(d, w - pw - 30, h - ph - 24, s, f3, pad=12) + return im + +SIZES = {"728x90": leaderboard, "468x60": leaderboard, "300x250": rectangle, "600x300": splash} +for s, fn in SIZES.items(): + w, h = map(int, s.split("x")) + im = fn(w, h) + assert im.size == (w, h) + p = os.path.join(OUT, "bixpay-" + s + ".png"); im.save(p, optimize=True) + print(p, os.path.getsize(p), "bytes") diff --git a/walletnudge.js b/walletnudge.js index dd6f52e..7aa02e4 100644 --- a/walletnudge.js +++ b/walletnudge.js @@ -74,7 +74,7 @@ function fetchRows(g) { }); } // copy (Marty, 2026-10-27): the ask is the LINK step only (one free signature), never "switch on payouts": a linked wallet is paid -function copy(games, stage, link) { +function copy(games, stage, link, bixLine) { const total = games.reduce((n, g) => n + g.unpaid, 0); const parts = games.map(g => g.unpaid.toFixed(2) + ' POL in ' + g.name); const list = parts.length > 1 ? parts.slice(0, -1).join(', ') + ' and ' + parts[parts.length - 1] : parts[0]; @@ -82,8 +82,11 @@ function copy(games, stage, link) { const p1 = "You've earned " + list + ". Link your wallet (one free signature) and it's sent automatically, including everything you've earned so far."; const p2 = 'It is not a transaction and it cannot move funds. Every game pays that same wallet from then on.'; const p3 = stage >= 2 ? 'This is the last reminder about this balance. It stays yours; it just waits for a wallet.' : 'Not sure which wallet to use? SafePal is the one we recommend; MetaMask and Phantom work too. The Wallet tab has a short guide.'; - const text = [p1, '', p2, '', 'Link your wallet: ' + link, '', p3].join('\n'); - const html = '

' + esc(p1).replace(esc(list), '' + esc(list) + '') + '

' + esc(p2) + '

Link your wallet

' + esc(p3) + '

'; + // BixPay (2026-10-29): one sentence after the wallet ask, the member's resolved partner link behind a counted /go link; '' while bixpayLive is off + const bx = String(bixLine || '').trim(); + const text = [p1, '', p2, '', 'Link your wallet: ' + link, '', p3].concat(bx ? ['', bx] : []).join('\n'); + const bxHtml = bx ? '

' + esc(bx).replace(/(https:\/\/\S+)/, '$1') + '

' : ''; + const html = '

' + esc(p1).replace(esc(list), '' + esc(list) + '') + '

' + esc(p2) + '

Link your wallet

' + esc(p3) + '

' + bxHtml; return { subject, text, html, total }; } async function tick() { @@ -132,7 +135,7 @@ async function tick() { const stage = p.sent.length; if (stage >= STAGES.length) continue; if (now - p.first < STAGES[stage]) continue; const link = (R.site || 'https://instantadpay.com') + '/my#wallet'; - const c = copy(gs, stage, link); + const c = copy(gs, stage, link, R.bixLine ? R.bixLine(a) : ''); let ok = false; try { await R.message(email, c.subject, c.html); ok = true; } catch (e) {} if (R.mailer && R.mailer.hasKey && R.mailer.hasKey() && R.optedIn) { try { if (await R.optedIn(email)) { await R.mailer.send(email, c.subject, c.text, c.html); ok = true; } } catch (e) {} } @@ -154,4 +157,4 @@ function adminView() { return { stats: Object.assign({ pushed: 0 }, S.stats), lastRun: S.lastRun, lastRows: S.lastRows, games: games().map(g => ({ key: g.key, name: g.name, url: g.url, nudge: g.nudge !== false })), pushed: (S.pushLog || []).slice(0, 100), pushRefused: Object.values(S.pushes || {}).filter(x => x.status !== 'ok').sort((a, b) => b.at - a.at).slice(0, 100), waiting: people.filter(p => !p.done), done: people.filter(p => p.done).slice(0, 100) }; } -module.exports = { init, tick, waitingFor, adminView, games, STAGES }; +module.exports = { init, tick, waitingFor, adminView, games, STAGES, copy };