Histórico de mensagens sobre url em pix

EXIBINDO CONVERSAS RECENTES:

Texto: url
Data: 21/08/2024
Canal: pix
Avatar discord do usuario rodrigo_90439

rodrigo_90439

Ver Respostas

$config = [
"certificado" => "./certificados/homologacao-certificado_cert.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',
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"],
CURLOPT_HTTPHEADER => array(
"Authorization: Basic $autorizacao",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);

curl_close($curl);

if(curl_errno($curl)) {
echo 'Erro no cURL: ' . curl_error($curl);
} else {
echo $response;
}

Avatar discord do usuario hiagosilvas

hiagosilvas

Ver Respostas

Envia o cURL ou a configuração realizada na SDK (ocultando credênciais Rodrigo). Talvez alguém ja tenha passado por isso e consiga te ajudar

Avatar discord do usuario rodrigo_90439

rodrigo_90439

Ver Respostas

@guilherme_efi Parece que não está carregando o certificado, pode me ajudar a resolver?
"Erro no cURL: could not load PEM client certificate, OpenSSL error error:80000002:system library::No such file or directory, (no key found, wrong pass phrase, or wrong file format?)"

Avatar discord do usuario rodrigo_90439

rodrigo_90439

Ver Respostas

Postman, deu certo agora.
Vou testar no CURL.

Avatar discord do usuario guilherme_efi

guilherme_efi

Ver Respostas

Esse mensagem você obteve na requisição com cURL ou no Postman?

Avatar discord do usuario rodrigo_90439

rodrigo_90439

Ver Respostas

eu enviaria as credenciais novamente?
CURLOPT_POSTFIELDS =>'{
"grant_type": "client_credentials",
"client_id": "' . CLIENT_ID . '",
"client_secret": "' . CLIENT_SECRET . '"
}',

Avatar discord do usuario guilherme_efi

guilherme_efi

Ver Respostas

Sim. utilizando o cURL deve usar o certificado convertido em .pem

Avatar discord do usuario guilherme_efi

guilherme_efi

Ver Respostas

Entendido. Sem problemas.
O erro provavelmente está no certificado. O CURL não reconhece o caminho do certificado sendo uma URL como havia colocado. Você deve colocar o caminho para o certificado no local do servidor.
Exemplo:

php
$config = [
"certificado" => "../certificado.pem",
"clientid" => "Client_Id???",
"client_secret" => "Client_Secret???"
];

Avatar discord do usuario rodrigo_90439

rodrigo_90439

Ver Respostas

Tudo bem Guilherme.
Eu gostaria de utilizar o CURL mesmo, não quero utilizar o SDK em minha aplicação, tem como me ajudar?
$config = [
"certificado" => "certificado.pem",
"client_id" => "Client_Id???",
"client_secret" => "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",
CURLOPT_URL => "https://pagarcontas.api.efipay.com.br/v1/oauth/token",
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 "
";

Avatar discord do usuario stoliarskiykostiantyn

stoliarskiykostiantyn

class Endpoints(object):

def __init__(self, options):
super(Endpoints, self).__init__()
self.token = None
self.options = options

def __getattr__(self, name):
print('PRINT ENDPOINT NAME -><><><>',name)
if name in Constants.APIS['PIX']['ENDPOINTS']:
self.endpoints = Constants.APIS['PIX']['ENDPOINTS']
self.urls = Constants.APIS['PIX']['URL']
elif name in Constants.APIS['OPEN-FINANCE']['ENDPOINTS']:
self.endpoints = Constants.APIS['OPEN-FINANCE']['ENDPOINTS']
self.urls = Constants.APIS['OPEN-FINANCE']['URL']
elif name in Constants.APIS['PAYMENTS']['ENDPOINTS']:
self.endpoints = Constants.APIS['PAYMENTS']['ENDPOINTS']
self.urls = Constants.APIS['PAYMENTS']['URL']
elif name in Constants.APIS['OPENING-ACCOUNTS']['ENDPOINTS']:
self.endpoints = Constants.APIS['OPENING-ACCOUNTS']['ENDPOINTS']
self.urls = Constants.APIS['OPENING-ACCOUNTS']['URL']
else:
self.endpoints = Constants.APIS['CHARGES']['ENDPOINTS']
self.urls = Constants.APIS['CHARGES']['URL']
self.options['certificate'] = None
print('Setting certificate to None')
self.get_url()
return partial( self.request, self.endpoints[name])

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!