Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rlzdesenv authored Dec 6, 2021
1 parent b36813c commit 0ba8a49
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions src/Bank/BrasilArrecadacaoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class BrasilArrecadacaoService implements InterfacePIX
private $listaInformacaoAdicional;
private $baseURIToken;
private $baseURI;
private $baseType;
private $appKey;
private $clientId;
private $clientSecret;
Expand Down Expand Up @@ -61,7 +60,6 @@ class BrasilArrecadacaoService implements InterfacePIX
* @param $listaInformacaoAdicional
* @param string $baseURIToken
* @param string $baseURI
* @param string $baseType
* @param string $appKey
* @param string $clientId
* @param string $clientSecret
Expand All @@ -71,8 +69,8 @@ public function __construct(int $numeroConvenio = null, string $indicadorCodigoB
string $numeroTelefoneDevedor = null, string $chavePIX = null,
string $descricaoSolicitacaoPagamento = null, $valorOriginalSolicitacao = null, string $cpfDevedor = null,
string $cnpjDevedor = null, string $nomeDevedor = null, int $vencimento = null, $listaInformacaoAdicional = null,
string $baseURIToken = null, string $baseURI = null, string $baseType = null,
string $appKey = null, string $clientId = null, string $clientSecret = null)
string $baseURIToken = null, string $baseURI = null, string $appKey = null, string $clientId = null,
string $clientSecret = null)
{
$this->cache = new ApcuCachePool();
$this->numeroConvenio = $numeroConvenio;
Expand All @@ -92,7 +90,6 @@ public function __construct(int $numeroConvenio = null, string $indicadorCodigoB
$this->listaInformacaoAdicional = $listaInformacaoAdicional;
$this->baseURIToken = $baseURIToken;
$this->baseURI = $baseURI;
$this->baseType = $baseType;
$this->appKey = $appKey;
$this->clientId = $clientId;
$this->clientSecret = $clientSecret;
Expand Down Expand Up @@ -122,14 +119,13 @@ private function getToken()
'verify' => false
]);

if ($response->getStatusCode() === 201) {
$result = json_decode($response->getBody()->getContents());
$result = json_decode($response->getBody()->getContents());

$item->set($result->access_token);
$item->expiresAfter($result->expires_in);
$this->cache->saveDeferred($item);
return $item->get();

$item->set($result->access_token);
$item->expiresAfter($result->expires_in);
$this->cache->saveDeferred($item);
return $item->get();
}
}
return $item->get();
} catch (RequestException $e) {
Expand Down Expand Up @@ -199,15 +195,14 @@ public function createPix()
//Requisição HTTPS
$res = $this->client->request('POST', $this->baseURI.'/arrecadacao-qrcodes', [
'headers' => ['Authorization' => 'Bearer '.$token],
'query' => [$this->baseType => $this->appKey],
'query' => ['gw-dev-app-key' => $this->appKey],
'json' => $body
]);

if ($res->getStatusCode() === 200) {
$retorno = json_decode($res->getBody()->getContents());
$this->setTransactionId($retorno->codigoConciliacaoSolicitante);
$this->setQrCode($retorno->qrCode);
}
$retorno = json_decode($res->getBody()->getContents());
$this->setTransactionId($retorno->codigoConciliacaoSolicitante);
$this->setQrCode($retorno->qrCode);

} catch (RequestException $e) {
if($e->hasResponse()) {
$error = json_decode($e->getResponse()->getBody()->getContents());
Expand All @@ -233,12 +228,6 @@ public function setbaseURI(string $baseURI): BrasilArrecadacaoService
return $this;
}

public function setbaseType(string $baseType): BrasilArrecadacaoService
{
$this->baseType = $baseType;
return $this;
}

public function setNumeroConvenio(int $numeroConvenio): BrasilArrecadacaoService
{
$this->numeroConvenio = $numeroConvenio;
Expand Down

0 comments on commit 0ba8a49

Please sign in to comment.