diff --git a/src/controllers/webhook.controller.ts b/src/controllers/webhook.controller.ts index 0c9a972..b6e3e3b 100644 --- a/src/controllers/webhook.controller.ts +++ b/src/controllers/webhook.controller.ts @@ -65,13 +65,13 @@ export const handleTinyOrderUpdate = async (req: Request, res: Response): Promis vendorParams.append('id', idVendedor); vendorParams.append('formato', 'JSON'); - const vendorResponse = await axios.post('https://api.tiny.com.br/api2/vendedor.obter.php', vendorParams, { + const vendorResponse = await axios.post('https://api.tiny.com.br/api2/contato.obter.php', vendorParams, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }); if (vendorResponse.data?.retorno?.status === 'OK') { - const vendedor = vendorResponse.data.retorno.vendedor; - whatsappVendedor = vendedor?.celular || vendedor?.fone || vendedor?.telefone || ""; + const contato = vendorResponse.data.retorno.contato; + whatsappVendedor = contato?.celular || contato?.fone || contato?.telefone || ""; console.log(`Successfully fetched seller WhatsApp: ${whatsappVendedor || 'None'}`); } else { console.error('Failed to fetch seller details:', JSON.stringify(vendorResponse.data?.retorno?.erros || 'Unknown API error'));