From cda515c0d83b11f33b8089dbac5315171bc0ad53 Mon Sep 17 00:00:00 2001 From: HotelSync Date: Wed, 8 Apr 2026 03:23:21 +0300 Subject: [PATCH] fix: create booking_payments record on YooKassa webhook payment.succeeded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- backend/src/routes/deposit.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/src/routes/deposit.ts b/backend/src/routes/deposit.ts index 995fe06..3af1029 100644 --- a/backend/src/routes/deposit.ts +++ b/backend/src/routes/deposit.ts @@ -767,6 +767,13 @@ ${refund > 0 && (!items || items.length === 0) ? `

Ос if (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) { sendBookingConfirmedEmail({