- Fix admin panel to show all pending orders (PendingPayment + PaymentReceived) - Fix currency display from USD ($) to GBP (£) throughout TeleBot - Update payment methods to use dynamic SilverPay currency list - Consolidate shipping address collection into single message - Implement cart backup/restore on payment failure - Remove unsupported XMR from TeleBot config 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
86 lines
2.9 KiB
C#
86 lines
2.9 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using LittleShop.Services;
|
|
using LittleShop.Enums;
|
|
|
|
namespace LittleShop.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class CurrencyController : ControllerBase
|
|
{
|
|
private readonly ISilverPayService _silverPayService;
|
|
private readonly ISystemSettingsService _systemSettingsService;
|
|
private readonly ILogger<CurrencyController> _logger;
|
|
|
|
public CurrencyController(
|
|
ISilverPayService silverPayService,
|
|
ISystemSettingsService systemSettingsService,
|
|
ILogger<CurrencyController> logger)
|
|
{
|
|
_silverPayService = silverPayService;
|
|
_systemSettingsService = systemSettingsService;
|
|
_logger = logger;
|
|
}
|
|
|
|
[HttpGet("available")]
|
|
public async Task<ActionResult<IEnumerable<string>>> GetAvailableCurrencies()
|
|
{
|
|
try
|
|
{
|
|
var availableCurrencies = new List<string>();
|
|
|
|
// Get SilverPay supported currencies
|
|
var silverPayCurrencies = await _silverPayService.GetSupportedCurrenciesAsync();
|
|
|
|
// Test currencies that should be excluded unless explicitly enabled
|
|
var testCurrencies = new[] { "TBTC", "TETH", "TLTC", "TESTBTC", "TESTNET" };
|
|
|
|
// Add all SilverPay supported currencies except test ones
|
|
foreach (var currency in silverPayCurrencies)
|
|
{
|
|
var isTestCurrency = testCurrencies.Any(tc =>
|
|
currency.Contains(tc, StringComparison.OrdinalIgnoreCase) ||
|
|
currency.StartsWith("T", StringComparison.OrdinalIgnoreCase));
|
|
|
|
if (isTestCurrency)
|
|
{
|
|
// Only add test currencies if explicitly enabled in settings
|
|
if (await _systemSettingsService.IsTestCurrencyEnabledAsync(currency))
|
|
{
|
|
availableCurrencies.Add(currency);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Add all production currencies
|
|
availableCurrencies.Add(currency);
|
|
}
|
|
}
|
|
|
|
_logger.LogInformation("Available currencies: {Currencies}", string.Join(", ", availableCurrencies));
|
|
|
|
return Ok(availableCurrencies);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Error getting available currencies");
|
|
// Return safe fallback currencies
|
|
return Ok(new[] { "BTC", "ETH" });
|
|
}
|
|
}
|
|
|
|
[HttpGet("silverpay/supported")]
|
|
public async Task<ActionResult<IEnumerable<string>>> GetSilverPaySupportedCurrencies()
|
|
{
|
|
try
|
|
{
|
|
var currencies = await _silverPayService.GetSupportedCurrenciesAsync();
|
|
return Ok(currencies);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Error getting SilverPay supported currencies");
|
|
return StatusCode(500, "Failed to get supported currencies");
|
|
}
|
|
}
|
|
} |