PHP code example of levicosta201 / gerencianet-pix-sdk

1. Go to this page and download the library: Download levicosta201/gerencianet-pix-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

levicosta201 / gerencianet-pix-sdk example snippets


//Aqui são aceitos dois parâmetros em forma de string, homolog ou production
$connect = new Gerencianet\Pix\Connect('production');
//Aqui você você precisa informar apenas o caminho do seu certificado .pem fornecido pela GN
$connect = $connect->setCertFile('PATH_TO_CERT_FILE')
    ->setClientId(env('GERENCIA_NET_CLIENT_ID'))
    ->setClientSecret(env('GERENCIA_NET_CLIENT_SECRET'));
return $connect->proccess();

[▼
  "data" => array:2 [▼
    "accessToken" => "AQUI_IRA_VIR_SEU_TOKEN_DE_ACESSO ▶"
    "tokenType" => "Bearer"
  ]
]

$pixCharge = new Gerencianet\Pix\Charge('production');
$pixCharge = $pixCharge->setCepDebtor('12300999')
    ->setCityDebtor('CIDADE_DE_QUEM_PAGA')
    ->setFreeValue(false)
    ->setNameDebtor('Nome de quem paga')
    ->setCpfCnpjDebtor('CPF_DEQUEM_PAGA')
    ->setValue(10.0)
    ->setType('estatico')
    ->setDescriptionService('Teste de descrição')
    ->setDimenQrCoode(256)
    ->setUniquePay(true)
    ->setExpiresTimeQrCode(3600)
    ->setAccessToken($authData['accessToken'])
    ->setTokenType('TIPO_TOKEN_RETORNO_API')
    ->setKeyPix('SUA_CHAVE_PIX_GN');
return $pixCharge->create();

array:4 [▼
  "success" => "true"
  "barCode" => "CODIGO_DE_BARRAS"
  "qrCodeBase64" => "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAABlB"
  "pixData" => array:7 [▼
    "calendario" => array:1 [▼
      "expiracao" => "3600"
    ]
    "devedor" => array:2 [▼
      "cpf" => "CPF_PAGADOR"
      "nome" => "NOME_PAGADOR"
    ]
    "valor" => array:1 [▼
      "original" => 0.01
    ]
    "chave" => "28656307000164"
    "solicitacaoPagador" => "Teste de descrição"
    "txid" => "5m6KHjHtDP2a 5Yva30gWjMrA"
  ]
]

$authData = PixService::auth();
$issuedPix = new Issued();
$issuedPix = $issuedPix->setInitDate("2020-12-09" . "T00:00:00Z")
    ->setEndDate("2021-12-12" . "T00:00:00Z")
    ->setCertFile(self::getCertFile())
    ->setTokenType($authData['tokenType'])
    ->setAccessToken($authData['accessToken']);

return $issuedPix->list();

array:2 [▼
  "parametros" => array:3 [▼
    "inicio" => "2020-12-09T00:00:00Z"
    "fim" => "2021-12-12T00:00:00Z"
    "paginacao" => array:4 [▼
      "paginaAtual" => 0
      "itensPorPagina" => 100
      "quantidadeDePaginas" => 1
      "quantidadeTotalDeItens" => 1
    ]
  ]
  "pix" => array:1 [▼
    0 => array:4 [▼
      "endToEndId" => "ABCDEFGR020121414PVXK1"
      "valor" => "0.01"
      "horario" => "2020-12-14T14:24:19.000Z"
      "infoPagador" => "API"
    ]
  ]
]