Karat
Karat est la plateforme SaaS qui permet aux commerçants de Mauritanie et du Sénégal de créer une boutique en ligne premium en quelques minutes. Essai gratuit de 3 jours.
翻譯準備中
尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證製作者的介紹僅有上面的一句話。 更多詳情請閱讀儲存庫 README。 儲存庫 README ↗
正在載入完整 README。
檢視完整 README ↗Creators sell digital files from a payment page. Buyers pay once with Razorpay and get lifetime access to their files by email. Anyone can sign up (email and password, verified) and starts on the Free plan (one page); the Creator plan (₹299/month with a ₹99 first month, or ₹2,999/year, via Razorpay Subscriptions) unlocks unlimited pages, coupons, analytics, Meta tracking, add-on offers and CSV export. Fees are all-inclusive (payment gateway covered): 6% per sale on Free, 4% on Creator, or a custom rate. Money lands in the platform's Razorpay account, an append-only ledger tracks what each creator is owed, and the admin pays creators manually.
Stack: Next.js 16 (App Router) · Supabase (Postgres, Auth, Storage) · Razorpay · Meta Pixel + Conversions API · Resend
/p/[slug] → POST /api/checkout creates order (amount from DB) + Razorpay order, CAPI InitiateCheckout
→ Razorpay Checkout popup
→ POST /api/checkout/verify verifies signature, fetches payment, records it if captured
→ /p/[slug]/success polls /api/orders/[id]/status, fires Pixel Purchase
Razorpay → POST /api/webhooks/razorpay source of truth: payment.captured / order.paid / refunds
cron → /api/cron/reconcile recovers missed webhooks, retries receipt + CAPI Purchase
The verify route, the webhook and the cron job all call the same Postgres function, mark_order_paid. It locks the order, checks the amount, writes the ledger rows keyed by payment ID, and creates the download grant. Running it any number of times gives the same result, and only one caller sees newly_paid = true, so the receipt and Purchase event go out once.
Everything is stored in paise (integers). ledger_entries is append-only: a trigger blocks updates and deletes.
| Event | Ledger entry |
|---|---|
| Sale | sale +amount |
| Razorpay fee (incl. GST) | gateway_fee −fee |
| Refund processed | refund −amount |
| Monthly plan (₹99) | subscription_fee −9900, one per creator per month |
| Admin pays creator | payout −amount (with UTR) |
| Correction | adjustment ±amount |
Creator balance = SUM(amount_paise), exposed through the creator_balances view.
cp .env.example .env.local
openssl rand -base64 32 # → ENCRYPTION_KEY
openssl rand -hex 32 # → CRON_SECRET
.env.local.supabase/migrations/ in order (0001 to 0011). Together they create the tables, Row Level Security policies, money functions, storage buckets, invites, coupons, analytics and per-page pixels.http://localhost:3000/auth/callback (plus your production URL) to the Redirect URLs./login, then make yourself the admin:
update profiles set is_admin = true where email = '[email protected]';
MAX_BYTES in files-manager.tsx.https://<your-domain>/api/webhooks/razorpay with a secret (RAZORPAY_WEBHOOK_SECRET). Enable these events:
payment.captured, payment.authorized, payment.failed, order.paid, refund.created, refund.processed, refund.failedcloudflared tunnel --url http://localhost:3000) and use that URL for the webhook.Add a verified domain in Resend and set RESEND_API_KEY and EMAIL_FROM. Without a key, emails are printed to the server console.
Each creator enters their Pixel ID under Dashboard → Settings (or per page). That alone turns on browser Pixel events. The CAPI access token is optional but recommended: with it the server sends the same events (deduplicated by event_id), and with a test event code the creator can click Send test event. Tokens are encrypted with AES-256-GCM and never reach the browser. Run migration 0017 so a page pixel can be saved without a token.
| Event | Browser (Pixel) | Server (CAPI) | Shared event_id |
|---|---|---|---|
| PageView, ViewContent | page load | /api/track | random per view |
| InitiateCheckout | after order created | /api/checkout | ic_<orderId> |
| Purchase | success page | webhook / verify | purchase_<orderId> |
Set NEXT_PUBLIC_META_PIXEL_ID to send our own ad events: PageView on marketing pages (ViewContent on pricing, features and compare), CompleteRegistration when a signup's email is verified, Subscribe on a Creator subscription's first charge and Purchase for Lifetime. Add META_CAPI_TOKEN to also send the conversions from the server (deduplicated by event_id, logged in meta_events). This pixel never loads on creators' public pages. META_TEST_EVENT_CODE is for checking events in Events Manager; remove it before running ads.
npm run dev
See DEPLOY.md for the full production checklist: GitHub, Vercel, domain, Supabase URLs, Razorpay live mode, the 15-minute recovery job and the launch smoke test.
/p/<slug>success@razorpay UPI → success page → download workswebhook_events with processed_at set; ledger has sale + gateway_feerefund.processed → ledger refund; a full refund disables downloadssupabase/migrations/0001_init.sql schema, RLS, money functions, storage
src/proxy.ts session refresh + /dashboard,/admin guard
src/lib/ env, supabase clients, razorpay, crypto, meta, email, fulfilment
src/app/p/[slug]/ public page, checkout form, success page
src/app/d/[token]/ buyer download page
src/app/api/ checkout, verify, webhooks, track, download, cron
src/app/dashboard/ creator: pages, orders, earnings, settings
src/app/admin/ creators, payouts, adjustments, refunds