@rubenskuhl obrigado pelo retorno, eu tentei integrar no meu Controller (uso nestjs) na minha API que está no heroku, aqui está o código:
import {
ClassSerializerInterceptor,
Controller,
HttpCode,
HttpStatus,
Logger,
Post,
Req,
UseInterceptors,
} from '@nestjs/common';
import { LoggerInterceptor } from '@src/common/logger/logger-interceptor';
import configuration from '@src/config/configuration';
import axios from 'axios';
import { Request } from 'express';
import as https from 'https';
const { httpsOptions } = configuration();
@Controller('efi-gerencianet')
@UseInterceptors(ClassSerializerInterceptor, LoggerInterceptor)
export class EfiGerencianetController {
private readonly logger = new Logger(EfiGerencianetController.name);
private instance = axios.create({
httpsAgent: new https.Agent({
ca: httpsOptions.ca,
requestCert: true,
rejectUnauthorized: true,
}),
headers: {
'x-skip-mtls-checking': true,
},
});
@Post('webhook/pix')
@HttpCode(HttpStatus.OK)
handlePixCallback(@Req() req: Request) {
const body = req.body;
this.logger.log(Received callback from Gerencianet);
this.logger.debug(body);
return body;
}
@Post('configure-webhook')
async configureWebhook() {
const url =
'https://api-pix.gerencianet.com.br/v2/webhook/4114c4e9-202c-4979-8534-34a4e5a29ad0';
const data = {
webhookUrl: '',
};
try {
const response = await this.instance.put(url, data);
this.logger.log(
Webhook configured successfully. Status code: ${response.status},
);
return response.data;
} catch (error) {
this.logger.error(Error configuring webhook: ${error.message});
throw new Error(Error configuring webhook: ${error.message});
}
}
}
subi pra produção, e ao chamar o endpoint recebo o erro: Error: Error configuring webhook: read ECONNRESET
Para SSL estou usando o heroku ACM (auto managed).
Sabem o que posso estar fazendo errado?