fix: create booking_payments record on YooKassa webhook payment.succeeded

Payment tab shows 'Оплачено' from booking_payments table, not from paid_amount.
Webhook now inserts a payment record so the tab shows the correct amount.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 03:23:21 +03:00
parent 60c49d97d1
commit cda515c0d8

View File

@@ -767,6 +767,13 @@ ${refund > 0 && (!items || items.length === 0) ? `<p style="color:#16a34a">Ос
if (bRows[0]) { if (bRows[0]) {
broadcast(ob.slug, { type: 'booking:updated', booking: bRows[0] }) broadcast(ob.slug, { type: 'booking:updated', booking: bRows[0] })
} }
// Insert payment record so the payment tab shows the amount
await db.query(
`INSERT INTO booking_payments (hotel_id, booking_id, amount, method, note)
VALUES ($1, $2, $3, 'yookassa', 'Оплата через ЮКассу (онлайн-бронирование)')
ON CONFLICT DO NOTHING`,
[ob.hotel_id, ob.booking_id, ob.total_amount],
).catch(() => {})
} }
if (ob.guest_email) { if (ob.guest_email) {
sendBookingConfirmedEmail({ sendBookingConfirmedEmail({