2024 • 5 min read

Tutor.In: Building a Peer-Learning
 Marketplace with React, Node.js, and Midtrans

How my 4-person team replaced chaotic WhatsApp study groups with a full-stack peer mentoring platform featuring secure Midtrans webhook verification.

Tutor.In: Building a Peer-Learning Marketplace with React, Node.js, and Midtrans

The WhatsApp Study Group Chaos

During exam weeks at Telkom University, informal study coordination was a mess. Important algorithm questions got buried in 200-member WhatsApp groups, lecture summaries were scattered across private Google Drive links that half the class could not access, and finding an affordable senior peer tutor usually meant sending awkward direct messages with no guarantee they would actually show up.

For our Software Implementation and Testing (IPPL) capstone, our 4-person team decided to build a dedicated platform: Tutor.In.

The goal was to give university students a single web application for course-specific discussion threads, study material downloads, and paid peer-tutoring sessions processed through Midtrans.

Mentee Browses Course Forum
               │
               ▼
   Selects Senior Peer Mentor
               │
               ▼
   Books a Tutoring Time Slot
               │
               ▼
      The Security Dilemma
   (Can we trust the React frontend
    when it says payment succeeded?)
               │
               ▼
   Midtrans Snap Server-to-Server Flow
   ├── Node.js backend requests snap_token
   ├── Mentee completes QRIS / VA in Snap popup
   └── Midtrans fires asynchronous webhook
               │
               ▼
   SHA-512 Signature Verification
   (Validates order_id + status + gross_amount)
               │
               ▼
  Booking Transitions to 'Confirmed'

The Peer Study Coordination Problem

Students needed two complementary roles:

  • Senior students (Mentors) who wanted to share study summaries, host topic discussion boards, and offer paid 1-on-1 tutoring sessions to earn extra income.
  • Junior students (Mentees) who needed structured answers to difficult coursework and wanted to book review sessions before midterm exams.

We structured the platform as a decoupled system: a React 18 single-page application built with Vite and Tailwind CSS on the frontend, and a Node.js Express service using Sequelize ORM on a MySQL database (mewing) on the backend.

Authentication runs on stateless JSON Web Tokens (JWT) with bcrypt password hashing, allowing students to switch between mentor and mentee modes within the same profile.

The Flawed Naive Approach: Trusting Client-Side Callbacks

When we first integrated the Midtrans Snap payment gateway, we followed an intuitive client-side pattern:

React Client -> Opens Snap Modal -> User Pays -> onSuccess() fires ->
React calls POST /api/sessions/confirm -> Backend marks session 'Booked'

It looked clean in our local development environment. But during testing, we noticed a critical vulnerability: anyone could open their browser developer console, intercept the network request, and trigger the POST /api/sessions/confirm endpoint directly with an arbitrary session ID.

A mentee could lock a senior tutor’s calendar schedule without a single rupiah ever leaving their bank account.

How do we guarantee a peer tutoring session only confirms after the payment actually clears, without trusting the client browser?

Securing Booking State with SHA-512 Webhook Verification

To solve this, we decoupled the user interface from the payment state machine.

When a student clicks “Book & Pay”, the React app does not confirm anything. It only asks our Express backend to generate a one-time Midtrans transaction token:

// backend/controllers/paymentController.js
const snap = new midtransClient.Snap({
  isProduction: false,
  serverKey: process.env.MIDTRANS_SERVER_KEY,
  clientKey: process.env.MIDTRANS_CLIENT_KEY
});

exports.createTransaction = async (req, res) => {
  const { sessionId, grossAmount } = req.body;
  
  const parameter = {
    transaction_details: {
      order_id: `TUTOR-${sessionId}-${Date.now()}`,
      gross_amount: grossAmount
    },
    customer_details: {
      first_name: req.user.name,
      email: req.user.email
    }
  };

  const transaction = await snap.createTransaction(parameter);
  
  // Session stays in PENDING status
  await MentoringSession.update(
    { status: 'pending_payment' },
    { where: { id: sessionId } }
  );

  return res.json({ token: transaction.token });
};

The session record stays locked in pending_payment. The only way the session status can change to confirmed is when Midtrans sends an asynchronous server-to-server webhook callback to our /api/payments/notification route.

To ensure the webhook is genuinely from Midtrans and not a spoofed request, our backend computes an SHA-512 signature hash and compares it against the signature provided in the payload:

// backend/controllers/paymentController.js
const crypto = require('crypto');

exports.handleNotification = async (req, res) => {
  const notification = req.body;
  
  const rawSignature = notification.order_id +
                       notification.status_code +
                       notification.gross_amount +
                       process.env.MIDTRANS_SERVER_KEY;

  const expectedSignature = crypto
    .createHash('sha512')
    .update(rawSignature)
    .digest('hex');

  if (notification.signature_key !== expectedSignature) {
    return res.status(403).json({ message: 'Invalid signature key' });
  }

  const transactionStatus = notification.transaction_status;
  const fraudStatus = notification.fraud_status;

  if (transactionStatus === 'capture' || transactionStatus === 'settlement') {
    if (fraudStatus === 'accept' || !fraudStatus) {
      // Extract sessionId and update database atomically
      const sessionId = notification.order_id.split('-')[1];
      await MentoringSession.update(
        { status: 'confirmed' },
        { where: { id: sessionId } }
      );
    }
  }

  return res.status(200).send('OK');
};

If a user closes their browser or manipulates client-side JavaScript, the database remains protected. The booking only confirms when Midtrans’s servers cryptographically verify the funds.

File Sharing and Community Discussion

Beyond tutoring sessions, students needed to share study materials. We used Multer middleware to process lecture notes, cheat sheets, and problem sets:

  • File constraints: PDF, DOC, DOCX, and PNG formats up to 10MB.
  • Storage: Server storage with metadata (uploader ID, forum ID, file size, mime type) saved in MySQL via Sequelize.
  • Delivery: Files are served with Content-Disposition: attachment headers, prompting a native browser save dialog rather than attempting to render complex PDFs inside tab memory.

Team Collaboration

Tutor.In was built across two active Git repositories under our IPPL-Bagus-King organization by a team of four:

  • Gede Bagus Krishnanditya Merta
  • Valentino Hartanto
  • Raka Aditya Waluya
  • Cut Nabilah Nuur Azizah

Working with decoupled frontend and backend repositories forced us to define API payload contracts before writing component code, avoiding integration surprises during sprint reviews.

What I Learned

Building Tutor.In taught me that whenever real transactions or calendar commitments are involved, the frontend should be treated with zero trust.

Our naive initial impulse was to let the client confirm bookings for speed. Reworking the flow to rely on cryptographically signed webhooks took extra time, but it guaranteed that mentor schedules and payments stayed synchronized.

Engineering a full-stack application as a 4-person team also reinforced the value of clear API specifications. When backend endpoints, error shapes, and token lifecycles are agreed upon early, building responsive user interfaces becomes predictable and enjoyable.

Project Resources