littleshop/LittleShop/Services/ISilverPayService.cs
SysAdmin 622bdcf111 🔒 SECURITY: Emergency fixes and hardening
EMERGENCY FIXES:
 DELETE MockSilverPayService.cs - removed fake payment system
 REMOVE mock service registration - no fake payments possible
 GENERATE new JWT secret - replaced hardcoded key
 FIX HttpClient disposal - proper resource management

SECURITY HARDENING:
 ADD production guards - prevent mock services in production
 CREATE environment configs - separate dev/prod settings
 ADD config validation - fail fast on misconfiguration

IMPACT:
- Mock payment system completely eliminated
- JWT authentication now uses secure keys
- Production deployment now validated on startup
- Resource leaks fixed in TeleBot currency API

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-22 05:45:49 +01:00

89 lines
3.3 KiB
C#

using LittleShop.Enums;
namespace LittleShop.Services;
public interface ISilverPayService
{
/// <summary>
/// Create a new payment order in SilverPAY
/// </summary>
/// <param name="externalId">External order ID (LittleShop order ID)</param>
/// <param name="amount">Amount in fiat currency (GBP)</param>
/// <param name="currency">Cryptocurrency to accept</param>
/// <param name="description">Optional order description</param>
/// <param name="webhookUrl">Optional webhook URL for payment notifications</param>
/// <returns>SilverPAY order details including payment address</returns>
Task<SilverPayOrderResponse> CreateOrderAsync(
string externalId,
decimal amount,
CryptoCurrency currency,
string? description = null,
string? webhookUrl = null);
/// <summary>
/// Get the status of a SilverPAY order
/// </summary>
/// <param name="orderId">SilverPAY order ID</param>
/// <returns>Order status and payment details</returns>
Task<SilverPayOrderResponse?> GetOrderStatusAsync(string orderId);
/// <summary>
/// Validate webhook signature from SilverPAY
/// </summary>
/// <param name="payload">Webhook payload</param>
/// <param name="signature">Webhook signature header</param>
/// <returns>True if signature is valid</returns>
Task<bool> ValidateWebhookAsync(string payload, string signature);
/// <summary>
/// Get current exchange rate for crypto to fiat
/// </summary>
/// <param name="cryptoCurrency">Cryptocurrency symbol</param>
/// <param name="fiatCurrency">Fiat currency (GBP, USD, EUR)</param>
/// <returns>Current exchange rate</returns>
Task<decimal?> GetExchangeRateAsync(string cryptoCurrency, string fiatCurrency = "GBP");
/// <summary>
/// Get list of supported cryptocurrencies from SilverPAY
/// </summary>
/// <returns>List of supported currency codes</returns>
Task<List<string>> GetSupportedCurrenciesAsync();
}
/// <summary>
/// Response from SilverPAY order creation/status
/// </summary>
public class SilverPayOrderResponse
{
public string Id { get; set; } = string.Empty;
public string ExternalId { get; set; } = string.Empty;
public decimal Amount { get; set; }
public string Currency { get; set; } = string.Empty;
public string PaymentAddress { get; set; } = string.Empty;
public string Status { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; }
public DateTime ExpiresAt { get; set; }
public DateTime? PaidAt { get; set; }
public Dictionary<string, object>? PaymentDetails { get; set; }
// Additional fields for crypto amounts
public decimal? CryptoAmount { get; set; }
public string? TransactionHash { get; set; }
public int? Confirmations { get; set; }
}
/// <summary>
/// Webhook notification from SilverPAY
/// </summary>
public class SilverPayWebhookNotification
{
public string OrderId { get; set; } = string.Empty;
public string ExternalId { get; set; } = string.Empty;
public string Status { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
public string? TxHash { get; set; }
public decimal Amount { get; set; }
public int Confirmations { get; set; }
public int? BlockHeight { get; set; }
public DateTime Timestamp { get; set; }
}