Commit ccf21f83 authored by Your Name's avatar Your Name

docs: add payment settings migration safety guide

- Explains that no data will be lost during upgrade
- Same database tables and API endpoints used
- Only UI location changed, not data storage
- Includes verification steps and backup instructions
- Addresses user concern about settings preservation
parent c59439a6
# Payment Settings Migration - No Data Loss
## Question: Will I lose my payment settings after the upgrade?
**Answer: NO - Your payment settings are safe!**
## Why Your Settings Are Preserved
### 1. Same Database Tables
The payment gateway settings are stored in the database, not in the HTML files. We only moved the **UI** (user interface), not the data storage.
**Database tables used** (unchanged):
- `payment_gateway_settings` - Stores all gateway configurations
- Same table structure
- Same data format
- Same API endpoints
### 2. Same API Endpoints
Both the old and new pages use the **exact same API endpoints**:
**Loading settings**:
```
GET /api/admin/settings/payment-gateways
```
**Saving settings**:
```
POST /api/admin/settings/payment-gateways
```
These endpoints call the same database functions:
- `db.get_payment_gateway_settings()` - Reads from database
- `db.save_payment_gateway_settings()` - Writes to database
### 3. What Actually Changed
**Before** (Admin Tiers Page):
```
Admin Tiers Page → JavaScript → API Endpoint → Database
```
**After** (Admin Payment Settings Page):
```
Admin Payment Settings Page → JavaScript → API Endpoint → Database
Same endpoint!
Database
Same data!
```
### 4. Data Flow Comparison
#### Old Location (admin_tiers.html)
```javascript
function loadPaymentGateways() {
fetch('/api/admin/settings/payment-gateways') // Same API
.then(response => response.json())
.then(gateways => {
// Load PayPal settings
document.getElementById('paypalEnabled').checked = gateways.paypal.enabled;
document.getElementById('paypalClientId').value = gateways.paypal.client_id;
// ... etc
});
}
```
#### New Location (admin_payment_settings.html)
```javascript
function loadPaymentGateways() {
fetch('/api/admin/settings/payment-gateways') // Same API
.then(response => response.json())
.then(gateways => {
// Load PayPal settings
document.getElementById('paypalEnabled').checked = gateways.paypal.enabled;
document.getElementById('paypalClientId').value = gateways.paypal.client_id;
// ... etc (identical code)
});
}
```
**Result**: The code is identical, just in a different file!
## What We Actually Moved
### HTML Elements (UI Only)
- ✅ PayPal configuration form
- ✅ Stripe configuration form
- ✅ Bitcoin configuration form
- ✅ Ethereum configuration form
- ✅ USDT configuration form
- ✅ USDC configuration form
### JavaScript Functions (Same Logic)
-`loadPaymentGateways()` - Reads from same API
-`savePaymentGateways()` - Writes to same API
### What We Did NOT Change
- ❌ Database tables (unchanged)
- ❌ Database schema (unchanged)
- ❌ API endpoints (unchanged)
- ❌ Data storage format (unchanged)
- ❌ Backend logic (unchanged)
## Verification Steps
### 1. Check Your Settings Are Still There
**Option A: Via Admin Payment Settings Page**
1. Go to `/dashboard/admin/payment-settings`
2. Scroll to "Payment Gateways Configuration" section
3. Your settings should be loaded automatically
**Option B: Via API Directly**
```bash
curl -X GET http://localhost:17765/api/admin/settings/payment-gateways \
-H "Cookie: session=YOUR_SESSION_COOKIE"
```
### 2. What You Should See
If you previously configured:
- **PayPal**: Client ID, Secret, Webhook Secret should be there
- **Stripe**: Publishable Key, Secret Key, Webhook Secret should be there
- **Bitcoin**: Address, confirmations should be there
- **Ethereum**: Address, confirmations, chain ID should be there
- **USDT**: Address, network, confirmations should be there
- **USDC**: Address, network, confirmations should be there
### 3. If Settings Appear Empty
This would only happen if:
1. You never saved settings before (first time setup)
2. Database was reset/cleared
3. Different database is being used
**To verify database is correct**:
```bash
# Check if payment_gateway_settings table exists
sqlite3 ~/.aisbf/aisbf.db "SELECT name FROM sqlite_master WHERE type='table' AND name='payment_gateway_settings';"
# Check if you have any saved settings
sqlite3 ~/.aisbf/aisbf.db "SELECT * FROM payment_gateway_settings;"
```
## Technical Details
### Database Function (Unchanged)
```python
def get_payment_gateway_settings(self):
"""Get payment gateway settings from database"""
# This function was NOT changed
# It reads from the same table as before
# Returns the same data format as before
```
### API Endpoint (Unchanged)
```python
@app.get("/api/admin/settings/payment-gateways")
async def api_get_payment_gateways(request: Request):
"""Get payment gateway settings - API endpoint"""
# This endpoint was NOT changed
# It calls the same database function
# Returns the same JSON format
db = DatabaseRegistry.get_config_database()
gateways = db.get_payment_gateway_settings()
return JSONResponse(gateways)
```
## Migration Summary
| Component | Status | Impact on Data |
|-----------|--------|----------------|
| Database tables | ✅ Unchanged | No impact |
| API endpoints | ✅ Unchanged | No impact |
| Backend logic | ✅ Unchanged | No impact |
| Data format | ✅ Unchanged | No impact |
| UI location | ⚠️ Changed | No impact on data |
| JavaScript functions | ⚠️ Moved | Same logic, no data impact |
## Conclusion
**Your payment settings are 100% safe!**
We only moved the **user interface** from one page to another. The actual data storage, API endpoints, and backend logic remain completely unchanged. Your previously saved settings will load automatically when you visit the new payment settings page.
Think of it like moving furniture in your house - you moved the couch from the living room to the den, but it's still the same couch with the same cushions!
## If You Still Have Concerns
1. **Backup your database** before upgrading (always a good practice):
```bash
cp ~/.aisbf/aisbf.db ~/.aisbf/aisbf.db.backup
```
2. **Export your settings** via API before upgrading:
```bash
curl -X GET http://localhost:17765/api/admin/settings/payment-gateways > payment_settings_backup.json
```
3. **After upgrading**, verify settings loaded correctly in the new location
4. **If needed**, you can always restore from backup or re-import settings
## Support
If you experience any issues with payment settings after upgrading:
1. Check the database file exists: `~/.aisbf/aisbf.db`
2. Check the API endpoint responds: `GET /api/admin/settings/payment-gateways`
3. Check browser console for JavaScript errors
4. Report issue with details of what's missing
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment