commit 555930869095f2e58f29aa27d5bbae5484c0a701 Author: eric Date: Sat Aug 22 22:29:23 2026 -0500 Initial TubeMart YPP channel market with NOWPayments checkout. Document local setup, env vars, and API in README; sync to Gitea. Co-authored-by: Cursor diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..3b6e397 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +NOWPAYMENTS_API_KEY= +NOWPAYMENTS_IPN_SECRET= +NOWPAYMENTS_PAYOUT_USDT_TRX= +SITE_URL=http://localhost:3000 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9339206 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +.next +.env.local +*.log +.DS_Store diff --git a/README.md b/README.md new file mode 100644 index 0000000..c0f261e --- /dev/null +++ b/README.md @@ -0,0 +1,74 @@ +# TubeMart (ecomYB) + +YouTube 色调的单页 SPA:出售已开通 **YPP(YouTube Partner Program)** 的频道,加密货币结账走 **NOWPayments**。 + +仓库:https://gitea.dsx2020.com/eric/ecomYB + +## 功能 + +- 单页市场:筛选、列表点选、右侧详情 +- 动效:漂浮 emoji、跑马灯、CountUp、SVG 折线 / 柱状图 +- 支付:`POST /api/pay/invoice` 创建 NOWPayments 发票并跳转收银台 +- 回调:`POST /api/pay/ipn` 校验 `x-nowpayments-sig`(HMAC-SHA512) + +## 技术栈 + +- Next.js 15(App Router)+ React 19 + TypeScript +- 前端:`src/components/SpaApp.tsx`、`Viz.tsx` +- 库存数据:`src/lib/channels.ts` +- 支付封装:`src/lib/nowpayments.ts` + +## 本地启动 + +```bash +npm install +cp .env.example .env.local # 填入 NOWPayments 密钥 +npm run dev +``` + +打开 http://localhost:3000 + +生产构建: + +```bash +npm run build +npm start +``` + +## 环境变量 + +| 变量 | 说明 | +|------|------| +| `NOWPAYMENTS_API_KEY` | NOWPayments API Key | +| `NOWPAYMENTS_IPN_SECRET` | IPN 签名密钥 | +| `NOWPAYMENTS_PAYOUT_USDT_TRX` | 结算钱包(USDT TRC20,可选备注) | +| `SITE_URL` | 站点根 URL;本地用 `http://localhost:3000`,上线须公网 HTTPS(IPN 依赖) | + +`.env.local` 已加入 `.gitignore`,不要提交密钥。 + +## 修改库存 + +编辑 `src/lib/channels.ts`:名称、niche、订阅数、价格、`trend` / `weekly` 图表数据等。 + +## API + +| 方法 | 路径 | 说明 | +|------|------|------| +| `POST` | `/api/pay/invoice` | Body: `{ "channelId": "ch-xxx" }` → `{ invoiceUrl }` | +| `POST` | `/api/pay/ipn` | NOWPayments IPN webhook | + +支付成功跳转:`/success?channel=` + +## 目录结构 + +``` +src/ + app/ # 页面与 API routes + components/ # SpaApp、图表与图标 + lib/ # channels、nowpayments +.env.example # 环境变量模板 +``` + +## License + +Private — eric / ecomYB diff --git a/next-env.d.ts b/next-env.d.ts new file mode 100644 index 0000000..830fb59 --- /dev/null +++ b/next-env.d.ts @@ -0,0 +1,6 @@ +/// +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/next.config.ts b/next.config.ts new file mode 100644 index 0000000..b08f02b --- /dev/null +++ b/next.config.ts @@ -0,0 +1,7 @@ +import type { NextConfig } from 'next'; + +const nextConfig: NextConfig = { + reactStrictMode: true, +}; + +export default nextConfig; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..8077f5f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1023 @@ +{ + "name": "ypp-market", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ypp-market", + "version": "1.0.0", + "dependencies": { + "next": "^15.3.3", + "react": "^19.1.0", + "react-dom": "^19.1.0" + }, + "devDependencies": { + "@types/node": "^22.15.21", + "@types/react": "^19.1.5", + "@types/react-dom": "^19.1.5", + "typescript": "^5.8.3" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz", + "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz", + "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz", + "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz", + "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz", + "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==", + "cpu": [ + "arm" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz", + "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz", + "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz", + "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==", + "cpu": [ + "riscv64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz", + "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz", + "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz", + "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz", + "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz", + "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==", + "cpu": [ + "arm" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz", + "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz", + "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz", + "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==", + "cpu": [ + "riscv64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz", + "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz", + "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz", + "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz", + "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz", + "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.7.0" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz", + "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz", + "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz", + "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@next/env": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.23.tgz", + "integrity": "sha512-Mv3Z9hVbFcPnoLevsZ6rnX1TBtyHb5E17yN7HTPDXSXxeNsGBjUFrdbjRXKKXIOhfth7/cg6Ay7PZ2UFawaWsQ==", + "license": "MIT" + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.23.tgz", + "integrity": "sha512-SrEwOROH/rhA03F59hHtdhgtfZMWGzr5duDBWgRQt2rS3mJhqMKOcnNx6txOd0/i3E3D3uFKYFvyHsEiwQxzag==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.23.tgz", + "integrity": "sha512-f0FpFbG2EhDCuptBGcfrLcYMDuQAhe6m1QA4VVfXFrIBoFXvXt/olGbBkYkloKlXQtmhuzvtdYyuu/6zf07GIg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.23.tgz", + "integrity": "sha512-WlNtfepUXKX2u2ZsJZ8c3c8+tJSRZqsYzoMwLOY72A8ucKCCgxgNhiePA3qzFYahVWrwcQd8jOeJmBinc+VFVQ==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.23.tgz", + "integrity": "sha512-W/6qKk7UG93mg14PmQC+2urt69MIdwTBLNQ6MJyeC4wOCIHCjz+VfgssvS1pK7mgYBtLC1g6VKNoHD9xB0WWGg==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.23.tgz", + "integrity": "sha512-vzefI32mi6VMk96RaTAyxApgfGbiFzQBXVsekEjsDv1fr48mlABTWx0sUYhaYCBHWqCalxmz3DxbxFcbFvzNtw==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.23.tgz", + "integrity": "sha512-qppK/3dTGOTI+aoWWBZc3DshFIhrzgL8guATlaN9V6M1QJxbkP/rhEZ22tdICsQ/2WWXopMZ2Jokzj2u3uKY3Q==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.23.tgz", + "integrity": "sha512-Wc29KFOdT7XBcII3Vtmw7aoU8Uk3Mes/FNJfhFeSHdYBFJWMcR/DsI8U9BCPUhq/uycsUVuqSKGthW15tLsigA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.23.tgz", + "integrity": "sha512-/C7wRW4fa9s/PKA18zGPPpVmx8ycgVpP8yOxro4gzGTzjPJdscbAP3ODeFvgiIovxD176Z2J/SXO9t8PJKHLeQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@swc/helpers": { + "version": "0.5.15", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz", + "integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.8.0" + } + }, + "node_modules/@types/node": { + "version": "22.20.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz", + "integrity": "sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/react": { + "version": "19.2.18", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.18.tgz", + "integrity": "sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "19.2.4", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.4.tgz", + "integrity": "sha512-Bsc+QHgp+P/F02XDzNCY9jnZNCUuLki36KT7VKrTXXLdHf+vHMNZnW1rVu5DNW/rCK+fya3DATySbLM4yhtKUw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.2.0" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001809", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001809.tgz", + "integrity": "sha512-xxWVywk6a6Arlk+hymeycyn/VgqEfLDxupvhH/xiY5SJ/18kmi9o6MiO320DCUzypORHLtvh0I4i04tUhCNHNQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/client-only": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", + "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==", + "license": "MIT" + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "optional": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/nanoid": { + "version": "3.3.18", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz", + "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/next": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/next/-/next-15.5.23.tgz", + "integrity": "sha512-Gvd2WKgvxIXCGotxcI1im/Uf3rS3J3oZGw0g/uskg6AVBZhyE3aAbujkYWzS3xLmEPEtTLfkaVQUKK0KMTSIkA==", + "license": "MIT", + "dependencies": { + "@next/env": "15.5.23", + "@swc/helpers": "0.5.15", + "caniuse-lite": "^1.0.30001579", + "postcss": "8.4.31", + "styled-jsx": "5.1.6" + }, + "bin": { + "next": "dist/bin/next" + }, + "engines": { + "node": "^18.18.0 || ^19.8.0 || >= 20.0.0" + }, + "optionalDependencies": { + "@next/swc-darwin-arm64": "15.5.23", + "@next/swc-darwin-x64": "15.5.23", + "@next/swc-linux-arm64-gnu": "15.5.23", + "@next/swc-linux-arm64-musl": "15.5.23", + "@next/swc-linux-x64-gnu": "15.5.23", + "@next/swc-linux-x64-musl": "15.5.23", + "@next/swc-win32-arm64-msvc": "15.5.23", + "@next/swc-win32-x64-msvc": "15.5.23", + "sharp": "^0.34.3" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.1.0", + "@playwright/test": "^1.51.1", + "babel-plugin-react-compiler": "*", + "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", + "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", + "sass": "^1.3.0" + }, + "peerDependenciesMeta": { + "@opentelemetry/api": { + "optional": true + }, + "@playwright/test": { + "optional": true + }, + "babel-plugin-react-compiler": { + "optional": true + }, + "sass": { + "optional": true + } + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/postcss": { + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/react": { + "version": "19.2.8", + "resolved": "https://registry.npmjs.org/react/-/react-19.2.8.tgz", + "integrity": "sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.2.8", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.8.tgz", + "integrity": "sha512-rVprimfGBG3DR+Tq0IQG2DT5PxKth1WIGDmj5yPmlzr4YBe7uyE+Du4oVqTDXZSHGGGXRtTJEGSSePyQCMBglQ==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.27.0" + }, + "peerDependencies": { + "react": "^19.2.8" + } + }, + "node_modules/scheduler": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", + "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "license": "ISC", + "optional": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sharp": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz", + "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==", + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/colour": "^1.0.0", + "detect-libc": "^2.1.2", + "semver": "^7.7.3" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.34.5", + "@img/sharp-darwin-x64": "0.34.5", + "@img/sharp-libvips-darwin-arm64": "1.2.4", + "@img/sharp-libvips-darwin-x64": "1.2.4", + "@img/sharp-libvips-linux-arm": "1.2.4", + "@img/sharp-libvips-linux-arm64": "1.2.4", + "@img/sharp-libvips-linux-ppc64": "1.2.4", + "@img/sharp-libvips-linux-riscv64": "1.2.4", + "@img/sharp-libvips-linux-s390x": "1.2.4", + "@img/sharp-libvips-linux-x64": "1.2.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", + "@img/sharp-libvips-linuxmusl-x64": "1.2.4", + "@img/sharp-linux-arm": "0.34.5", + "@img/sharp-linux-arm64": "0.34.5", + "@img/sharp-linux-ppc64": "0.34.5", + "@img/sharp-linux-riscv64": "0.34.5", + "@img/sharp-linux-s390x": "0.34.5", + "@img/sharp-linux-x64": "0.34.5", + "@img/sharp-linuxmusl-arm64": "0.34.5", + "@img/sharp-linuxmusl-x64": "0.34.5", + "@img/sharp-wasm32": "0.34.5", + "@img/sharp-win32-arm64": "0.34.5", + "@img/sharp-win32-ia32": "0.34.5", + "@img/sharp-win32-x64": "0.34.5" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/styled-jsx": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.6.tgz", + "integrity": "sha512-qSVyDTeMotdvQYoHWLNGwRFJHC+i+ZvdBRYosOFgC+Wg1vx4frN2/RG/NA7SYqqvKNLf39P2LSRA2pu6n0XYZA==", + "license": "MIT", + "dependencies": { + "client-only": "0.0.1" + }, + "engines": { + "node": ">= 12.0.0" + }, + "peerDependencies": { + "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0 || ^19.0.0-0" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..a1c518b --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "ypp-market", + "version": "1.0.0", + "private": true, + "scripts": { + "dev": "next dev", + "build": "next build", + "start": "next start" + }, + "dependencies": { + "next": "^15.3.3", + "react": "^19.1.0", + "react-dom": "^19.1.0" + }, + "devDependencies": { + "@types/node": "^22.15.21", + "@types/react": "^19.1.5", + "@types/react-dom": "^19.1.5", + "typescript": "^5.8.3" + } +} diff --git a/src/app/api/pay/invoice/route.ts b/src/app/api/pay/invoice/route.ts new file mode 100644 index 0000000..7056d93 --- /dev/null +++ b/src/app/api/pay/invoice/route.ts @@ -0,0 +1,34 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { createChannelInvoice, isNowPaymentsConfigured } from '@/lib/nowpayments'; + +export async function POST(req: NextRequest) { + if (!isNowPaymentsConfigured()) { + return NextResponse.json({ ok: false, error: 'payments not configured' }, { status: 503 }); + } + + let body: { channelId?: string }; + try { + body = await req.json(); + } catch { + return NextResponse.json({ ok: false, error: 'invalid json' }, { status: 400 }); + } + + const channelId = String(body.channelId || ''); + if (!channelId) { + return NextResponse.json({ ok: false, error: 'channelId required' }, { status: 400 }); + } + + try { + const invoice = await createChannelInvoice(channelId); + return NextResponse.json({ + ok: true, + invoiceUrl: invoice.invoiceUrl, + orderId: invoice.orderId, + }); + } catch (err) { + const message = err instanceof Error ? err.message : 'invoice failed'; + console.error('NOWPayments invoice:', message); + const status = message.includes('not found') ? 404 : 502; + return NextResponse.json({ ok: false, error: message }, { status }); + } +} diff --git a/src/app/api/pay/ipn/route.ts b/src/app/api/pay/ipn/route.ts new file mode 100644 index 0000000..ca4f626 --- /dev/null +++ b/src/app/api/pay/ipn/route.ts @@ -0,0 +1,27 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { verifyIpnSignature } from '@/lib/nowpayments'; + +export async function POST(req: NextRequest) { + const raw = await req.text(); + const signature = req.headers.get('x-nowpayments-sig'); + + if (!verifyIpnSignature(raw, signature)) { + return NextResponse.json({ ok: false }, { status: 401 }); + } + + try { + const payload = JSON.parse(raw) as Record; + console.info( + 'NOWPayments IPN: status=%s order=%s amount=%s currency=%s paid=%s', + payload.payment_status, + payload.order_id, + payload.price_amount, + payload.pay_currency, + payload.actually_paid, + ); + } catch { + // signature already validated structure enough for ack + } + + return NextResponse.json({ ok: true }); +} diff --git a/src/app/globals.css b/src/app/globals.css new file mode 100644 index 0000000..d31faf0 --- /dev/null +++ b/src/app/globals.css @@ -0,0 +1,944 @@ +:root { + --yt-red: #ff0000; + --yt-red-deep: #cc0000; + --yt-bg: #0f0f0f; + --yt-elev: #212121; + --yt-elev-2: #272727; + --yt-line: #3f3f3f; + --yt-text: #f1f1f1; + --yt-muted: #aaaaaa; + --yt-white: #ffffff; + --font-display: 'Figtree', sans-serif; + --font-body: 'Figtree', sans-serif; +} + +* { + box-sizing: border-box; + margin: 0; + padding: 0; +} + +html { + scroll-behavior: smooth; +} + +body { + min-height: 100vh; + background: var(--yt-bg); + color: var(--yt-text); + font-family: var(--font-body); + overflow-x: hidden; +} + +a { + color: inherit; + text-decoration: none; +} + +button { + font: inherit; + color: inherit; + background: none; + border: none; + cursor: pointer; +} + +.spa { + position: relative; + width: min(1180px, calc(100% - 1.5rem)); + margin: 0 auto; + padding-bottom: 3rem; +} + +.bg-grid { + position: fixed; + inset: 0; + pointer-events: none; + background: + radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 0, 0, 0.28), transparent 55%), + linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px), + linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px); + background-size: auto, 48px 48px, 48px 48px; + mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 100%); + z-index: 0; +} + +.float-bits { + position: fixed; + inset: 0; + pointer-events: none; + overflow: hidden; + z-index: 0; +} + +.float-bit { + position: absolute; + bottom: -10%; + opacity: 0.22; + animation: floatUp linear infinite; + filter: blur(0.2px); +} + +@keyframes floatUp { + 0% { + transform: translateY(0) rotate(0deg); + opacity: 0; + } + 12% { + opacity: 0.35; + } + 100% { + transform: translateY(-120vh) rotate(28deg); + opacity: 0; + } +} + +.topbar, +.hero, +.market, +.flow, +.strip, +.foot, +.section-title { + position: relative; + z-index: 1; +} + +.topbar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; + padding: 1.1rem 0 0.5rem; + animation: fadeUp 0.7s ease both; +} + +.logo { + display: inline-flex; + align-items: center; + gap: 0.55rem; + font-weight: 800; + font-size: 1.2rem; + letter-spacing: -0.03em; +} + +.logo .red, +.red { + color: var(--yt-red); +} + +.topbar nav { + display: flex; + gap: 1.25rem; + color: var(--yt-muted); + font-size: 0.92rem; +} + +.topbar nav a:hover { + color: var(--yt-white); +} + +.btn-pill { + background: rgba(255, 0, 0, 0.12); + border: 1px solid rgba(255, 0, 0, 0.45); + color: #ffb4b4; + padding: 0.45rem 0.8rem; + border-radius: 999px; + font-size: 0.82rem; + font-weight: 600; +} + +.hero { + display: grid; + grid-template-columns: 1.05fr 0.95fr; + gap: 2rem; + align-items: center; + min-height: calc(100svh - 5rem); + padding: 2rem 0 2.5rem; +} + +.eyebrow { + display: inline-flex; + align-items: center; + gap: 0.45rem; + color: #ff8e8e; + font-size: 0.86rem; + font-weight: 600; + margin-bottom: 0.9rem; + letter-spacing: 0.02em; +} + +.live-dot { + width: 8px; + height: 8px; + border-radius: 50%; + background: var(--yt-red); + box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7); + animation: ping 1.6s infinite; +} + +@keyframes ping { + 0% { + box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.55); + } + 70% { + box-shadow: 0 0 0 10px rgba(255, 0, 0, 0); + } + 100% { + box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); + } +} + +.hero h1 { + font-size: clamp(2.4rem, 6vw, 4.2rem); + line-height: 1.02; + letter-spacing: -0.045em; + font-weight: 800; + margin-bottom: 1rem; + animation: fadeUp 0.8s 0.05s ease both; +} + +.hero h1 em { + font-style: normal; + color: var(--yt-red); + text-shadow: 0 0 28px rgba(255, 0, 0, 0.35); +} + +.lede { + color: var(--yt-muted); + font-size: 1.05rem; + line-height: 1.55; + max-width: 34rem; + margin-bottom: 1.4rem; + animation: fadeUp 0.8s 0.12s ease both; +} + +.hero-cta { + display: flex; + flex-wrap: wrap; + gap: 0.7rem; + margin-bottom: 1.6rem; + animation: fadeUp 0.8s 0.18s ease both; +} + +.btn-yt, +.btn-buy { + display: inline-flex; + align-items: center; + gap: 0.45rem; + background: var(--yt-red); + color: #fff; + font-weight: 700; + padding: 0.85rem 1.2rem; + border-radius: 999px; + transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease; + box-shadow: 0 10px 30px rgba(255, 0, 0, 0.28); +} + +.btn-yt:hover, +.btn-buy:hover { + transform: translateY(-2px) scale(1.02); + filter: brightness(1.08); +} + +.btn-buy:disabled { + opacity: 0.7; + cursor: wait; + transform: none; +} + +.btn-ghost { + display: inline-flex; + align-items: center; + gap: 0.4rem; + color: var(--yt-muted); + padding: 0.85rem 0.9rem; + border-radius: 999px; + border: 1px solid var(--yt-line); + transition: color 0.15s ease, border-color 0.15s ease; +} + +.btn-ghost:hover { + color: var(--yt-white); + border-color: #666; +} + +.hero-kpis { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 0.75rem; + animation: fadeUp 0.8s 0.24s ease both; +} + +.hero-kpis strong { + display: block; + font-size: 1.45rem; + font-weight: 800; + letter-spacing: -0.03em; +} + +.hero-kpis span { + color: var(--yt-muted); + font-size: 0.78rem; +} + +.hero-stage { + animation: fadeUp 0.9s 0.15s ease both; +} + +.yt-window { + background: var(--yt-elev); + border: 1px solid var(--yt-line); + border-radius: 16px; + overflow: hidden; + box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); + transform: perspective(900px) rotateY(-6deg) rotateX(3deg); + transition: transform 0.4s ease; +} + +.yt-window:hover { + transform: perspective(900px) rotateY(-2deg) rotateX(1deg) scale(1.01); +} + +.yt-chrome { + display: flex; + align-items: center; + gap: 0.35rem; + padding: 0.7rem 0.85rem; + background: #181818; + border-bottom: 1px solid var(--yt-line); +} + +.yt-chrome > span { + width: 9px; + height: 9px; + border-radius: 50%; + background: #555; +} + +.yt-chrome > span:nth-child(1) { + background: #ff5f57; +} +.yt-chrome > span:nth-child(2) { + background: #febc2e; +} +.yt-chrome > span:nth-child(3) { + background: #28c840; +} + +.yt-url { + margin-left: 0.6rem; + flex: 1; + background: #0f0f0f; + border-radius: 999px; + padding: 0.25rem 0.7rem; + color: var(--yt-muted); + font-size: 0.75rem; +} + +.yt-player { + position: relative; + aspect-ratio: 16 / 9; + background: + radial-gradient(circle at 50% 45%, rgba(255, 0, 0, 0.35), transparent 45%), + linear-gradient(145deg, #1a1a1a, #0a0a0a); + display: grid; + place-items: center; +} + +.big-play { + width: 76px; + height: 54px; + border-radius: 18px / 14px; + background: var(--yt-red); + display: grid; + place-items: center; + color: #fff; + animation: pulsePlay 2.2s ease-in-out infinite; + box-shadow: 0 12px 40px rgba(255, 0, 0, 0.4); +} + +@keyframes pulsePlay { + 0%, + 100% { + transform: scale(1); + } + 50% { + transform: scale(1.06); + } +} + +.player-meta { + position: absolute; + left: 0.9rem; + bottom: 1.4rem; + display: flex; + gap: 0.55rem; + align-items: center; +} + +.emoji-lg { + font-size: 1.6rem; +} + +.player-meta b { + display: block; + font-size: 0.92rem; +} + +.player-meta small { + color: var(--yt-muted); + font-size: 0.75rem; +} + +.progress { + position: absolute; + left: 0; + right: 0; + bottom: 0; + height: 4px; + background: #333; +} + +.progress i { + display: block; + height: 100%; + background: var(--yt-red); + animation: scrub 5s ease-in-out infinite alternate; +} + +@keyframes scrub { + from { + width: 28%; + } + to { + width: 78%; + } +} + +.mini-charts { + display: grid; + grid-template-columns: 1.2fr 0.8fr; + gap: 0.75rem; + padding: 0.85rem; + background: #181818; +} + +.mini { + background: var(--yt-elev-2); + border-radius: 10px; + padding: 0.55rem 0.65rem 0.4rem; +} + +.mini > span { + display: block; + font-size: 0.75rem; + color: var(--yt-muted); + margin-bottom: 0.25rem; +} + +.sparkline { + width: 100%; + height: 42px; + display: block; +} + +.spark-line { + stroke-dasharray: 240; + stroke-dashoffset: 240; + animation: drawLine 1.4s ease forwards; +} + +.spark-area { + opacity: 0; + animation: fadeIn 0.8s 0.3s ease forwards; +} + +.spark-dot { + animation: blink 1.4s ease-in-out infinite; +} + +@keyframes drawLine { + to { + stroke-dashoffset: 0; + } +} + +@keyframes fadeIn { + to { + opacity: 1; + } +} + +@keyframes blink { + 0%, + 100% { + opacity: 1; + } + 50% { + opacity: 0.35; + } +} + +.bar-chart { + display: flex; + align-items: flex-end; + gap: 0.35rem; + height: 56px; + padding-top: 0.2rem; +} + +.bar-col { + flex: 1; + display: flex; + flex-direction: column; + align-items: center; + height: 100%; + justify-content: flex-end; + gap: 0.2rem; +} + +.bar { + width: 100%; + border-radius: 4px 4px 1px 1px; + background: linear-gradient(180deg, #ff4d4d, var(--yt-red)); + transform-origin: bottom; + animation: growBar 0.7s ease both; +} + +.bar-col span { + font-size: 0.62rem; + color: var(--yt-muted); +} + +@keyframes growBar { + from { + transform: scaleY(0.15); + opacity: 0.3; + } + to { + transform: scaleY(1); + opacity: 1; + } +} + +.strip { + margin: 0.5rem 0 1.5rem; + border-block: 1px solid var(--yt-line); + background: rgba(255, 0, 0, 0.05); + overflow: hidden; +} + +.marquee { + overflow: hidden; + mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); +} + +.marquee-track { + display: flex; + gap: 2rem; + width: max-content; + padding: 0.85rem 0; + animation: marquee 28s linear infinite; + color: var(--yt-muted); + font-size: 0.9rem; + font-weight: 600; +} + +.marquee-track span { + white-space: nowrap; +} + +@keyframes marquee { + from { + transform: translateX(0); + } + to { + transform: translateX(-50%); + } +} + +.section-title { + margin: 1.5rem 0 1.1rem; +} + +.section-title h2 { + font-size: clamp(1.7rem, 3.5vw, 2.35rem); + letter-spacing: -0.035em; + font-weight: 800; + margin-bottom: 0.35rem; +} + +.section-title p { + color: var(--yt-muted); +} + +.filters { + display: flex; + flex-wrap: wrap; + gap: 0.5rem; + margin-bottom: 1rem; +} + +.filters button { + padding: 0.45rem 0.85rem; + border-radius: 999px; + background: var(--yt-elev); + border: 1px solid var(--yt-line); + color: var(--yt-muted); + font-size: 0.88rem; + transition: 0.15s ease; +} + +.filters button.on, +.filters button:hover { + color: #fff; + border-color: rgba(255, 0, 0, 0.55); + background: rgba(255, 0, 0, 0.14); +} + +.market-grid { + display: grid; + grid-template-columns: 1.15fr 0.85fr; + gap: 1rem; + align-items: start; +} + +.channel-list { + display: flex; + flex-direction: column; + gap: 0.55rem; +} + +.channel-row { + display: grid; + grid-template-columns: auto 1fr 88px auto; + gap: 0.75rem; + align-items: center; + text-align: left; + padding: 0.85rem 0.95rem; + background: var(--yt-elev); + border: 1px solid transparent; + border-radius: 14px; + transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease; + animation: fadeUp 0.55s ease both; +} + +.channel-row:hover { + transform: translateX(3px); + border-color: #555; +} + +.channel-row.active { + border-color: var(--yt-red); + background: linear-gradient(90deg, rgba(255, 0, 0, 0.16), var(--yt-elev)); + box-shadow: inset 3px 0 0 var(--yt-red); +} + +.ch-emoji { + font-size: 1.45rem; +} + +.ch-main { + min-width: 0; +} + +.ch-main b { + display: block; + font-size: 0.98rem; + margin-bottom: 0.15rem; +} + +.ch-main small { + color: var(--yt-muted); + font-size: 0.78rem; + display: block; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.ch-spark { + height: 34px; +} + +.ch-spark .sparkline { + height: 34px; +} + +.ch-price { + font-weight: 800; + color: #fff; + white-space: nowrap; +} + +.detail { + position: sticky; + top: 1rem; + background: var(--yt-elev); + border: 1px solid var(--yt-line); + border-radius: 18px; + padding: 1.1rem; + animation: fadeUp 0.5s ease both; +} + +.detail-head { + display: flex; + gap: 0.75rem; + align-items: center; + margin-bottom: 1rem; +} + +.detail-emoji { + font-size: 2.2rem; + width: 3.2rem; + height: 3.2rem; + display: grid; + place-items: center; + background: #181818; + border-radius: 14px; +} + +.detail-head h3 { + font-size: 1.2rem; + letter-spacing: -0.02em; +} + +.detail-head p { + color: var(--yt-muted); + font-size: 0.86rem; + margin-top: 0.2rem; +} + +.badge { + display: inline-block; + background: rgba(255, 0, 0, 0.15); + color: #ff9b9b; + border: 1px solid rgba(255, 0, 0, 0.35); + border-radius: 999px; + padding: 0.1rem 0.45rem; + font-size: 0.72rem; + font-weight: 700; + margin-right: 0.25rem; +} + +.detail-stats { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 0.55rem; + margin-bottom: 0.9rem; +} + +.detail-stats div { + background: #181818; + border-radius: 12px; + padding: 0.7rem 0.75rem; +} + +.detail-stats strong { + display: block; + font-size: 1.15rem; + font-weight: 800; +} + +.detail-stats span { + color: var(--yt-muted); + font-size: 0.74rem; +} + +.chart-block { + background: #181818; + border-radius: 12px; + padding: 0.7rem 0.8rem 0.55rem; + margin-bottom: 0.65rem; +} + +.chart-label { + display: flex; + justify-content: space-between; + color: var(--yt-muted); + font-size: 0.78rem; + margin-bottom: 0.35rem; +} + +.chart-label em { + font-style: normal; + color: #3ddc84; + font-weight: 700; +} + +.detail-foot { + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.75rem; + margin-top: 0.85rem; + padding-top: 0.85rem; + border-top: 1px solid var(--yt-line); +} + +.price-lg { + font-size: 1.55rem; + font-weight: 800; + letter-spacing: -0.03em; +} + +.detail-foot small { + color: var(--yt-muted); +} + +.err { + color: #ff8e8e; + font-size: 0.78rem; + margin-top: 0.35rem; +} + +.flow { + margin-top: 2.5rem; +} + +.steps { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 0.9rem; +} + +.steps article { + background: var(--yt-elev); + border: 1px solid var(--yt-line); + border-radius: 16px; + padding: 1.15rem; + transition: transform 0.2s ease, border-color 0.2s ease; + animation: fadeUp 0.6s ease both; +} + +.steps article:nth-child(2) { + animation-delay: 0.08s; +} +.steps article:nth-child(3) { + animation-delay: 0.16s; +} + +.steps article:hover { + transform: translateY(-4px); + border-color: rgba(255, 0, 0, 0.45); +} + +.step-ico { + width: 2.4rem; + height: 2.4rem; + border-radius: 999px; + display: grid; + place-items: center; + background: rgba(255, 0, 0, 0.15); + color: var(--yt-red); + margin-bottom: 0.75rem; +} + +.steps h3 { + font-size: 1.05rem; + margin-bottom: 0.35rem; +} + +.steps p { + color: var(--yt-muted); + font-size: 0.9rem; + line-height: 1.45; +} + +.foot { + margin-top: 3rem; + padding-top: 1.2rem; + border-top: 1px solid var(--yt-line); + display: flex; + justify-content: space-between; + gap: 1rem; + color: var(--yt-muted); + font-size: 0.86rem; + flex-wrap: wrap; +} + +.foot > div { + display: inline-flex; + align-items: center; + gap: 0.45rem; + color: var(--yt-text); + font-weight: 700; +} + +.success-wrap { + min-height: 100svh; + display: grid; + place-items: center; + position: relative; + z-index: 1; +} + +.success-panel { + width: min(420px, 100%); + background: var(--yt-elev); + border: 1px solid var(--yt-line); + border-radius: 18px; + padding: 1.5rem; + animation: fadeUp 0.7s ease both; +} + +.success-panel h1 { + font-size: 2rem; + letter-spacing: -0.03em; + margin: 0.8rem 0 0.6rem; +} + +.success-panel p { + color: var(--yt-muted); + line-height: 1.5; + margin-bottom: 1.2rem; +} + +@keyframes fadeUp { + from { + opacity: 0; + transform: translateY(16px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +@media (max-width: 920px) { + .hero, + .market-grid, + .steps { + grid-template-columns: 1fr; + } + + .hero { + min-height: auto; + padding-top: 1.5rem; + } + + .yt-window { + transform: none; + } + + .topbar nav { + display: none; + } + + .channel-row { + grid-template-columns: auto 1fr auto; + } + + .ch-spark { + display: none; + } + + .detail { + position: static; + } + + .hero-kpis { + grid-template-columns: repeat(3, 1fr); + } +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx new file mode 100644 index 0000000..7e53a09 --- /dev/null +++ b/src/app/layout.tsx @@ -0,0 +1,25 @@ +import type { Metadata } from 'next'; +import { Figtree } from 'next/font/google'; +import './globals.css'; + +const figtree = Figtree({ + subsets: ['latin'], + variable: '--font-figtree', + display: 'swap', +}); + +export const metadata: Metadata = { + title: 'TubeMart — YPP YouTube Channels for Sale', + description: 'Buy monetized YouTube Partner Program channels. Crypto checkout via NOWPayments.', +}; + +export default function RootLayout({ children }: { children: React.ReactNode }) { + return ( + + + + {children} + + + ); +} diff --git a/src/app/page.tsx b/src/app/page.tsx new file mode 100644 index 0000000..db5ae8a --- /dev/null +++ b/src/app/page.tsx @@ -0,0 +1,5 @@ +import SpaApp from '@/components/SpaApp'; + +export default function HomePage() { + return ; +} diff --git a/src/app/success/page.tsx b/src/app/success/page.tsx new file mode 100644 index 0000000..feb70cf --- /dev/null +++ b/src/app/success/page.tsx @@ -0,0 +1,37 @@ +import Link from 'next/link'; +import { getChannel } from '@/lib/channels'; +import { YtLogo } from '@/components/Viz'; + +export default async function SuccessPage({ + searchParams, +}: { + searchParams: Promise<{ channel?: string }>; +}) { + const params = await searchParams; + const channel = params.channel ? getChannel(params.channel) : undefined; + + return ( +
+
+
+
+
+ + + TubeMart + +
+

✅ Payment received

+

+ {channel + ? `Thanks — your order for ${channel.emoji} ${channel.name} is confirmed. We’ll send transfer steps next.` + : 'Thanks — your crypto payment is confirmed. We’ll send transfer steps next.'} +

+ + Back to market + +
+
+
+ ); +} diff --git a/src/components/SpaApp.tsx b/src/components/SpaApp.tsx new file mode 100644 index 0000000..a74e2e1 --- /dev/null +++ b/src/components/SpaApp.tsx @@ -0,0 +1,337 @@ +'use client'; + +import { useMemo, useState } from 'react'; +import { + CHANNELS, + formatPrice, + formatSubs, + marketTotals, + type Channel, +} from '@/lib/channels'; +import { + BarChart, + CheckIcon, + CountUp, + CryptoIcon, + FloatingBits, + PlayIcon, + Sparkline, + YtLogo, +} from '@/components/Viz'; + +type Filter = 'all' | 'shorts' | 'long'; + +function matchesFilter(ch: Channel, f: Filter) { + if (f === 'all') return true; + if (f === 'shorts') return /shorts|viral/i.test(ch.niche); + return !/shorts|viral/i.test(ch.niche); +} + +function BuyButton({ channel }: { channel: Channel }) { + const [loading, setLoading] = useState(false); + const [error, setError] = useState(''); + + async function buy() { + setLoading(true); + setError(''); + try { + const res = await fetch('/api/pay/invoice', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ channelId: channel.id }), + }); + const data = (await res.json()) as { ok?: boolean; invoiceUrl?: string; error?: string }; + if (!res.ok || !data.ok || !data.invoiceUrl) { + throw new Error(data.error || 'Payment unavailable'); + } + window.location.href = data.invoiceUrl; + } catch (err) { + setError(err instanceof Error ? err.message : 'Payment failed'); + setLoading(false); + } + } + + return ( +
+ + {error ?

{error}

: null} +
+ ); +} + +export default function SpaApp() { + const [filter, setFilter] = useState('all'); + const [activeId, setActiveId] = useState(CHANNELS[0]?.id ?? ''); + const totals = marketTotals(); + const list = useMemo(() => CHANNELS.filter((c) => matchesFilter(c, filter)), [filter]); + const active = CHANNELS.find((c) => c.id === activeId) ?? list[0] ?? CHANNELS[0]; + + return ( +
+
+ + +
+ + + + TubeMart + + + + + 🔴 Live · {CHANNELS.length} YPP + +
+ +
+
+
+

+ YouTube Partner ready +

+

+ Buy YPP channels +
+ that already earn 💸 +

+

+ Single marketplace for monetized YouTube channels. Pick a niche, check the charts, + pay with crypto — transfer after confirm. +

+ +
+
+ + + + Live listings +
+
+ + + + Combined subs +
+
+ + + + 30d views +
+
+
+ +
+
+
+ + + +
youtube.com/@ypp-market
+
+
+
+ +
+
+ 📺 +
+ YPP Transfer Showcase + Monetized · Verified inventory +
+
+
+ +
+
+
+
+ 📈 Growth + +
+
+ 🔥 This week + +
+
+
+
+
+ +
+
+
+ {[...CHANNELS, ...CHANNELS].map((c, i) => ( + + {c.emoji} {c.name} · {formatSubs(c.subs)} · {formatPrice(c.priceUsd)} · YPP ✅ + + ))} +
+
+
+ +
+
+

+ 🛒 Channel market live +

+

Tap a channel to inspect charts, then checkout with NOWPayments.

+
+ +
+ {( + [ + ['all', '✨ All'], + ['long', '🎬 Long-form'], + ['shorts', '⚡ Shorts'], + ] as const + ).map(([key, label]) => ( + + ))} +
+ +
+
+ {list.map((ch, idx) => ( + + ))} +
+ + {active ? ( + + ) : null} +
+
+ +
+
+

🚀 Three steps to transfer

+

Same NOWPayments flow as your ebook stack — invoice → pay → IPN confirm.

+
+
+
+
+ +
+

1. Pick a YPP listing

+

Compare niches, subs, RPM and weekly charts on the live board.

+
+
+
+ +
+

2. Pay in crypto

+

USDT and other coins on NOWPayments hosted checkout. Fees paid by buyer.

+
+
+
+ +
+

3. Get the account

+

After on-chain confirm, we send Google login + transfer checklist.

+
+
+
+
+ +
+
+ TubeMart +
+ © {new Date().getFullYear()} · Settles to USDT TRC20 +
+
+ ); +} diff --git a/src/components/Viz.tsx b/src/components/Viz.tsx new file mode 100644 index 0000000..1f96028 --- /dev/null +++ b/src/components/Viz.tsx @@ -0,0 +1,175 @@ +'use client'; + +import { useEffect, useId, useMemo, useRef, useState } from 'react'; + +export function CountUp({ + to, + duration = 1400, + decimals = 0, + prefix = '', + suffix = '', +}: { + to: number; + duration?: number; + decimals?: number; + prefix?: string; + suffix?: string; +}) { + const [val, setVal] = useState(0); + const started = useRef(false); + const ref = useRef(null); + + useEffect(() => { + const el = ref.current; + if (!el) return; + + const io = new IntersectionObserver( + ([entry]) => { + if (!entry.isIntersecting || started.current) return; + started.current = true; + const t0 = performance.now(); + const tick = (now: number) => { + const p = Math.min(1, (now - t0) / duration); + const eased = 1 - Math.pow(1 - p, 3); + setVal(to * eased); + if (p < 1) requestAnimationFrame(tick); + }; + requestAnimationFrame(tick); + }, + { threshold: 0.4 }, + ); + io.observe(el); + return () => io.disconnect(); + }, [to, duration]); + + return ( + + {prefix} + {val.toFixed(decimals)} + {suffix} + + ); +} + +export function Sparkline({ data, color = '#FF0000' }: { data: number[]; color?: string }) { + const id = useId(); + const { points, area, last } = useMemo(() => { + const max = Math.max(...data); + const min = Math.min(...data); + const span = max - min || 1; + const coords = data.map((v, i) => { + const x = (i / (data.length - 1)) * 100; + const y = 28 - ((v - min) / span) * 24; + return `${x},${y}`; + }); + const line = coords.join(' '); + const areaPath = `M0,30 L${line.replace(/ /g, ' L')} L100,30 Z`; + return { points: line, area: areaPath, last: data[data.length - 1] }; + }, [data]); + + return ( + + + + + + + + + + + + ); +} + +export function BarChart({ data }: { data: number[] }) { + const max = Math.max(...data); + const days = ['M', 'T', 'W', 'T', 'F', 'S', 'S']; + return ( +
+ {data.map((v, i) => ( +
+
+ {days[i]} +
+ ))} +
+ ); +} + +export function PlayIcon({ size = 22 }: { size?: number }) { + return ( + + + + ); +} + +export function YtLogo({ size = 28 }: { size?: number }) { + return ( + + + + + ); +} + +export function CryptoIcon() { + return ( + + + + + ); +} + +export function CheckIcon() { + return ( + + + + + ); +} + +export function FloatingBits() { + const bits = useMemo( + () => + ['▶️', '💰', '📈', '🔴', '✨', '💎', '🎯', '📊'].map((emoji, i) => ({ + emoji, + left: 8 + ((i * 12) % 84), + delay: i * 0.7, + dur: 10 + (i % 4) * 2, + size: 18 + (i % 3) * 6, + })), + [], + ); + + return ( +
+ {bits.map((b) => ( + + {b.emoji} + + ))} +
+ ); +} diff --git a/src/lib/channels.ts b/src/lib/channels.ts new file mode 100644 index 0000000..3902c97 --- /dev/null +++ b/src/lib/channels.ts @@ -0,0 +1,141 @@ +export type Channel = { + id: string; + name: string; + niche: string; + emoji: string; + subs: number; + views30d: number; + viewsLabel: string; + age: string; + rpm: number; + monetized: boolean; + priceUsd: number; + notes: string; + trend: number[]; + weekly: number[]; +}; + +/** Edit these listings to match your real inventory. */ +export const CHANNELS: Channel[] = [ + { + id: 'ch-techpulse', + name: 'TechPulse Daily', + niche: 'Consumer Tech', + emoji: '📱', + subs: 18400, + views30d: 420000, + viewsLabel: '420K', + age: '2.1 yr', + rpm: 4.2, + monetized: true, + priceUsd: 3200, + notes: 'YPP live · AdSense clean · English', + trend: [42, 48, 45, 55, 62, 58, 71, 68, 74, 80, 77, 86], + weekly: [62, 71, 68, 79, 88, 84, 92], + }, + { + id: 'ch-clipforge', + name: 'ClipForge Shorts', + niche: 'Shorts / Viral', + emoji: '⚡', + subs: 51200, + views30d: 2100000, + viewsLabel: '2.1M', + age: '14 mo', + rpm: 1.8, + monetized: true, + priceUsd: 4800, + notes: 'YPP + Shorts fund eligible', + trend: [90, 110, 95, 140, 160, 155, 180, 210, 195, 230, 250, 280], + weekly: [180, 210, 195, 240, 260, 255, 290], + }, + { + id: 'ch-nightlane', + name: 'Night Lane Gaming', + niche: 'Gaming Highlights', + emoji: '🎮', + subs: 27600, + views30d: 680000, + viewsLabel: '680K', + age: '3.0 yr', + rpm: 3.1, + monetized: true, + priceUsd: 3900, + notes: 'Stable RPM · No strikes', + trend: [50, 52, 55, 54, 58, 61, 59, 64, 66, 65, 70, 72], + weekly: [58, 61, 59, 67, 70, 68, 74], + }, + { + id: 'ch-kitchenwire', + name: 'Kitchen Wire', + niche: 'Food / Lifestyle', + emoji: '🍜', + subs: 22100, + views30d: 510000, + viewsLabel: '510K', + age: '2.4 yr', + rpm: 5.6, + monetized: true, + priceUsd: 3500, + notes: 'YPP · Brand-safe catalog', + trend: [38, 40, 44, 43, 49, 52, 55, 53, 58, 61, 60, 66], + weekly: [49, 52, 55, 57, 61, 59, 65], + }, + { + id: 'ch-signaldesk', + name: 'Signal Desk News', + niche: 'News Commentary', + emoji: '🛰️', + subs: 14900, + views30d: 390000, + viewsLabel: '390K', + age: '1.8 yr', + rpm: 6.4, + monetized: true, + priceUsd: 2900, + notes: 'YPP · Mid-tier CPM niche', + trend: [30, 34, 32, 38, 41, 39, 45, 48, 46, 52, 55, 58], + weekly: [41, 45, 43, 50, 54, 52, 57], + }, + { + id: 'ch-fitframe', + name: 'FitFrame Studio', + niche: 'Fitness', + emoji: '💪', + subs: 33800, + views30d: 910000, + viewsLabel: '910K', + age: '2.7 yr', + rpm: 4.8, + monetized: true, + priceUsd: 5200, + notes: 'YPP · High retention series', + trend: [60, 64, 70, 68, 75, 82, 80, 88, 92, 90, 98, 105], + weekly: [78, 82, 80, 90, 95, 93, 102], + }, +]; + +export function getChannel(id: string) { + return CHANNELS.find((c) => c.id === id); +} + +export function formatSubs(n: number) { + if (n >= 1000) return `${(n / 1000).toFixed(n >= 10000 ? 0 : 1)}K`; + return String(n); +} + +export function formatPrice(usd: number) { + return new Intl.NumberFormat('en-US', { + style: 'currency', + currency: 'USD', + maximumFractionDigits: 0, + }).format(usd); +} + +export function marketTotals() { + return { + channels: CHANNELS.length, + subs: CHANNELS.reduce((s, c) => s + c.subs, 0), + views: CHANNELS.reduce((s, c) => s + c.views30d, 0), + }; +} diff --git a/src/lib/nowpayments.ts b/src/lib/nowpayments.ts new file mode 100644 index 0000000..269717d --- /dev/null +++ b/src/lib/nowpayments.ts @@ -0,0 +1,103 @@ +import { createHmac, timingSafeEqual } from 'crypto'; +import { getChannel } from './channels'; + +const API_BASE = 'https://api.nowpayments.io/v1'; + +export function isNowPaymentsConfigured() { + return Boolean( + process.env.NOWPAYMENTS_API_KEY?.trim() && process.env.NOWPAYMENTS_IPN_SECRET?.trim(), + ); +} + +function apiKey() { + const key = process.env.NOWPAYMENTS_API_KEY?.trim(); + if (!key) throw new Error('NOWPAYMENTS_API_KEY missing'); + return key; +} + +function ipnSecret() { + const secret = process.env.NOWPAYMENTS_IPN_SECRET?.trim(); + if (!secret) throw new Error('NOWPAYMENTS_IPN_SECRET missing'); + return secret; +} + +function siteUrl() { + return (process.env.SITE_URL || 'http://localhost:3000').replace(/\/$/, ''); +} + +export async function createChannelInvoice(channelId: string) { + const channel = getChannel(channelId); + if (!channel) throw new Error('channel not found'); + + const site = siteUrl(); + const orderId = `ypp-${channel.id}-${Date.now()}`; + + const res = await fetch(`${API_BASE}/invoice`, { + method: 'POST', + headers: { + 'x-api-key': apiKey(), + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + price_amount: channel.priceUsd, + price_currency: 'usd', + order_id: orderId, + order_description: `YPP Channel — ${channel.name}`, + ipn_callback_url: `${site}/api/pay/ipn`, + success_url: `${site}/success?channel=${encodeURIComponent(channel.id)}`, + cancel_url: `${site}/#inventory`, + is_fee_paid_by_user: true, + }), + cache: 'no-store', + }); + + const data = (await res.json()) as { + id?: string | number; + invoice_url?: string; + message?: string; + }; + + if (!res.ok || !data.invoice_url) { + throw new Error(data.message || `NOWPayments invoice failed (${res.status})`); + } + + return { + id: String(data.id ?? ''), + invoiceUrl: data.invoice_url, + orderId, + channelId: channel.id, + amountUsd: channel.priceUsd, + }; +} + +function sortObject(value: unknown): unknown { + if (!value || typeof value !== 'object' || Array.isArray(value)) return value; + const obj = value as Record; + return Object.keys(obj) + .sort() + .reduce>((result, key) => { + const item = obj[key]; + result[key] = + item && typeof item === 'object' && !Array.isArray(item) ? sortObject(item) : item; + return result; + }, {}); +} + +export function verifyIpnSignature(rawBody: string, signature: string | null) { + if (!signature) return false; + let payload: unknown; + try { + payload = JSON.parse(rawBody); + } catch { + return false; + } + + const expected = createHmac('sha512', ipnSecret()) + .update(JSON.stringify(sortObject(payload))) + .digest('hex'); + + const a = Buffer.from(expected, 'utf8'); + const b = Buffer.from(signature, 'utf8'); + if (a.length !== b.length) return false; + return timingSafeEqual(a, b); +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..fba2bf3 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2017", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "bundler", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true, + "plugins": [{ "name": "next" }], + "paths": { "@/*": ["./src/*"] } + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "exclude": ["node_modules"] +}