Major changes:
• Remove BTCPay Server integration in favor of SilverPAY manual verification
• Add test data cleanup mechanisms (API endpoints and shell scripts)
• Fix compilation errors in TestController (IdentityReference vs CustomerIdentity)
• Add deployment automation scripts for Hostinger VPS
• Enhance integration testing with comprehensive E2E validation
• Add Blazor components and mobile-responsive CSS for admin interface
• Create production environment configuration scripts
Key Features Added:
• Manual payment verification through Admin panel Order Details
• Bulk test data cleanup with proper cascade handling
• Deployment automation with systemd service configuration
• Comprehensive E2E testing suite with SilverPAY integration validation
• Mobile-first admin interface improvements
Security & Production:
• Environment variable configuration for production secrets
• Proper JWT and VAPID key management
• SilverPAY API integration with live credentials
• Database cleanup and maintenance tools
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
203 lines
6.8 KiB
Bash
203 lines
6.8 KiB
Bash
#!/bin/bash
|
|
|
|
# Production Cleanup Script - Remove All Test Data
|
|
# WARNING: This removes ALL orders and payments from the system
|
|
|
|
echo "========================================"
|
|
echo "PRODUCTION CLEANUP SCRIPT"
|
|
echo "========================================"
|
|
echo ""
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
RED='\033[0;31m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
LITTLESHOP_URL="http://localhost:8080"
|
|
SILVERPAY_URL="http://31.97.57.205:8001"
|
|
SILVERPAY_API_KEY="sk_live_edba50ac32dfa7f997b2597d5785afdbaf17b8a9f4a73dfbbd46dbe2a02e5757"
|
|
|
|
echo -e "${RED}⚠️ WARNING: This will remove ALL test data!${NC}"
|
|
echo ""
|
|
echo "This script will clean up:"
|
|
echo " • All LittleShop orders with test identities"
|
|
echo " • All SilverPAY test orders"
|
|
echo " • All associated webhooks"
|
|
echo " • All crypto payment records"
|
|
echo ""
|
|
read -p "Are you sure you want to proceed? (y/N): " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "Cleanup cancelled."
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${BLUE}[1] Identifying Test Orders in LittleShop${NC}"
|
|
echo "----------------------------------------"
|
|
|
|
# Get all orders from LittleShop API
|
|
ORDERS_RESPONSE=$(curl -s "$LITTLESHOP_URL/api/orders" 2>/dev/null)
|
|
|
|
if [ $? -eq 0 ]; then
|
|
# Count total orders
|
|
ORDER_COUNT=$(echo "$ORDERS_RESPONSE" | grep -o '"id":' | wc -l)
|
|
echo "Found $ORDER_COUNT total orders"
|
|
|
|
# Extract test customer identities (starting with 'test-')
|
|
TEST_CUSTOMERS=$(echo "$ORDERS_RESPONSE" | grep -o '"customerIdentity":"test-[^"]*"' | cut -d'"' -f4 | sort | uniq)
|
|
|
|
if [ -n "$TEST_CUSTOMERS" ]; then
|
|
echo "Test customer identities found:"
|
|
echo "$TEST_CUSTOMERS" | while read customer; do
|
|
echo " • $customer"
|
|
done
|
|
else
|
|
echo "No test customer identities found"
|
|
fi
|
|
else
|
|
echo -e "${RED}✗ Failed to retrieve orders from LittleShop${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${BLUE}[2] Checking SilverPAY Test Orders${NC}"
|
|
echo "----------------------------------------"
|
|
|
|
# List SilverPAY orders (requires authentication)
|
|
SPAY_ORDERS=$(curl -s -X GET "$SILVERPAY_URL/api/v1/orders" \
|
|
-H "X-API-Key: $SILVERPAY_API_KEY" 2>/dev/null)
|
|
|
|
if echo "$SPAY_ORDERS" | grep -q '"id":'; then
|
|
SPAY_COUNT=$(echo "$SPAY_ORDERS" | grep -o '"id":' | wc -l)
|
|
echo "Found $SPAY_COUNT SilverPAY orders"
|
|
|
|
# Show external_ids for identification
|
|
echo "SilverPAY test orders:"
|
|
echo "$SPAY_ORDERS" | grep -o '"external_id":"[^"]*"' | cut -d'"' -f4 | while read ext_id; do
|
|
echo " • $ext_id"
|
|
done
|
|
else
|
|
echo "No SilverPAY orders found or authentication failed"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${BLUE}[3] Database Cleanup (Direct SQLite)${NC}"
|
|
echo "----------------------------------------"
|
|
|
|
# Direct database cleanup via SQLite
|
|
DB_FILE="littleshop.db"
|
|
|
|
if [ -f "$DB_FILE" ]; then
|
|
echo "Cleaning up LittleShop database..."
|
|
|
|
# Count records before cleanup
|
|
ORDERS_BEFORE=$(sqlite3 "$DB_FILE" "SELECT COUNT(*) FROM Orders;")
|
|
PAYMENTS_BEFORE=$(sqlite3 "$DB_FILE" "SELECT COUNT(*) FROM CryptoPayments;" 2>/dev/null || echo "0")
|
|
ORDERITEMS_BEFORE=$(sqlite3 "$DB_FILE" "SELECT COUNT(*) FROM OrderItems;")
|
|
|
|
echo "Records before cleanup:"
|
|
echo " • Orders: $ORDERS_BEFORE"
|
|
echo " • OrderItems: $ORDERITEMS_BEFORE"
|
|
echo " • CryptoPayments: $PAYMENTS_BEFORE"
|
|
|
|
# Delete test orders and associated data
|
|
sqlite3 "$DB_FILE" <<EOF
|
|
-- Delete crypto payments for test orders
|
|
DELETE FROM CryptoPayments
|
|
WHERE OrderId IN (
|
|
SELECT Id FROM Orders
|
|
WHERE CustomerIdentity LIKE 'test-%'
|
|
);
|
|
|
|
-- Delete order items for test orders
|
|
DELETE FROM OrderItems
|
|
WHERE OrderId IN (
|
|
SELECT Id FROM Orders
|
|
WHERE CustomerIdentity LIKE 'test-%'
|
|
);
|
|
|
|
-- Delete test orders
|
|
DELETE FROM Orders
|
|
WHERE CustomerIdentity LIKE 'test-%';
|
|
|
|
-- Clean up any orphaned records
|
|
DELETE FROM OrderItems WHERE OrderId NOT IN (SELECT Id FROM Orders);
|
|
DELETE FROM CryptoPayments WHERE OrderId NOT IN (SELECT Id FROM Orders);
|
|
EOF
|
|
|
|
# Count records after cleanup
|
|
ORDERS_AFTER=$(sqlite3 "$DB_FILE" "SELECT COUNT(*) FROM Orders;")
|
|
PAYMENTS_AFTER=$(sqlite3 "$DB_FILE" "SELECT COUNT(*) FROM CryptoPayments;" 2>/dev/null || echo "0")
|
|
ORDERITEMS_AFTER=$(sqlite3 "$DB_FILE" "SELECT COUNT(*) FROM OrderItems;")
|
|
|
|
echo ""
|
|
echo "Records after cleanup:"
|
|
echo " • Orders: $ORDERS_AFTER (removed: $((ORDERS_BEFORE - ORDERS_AFTER)))"
|
|
echo " • OrderItems: $ORDERITEMS_AFTER (removed: $((ORDERITEMS_BEFORE - ORDERITEMS_AFTER)))"
|
|
echo " • CryptoPayments: $PAYMENTS_AFTER (removed: $((PAYMENTS_BEFORE - PAYMENTS_AFTER)))"
|
|
|
|
echo -e "${GREEN}✓ Database cleanup completed${NC}"
|
|
else
|
|
echo -e "${YELLOW}⚠ Database file not found: $DB_FILE${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${BLUE}[4] SilverPAY Cleanup${NC}"
|
|
echo "----------------------------------------"
|
|
|
|
# Note: SilverPAY cleanup would require admin API access
|
|
# For now, we document what needs to be done
|
|
echo "SilverPAY cleanup requires manual intervention:"
|
|
echo " 1. Access SilverPAY admin panel"
|
|
echo " 2. Delete test orders with external_id starting with 'test-'"
|
|
echo " 3. Remove any webhook configurations for test URLs"
|
|
echo " 4. Clear test payment addresses from wallet"
|
|
echo ""
|
|
echo "Test external_ids to clean up:"
|
|
if [ -n "$SPAY_ORDERS" ]; then
|
|
echo "$SPAY_ORDERS" | grep -o '"external_id":"test-[^"]*"' | cut -d'"' -f4 | while read ext_id; do
|
|
echo " • $ext_id"
|
|
done
|
|
else
|
|
echo " • Check SilverPAY admin panel for orders starting with 'test-'"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${BLUE}[5] Verification${NC}"
|
|
echo "----------------------------------------"
|
|
|
|
# Verify cleanup
|
|
echo "Verifying cleanup..."
|
|
|
|
# Check LittleShop
|
|
REMAINING_ORDERS=$(curl -s "$LITTLESHOP_URL/api/orders" 2>/dev/null | grep -o '"customerIdentity":"test-[^"]*"' | wc -l)
|
|
if [ "$REMAINING_ORDERS" -eq 0 ]; then
|
|
echo -e "${GREEN}✓ No test orders remain in LittleShop${NC}"
|
|
else
|
|
echo -e "${RED}✗ $REMAINING_ORDERS test orders still exist in LittleShop${NC}"
|
|
fi
|
|
|
|
# Final database verification
|
|
if [ -f "$DB_FILE" ]; then
|
|
FINAL_TEST_ORDERS=$(sqlite3 "$DB_FILE" "SELECT COUNT(*) FROM Orders WHERE CustomerIdentity LIKE 'test-%';")
|
|
if [ "$FINAL_TEST_ORDERS" -eq 0 ]; then
|
|
echo -e "${GREEN}✓ Database is clean${NC}"
|
|
else
|
|
echo -e "${RED}✗ $FINAL_TEST_ORDERS test orders remain in database${NC}"
|
|
fi
|
|
fi
|
|
|
|
echo ""
|
|
echo "========================================"
|
|
echo -e "${GREEN}CLEANUP COMPLETED${NC}"
|
|
echo "========================================"
|
|
echo ""
|
|
echo "Summary:"
|
|
echo " • LittleShop test orders: Removed"
|
|
echo " • Database records: Cleaned"
|
|
echo " • SilverPAY cleanup: Requires manual intervention"
|
|
echo ""
|
|
echo -e "${YELLOW}IMPORTANT: Complete SilverPAY cleanup manually via admin panel${NC}"
|
|
echo "" |