fake-stripe-payments

/home/avalon/.hermes/skills/.archive/fake-stripe-testing/fake-stripe-payments/SKILL.md ยท raw

Fake Stripe Payment System

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.

When to Use

Implementation Pattern

1. Database Schema

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

2. API Endpoints

// 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)

3. Checkout Modal Component

4. Order Number Generation

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
}

5. Fake Stripe IDs

const chargeId = `ch_fake_${Math.random().toString(36).substring(2, 12)}`;
const paymentIntentId = `pi_fake_${Math.random().toString(36).substring(2, 12)}`;

Key Details

Verification

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)

Pitfalls

Testing Flow

  1. Profile โ†’ Sign In (Demo) โ†’ search customer
  2. Navigate to class/product detail
  3. Tap Book/Purchase button
  4. Confirm in checkout modal
  5. Verify success message + UI updates
  6. Check admin dashboard for new records