# SilverPay Settings Configuration ## Overview The LittleShop admin panel now includes a comprehensive SilverPay integration settings page that allows you to configure the payment gateway connection dynamically without modifying code or configuration files. ## Accessing the Settings 1. **Start the Application** ```bash dotnet run --project LittleShop/LittleShop.csproj ``` 2. **Navigate to Admin Panel** - Open your browser and go to: http://localhost:5000/Admin - Login with default credentials: `admin` / `admin` 3. **Access System Settings** - Click on "Settings" in the navigation menu (gear icon) - Or directly navigate to: http://localhost:5000/Admin/SystemSettings ## SilverPay Configuration Options ### Base URL - **Purpose**: The API endpoint URL for SilverPay services - **Example**: `http://31.97.57.205:8001` or `https://api.silverpay.com` - **Required**: Yes ### API Key - **Purpose**: Authentication key for SilverPay API requests - **Security**: Displayed as password field with toggle visibility - **Required**: Optional (leave empty if SilverPay doesn't require authentication) ### Webhook Secret - **Purpose**: Secret key used to validate incoming webhook requests from SilverPay - **Security**: Displayed as password field with toggle visibility - **Required**: Optional but recommended for production ### Default Webhook URL - **Purpose**: Your endpoint URL where SilverPay will send payment notifications - **Example**: `https://yourdomain.com/api/silverpay/webhook` - **Required**: Optional (can be set per order) ## Features ### Connection Testing - Click the "Test Connection" button to verify your SilverPay settings - The test will attempt to retrieve supported currencies from SilverPay - Results are displayed immediately with success/failure status - Connection status and last test timestamp are shown in the interface ### Status Indicators - **Not Configured**: No base URL has been set - **Configured**: Settings are saved but not tested - **Connected**: Settings are saved and successfully tested - **Not Tested**: Settings changed since last test ### Dynamic Configuration - Settings are stored in the database and loaded dynamically - Changes take effect immediately without application restart - Falls back to appsettings.json if database settings are not configured ## Implementation Details ### Database Storage Settings are stored in the `SystemSettings` table with the following keys: - `SilverPay.BaseUrl` - `SilverPay.ApiKey` - `SilverPay.WebhookSecret` - `SilverPay.DefaultWebhookUrl` - `SilverPay.LastTestDate` - `SilverPay.LastTestSuccess` - `SilverPay.LastTestMessage` ### Service Architecture The `SilverPayService` has been updated to: 1. Check database settings first 2. Fall back to configuration file settings 3. Update HTTP client configuration dynamically per request 4. Use dependency injection with scoped service provider for settings access ### Security Considerations - API keys and webhook secrets are stored encrypted in the database - Password fields are used in the UI to prevent shoulder surfing - HTTPS should be used in production environments - Consider using Azure Key Vault or similar for production secrets ## Migration from Configuration Files If you have existing settings in `appsettings.json`: 1. The system will automatically use them as fallback 2. Navigate to the Settings page 3. Save the settings to migrate them to the database 4. Once saved in database, those settings take precedence ## Troubleshooting ### Settings Not Saving - Check browser console for JavaScript errors - Ensure you have Admin role permissions - Verify database write permissions ### Connection Test Fails - Verify the Base URL is correct and accessible - Check if API key is required and correctly entered - Ensure SilverPay service is running and reachable - Check firewall/network settings ### Settings Not Taking Effect - Settings are loaded per request, no restart needed - Clear browser cache if UI shows old values - Check application logs for configuration errors ## Production Deployment For production environments: 1. Use HTTPS for both your application and SilverPay endpoints 2. Set strong webhook secrets 3. Configure proper CORS settings if needed 4. Monitor connection test results regularly 5. Set up alerts for payment webhook failures ## API Integration The settings are used by: - `ISilverPayService` for payment processing - `CryptoPaymentService` for order payment creation - `SilverPayWebhookController` for webhook validation All services automatically use the latest settings from the database.