axios
.post('https://api-pix-h.gerencianet.com.br/oauth/token', data, {
headers: {
Authorization: Basic ${auth},
'Content-Type': 'application/json'
},
httpsAgent: agent,
})
.then((response) => {
const accessToken = response.data?.access_token;
console.log(JSON.stringify(response.data));
const endpoint = 'https://api-pix-h.gerencianet.com.br/v2/cob';
const dataCob = {
calendario: {
"expiracao": 3600
},
devedor: {
"cpf": "12345678910",
"nome": "John Doe"
},
valor: {
"original": "123.45"
},
chave: "d6d67ce2-9225-4902-b298-e7b86d1b6a3a",
solicitacaoPagador: "Informe o número ou identificador do pedido."
}
const config = {
httpsAgent: agent,
headers: {
Authorization: Bearer ${accessToken},
'Content-Type': 'application/json'
}
}
axios.post(endpoint, dataCob, config).then(console.log)
})
.catch(error => {
console.error(error);
});