Build a fake Stripe-like payment system for testing booking and purchase flows without real Stripe credentials. Creates real database records that integrate with existing admin dashboards.
Create records in existing tables (no new tables needed):
For Class Bookings:
- reservations table: customer_id, class_id, status='confirmed'
- Decrement class spots_available
For Product Purchases:
- orders table: customer_id, total, order_number (generate like VAGD-DG2B-5KV7)
- order_line_items table: order_id, product_id, quantity, unit_price
- transactions table: order_id, amount, stripe_fee, net_amount, payment_method, gateway='Stripe (Fake)', device_type='Mobile App'
- customer_credits table: customer_id, credit_package_id, credits (if product is credit package)
- Update customers.total_remaining_credits and customers.total_spent_all
// POST /api/bookings
// Body: { customer_id, class_id }
// Creates reservation, decrements spots, returns success
// POST /api/orders
// Body: { customer_id, items: [{ product_id, quantity }] }
// Creates order + line items + transaction
// If credit package: creates customer_credits, updates customer totals
// Returns order with fake Stripe ID (ch_fake_abc123)
function generateOrderNumber() {
const parts = [
Math.random().toString(36).substring(2, 6).toUpperCase(),
Math.random().toString(36).substring(2, 6).toUpperCase(),
Math.random().toString(36).substring(2, 6).toUpperCase()
];
return parts.join('-'); // e.g., VAGD-DG2B-5KV7
}
const chargeId = `ch_fake_${Math.random().toString(36).substring(2, 12)}`;
const paymentIntentId = `pi_fake_${Math.random().toString(36).substring(2, 12)}`;
After checkout, verify in database: - Reservation/order appears in admin dashboard - Transaction record with correct amount/fees - Customer credits updated (if applicable) - Class spots decremented (for bookings)
/api/customers/search before /api/customers/:id to avoid param matching issues