Fix: reservation_id must be string not number (NetUP API)
This commit is contained in:
@@ -318,7 +318,7 @@ const netup: FastifyPluginAsync = async (fastify) => {
|
|||||||
if (!room) return reply.code(404).send({ error: 'Room not found' })
|
if (!room) return reply.code(404).send({ error: 'Room not found' })
|
||||||
|
|
||||||
const result = await notifyNetupCheckinInternal(
|
const result = await notifyNetupCheckinInternal(
|
||||||
hotelId, room_id, room.number, 'Тестовый гость', 'test-' + Date.now(),
|
hotelId, room_id, room.number, 'Тестовый гость', 'TEST-' + room.number,
|
||||||
)
|
)
|
||||||
if (result.ok) return { ok: true, message: `Check-in отправлен в NetUP (номер ${result.netupRoom})` }
|
if (result.ok) return { ok: true, message: `Check-in отправлен в NetUP (номер ${result.netupRoom})` }
|
||||||
return reply.code(502).send({ error: result.error ?? 'Ошибка' })
|
return reply.code(502).send({ error: result.error ?? 'Ошибка' })
|
||||||
@@ -368,9 +368,8 @@ async function notifyNetupCheckinInternal(
|
|||||||
const url = `${base}/mw/api/hotel-room/${encodeURIComponent(mapping.netup_room_number)}/check-in`
|
const url = `${base}/mw/api/hotel-room/${encodeURIComponent(mapping.netup_room_number)}/check-in`
|
||||||
const cred = Buffer.from(`${cfg.username}:${cfg.password}`).toString('base64')
|
const cred = Buffer.from(`${cfg.username}:${cfg.password}`).toString('base64')
|
||||||
|
|
||||||
// reservation_id must be a number in NetUP — convert UUID/string to integer
|
// NetUP expects reservation_id as a string
|
||||||
const resIdNum = parseInt(reservationId.replace(/\D/g, '').slice(-8), 10) || Date.now() % 1000000
|
const requestBody = { reservation_id: reservationId, name: guestName, language: language ?? cfg.default_language }
|
||||||
const requestBody = { reservation_id: resIdNum, name: guestName, language: language ?? cfg.default_language }
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(url, {
|
const res = await fetch(url, {
|
||||||
|
|||||||
Reference in New Issue
Block a user