# BTCPay Server Integration Setup

## Current Status
✅ BTCPay Server deployed at: https://pay.silverlabs.uk
✅ Admin account created: jamie@Silverlabs.uk
✅ Store created in BTCPay Server
✅ LittleShop BaseUrl updated to: https://pay.silverlabs.uk

## Required Configuration Steps

### 1. Get Store ID
1. Login to https://pay.silverlabs.uk
2. Go to **Stores** → **Settings** → **General**
3. Copy the Store ID (usually found in URL or displayed on settings page)

### 2. Generate API Key
1. Go to **Account** → **Manage Account** → **API Keys**
2. Click **Generate Key**
3. Label: `LittleShop Integration`
4. Required Permissions:
   - `btcpay.store.canviewstores`
   - `btcpay.store.canmodifyinvoices`
   - `btcpay.store.cancreateinvoice`
5. Copy the generated API key

### 3. Configure Webhook
1. Go to **Stores** → **Settings** → **Webhooks**
2. Click **Create Webhook**
3. Webhook URL: `https://your-littleshop-domain.com/api/btcpay/webhook`
4. Events to enable:
   - Invoice payment settled
   - Invoice expired
   - Invoice invalid
5. Copy the webhook secret

### 4. Configure Bitcoin Wallet
1. Go to **Stores** → **Settings** → **Bitcoin**
2. Click **Set up a wallet**
3. For development: Choose **Use the hot wallet**
4. Generate new wallet or import existing
5. Complete wallet setup

## LittleShop Configuration Template

Once you have the values above, update your appsettings.json:

```json
{
  "BTCPayServer": {
    "BaseUrl": "https://pay.silverlabs.uk",
    "ApiKey": "YOUR_API_KEY_HERE",
    "StoreId": "YOUR_STORE_ID_HERE",
    "WebhookSecret": "YOUR_WEBHOOK_SECRET_HERE"
  }
}
```

## Supported Cryptocurrencies

The LittleShop integration supports:
- BTC (Bitcoin)
- XMR (Monero) - requires additional setup
- USDT (Tether)
- LTC (Litecoin)
- ETH (Ethereum)
- ZEC (Zcash)
- DASH (Dash)
- DOGE (Dogecoin)

Note: Only Bitcoin is enabled by default. Additional cryptocurrencies require:
1. Enabling them in BTCPay Server store settings
2. Configuring wallets for each currency

## Testing the Integration

After configuration:
1. Start your LittleShop application
2. Create a test order
3. Select cryptocurrency payment
4. Verify invoice creation in BTCPay Server
5. Test payment flow and webhook notifications

## Webhook Endpoint

The webhook endpoint is already implemented in LittleShop:
- URL: `/api/btcpay/webhook`
- Controller: `BTCPayWebhookController.ProcessWebhook`
- Features: 
  - HMAC-SHA256 signature validation
  - Proper BTCPay Server webhook format handling
  - Payment status mapping and processing
- Handles: All BTCPay Server webhook events (invoice created, payment settled, expired, etc.)