feat(billing): PaymentProvider + Mock, self-service пополнение баланса

Шаг 0.13 плана production-готовности:
- интерфейс PaymentProvider (createPayment/verifyWebhook/getPaymentStatus)
- MockPaymentProvider с настоящим webhook (sha256-подпись, идемпотентность)
- applySucceededPayment: транзакция с guard, credit, авто-снятие billingBlocked
- роуты payments + confirm-test (только mock) + публичный webhook
- Billing.tsx: Пополнить/Подтвердить (тест), фикс setLocation в рендере
- миграция 0080 billing_payments, 13 новых тестов (78/78)
This commit is contained in:
2026-09-07 22:45:30 +03:00
parent 23c49adcd1
commit 701af06290
11 changed files with 1039 additions and 14 deletions

View File

@@ -311,7 +311,8 @@ const router = Router();
router.get('/api/billing/summary', authenticateToken, requirePermission('billing.manage'), async (req: AuthenticatedRequest, res) => {
try {
const summary = await storage.getBillingSummary(req.organizationId!);
return res.json({ success: true, summary });
const { getPaymentProviderName } = await import('../billing/payment-provider');
return res.json({ success: true, summary: { ...summary, paymentProvider: getPaymentProviderName() } });
} catch (error) {
console.error('Billing summary error:', error);
return res.status(500).json({ success: false, error: 'Внутренняя ошибка сервера' });