# Manual Deployment Instructions for BTCPay Fix

Since SSH access is currently unavailable, please follow these manual steps to deploy the BTCPay fixes to Hostinger:

## Option 1: Via Git Pull (Recommended)

1. **Access your Hostinger VPS** through their web console or SSH client

2. **Navigate to the application directory**:
```bash
cd /home/littleshop
# OR wherever your LittleShop is deployed
```

3. **Pull the latest changes from Gitea**:
```bash
git pull origin main
```

4. **Build the application**:
```bash
dotnet publish -c Release -o ./publish --no-self-contained
```

5. **Restart the application**:
```bash
# If using systemd
sudo systemctl restart littleshop

# If using Docker
docker-compose down
docker-compose up -d

# If running directly
pkill -f "dotnet LittleShop.dll"
nohup dotnet publish/LittleShop.dll > logs/app.log 2>&1 &
```

## Option 2: Manual File Upload

If git is not available, you can manually upload the changed files:

### Files to Update:
1. `/LittleShop/Services/BTCPayServerService.cs`
2. `/LittleShop/Services/CryptoPaymentService.cs`
3. `/LittleShop/Controllers/BTCPayTestController.cs`

### Upload Method:
- Use Hostinger's File Manager in their control panel
- Or use SFTP if available
- The compiled package is available at: `/silverlabs/src/LittleShop/littleshop-btcpay-fix.tar.gz`

### After Upload:
```bash
cd /home/littleshop
tar -xzf littleshop-btcpay-fix.tar.gz
# Restart the application as shown above
```

## Testing the Fix

Once deployed, test the BTCPay integration:

### 1. Test Connection
```bash
curl -X GET https://your-app-domain.com/api/btcpay-test/connection \
  -H "Cookie: .AspNetCore.Cookies=YOUR_ADMIN_COOKIE"
```

Expected response:
```json
{
  "status": "Connected",
  "baseUrl": "https://thebankofdebbie.giize.com",
  "message": "BTCPay Server connection successful"
}
```

### 2. Create Test Payment
```bash
curl -X POST https://your-app-domain.com/api/btcpay-test/test-payment \
  -H "Content-Type: application/json" \
  -H "Cookie: .AspNetCore.Cookies=YOUR_ADMIN_COOKIE" \
  -d '{"amount": 10.00, "cryptoCurrency": 0}'
```

Expected response:
```json
{
  "status": "Success",
  "invoiceId": "xxx",
  "checkoutLink": "https://thebankofdebbie.giize.com/i/xxx",
  "message": "✅ Test payment created successfully - Use checkout link to complete payment"
}
```

## What Was Fixed

1. **Currency Issue**: Changed from creating invoices in BTC to GBP (fiat currency)
2. **Address Extraction**: Removed incorrect CryptoInfo access, now uses CheckoutLink
3. **Payment Methods**: Properly specifies which cryptocurrencies to accept
4. **Logging**: Added comprehensive logging for debugging

## Important Notes

- BTCPay Server v2 doesn't expose raw wallet addresses via API
- Customers must use the checkout link to complete payments
- The checkout page shows the wallet address and QR code
- Webhook notifications will update order status automatically

## Troubleshooting

If payments still don't work:

1. **Check BTCPay Configuration**:
   - Login to https://thebankofdebbie.giize.com
   - Verify wallets are configured for each currency
   - Check Store Settings → Payment Methods

2. **Check Application Logs**:
   ```bash
   tail -f /home/littleshop/logs/app.log
   # Look for BTCPay-related errors
   ```

3. **Verify Configuration**:
   - Ensure `appsettings.Hostinger.json` or `appsettings.Production.json` has correct BTCPay settings
   - API Key, Store ID, and Base URL must match your BTCPay setup

## Contact

If you need assistance with deployment, the changes are in the Gitea repository:
- Repository: https://git.silverlabs.uk/SilverLABS/LittleShop
- Commit: "Fix BTCPay Server integration for production deployment"