Histórico de mensagens sobre php

EXIBINDO CONVERSAS RECENTES:

Texto: php
# pix
Avatar discord do usuario vinicio254

vinicio254

estou utilizando php e até agora não consegui cadastrar o webhook usando curl , falta isso

# pix
Avatar discord do usuario guilherme_efi

guilherme_efi

Ver Respostas

Bom dia, @roxzin! Como vai?
Aqui está um código que funciona:

php

$homolog = true; // false para produção

$config = [
"certificado" => realpath(__DIR__ . "/certificado.pem"), // certificado em .pem de produção ou homologação
"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 => $homolog ? "https://pix-h.api.efipay.com.br/oauth/token" : "https://pix.api.efipay.com.br/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 8,
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"
),
));
var_dump(curl_exec($curl));
$returnAuth = json_decode(curl_exec($curl), true);
$access_token = $returnAuth['access_token'];
curl_close($curl);


//Criação da cobrança
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => $homolog ? 'https://pix-h.api.efipay.com.br/v2/cob/' : 'https://pix.api.efipay.com.br/v2/cob/',
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 => '{
"calendario": {
"expiracao": 3600
},
"devedor": {
"cpf": "12345678909",
"nome": "Francisco da Silva"
},
"valor": {
"original": "0.45"
},
"chave": "[email protected]"
}',
CURLOPT_SSLCERT => $config["certificado"], // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer $access_token",
"Content-Type: application/json"
),
));
$responsePix = json_decode(curl_exec($curl), true);
curl_close($curl);

echo '
' . json_encode($responsePix, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . '
';

if ($responsePix['loc']['id']) {
$idlocationPix = $responsePix['loc']['id'];

// Obtêm o Pix Copia e Cola e QR Code
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => $homolog ? 'https://pix-h.api.efipay.com.br/v2/loc/' . $idlocationPix . '/qrcode' : 'https://pix.api.efipay.com.br/v2/loc/' . $idlocationPix . '/qrcode',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_SSLCERT => $config["certificado"], // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer $access_token",
),
));

$response = json_decode(curl_exec($curl), true);

curl_close($curl);


$PixCopiaCola = $response['qrcode'];
$imagemQrcode = $response['imagemQrcode'];


echo 'QR Code:';
echo '
' . json_encode($PixCopiaCola, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . '
';

echo 'Imagem:
';
echo '';
}
Também temos nossa SDK de PHP (https://github.com/efipay/sdk-php-apis-efi), que usa o Guzzle.

# pix
Avatar discord do usuario roxzin

roxzin

Ver Respostas

Bom dia, alguem tem um codigo funcional em php usando curl apenas para gerar qrcode dinamico? tudo que encontro é desatualizo e nao funciona direito.

# freelancer
Avatar discord do usuario _shinjisakai_

_shinjisakai_

css
[FOR HIRE] [Remote] [Full-stack] [Full-time]
--------------------------------------------
I am looking for a remote job or task as I am a senior full-stack dev.
diff
- Background:
- Dev who creates highly stable code based on powerful mathematical algorithm.
- Dev who works while maintaining a good relationship with the client.
- Dev that provides perfect results on time and flexible timezone.
- Dev that keeps each 50% work and 50% communication.

- Skillset:
+ Frontend:
- JavaScript / TypeScript / React / Redux / Next / Gatsby / React Native / Vue / Angular
- Tailwind CSS / Material UI / Styled-component / BootStrap
+ Backend:
- Laravel / CI / PHP / Python / Django
- Node / Express / Nest
+ DB Management:
- MySQL / MongoDB / PostgreSQL / Firebase
+ SVN and Agile Methods:
- Github / Gitlab / BitBucket / Git
- Jira / Trello / Notion
+ Cloud Services:
- AWS Lamda / S3 / EC2 / RDS / Cognito
- Firebase / Heroku / GCP
- Microsoft Azure

✨ Sincerely.

# dúvidas
Avatar discord do usuario guilherme_efi

guilherme_efi

Ver Respostas

Bom dia, @esdrasfyy! Tudo bem?
Você está implementando a SDK de PHP com Laravel, certo?
Verifique se no arquivo de credenciais está debub => true e troque para debug => false ou para debug => fopen('php://stderr', 'w').

# dúvidas
Avatar discord do usuario esdrasfyy

esdrasfyy

Ver Respostas

'pix_cert' => public_path('certs/certificate-chain-prod.crt'),

alguem que manja de php e efipay ai me da uma ajuda aqui, estou cadastrando o webhook e passando o pix_cet porem ta dando esse erro

"curl_setopt_array(): Cannot represent a stream of type Output as a STDIO FILE"

# freelancer
Avatar discord do usuario _shinjisakai_

_shinjisakai_

css
[FOR HIRE] [Remote] [Full-stack] [Full-time]
--------------------------------------------
I am looking for a remote job or task as I am a senior full-stack dev.
diff
- Background:
- Dev who creates highly stable code based on powerful mathematical algorithm.
- Dev who works while maintaining a good relationship with the client.
- Dev that provides perfect results on time and flexible timezone.
- Dev that keeps each 50% work and 50% communication.

- Skillset:
+ Frontend:
- JavaScript / TypeScript / React / Redux / Next / Gatsby / React Native / Vue / Angular
- Tailwind CSS / Material UI / Styled-component / BootStrap
+ Backend:
- Laravel / CI / PHP / Python / Django
- Node / Express / Nest
+ DB Management:
- MySQL / MongoDB / PostgreSQL / Firebase
+ SVN and Agile Methods:
- Github / Gitlab / BitBucket / Git
- Jira / Trello / Notion
+ Cloud Services:
- AWS Lamda / S3 / EC2 / RDS / Cognito
- Firebase / Heroku / GCP
- Microsoft Azure

✨ Sincerely.

# dúvidas
Avatar discord do usuario luizfeleal

luizfeleal

Ver Respostas

Eu tenho um código em php que faz isso, e também já testei utilizando o conversor de vocês, mas o mesmo erro é retornado

# dúvidas
Avatar discord do usuario luizfeleal

luizfeleal

Ver Respostas

recebi esse erro com o arquivo .p12:
Exception: could not load PEM client certificate from /projeto_maquina_api/storage/app/Certificados/certificate12.p12, OpenSSL error error:0480006C:PEM routines::no start line, (no key found, wrong pass phrase, in file /projeto_maquina_api/app/Services/Efi/AuthService.php on line 62

# dúvidas
Avatar discord do usuario luizfeleal

luizfeleal

Ver Respostas

Agora o erro retornado é esse:
Exception: unable to set private key file: '/projeto_maquina_api/storage/app/Certificados/certificate12.pem' type PEM in file /projeto_maquina_api/app/Services/Efi/AuthService.php on line 59

# dúvidas
Avatar discord do usuario joaolucas_efi

joaolucas_efi

Ver Respostas

@luizfeleal existem algumas falha em como você montou a requisição, segue um exemplo de como fazer a autenticação:

php
//Desenvolvido pela Consultoria Técnica da Efí
$config = [
"certificado" => "./certificado.pem",
"client_id" => "YOUR-CLIENT-ID",
"client_secret" => "YOUR-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 "
";
?>

# pix
Avatar discord do usuario claudinei02368

claudinei02368

Ver Respostas

PHP 7.4.33, WordPress 6.6.1, woocommerce 9.2.3, EFI 2.3.0

# pix
Avatar discord do usuario igor_efi

igor_efi

Ver Respostas

Qual versão do PHP, Wordpress, Wocommerce e Plugin Efí você esta utilizando?

# freelancer
Avatar discord do usuario _shinjisakai_

_shinjisakai_

css
[FOR HIRE] [Remote] [Full-stack] [Full-time]
diff
- Background:
- Dev who creates highly stable code based on powerful mathematical algorithm.
- Dev who works while maintaining a good relationship with the client.
- Dev that provides perfect results on time and flexible timezone.
- Dev that keeps each 50% work and 50% communication.

- Skillset:
+ Frontend:
- JavaScript / TypeScript / React / Redux / Next / Gatsby / React Native / Vue / Angular
- Tailwind CSS / Material UI / Styled-component / BootStrap
+ Backend:
- Laravel / CI / PHP / Python / Django
- Node / Express / Nest
+ DB Management:
- MySQL / MongoDB / PostgreSQL / Firebase
+ SVN and Agile Methods:
- Github / Gitlab / BitBucket / Git
- Jira / Trello / Notion
+ Cloud Services:
- AWS Lamda / S3 / EC2 / RDS / Cognito
- Firebase / Heroku / GCP
- Microsoft Azure

✨ Sincerely.

# módulos-plugins
Avatar discord do usuario jessica_efi

jessica_efi

Ver Respostas

Estamos analisando se pode ser algo relacionado ao plugin ou à versão do php/cURL.

# pix
Avatar discord do usuario hiagosilvas

hiagosilvas

Ver Respostas

php
$config [
"certificado" => "../certificados/homologacao-certificado_cert.pem",
"client_id" => "???",
"client_secret" => "???"
];

# pix
Avatar discord do usuario hiagosilvas

hiagosilvas

Ver Respostas

Ah sim, seu script php está em qual diretório?

# pix
Avatar discord do usuario hiagosilvas

hiagosilvas

Ver Respostas

Seu script php tá no / do SO?

# pix
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???"
];