50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
const { MercadoPagoConfig, Payment } = require('mercadopago');
|
|
|
|
// Teste simples do PIX
|
|
async function testePix() {
|
|
try {
|
|
console.log('🧪 Testando PIX com credenciais...');
|
|
|
|
const client = new MercadoPagoConfig({
|
|
accessToken: process.env.MERCADOPAGO_ACCESS_TOKEN,
|
|
options: { timeout: 5000 }
|
|
});
|
|
|
|
const payment = new Payment(client);
|
|
|
|
const payment_data = {
|
|
transaction_amount: 1.00,
|
|
description: 'Teste PIX - Liberi Kids',
|
|
payment_method_id: 'pix',
|
|
payer: {
|
|
email: 'test@test.com',
|
|
first_name: 'Test',
|
|
last_name: 'User',
|
|
identification: {
|
|
type: 'CPF',
|
|
number: '12345678909'
|
|
}
|
|
}
|
|
};
|
|
|
|
console.log('📤 Dados enviados:', JSON.stringify(payment_data, null, 2));
|
|
|
|
const result = await payment.create({ body: payment_data });
|
|
|
|
console.log('✅ Sucesso! PIX criado:', {
|
|
id: result.id,
|
|
status: result.status,
|
|
qr_code: result.point_of_interaction?.transaction_data?.qr_code ? 'Gerado' : 'Não gerado'
|
|
});
|
|
|
|
} catch (error) {
|
|
console.error('❌ Erro:', error);
|
|
if (error.cause) {
|
|
console.error('📋 Detalhes:', error.cause);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Executar teste
|
|
testePix();
|