#!/bin/bash
#
# Manual test script for TO-003-S1: POS Order Confirmation
# Tests cash, credit_card, and debit_card payment methods
#

BASE_URL="http://localhost:8000"
EVENT_ID=1

echo "================================"
echo "TO-003-S1: POS Order Confirmation Test"
echo "================================"
echo ""

# Test 1: Cash Payment
echo "Test 1: Cash Payment"
echo "-------------------"
IDEMPOTENCY_KEY=$(uuidgen)
curl -X POST "${BASE_URL}/api/seats/confirm" \
  -H "Content-Type: application/json" \
  -H "Payment-Idempotency-Key: ${IDEMPOTENCY_KEY}" \
  -d '{
    "hold_token": "test-hold-token-cash-' + $(date +%s)",
    "payment_method": "cash",
    "payment_verified": true,
    "staff_id": 1,
    "customer_name": "Walk-in Customer (Cash)",
    "customer_email": "cash@test.com",
    "customer_phone": "+1234567890"
  }' | jq .

echo ""
echo ""

# Test 2: Credit Card Payment
echo "Test 2: Credit Card Payment"
echo "-------------------"
IDEMPOTENCY_KEY=$(uuidgen)
curl -X POST "${BASE_URL}/api/seats/confirm" \
  -H "Content-Type: application/json" \
  -H "Payment-Idempotency-Key: ${IDEMPOTENCY_KEY}" \
  -d '{
    "hold_token": "test-hold-token-cc-' + $(date +%s)",
    "payment_method": "credit_card",
    "payment_verified": true,
    "staff_id": 1,
    "customer_name": "Walk-in Customer (Credit)",
    "customer_email": "credit@test.com",
    "customer_phone": "+1234567891"
  }' | jq .

echo ""
echo ""

# Test 3: Debit Card Payment
echo "Test 3: Debit Card Payment"
echo "-------------------"
IDEMPOTENCY_KEY=$(uuidgen)
curl -X POST "${BASE_URL}/api/seats/confirm" \
  -H "Content-Type: application/json" \
  -H "Payment-Idempotency-Key: ${IDEMPOTENCY_KEY}" \
  -d '{
    "hold_token": "test-hold-token-dc-' + $(date +%s)",
    "payment_method": "debit_card",
    "payment_verified": true,
    "staff_id": 1,
    "customer_name": "Walk-in Customer (Debit)",
    "customer_email": "debit@test.com",
    "customer_phone": "+1234567892"
  }' | jq .

echo ""
echo "================================"
echo "Tests Complete!"
echo "================================"
echo ""
echo "Expected Results:"
echo "- All 3 tests should return 404 (hold not found) - this is expected"
echo "- Validation should pass (no 422 errors)"
echo "- If you create real holds first, should return 201 with receipt_pdf_url"
echo ""
echo "To test with real holds:"
echo "1. Create seat hold via /api/seats/hold"
echo "2. Use the returned hold_token in confirm request"
echo "3. Check response for receipt_pdf_url field"
