Payments, email and Discord

🇮🇩 Bahasa Indonesia

All three are optional. Each one is off until its environment variables are set, and the platform keeps working without it. Check what the server sees at /api/config/features.

Payments with Midtrans (Indonesia, IDR)

Without Midtrans, the buy buttons read “Payments are not set up yet”. Free courses, free workshops and manual Learning Pass grants still work.

  1. Sandbox first. Sign up at midtrans.com and open the Sandbox dashboard (dashboard.sandbox.midtrans.com) → Settings → Access Keys. Copy the Server Key (SB-Mid-server-…).
  2. Set the secrets:

    MIDTRANS_SERVER_KEY=SB-Mid-server-…
    MIDTRANS_IS_PRODUCTION=false
    LEARNING_PASS_PUBLIC_URL=https://<your public address>
    

    The notification URL (<LEARNING_PASS_PUBLIC_URL>/api/payments/midtrans/notifications) and the return page (/checkout/result) are sent with every transaction, so you don’t have to enter them in Midtrans. They must be reachable from the internet: test payments from a published Replit app, not from localhost. (You may also put the notification URL under Settings → Payment → Notification URL as a fallback.)

  3. Buy a Learning Pass with a sandbox test card or e-wallet. After payment you return to /checkout/result, the pass becomes active within seconds, and the buyer gets an email (if email is set up).
  4. Production. Complete Midtrans’ merchant verification, then use the production Server Key and set MIDTRANS_IS_PRODUCTION=true. Publish your legal pages (privacy, terms, refund terms) first: Midtrans asks for them.

Prices live in site.config.ts (learningPass.price, promoCode, promoDiscount, workshopDiscountPercent) and in each workshop’s price. The server computes every amount; the browser only displays it.

Other countries / Stripe: Midtrans charges in IDR only. The payment code is contained in artifacts/api-server/src/lib/midtrans.ts (create transaction, verify notification, fetch status) and routes/payments.ts; a different provider means implementing those three functions for it and its webhook route.

Email with Resend

Used for: payment confirmations, paid-workshop notices to creators, new-course announcements, webinar reminders and admin emails to pass holders.

  1. Create an account at resend.com and verify your domain (Domains → Add, then the DNS records). Resend’s shared resend.dev sender only delivers to your own address, so the platform refuses to use it.
  2. Create an API key.
  3. Set:

    RESEND_API_KEY=re_…
    RESEND_FROM_EMAIL=notifications@yourdomain.com
    

    The sender shows as <site.name> <notifications@yourdomain.com>. On Replit you may add the Resend connector instead of RESEND_API_KEY; the key wins if both are present.

  4. Test: Admin → Member emails → send test emails you.

Email language follows site.defaultLocale.

Invitation emails (optional, SMTP)

Manual Learning Pass grants can email an invitation through any SMTP mailbox (the code defaults to Postale):

POSTALE_FROM_EMAIL=info@yourdomain.com
POSTALE_SMTP_USER=info@yourdomain.com
POSTALE_SMTP_PASSWORD=…
POSTALE_SMTP_HOST=mail.postale.io

Discord community

Learners link their Discord account on /community; while their Learning Pass is active they get a member role on your server, and it’s removed when the pass ends.

  1. In the Discord Developer Portal create an application.
    • OAuth2 → Redirects: add https://<your domain>/api/community/discord/callback (https is required).
    • Bot: create the bot and copy its token.
  2. Invite the bot to your server with the Manage Roles permission. Create the member role and place it below the bot’s own role in the role list (Discord only lets bots manage roles under them).
  3. Copy the server (guild) ID and the role ID (Developer Mode on → right-click → Copy ID).
  4. Set:

    DISCORD_CLIENT_ID=…
    DISCORD_CLIENT_SECRET=…
    DISCORD_BOT_TOKEN=…
    DISCORD_GUILD_ID=…
    DISCORD_MEMBER_ROLE_ID=…
    DISCORD_REDIRECT_URI=https://<your domain>/api/community/discord/callback
    
  5. Check Admin → Discord: it reports whether the bot can manage the role.

Role changes only happen when NODE_ENV=production (the published app), so a development copy never adds or removes roles of real members. Other roles and public channels are never touched.

File uploads (Replit App Storage)

Course resource files and uploaded MP4 lesson videos are stored in Replit App Storage. In the Repl open Tools → App Storage, create a bucket; Replit sets PRIVATE_OBJECT_DIR. Development and the published app share the bucket. Outside Replit, uploads answer “not available”; use YouTube links and resource links instead, or replace artifacts/api-server/src/lib/course-resource-storage.ts and routes/course-videos.ts with your own S3-compatible storage.