feat: enable payment provider for admin only

This commit is contained in:
3252a8
2026-05-25 11:19:54 +03:00
parent d30b069876
commit de1763cfe1
24 changed files with 509 additions and 39 deletions
+13 -4
View File
@@ -28,6 +28,7 @@ from .base import (
ServiceFactoryContext,
WebAppPaymentContext,
provider_env_file,
provider_runtime_enabled,
)
from .shared import (
HttpClientMixin,
@@ -181,7 +182,7 @@ class WataService(HttpClientMixin):
@property
def configured(self) -> bool:
return bool(self.config.ENABLED and self.api_token)
return bool(provider_runtime_enabled(self.config) and self.api_token)
@property
def base_url(self) -> str:
@@ -234,9 +235,9 @@ class WataService(HttpClientMixin):
return False, {"message": "service_not_configured"}
session = await self._get_session()
expires_at = (datetime.now(timezone.utc) + timedelta(days=self.payment_link_ttl_days)).replace(
microsecond=0
)
expires_at = (
datetime.now(timezone.utc) + timedelta(days=self.payment_link_ttl_days)
).replace(microsecond=0)
body: Dict[str, Any] = {
"amount": float(format_decimal_amount(amount)),
"currency": (currency or self.settings.DEFAULT_CURRENCY_SYMBOL or "RUB").upper(),
@@ -744,6 +745,14 @@ async def pay_wata_callback_handler(
await notify_callback_parse_error(callback, translator)
return
if not SPEC.is_available_to_user(
settings,
user_id=callback.from_user.id,
require_configured=False,
):
await notify_service_unavailable(callback, translator)
return
if not wata_service or not wata_service.configured:
logging.error("Wata service is not configured or unavailable.")
await notify_service_unavailable(callback, translator)