API-3.0-PHP
API-3.0-PHP copied to clipboard
Alguma informação/documentação de como vamos poder integrar o PIX na API Cielo eCommerce ?
Alguém sabe alguma informação sobre o PIX na API Cielo eCommerce ?
Boa pergunta, também estou na expectativa.
Aparentemente sem previsão de quando irão implementar na CIELO API. Perguntei em dezembro sobre o assunto para o pessoal. Também tenho interesse no assunto.
Que demora em implementar o pix. A pagseguro já tem!
Opa,
Eu fiz por fora a chamada e deu boa, segue código...
Abraços
/*
$url = https://api.cieloecommerce.cielo.com.br/1/sales/
$obj = new stdClass();
$obj->MerchantOrderId = date('YmdHis');
$obj->Customer = new stdClass();
$obj->Customer->Name = 'Seu nome';
$obj->Customer->Identity = 'CPF';
$obj->Customer->IdentityType = 'NRO DO CPF';
$obj->Payment = new stdClass();
$obj->Payment->Type = 'Pix';
$obj->Payment->Amount = (float) '001'; // = R$ 0,01
*/
public function curlPOST($url, $merchantId, $merchantKey, $obj)
{
$headers = array(
'Content-Type: application/json',
'MerchantId: '.$merchantId,
'MerchantKey: '.$merchantKey,
'RequestId: '.uniqid(),
);
$curl = curl_init($url);
curl_setopt($curl, \CURLOPT_SSLVERSION, \CURL_SSLVERSION_TLSv1_2);
curl_setopt($curl, \CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, \CURLOPT_POST, true);
curl_setopt($curl, \CURLOPT_POSTFIELDS, json_encode($obj));
curl_setopt($curl, \CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, \CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
$statusCode = curl_getinfo($curl, \CURLINFO_HTTP_CODE);
$message = '';
if (curl_errno($curl)) {
$message = sprintf('cURL error[%s]: %s', curl_errno($curl), curl_error($curl));
}
curl_close($curl);
$result = new stdClass();
$result->response = $response;
$result->statusCode = $statusCode;
$result->message = $message;
return $result;
}
A documentação da api foi atualizada, mas provavelmente eles não vão atualizar essa sdk php já que parece que abandonaram.
https://developercielo.github.io/manual/cielo-ecommerce#pix
Opa,
Eu fiz por fora a chamada e deu boa, segue código...
Abraços
/* $url = https://api.cieloecommerce.cielo.com.br/1/sales/ $obj = new stdClass(); $obj->MerchantOrderId = date('YmdHis'); $obj->Customer = new stdClass(); $obj->Customer->Name = 'Seu nome'; $obj->Customer->Identity = 'CPF'; $obj->Customer->IdentityType = 'NRO DO CPF'; $obj->Payment = new stdClass(); $obj->Payment->Type = 'Pix'; $obj->Payment->Amount = (float) '001'; // = R$ 0,01 */ public function curlPOST($url, $merchantId, $merchantKey, $obj) { $headers = array( 'Content-Type: application/json', 'MerchantId: '.$merchantId, 'MerchantKey: '.$merchantKey, 'RequestId: '.uniqid(), ); $curl = curl_init($url); curl_setopt($curl, \CURLOPT_SSLVERSION, \CURL_SSLVERSION_TLSv1_2); curl_setopt($curl, \CURLOPT_SSL_VERIFYPEER, true); curl_setopt($curl, \CURLOPT_POST, true); curl_setopt($curl, \CURLOPT_POSTFIELDS, json_encode($obj)); curl_setopt($curl, \CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, \CURLOPT_HTTPHEADER, $headers); $response = curl_exec($curl); $statusCode = curl_getinfo($curl, \CURLINFO_HTTP_CODE); $message = ''; if (curl_errno($curl)) { $message = sprintf('cURL error[%s]: %s', curl_errno($curl), curl_error($curl)); } curl_close($curl); $result = new stdClass(); $result->response = $response; $result->statusCode = $statusCode; $result->message = $message; return $result; }
Conseguiu fazer funcionar em sandbox @emalherbi ?
@edson-nascimento eu testei direto em ambiente de produção e deu boa... Fiz PIX de 001 (R$ 0,01) e 050 (R$ 0,50)