1. POST /api/checkout/class
- Accepts: { class_id, customer_id }
- Creates: reservations record with payment_status: 'Paid'
- Decrements available_spots on the class
- Returns: reservation object with fake Stripe ID
2. POST /api/checkout/product
- Accepts: { product_id, customer_id }
- Creates: orders, line_items, transactions records
- If credit package: auto-creates credits record and updates customer totals
- Calculates sales tax (e.g., 8.25% TX rate)
- Generates fake but realistic transaction data
Generate realistic-looking Stripe-style data:
function generateFakeTransaction(amount, feePercent = 0.029, flatFee = 0.30) {
const fee = amount * feePercent + flatFee;
const net = amount - fee;
const orderId = [random(4), random(4), random(4)].map(s =>
s.toUpperCase().replace(/\d/g, c => 'ABCDEFGH'[parseInt(c)])
).join('-');
const stripeId = 'ch_fake_' + random(8);
return {
order_number: orderId,
stripe_charge_id: stripeId,
payment_method: 'Card (Visa •••• 4242)',
gateway: 'Stripe (Fake)',
device_type: 'Mobile App',
fee_amount: fee.toFixed(2),
net_amount: net.toFixed(2),
created_at: new Date().toISOString()
};
}
Key UI components: - Pre-filled test card number: 4242 4242 4242 4242 - Expiry: any future date (e.g., 12/28) - CVC: any 3 digits - Shows breakdown: subtotal, tax, total - Green confirmation on success: "You're booked!" or "Purchase complete!" - Updates UI state immediately (e.g., spots remaining decreases)
Add backend endpoints in server/index.js:
- Route order matters: /customers/search BEFORE /customers/:id
- Use transactions for multi-table writes (orders + line_items + transactions)
Create CheckoutModal component:
- Accepts type ('class' or 'product') and item props
- Shows item details, price breakdown, fake card form
- Calls appropriate API endpoint on confirm
Wire up existing screens: - ClassDetail: "Book This Class" → opens CheckoutModal - ProductDetail: "Purchase" → opens CheckoutModal - Add success state handling (show confirmation, refetch data)
Test the full flow: - Profile → Sign In (Demo) → search customer - Schedule/Shop → select item → Book/Purchase → Confirm - Verify DB records created - Check admin dashboard shows new reservation/order
:id param routesAfter booking/purchase:
-- Check reservation
SELECT * FROM reservations WHERE customer_id = 9999 ORDER BY created_at DESC LIMIT 1;
-- Check order + transaction
SELECT * FROM orders WHERE customer_id = 9999 ORDER BY created_at DESC LIMIT 1;
SELECT * FROM transactions WHERE order_id = [last_order_id];
-- Check customer credits updated (if applicable)
SELECT total_remaining_credits, total_spent_all FROM customers WHERE id = 9999;
All records should appear in the admin dashboard under their respective sections.
fake-stripe-paymentsreservations with confirmed/paid semantics and decrement class spotsorders, order_line_items, transactions, and optionally customer_creditsch_fake_<random>pi_fake_<random>VAGD-DG2B-5KV7Stripe (Fake) and display payment method Visa ending in 42424242 4242 4242 4242