
> liberi-kids-estoque@1.0.0 start
> node server-supabase.js

🚀 Servidor rodando na porta 5000
📊 Usando Supabase como banco de dados
🌐 Frontend disponível em: http://localhost:5000
🔍 Gerando PIX para parcela: {
  id: 'b0acd589-e8e8-43e3-aac4-fc7e3157272f',
  fallbackVendaId: '227ed50d-48a6-4894-9eb2-b9ff200f5eb1',
  fallbackNumeroParcela: 1
}
📝 Buscando parcela por ID: b0acd589-e8e8-43e3-aac4-fc7e3157272f
📊 Resultado da busca: { error: null, hasData: true }
🏦 Criando PIX Payment: {
  transaction_amount: 43.49,
  description: 'Parcela 1 - Venda VD20251018211409',
  payment_method_id: 'pix',
  payer: {
    email: 'tiago27.dossantos@gmail.com',
    first_name: 'Tiago',
    last_name: 'dos Santos',
    identification: { type: 'CPF', number: '00000000000' }
  }
}
🔑 Access Token: Configurado
📤 Enviando dados para Mercado Pago: {
  "transaction_amount": 43.49,
  "description": "Parcela 1 - Venda VD20251018211409",
  "payment_method_id": "pix",
  "payer": {
    "email": "tiago27.dossantos@gmail.com",
    "first_name": "Tiago",
    "last_name": "dos Santos",
    "identification": {
      "type": "CPF",
      "number": "00000000000"
    }
  },
  "date_of_expiration": "2025-10-19T01:14:48.897Z"
}
✅ PIX criado com sucesso: 129914478209
🔍 Gerando PIX para parcela: {
  id: '9d465a31-40d2-4b0c-8a75-8ef2773c0b21',
  fallbackVendaId: '227ed50d-48a6-4894-9eb2-b9ff200f5eb1',
  fallbackNumeroParcela: 2
}
📝 Buscando parcela por ID: 9d465a31-40d2-4b0c-8a75-8ef2773c0b21
📊 Resultado da busca: { error: null, hasData: true }
🏦 Criando PIX Payment: {
  transaction_amount: 43.49,
  description: 'Parcela 2 - Venda VD20251018211409',
  payment_method_id: 'pix',
  payer: {
    email: 'tiago27.dossantos@gmail.com',
    first_name: 'Tiago',
    last_name: 'dos Santos',
    identification: { type: 'CPF', number: '00000000000' }
  }
}
🔑 Access Token: Configurado
📤 Enviando dados para Mercado Pago: {
  "transaction_amount": 43.49,
  "description": "Parcela 2 - Venda VD20251018211409",
  "payment_method_id": "pix",
  "payer": {
    "email": "tiago27.dossantos@gmail.com",
    "first_name": "Tiago",
    "last_name": "dos Santos",
    "identification": {
      "type": "CPF",
      "number": "00000000000"
    }
  },
  "date_of_expiration": "2025-10-19T01:14:59.305Z"
}
✅ PIX criado com sucesso: 129913974685
🔍 Buscando venda: 788d09e7-c6cb-409b-8014-5722fc63ec0b
📊 Dados da venda: {
  id: '788d09e7-c6cb-409b-8014-5722fc63ec0b',
  id_venda: 'VD20251018211756',
  cliente_id: '26e21ab1-376d-4fe3-b1ab-715090f8e146',
  tipo_pagamento: 'prazo',
  valor_total: 65.24,
  desconto: 0,
  parcelas: 1,
  valor_parcela: 65.24,
  data_venda: '2025-10-18',
  data_primeiro_vencimento: '2025-11-07',
  observacoes: null,
  status: 'concluida',
  origem: 'loja',
  eh_troca_devolucao: false,
  created_at: '2025-10-19T00:17:56.331009+00:00',
  updated_at: '2025-10-19T00:17:56.331009+00:00'
}
❌ Erro da consulta: null
💰 Venda à prazo: Valor total R$ 65.24
🏦 Gerando PIX: R$ 65.24 para venda 788d09e7-c6cb-409b-8014-5722fc63ec0b
🏦 Gerando PIX com dados: {
  valor: 65.24,
  descricao: 'Venda #VD20251018211756 - Liberi Kids',
  cliente_email: 'cliente@liberikids.com',
  cliente_nome: 'Tiago dos Santos',
  cliente_cpf: '00000000000',
  venda_id: '788d09e7-c6cb-409b-8014-5722fc63ec0b'
}
🔑 Access Token: Configurado
📤 Enviando dados para Mercado Pago: {
  "transaction_amount": 65.24,
  "description": "Venda #VD20251018211756 - Liberi Kids",
  "payment_method_id": "pix",
  "payer": {
    "email": "cliente@liberikids.com",
    "first_name": "Tiago dos Santos",
    "identification": {
      "type": "CPF",
      "number": "00000000000"
    }
  },
  "external_reference": "788d09e7-c6cb-409b-8014-5722fc63ec0b",
  "date_of_expiration": "2025-10-19T01:15:07.763Z"
}
✅ Resposta do Mercado Pago: {
  accounts_info: null,
  acquirer_reconciliation: [],
  additional_info: {
    tracking_id: 'platform:v22|v22.19.0,so:so;,type:SDK2.9.0,security:none'
  },
  authorization_code: null,
  binary_mode: false,
  brand_id: null,
  build_version: '3.123.1-hotfix-56',
  call_for_authorize_id: null,
  callback_url: null,
  captured: true,
  card: {},
  charges_details: [
    {
      accounts: [Object],
      amounts: [Object],
      client_id: 0,
      date_created: '2025-10-18T20:45:08.270-04:00',
      id: '130491595652-001',
      last_updated: '2025-10-18T20:45:08.270-04:00',
      metadata: [Object],
      name: 'mercadopago_fee',
      refund_charges: [],
      reserve_id: null,
      type: 'fee'
    }
  ],
  charges_execution_info: {
    internal_execution: {
      date: '2025-10-18T20:45:08.256-04:00',
      execution_id: '01K7WYTRQA18QBF60FXVT1TSBX'
    }
  },
  collector_id: 1338153931,
  corporation_id: null,
  counter_currency: null,
  coupon_amount: 0,
  currency_id: 'BRL',
  date_approved: null,
  date_created: '2025-10-18T20:45:08.268-04:00',
  date_last_updated: '2025-10-18T20:45:08.268-04:00',
  date_of_expiration: '2025-10-18T21:15:07.763-04:00',
  deduction_schema: null,
  description: 'Venda #VD20251018211756 - Liberi Kids',
  differential_pricing_id: null,
  external_reference: '788d09e7-c6cb-409b-8014-5722fc63ec0b',
  fee_details: [],
  financing_group: null,
  id: 130491595652,
  installments: 1,
  integrator_id: null,
  issuer_id: '12501',
  live_mode: true,
  marketplace_owner: null,
  merchant_account_id: null,
  merchant_number: null,
  metadata: {},
  money_release_date: null,
  money_release_schema: null,
  money_release_status: 'released',
  notification_url: null,
  operation_type: 'regular_payment',
  order: {},
  payer: {
    email: null,
    entity_type: null,
    first_name: null,
    id: '2915883442',
    identification: { number: null, type: null },
    last_name: null,
    operator_id: null,
    phone: { area_code: null, extension: null, number: null },
    type: null
  },
  payment_method: { id: 'pix', issuer_id: '12501', type: 'bank_transfer' },
  payment_method_id: 'pix',
  payment_type_id: 'bank_transfer',
  platform_id: null,
  point_of_interaction: {
    application_data: { name: null, operating_system: null, version: null },
    business_info: { branch: null, sub_unit: 'sdk', unit: 'online_payments' },
    location: { source: null, state_id: null },
    transaction_data: {
      bank_info: [Object],
      bank_transfer_id: null,
      e2e_id: null,
      financial_institution: null,
      merchant_category_code: null,
      qr_code: '00020126580014br.gov.bcb.pix01366b725c3b-5ebb-4ec2-86b5-55580006c7dc520400005303986540565.245802BR5924TIAGOTIAGO202303242009436009Sao Paulo62250521mpqrinter13049159565263042C4E',
      qr_code_base64: 'iVBORw0KGgoAAAANSUhEUgAABWQAAAVkAQMAAABpQ4TyAAAABlBMVEX///8AAABVwtN+AAAKvElEQVR42uzdQXIaP9MH4KFYsOQIHIWj4aNxFI7gJQsKfRU+BnVLGpP8nQTy1vPbuCgbzTPedbXUmkRERERERERERERERERERERERERERERERERERETkz2ZTuhynVSmf07Qv12nalvLx4++2P35zWV7kNE2lnH98qdw+3xa5LTbn/xc9/Fjktuj69vvbr3Y9gpaWlpaWlpaWlpaWlpb2N2hPzef5Afv7Fz/uDy73B9UF5wfOr3xuFt/WxQ6PxUJ2VZu+t6elpaWlpaWlpaWlpaV9Z20FbEY1byhXU7K2+eWqjHNJ+qoNr0xLS0tLS0tLS0tLS0v7j2lvCdqQ1PSc7l8+de3Ya1M4h/br3I7d0dLS0tLS0tLS0tLS0v4PaOem51zrltvPW437GWvd9kHDwjlr51e9qWlpaWlpaWlpaWlpaWlp/7i22S0cKvLPeFw0qG+veKkPOjUbfecmcV1kqpX5VBf5DXubaWlpaWlpaWlpaWlpaf+m9vnkosHQoYG2n1z0C4v8xjlLtLS0tLS0tLS0tLS0tH9MO8wq1bpTnFw0Hxf9suYdzL9tJxcdmjOo3wgtLS0tLS0tLS0tLS3t39Tu6r7b1DHdj0bWhi+l/bZ9ubqqHdOpvnLSnuITz/dFv9p/S0tLS0tLS0tLS0tLS/tabW561p9z0zM9eF334Q4fFLTt/ttD/Dxn0DlN97jQ0tLS0tLS0tLS0tLS0n5PW776220sqnOfd06z1fjR761bj5cmFw3yK3ubaWlpaWlpaWlpaWlpaV+lPd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8dHHMVF857BZu7i6lpaWlpaWlpaWlpaWlfTdtic3PwcjaKWrD0KHhzaElDh/aLmzF/YyF8jr9v76eXERLS0tLS0tLS0tLS0v7Wu1Af3zMv72mMjWd4jzFzmn7ykFba95VP/5o17zF3DndP9t/S0tLS0tLS0tLS0tLS0v769ppehwXPT4ecK0DdtPNoevhg+67hXNFfnjsHl6nCr1uPf6Vvc20tLS0tLS0tLS0tLS0r9Fu+i5sqnnb/m6qbbN2VqZm8b778iXtEu6H6H41uYiWlpaWlpaWlpaWlpb25drTqHNaSrj4ZJUe+BHL1V29ACXVvFM3PHd85rStedO+ZVpaWlpaWlpaWlpaWtq31C5vnU2Tiy715+D2lH6R9Kq5gK5nTcvw1CstLS0tLS0tLS0tLS0t7R/RhmOiZeG6lnmu0mnUND73w5oOjwOs4ZXTfOBz0++lpaWlpaWlpaWlpaWl/Ue0c8071TOmqeYNk4tK7fNW5Tx4t53Wm/SXdOa03jpz/q8VOi0tLS0tLS0tLS0tLe1f0va7hT9HZWtJx0Trzy8eNDxzujT+qG+70tLS0tLS0tLS0tLS0r6btp9cNJer16ZsvaTP0xQuQpkL52P9mfbfpho47L9NV7GkG0RpaWlpaWlpaWlpaWlpab+nFREREREREREREREREREREREREREREREREREREXnr/F8AAAD//4GE/cTJNCO8AAAAAElFTkSuQmCC',
      ticket_url: 'https://www.mercadopago.com.br/payments/130491595652/ticket?caller_id=2915883442&hash=9f34c5cf-3a2f-47f0-b3fd-d684da2beee5',
      transaction_id: null
    },
    type: 'OPENPLATFORM'
  },
  pos_id: null,
  processing_mode: 'aggregator',
  refunds: [],
  release_info: null,
  shipping_amount: 0,
  sponsor_id: null,
  statement_descriptor: null,
  status: 'pending',
  status_detail: 'pending_waiting_transfer',
  store_id: null,
  tags: null,
  taxes_amount: 0,
  transaction_amount: 65.24,
  transaction_amount_refunded: 0,
  transaction_details: {
    acquirer_reference: null,
    bank_transfer_id: null,
    external_resource_url: null,
    financial_institution: null,
    installment_amount: 0,
    net_received_amount: 0,
    overpaid_amount: 0,
    payable_deferral_period: null,
    payment_method_reference_id: null,
    total_paid_amount: 65.24,
    transaction_id: null
  },
  api_response: {
    status: 201,
    headers: [Object: null prototype] {
      date: [Array],
      'content-type': [Array],
      'transfer-encoding': [Array],
      connection: [Array],
      'cache-control': [Array],
      'content-encoding': [Array],
      etag: [Array],
      'processed-by': [Array],
      vary: [Array],
      'x-caller-id': [Array],
      'x-request-id': [Array],
      'x-response-status': [Array],
      'x-site-id': [Array],
      'x-content-type-options': [Array],
      'x-xss-protection': [Array],
      'strict-transport-security': [Array],
      'access-control-allow-origin': [Array],
      'access-control-allow-headers': [Array],
      'access-control-allow-methods': [Array],
      'access-control-max-age': [Array],
      'timing-allow-origin': [Array]
    }
  }
}
Erro ao salvar PIX na venda: {
  code: 'PGRST204',
  details: null,
  hint: null,
  message: "Could not find the 'metodo_pagamento' column of 'vendas' in the schema cache"
}
🔍 Gerando PIX para parcela: {
  id: 'b0acd589-e8e8-43e3-aac4-fc7e3157272f',
  fallbackVendaId: undefined,
  fallbackNumeroParcela: undefined
}
📝 Buscando parcela por ID: b0acd589-e8e8-43e3-aac4-fc7e3157272f
📊 Resultado da busca: { error: null, hasData: true }
🏦 Criando PIX Payment: {
  transaction_amount: 43.49,
  description: 'Parcela 1 - Venda VD20251018211409',
  payment_method_id: 'pix',
  payer: {
    email: 'tiago27.dossantos@gmail.com',
    first_name: 'Tiago',
    last_name: 'dos Santos',
    identification: { type: 'CPF', number: '00000000000' }
  }
}
🔑 Access Token: Configurado
📤 Enviando dados para Mercado Pago: {
  "transaction_amount": 43.49,
  "description": "Parcela 1 - Venda VD20251018211409",
  "payment_method_id": "pix",
  "payer": {
    "email": "tiago27.dossantos@gmail.com",
    "first_name": "Tiago",
    "last_name": "dos Santos",
    "identification": {
      "type": "CPF",
      "number": "00000000000"
    }
  },
  "date_of_expiration": "2025-10-19T01:15:26.065Z"
}
✅ PIX criado com sucesso: 129913545211
🔄 Iniciando devolucao para venda 227ed50d-48a6-4894-9eb2-b9ff200f5eb1
✅ Produto devolvido ao estoque: +1 unidades (total: 2)
✅ Item da venda atualizado: quantidade 0, valor R$ 0.00
✅ Devolução registrada no histórico
✅ Produto devolvido ao estoque: +1 unidades (total: 2)
✅ Item da venda atualizado: quantidade 0, valor R$ 0.00
✅ Devolução registrada no histórico
Error: ENOENT: no such file or directory, stat '/home/tiago/Downloads/app_estoque/client/build/index.html'
Error: ENOENT: no such file or directory, stat '/home/tiago/Downloads/app_estoque/client/build/index.html'
