Histórico de mensagens sobre credentials em pix

EXIBINDO CONVERSAS RECENTES:

Texto: credentials
Canal: pix
Avatar discord do usuario stoliarskiykostiantyn

stoliarskiykostiantyn

Hi everyone! Could someone help me please! I'm trying to implement EfiPay to send payment to pix with such code from python sdk from github repo https://github.com/efipay/sdk-python-apis-efi

Code looks like this now:

class EfiClient:
EFI_FT_PIX_KEY: str
EFI_FT_PIX_WEBHOOK_URL: str
efi: EfiPay
creds: s.EfiCredentials

def configure(self, config: BaseConfig):
# Notion: Sandbox = False on prod machine
self.creds = s.EfiCredentials(
client_id=config.EFI_CLIENT_ID,
client_secret=config.EFI_CLIENT_SECRET,
sandbox=config.EFI_IS_SANDBOX,
certificate=config.EFI_CERTIFICATE,
)

self.efi = EfiPay(self.creds.model_dump())
self.EFI_FT_PIX_KEY = config.EFI_FT_PIX_KEY
self.EFI_FT_PIX_WEBHOOK_URL = config.EFI_FT_PIX_WEBHOOK_URL

And the toruble is that efipay class doesn't acceprt certificates, support told me to chage base_url BUT there no way to do it! Help please) Would be very grateful!

Avatar discord do usuario felipenunes0714

felipenunes0714

Ver Respostas

400
webhook_invalido
A autenticação de TLS mútuo não está configurada na URL informada
{
"Server": [
"nginx"
],
"Date": [
"Tue, 06 Aug 2024 20:01:54 GMT"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"111"
],
"Connection": [
"keep-alive"
],
"x-request-id": [
"aeaebb97-0acd-4c9c-a641-1bbfbe59461b"
],
"Vary": [
"Origin"
],
"Access-Control-Allow-Credentials": [
"true"
],
"ETag": [
"W/\"6f-u8LmFRZhTY5OErn2m2iNSr2g7AI\""
]
}


alguém consegue me dar uma base de como fuciona o código de recebimento da url? li a documentação e não estou conseguindo resolver isso

Avatar discord do usuario felipenunes0714

felipenunes0714

Ver Respostas

me retornou o seguinte erro:


400
json_invalido
Parâmetro ".headers['x-skip-mtls-checking']", deve ser igual a um dos valores predefinidos
{
"Server": [
"nginx"
],
"Date": [
"Tue, 06 Aug 2024 18:59:18 GMT"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"241"
],
"Connection": [
"keep-alive"
],
"x-request-id": [
"xxxx"
],
"Vary": [
"Origin"
],
"Access-Control-Allow-Credentials": [
"true"
],
"ETag": [
"xxx""
]
}

Avatar discord do usuario felipenunes0714

felipenunes0714


/
Detailed endpoint documentation
https://dev.efipay.com.br/docs/api-pix/webhooks#configurar-o-webhook-pix
/

$autoload = realpath(__DIR__ . "../../../../../../../vendor/autoload.php");
if (!file_exists($autoload)) {
die("Autoload file not found or on path $autoload.");
}
require_once $autoload;

use Efi\Exception\EfiException;
use Efi\EfiPay;

$optionsFile = __DIR__ . "/../../credentials/options.php";
if (!file_exists($optionsFile)) {
die("Options file not found or on path $options.");
}
$options = include $optionsFile;

$options["headers"] = [
"x-skip-mtls-checking" => false
];

$params = [
"chave" => ""
];

$body = [
"webhookUrl" => ""
];


try {
$api = new EfiPay($options);
$response = $api->pixConfigWebhook($params, $body);

if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("

" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
print_r("
" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
} else {
print_r("
" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (EfiException $e) {
print_r($e->code . "
");
print_r($e->error . "
");
print_r($e->errorDescription) . "
";
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("
" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (Exception $e) {
print_r($e->getMessage());
}

Avatar discord do usuario felipenunes0714

felipenunes0714

Ver Respostas


/
Detailed endpoint documentation
https://dev.efipay.com.br/docs/api-pix/webhooks#configurar-o-webhook-pix
/

$autoload = realpath(__DIR__ . "/../../../vendor/autoload.php");
if (!file_exists($autoload)) {
die("Autoload file not found or on path $autoload.");
}
require_once $autoload;

use Efi\Exception\EfiException;
use Efi\EfiPay;

$optionsFile = __DIR__ . "/../../credentials/options.php";
if (!file_exists($optionsFile)) {
die("Options file not found or on path $options.");
}
$options = include $optionsFile;

$options["headers"] = [
"x-skip-mtls-checking" => false
];

$params = [
"chave" => "12345"
];

$body = [
"webhookUrl" => "www.meulink.com"
];

try {
$api = new EfiPay($options);
$response = $api->pixConfigWebhook($params, $body);

if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("

" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
print_r("
" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
} else {
print_r("
" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (EfiException $e) {
print_r($e->code . "
");
print_r($e->error . "
");
print_r($e->errorDescription) . "
";
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("
" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (Exception $e) {
print_r($e->getMessage());
}

Avatar discord do usuario gustavojr5502

gustavojr5502

Ola boa tarde ! Estou com problema na chamada do PixCreateImmediateCharge o erro do retorno é esse: "Could not authenticate. Please make sure you are using correct credentials and if you are using then in the correct environment.com"

Avatar discord do usuario felipenunes0714

felipenunes0714

Ver Respostas

$config = [
"certificado" => "./producao.pem",
"client_id" => "",
"client_secret" => ""
];


$autorizacao = base64_encode($config["client_id"] . ":" . $config["client_secret"]);

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://pix-h.api.efipay.com.br/oauth/token", // Rota base, homologação ou produção
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"grant_type": "client_credentials"}',
CURLOPT_SSLCERT => $config["certificado"], // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic $autorizacao",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);

curl_close($curl);

echo "

";
echo $response;
echo "
";
?>

eu estou chamando essa chamada simples da documentação, e ela me retorna a pagina em branco ao invés de retornar o token

Avatar discord do usuario frankkafka

frankkafka

js
const EfiPay = require('sdk-node-apis-efi')
const options = require('../../credentials')

let params = {
id: '95',
}

const efipay = new EfiPay(options)
console.log(efipay);

efipay.pixGenerateQRCode(params)
.then((resposta) => {
console.log(resposta)
})
.catch((error) => {
console.log(error)
})

Avatar discord do usuario _acb09

_acb09

Ver Respostas

O meu código está assim:

$config = [];
$config["certificado"] = config("services.efipay.certificate_path");
$config["client_id"] = config("services.efipay.client_id");
$config["client_secret"] = config("services.efipay.client_secret");

$headers = [];
$headers['Authorization'] = "Basic " . base64_encode($config["client_id"] . ":" . $config["client_secret"]);
$headers['Content-Type'] = 'application/json';

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://pix-h.api.efipay.com.br/oauth/token", // Rota base, homologação ou produção
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 60,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"grant_type": "client_credentials"}',
CURLOPT_SSLCERT => $config["certificado"], // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => $headers
));

$response = curl_exec($curl);

if (curl_errno($curl)) {
dd('Error:' . curl_error($curl));
}

curl_close($curl);

dd($response);

Avatar discord do usuario guilherme_efi

guilherme_efi

Ver Respostas

Provavelmente será isto.
Em nossa documentação técnica tem uma sessão sobre isto: https://dev.efipay.com.br/docs/api-pix/credenciais/#convers%C3%A3o-de-certificado-p12-para-o-formato-pem
Você pode usar este link para fazer a conversão do certificado: https://efipay.github.io/encode-credentials/certificado.html
Despois é só baixar o certificado, e este convertido você inseir no diretório.

Avatar discord do usuario d_coder_

d_coder_

Ver Respostas

pessoal quando estou fazendo a requisição para conseguir o access_token tenho como reposta
{"error":"invalid_client","error_description":"Invalid or inactive credentials"}
Isso é o certificado que esta errado ou as credenciais, client id e secrect que estão ? Tipo estou usando a url e homologação.

Avatar discord do usuario rubenskuhl

rubenskuhl

Ver Respostas

cob.write é escopo. Tem que ser client_credentials.

Avatar discord do usuario rubenskuhl

rubenskuhl

Ver Respostas

Parece que está faltando o

'{"grant_type": "client_credentials"}',

Avatar discord do usuario joaolucas_efi

joaolucas_efi

Ver Respostas

A requisição não esta enviado os campos corretos, um exemplo de envio seria esse aqui:

py

# encoding: utf-8

from efipay import EfiPay
from ...credentials import credentials

efi = EfiPay(credentials.CREDENTIALS)


params = {
'idEnvio': 1
}

body = {
'valor': '0.01',
'pagador': {
'chave': '' # Sua chave aqui
},
'favorecido': {
'chave': '' # Chave de quem vai receber aqui
}
}

response = efi.pix_send(params=params, body=body)
print(response)

Também informamos que é para habilitar o endpoint de Envio de Pix em produção, é necessário preencher este formulário. Após o preenchimento, basta aguardar que entraremos em contato.

Avatar discord do usuario diogojunior.

diogojunior.

def enviar_pagamento_pix(chave_pix, valor):
try:
efi = EfiPay(credentials)

# Corpo da requisição para enviar um pagamento PIX
body = {
'valor': {
'original': valor # Valor da transferência
},
'chave': chave_pix, # Chave PIX do destinatário
'infoPagador': 'Pagamento pelos serviços prestados.' # Informação adicional
}

# Tentando diferentes métodos para enviar o pagamento PIX
response = None
if hasattr(efi, 'pix_send_payment'):
response = efi.pix_send_payment(body=body)
elif hasattr(efi, 'pix_transfer'):
response = efi.pix_transfer(body=body)
else:
raise AttributeError("Nenhum método encontrado para enviar pagamento PIX.")

print("Resposta da API:", response)

except Exception as e:
print(f"Erro ao enviar pagamento PIX: {e}")
sys.exit(1)

if __name__ == "__main__":
chave_pix, valor = obter_dados_usuario()
enviar_pagamento_pix(chave_pix, valor)

Avatar discord do usuario diogojunior.

diogojunior.

# encoding: utf-8

from efipay import EfiPay
import sys

# Configurações de credenciais
credentials = {
'client_id': '',
'client_secret': '',
'sandbox': False, # Altere para True se estiver usando o ambiente de sandbox
'certificate': r''
}

def obter_dados_usuario():
try:
chave_pix = input("Informe a chave PIX do destinatário: ")
valor = input("Informe o valor da transferência: ")

# Verificando se os valores informados são válidos
if not chave_pix:
raise ValueError("A chave PIX não pode ser vazia.")

# Substituir vírgula por ponto e converter para float
valor_float = float(valor.replace(',', '.'))

if valor_float <= 0:
raise ValueError("O valor deve ser um número positivo.")

return chave_pix, "{:.2f}".format(valor_float)
except ValueError as ve:
print(f"Erro de validação: {ve}")
sys.exit(1)

Avatar discord do usuario joaolucas_efi

joaolucas_efi

Ver Respostas

This is correct, but in this case the credentials that you use are not from the account that own the self.EFI_FT_PIX_KEY.

Avatar discord do usuario _franciscovieira

_franciscovieira

json {"grant_type":"client_credentials"}

Avatar discord do usuario _franciscovieira

_franciscovieira

Boa tarde pessoal
Estou com uma dúvida aqui
params.put("grant_type", "client_credentials");

String json = g.toJson(new GrantType("client_credentials"));

Esse cara está me retornando que está fatando grantType