Secure Payment Integration: Lessons from Joco Exec
Security

Secure Payment Integration: Lessons from Joco Exec

Kaleb McIntosh
Dec 20, 2025
10 min read

## Security First

When building Joco Exec's payment system, security was paramount. Handling payment data for a luxury transportation service means zero tolerance for vulnerabilities.

Key Security Implementations

1. Server-Side Validation

Never trust client-side data. All payment amounts are calculated server-side:

// Server-side price calculation
const calculateFare = async (bookingId) => {
  const booking = await Booking.findById(bookingId);
  const distance = await calculateDistance(
    booking.pickup, 
    booking.dropoff
  );
  return {
    baseFare: 50,
    perMile: distance * 3.50,
    total: 50 + (distance * 3.50)
  };
};

2. JWT Authentication with Role-Based Access

const verifyAdmin = (req, res, next) => {
  const token = req.headers.authorization?.split(' ')[1];
  const decoded = jwt.verify(token, 'your-secret-key');
  
  if (decoded.role !== 'admin') {
    return res.status(403).json({ 
      error: 'Admin access required' 
    });
  }
  next();
};

3. Square Payment Integration

const processPayment = async (amount, sourceId) => {
  const response = await squareClient.paymentsApi.createPayment({
    sourceId,
    amountMoney: {
      amount: amount * 100, // Convert to cents
      currency: 'USD'
    },
    idempotencyKey: crypto.randomUUID()
  });
  return response.result.payment;
};

Lessons Learned

  1. Always validate on the server
  2. Use idempotency keys for payments
  3. Implement proper error handling
  4. Log everything for auditing
Kaleb McIntosh

Kaleb McIntosh

Full-Stack Software Engineer

Founder, McIntosh Digital Solutions

Kaleb McIntosh | Full-Stack Software Engineer