API-3.0-PHP icon indicating copy to clipboard operation
API-3.0-PHP copied to clipboard

Alguma informação/documentação de como vamos poder integrar o PIX na API Cielo eCommerce ?

Open edson-nascimento opened this issue 4 years ago • 7 comments

Alguém sabe alguma informação sobre o PIX na API Cielo eCommerce ?

edson-nascimento avatar Nov 09 '20 18:11 edson-nascimento

Boa pergunta, também estou na expectativa.

souzadavi avatar Nov 10 '20 16:11 souzadavi

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.

Screenshot from 2021-02-28 17-12-14

souzadavi avatar Feb 28 '21 20:02 souzadavi

Que demora em implementar o pix. A pagseguro já tem!

marcosguilhermef avatar Oct 06 '21 13:10 marcosguilhermef

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

emalherbi avatar Aug 08 '22 14:08 emalherbi

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 image

edson-nascimento avatar Aug 08 '22 15:08 edson-nascimento

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 avatar Aug 09 '22 12:08 edson-nascimento

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

emalherbi avatar Aug 09 '22 16:08 emalherbi