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);