chore: sincroniza projeto para gitea
This commit is contained in:
@@ -57,6 +57,39 @@ class MercadoPagoService {
|
||||
}
|
||||
}
|
||||
|
||||
async createPixPayment(paymentData) {
|
||||
try {
|
||||
console.log('🏦 Criando PIX Payment:', paymentData);
|
||||
console.log('🔑 Access Token:', process.env.MERCADOPAGO_ACCESS_TOKEN ? 'Configurado' : 'NÃO CONFIGURADO');
|
||||
|
||||
if (!this.payment) {
|
||||
throw new Error('MercadoPago não configurado. Verifique o MERCADOPAGO_ACCESS_TOKEN no .env');
|
||||
}
|
||||
|
||||
const payment_data = {
|
||||
transaction_amount: parseFloat(paymentData.transaction_amount),
|
||||
description: paymentData.description,
|
||||
payment_method_id: paymentData.payment_method_id || 'pix',
|
||||
payer: paymentData.payer,
|
||||
date_of_expiration: new Date(Date.now() + 30 * 60 * 1000).toISOString() // 30 minutos
|
||||
};
|
||||
|
||||
if (paymentData.external_reference) {
|
||||
payment_data.external_reference = paymentData.external_reference.toString();
|
||||
}
|
||||
|
||||
console.log('📤 Enviando dados para Mercado Pago:', JSON.stringify(payment_data, null, 2));
|
||||
const payment = await this.payment.create({ body: payment_data });
|
||||
console.log('✅ PIX criado com sucesso:', payment.id);
|
||||
|
||||
return payment;
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Erro ao criar PIX:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async consultarPagamento(payment_id) {
|
||||
try {
|
||||
const payment = await this.payment.get({ id: payment_id });
|
||||
|
||||
Reference in New Issue
Block a user