├── .editorconfig ├── LICENSE ├── composer.json ├── config └── juno.php ├── phpunit.xml └── src ├── Api ├── AbstractApi.php ├── Account │ ├── AccountApi.php │ ├── AccountDTO.php │ ├── AccountUpdateDTO.php │ ├── CreateAccountResponse.php │ ├── FindAccountResponse.php │ └── UpdateAccountResponse.php ├── AdditionalData │ ├── AdditionalDataApi.php │ ├── BankListResponse.php │ ├── BusinessAreasListResponse.php │ └── CompanyTypesListResponse.php ├── AuthorizedRequest.php ├── Balance │ ├── BalanceApi.php │ └── BalanceResponse.php ├── Charge │ ├── CancelChargeResponse.php │ ├── ChargeApi.php │ ├── ChargeListResponse.php │ ├── CreateChargeResponse.php │ ├── FindChargeResponse.php │ └── ListChargesRequest.php ├── Credentials │ └── CredentialsApi.php ├── Document │ ├── DocumentApi.php │ ├── DocumentListResponse.php │ ├── FindDocumentResponse.php │ └── UploadDocumentResponse.php ├── EmbeddedResponse.php ├── HasEmbeddedData.php ├── JunoResponse.php ├── Payment │ ├── CaptureResponse.php │ ├── CreatePaymentResponse.php │ ├── PaymentApi.php │ ├── PaymentResponse.php │ ├── RefundResponse.php │ └── TokenizationResponse.php ├── Pix │ ├── CreatePixKeyResponse.php │ ├── CreatePixStaticQRCodeResponse.php │ └── PixApi.php ├── Subscription │ ├── CreatePlanResponse.php │ ├── CreateSubscriptionResponse.php │ ├── PlanListResponse.php │ ├── SubscriptionApi.php │ └── SubscriptionListResponse.php ├── Transference │ ├── TransferenceApi.php │ └── TransferenceResponse.php └── Webhook │ ├── FindWebhookResponse.php │ ├── Notification │ ├── ChargeNotification.php │ ├── NotificationBase.php │ ├── PaymentNotification.php │ └── TransferNotification.php │ ├── WebhookApi.php │ ├── WebhookBase.php │ ├── WebhookListResponse.php │ └── WebhookTypeListResponse.php ├── Console └── InstallJunoPackage.php ├── Entity ├── AccountHolder.php ├── Address.php ├── BankAccount.php ├── BankResource.php ├── BilletDetails.php ├── Billing.php ├── BusinessAreaResource.php ├── Charge.php ├── ChargeResource.php ├── CompanyMember.php ├── CreatePlansResource.php ├── CreateSubscriptionResource.php ├── CreditCardDetails.php ├── DocumentResource.php ├── ErrorDetail.php ├── LegalRepresentative.php ├── Link.php ├── Notification │ ├── BankAccount.php │ ├── Charge.php │ ├── ChargeAttributes.php │ ├── ChargeData.php │ ├── EntityBaseTrait.php │ ├── Payer.php │ ├── PaymentAttributes.php │ ├── PaymentData.php │ ├── Recipient.php │ ├── TransferAttributes.php │ └── TransferData.php ├── Payment.php ├── PaymentBilling.php ├── Pix.php ├── Pix │ ├── AdditionalInfo.php │ ├── Calendar.php │ ├── LegalPerson.php │ ├── MonetaryValue.php │ └── PhysicalPerson.php ├── PixBankAccount.php ├── PlanBase.php ├── Recipient.php ├── Split.php ├── SubscriptionBase.php ├── WebhookEventType.php └── WebhookResource.php ├── Exception ├── InvalidArgumentException.php ├── JunoException.php ├── JunoRequestException.php └── RuntimeException.php ├── Facades └── Juno.php ├── Http └── OAuthClientCredentialsTokenResolver.php ├── Juno.php └── JunoServiceProvider.php /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2021 Jetimob 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jetimob/juno-sdk-php-laravel", 3 | "keywords": ["laravel", "juno", "pix", "sdk", "pagamento", "boleto", "conta digital"], 4 | "description": "SDK de integração com a Juno", 5 | "type": "library", 6 | "require": { 7 | "php": "^8.0", 8 | "ext-json": "*", 9 | "jetimob/http-php-laravel": "^2", 10 | "illuminate/support": "^9.0 | ^10.0", 11 | "illuminate/console": "^9.0 | ^10.0", 12 | "illuminate/container": "^9.0 | ^10.0" 13 | }, 14 | "require-dev": { 15 | "orchestra/testbench": "^7.6.1", 16 | "phpunit/phpunit": "^v9.5.5 | ^10.0" 17 | }, 18 | "license": "MIT", 19 | "autoload": { 20 | "psr-4": { 21 | "Jetimob\\Juno\\": "src/" 22 | } 23 | }, 24 | "autoload-dev": { 25 | "psr-4": { 26 | "Jetimob\\Juno\\Tests\\": "tests/" 27 | } 28 | }, 29 | "extra": { 30 | "laravel": { 31 | "providers": [ 32 | "Jetimob\\Juno\\JunoServiceProvider" 33 | ], 34 | "aliases": { 35 | "Juno": "Jetimob\\Juno\\Facades\\Juno" 36 | } 37 | } 38 | }, 39 | "authors": [ 40 | { 41 | "name": "Alan Weingartner", 42 | "email": "hi@alanwgt.com", 43 | "role": "Developer" 44 | }, 45 | { 46 | "name": "Jetimob", 47 | "email": "contato@jetimob.com", 48 | "homepage": "https://jetimob.com" 49 | } 50 | ], 51 | "support": { 52 | "issues": "https://github.com/jetimob/juno-sdk-php-laravel/issues" 53 | }, 54 | "config": { 55 | "sort-packages": true 56 | }, 57 | "minimum-stability": "stable" 58 | } 59 | -------------------------------------------------------------------------------- /config/juno.php: -------------------------------------------------------------------------------- 1 | [ 15 | 'base_uri' => 'https://sandbox.boletobancario.com/api-integration/', 16 | 'oauth_token_uri' => 'https://sandbox.boletobancario.com/authorization-server/oauth/token', 17 | ], 18 | 'production' => [ 19 | 'base_uri' => 'https://api.juno.com.br/', 20 | 'oauth_token_uri' => 'https://api.juno.com.br/authorization-server/oauth/token', 21 | ], 22 | ]; 23 | 24 | return [ 25 | /* 26 | |-------------------------------------------------------------------------- 27 | | X-Resource-Token 28 | |-------------------------------------------------------------------------- 29 | | 30 | | Muitos dos recursos também necessitam de um token de recurso, X-Resource-Token que identifica a conta digital 31 | | que deverá ser utilizada durante a execução de uma operação. Cada conta digital tem o seu próprio token de 32 | | recurso. 33 | | Contas digitais criadas via API incluem o token de recurso na resposta da requisição. Para obter o token de 34 | | recurso de uma conta digital já existente ou para redefinir o token de recurso, o cliente precisa acessar o 35 | | painel do cliente Juno e realizar esta operação na aba Integração, opção Token Privado. 36 | | 37 | | O `resource_token` é utilizado como valor padrão para o header 'X-Resource-Token' que identifica uma conta 38 | | dentro da API da Juno e pode ser sobrescrito programaticamente da seguinte forma: 39 | | 40 | | Juno::{$endpoint}()->using('X-Resource-Token')->find(); 41 | */ 42 | 43 | 'resource_token' => env('JUNO_RESOURCE_TOKEN'), 44 | 45 | 'http' => [ 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Client ID 49 | |-------------------------------------------------------------------------- 50 | | 51 | | Deve ser gerado dentro da aplicação da Juno. 52 | | @link https://dev.juno.com.br/api/v2#operation/getAccessToken 53 | | 54 | */ 55 | 56 | 'oauth_client_id' => env('JUNO_CLIENT_ID'), 57 | 58 | /* 59 | |-------------------------------------------------------------------------- 60 | | Client Secret 61 | |-------------------------------------------------------------------------- 62 | | 63 | | Deve ser gerado dentro da aplicação da Juno. 64 | | @link https://dev.juno.com.br/api/v2#operation/getAccessToken 65 | | 66 | */ 67 | 68 | 'oauth_client_secret' => env('JUNO_CLIENT_SECRET'), 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Retries 73 | |-------------------------------------------------------------------------- 74 | | 75 | | Quantas vezes uma requisição pode ser reexecutada (em caso de falha) antes de gerar uma exceção. 76 | | 77 | */ 78 | 79 | 'retries' => 0, 80 | 81 | /* 82 | |-------------------------------------------------------------------------- 83 | | Retry On Status Code 84 | |-------------------------------------------------------------------------- 85 | | 86 | | Em quais códigos HTTP de uma resposta falha podemos tentar reexecutar a requisição. 87 | | 88 | */ 89 | 90 | 'retry_on_status_code' => [401], 91 | 92 | /* 93 | |-------------------------------------------------------------------------- 94 | | Retry Delay 95 | |-------------------------------------------------------------------------- 96 | | 97 | | Antes de tentar reexecutar uma requisição falha, aguardar em ms. 98 | | 99 | */ 100 | 101 | 'retry_delay' => 2000, 102 | 103 | /* 104 | |-------------------------------------------------------------------------- 105 | | Guzzle 106 | |-------------------------------------------------------------------------- 107 | | 108 | | Configurações passadas à instância do Guzzle. 109 | | @link https://docs.guzzlephp.org/en/stable/request-options.html 110 | | 111 | */ 112 | 113 | 'guzzle' => [ 114 | 'base_uri' => $endpoints[env('JUNO_ENVIRONMENT', 'sandbox')]['base_uri'], 115 | 116 | /* 117 | |-------------------------------------------------------------------------- 118 | | Connect Timeout 119 | |-------------------------------------------------------------------------- 120 | | 121 | | Quantos segundos esperar por uma conexão com o servidor da Juno. 0 significa sem limite de espera. 122 | | https://docs.guzzlephp.org/en/stable/request-options.html#connect-timeout 123 | | 124 | */ 125 | 126 | 'connect_timeout' => 10.0, 127 | 128 | /* 129 | |-------------------------------------------------------------------------- 130 | | Timeout 131 | |-------------------------------------------------------------------------- 132 | | 133 | | Quantos segundos esperar pela resposta do servidor. 0 significa sem limite de espera. 134 | | @link https://docs.guzzlephp.org/en/stable/request-options.html#timeout 135 | | 136 | */ 137 | 138 | 'timeout' => 0.0, 139 | 140 | /* 141 | |-------------------------------------------------------------------------- 142 | | Debug 143 | |-------------------------------------------------------------------------- 144 | | 145 | | Usar true para ativar o modo debug do Guzzle. 146 | | @link https://docs.guzzlephp.org/en/stable/request-options.html#debug 147 | | 148 | */ 149 | 150 | 'debug' => false, 151 | 152 | /* 153 | |-------------------------------------------------------------------------- 154 | | Middlewares 155 | |-------------------------------------------------------------------------- 156 | | 157 | | @link https://docs.guzzlephp.org/en/stable/handlers-and-middleware.html#middleware 158 | | 159 | */ 160 | 161 | 'middlewares' => [ 162 | \Jetimob\Http\Middlewares\OAuthRequestMiddleware::class, 163 | ], 164 | 165 | /* 166 | |-------------------------------------------------------------------------- 167 | | Headers 168 | |-------------------------------------------------------------------------- 169 | | 170 | | Headers de requisição. 171 | | @link https://docs.guzzlephp.org/en/stable/request-options.html#headers 172 | | 173 | */ 174 | 175 | 'headers' => [ 176 | // Versão da API da Juno 177 | 'X-Api-Version' => 2, 178 | ], 179 | ], 180 | 181 | /* 182 | |-------------------------------------------------------------------------- 183 | | OAuth Access Token Repository 184 | |-------------------------------------------------------------------------- 185 | | 186 | | Essa classe é responsável por gerenciar os AccessTokens. Por padrão ela utiliza o repositório de cache padrão. 187 | | 188 | | PRECISA implementar \Jetimob\Http\Authorization\OAuth\Storage\CacheRepositoryContract 189 | */ 190 | 191 | 'oauth_access_token_repository' => \Jetimob\Http\Authorization\OAuth\Storage\CacheRepository::class, 192 | 193 | /* 194 | |-------------------------------------------------------------------------- 195 | | OAuth Token Cache Key Resolver 196 | |-------------------------------------------------------------------------- 197 | | 198 | | Classe responsável por gerar uma chave de identificação única para o cliente OAuth. 199 | | 200 | | PRECISA implementar \Jetimob\Http\Authorization\OAuth\Storage\AccessTokenCacheKeyResolverInterface 201 | */ 202 | 203 | 'oauth_token_cache_key_resolver' => 204 | \Jetimob\Http\Authorization\OAuth\Storage\AccessTokenCacheKeyResolver::class, 205 | 206 | /* 207 | |-------------------------------------------------------------------------- 208 | | OAuth Client Resolver 209 | |-------------------------------------------------------------------------- 210 | | 211 | | Classe responsável por resolver o client OAuth. 212 | | 213 | | PRECISA implementar \Jetimob\Http\Authorization\OAuth\ClientProviders\OAuthClientResolverInterface 214 | */ 215 | 216 | 'oauth_client_resolver' => \Jetimob\Http\Authorization\OAuth\ClientProviders\OAuthClientResolver::class, 217 | 218 | 'oauth_access_token_resolver' => [ 219 | \Jetimob\Http\Authorization\OAuth\OAuthFlow::CLIENT_CREDENTIALS => 220 | \Jetimob\Juno\Http\OAuthClientCredentialsTokenResolver::class, 221 | ], 222 | 223 | 'oauth_token_uri' => $endpoints[env('JUNO_ENVIRONMENT', 'sandbox')]['oauth_token_uri'], 224 | ], 225 | 226 | /* 227 | |-------------------------------------------------------------------------- 228 | | Implementação dos endpoints da API 229 | |-------------------------------------------------------------------------- 230 | | 231 | | Escolheu-se dar a opção de sobrescrever a implementação de um endpoint para que, se necessário, possam ser 232 | | modificados sem a necessidade de alterar o pacote original. 233 | | 234 | | A única obrigatoriedade é que a classe estenda \Jetimob\Juno\Api\AbstractApi. 235 | | 236 | | Chaves também podem ser adicionadas neste vetor e assim serem chamadas direto da facade. 237 | | 238 | */ 239 | 240 | 'api_impl' => [ 241 | 'account' => \Jetimob\Juno\Api\Account\AccountApi::class, 242 | 'additionalData' => \Jetimob\Juno\Api\AdditionalData\AdditionalDataApi::class, 243 | 'balance' => \Jetimob\Juno\Api\Balance\BalanceApi::class, 244 | 'charge' => \Jetimob\Juno\Api\Charge\ChargeApi::class, 245 | 'credentials' => \Jetimob\Juno\Api\Credentials\CredentialsApi::class, 246 | 'document' => \Jetimob\Juno\Api\Document\DocumentApi::class, 247 | 'payment' => \Jetimob\Juno\Api\Payment\PaymentApi::class, 248 | 'pix' => \Jetimob\Juno\Api\Pix\PixApi::class, 249 | 'transference' => \Jetimob\Juno\Api\Transference\TransferenceApi::class, 250 | 'webhook' => \Jetimob\Juno\Api\Webhook\WebhookApi::class, 251 | ], 252 | ]; 253 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | ./src 11 | 12 | 13 | 14 | 15 | ./tests 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Api/AbstractApi.php: -------------------------------------------------------------------------------- 1 | resourceToken = config('juno.resource_token', ''); 23 | } 24 | 25 | /** 26 | * @return string 27 | */ 28 | public function getResourceToken(): string 29 | { 30 | return $this->resourceToken; 31 | } 32 | 33 | /** 34 | * Sobrescreve o X-Resource-Token da próxima requisição. 35 | * 36 | * @param string $resourceToken 37 | * @return $this 38 | */ 39 | public function setResourceToken(string $resourceToken): self 40 | { 41 | $this->resourceToken = $resourceToken; 42 | return $this; 43 | } 44 | 45 | /** 46 | * Sobrescreve o X-Resource-Token da próxima requisição. 47 | * 48 | * @param string $resourceToken 49 | * @return $this 50 | */ 51 | public function using(string $resourceToken): self 52 | { 53 | if (empty($resourceToken)) { 54 | throw new InvalidArgumentException('O token de recurso NÃO pode ser vazio!'); 55 | } 56 | 57 | $this->resourceToken = $resourceToken; 58 | return $this; 59 | } 60 | 61 | protected function makeBaseRequest($method, $path, array $headers = [], $body = null): Request 62 | { 63 | return (new AuthorizedRequest($method, $path, $headers, $body)) 64 | ->withAddedHeader('X-Resource-Token', $this->resourceToken); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Api/Account/AccountApi.php: -------------------------------------------------------------------------------- 1 | mappedGet('digital-accounts', FindAccountResponse::class); 24 | } 25 | 26 | /** 27 | * Para a criação de uma nova conta digital deve ser informado o Token Privado da Conta Digital que fará a 28 | * integração no parâmetro X-Resource-Token. 29 | * 30 | * As contas criadas são do tipo Payment Account e os dados retornados na criação das contas devem ser armazenados 31 | * para fins de manipulação da conta recém-criada. 32 | * 33 | * @param AccountDTO $account 34 | * @link https://dev.juno.com.br/api/v2#operation/createDigitalAccount 35 | * @return CreateAccountResponse 36 | */ 37 | public function create(AccountDTO $account): CreateAccountResponse 38 | { 39 | return $this->mappedPost('digital-accounts', CreateAccountResponse::class, [ 40 | RequestOptions::JSON => $account, 41 | ]); 42 | } 43 | 44 | /** 45 | * Realiza a atualização de dados de uma conta digital do tipo pagamento. 46 | * As seguintes informações serão atualizadas durante a requisição: 47 | * - Email de contato e Telefone 48 | * - Informações do Endereço 49 | * - Dados bancários 50 | * 51 | * Alguns dados não podem ser atualizados instantaneamente durante a chamada via API, pois dependem de uma análise 52 | * pelas áreas internas da Juno, sendo eles: 53 | * - Nome e data de Nascimento 54 | * - Dados do representante legal 55 | * - Razão Social 56 | * - Área e Linha de Negócio 57 | * - Tipo de Empresa 58 | * 59 | * Nossa equipe será informada sobre as alterações e irá efetivá-las em breve. 60 | * Os dados informados na requisição são opcionais, e só serão atualizados caso sejam enviados. 61 | * Caso seja criada uma conta com numeração de documento incorreto (CPF/CNPJ) é necessário criar uma nova conta. 62 | * Pois não é possível realizar a alteração desses dados. 63 | * Importante: para atualização de qualquer um dos dados que compõem o objeto dessa request, todos os dados devem 64 | * ser informados, caso contrário a alteração destes campos será ignorada. 65 | * 66 | * @param AccountUpdateDTO $account 67 | * @link https://dev.juno.com.br/api/v2#operation/updateDigitalAccount 68 | * @return UpdateAccountResponse 69 | */ 70 | public function update(AccountUpdateDTO $account): UpdateAccountResponse 71 | { 72 | return $this->mappedPatch('digital-accounts', UpdateAccountResponse::class, [ 73 | RequestOptions::JSON => $account, 74 | ]); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/Api/Account/AccountDTO.php: -------------------------------------------------------------------------------- 1 | Data de nascimento. 76 | * Obrigatório para contas PF. 77 | * 10 chars. 78 | */ 79 | protected string $birthDate; 80 | 81 | /** 82 | * @var Address $address Endereço. 83 | */ 84 | protected Address $address; 85 | 86 | /** 87 | * @var BankAccount $bankAccount Conta Bancária. 88 | */ 89 | protected BankAccount $bankAccount; 90 | 91 | /** 92 | * @var LegalRepresentative|null $legalRepresentative Representante Legal. 93 | * Obrigatório para contas PJ. 94 | */ 95 | protected ?LegalRepresentative $legalRepresentative = null; 96 | 97 | /** 98 | * @var string Cria uma conta digital. 99 | * @link https://dev.juno.com.br/api/v2#tag/Contas-Digitais 100 | */ 101 | protected string $type = self::PAYMENT_ACCOUNT_TYPE; 102 | 103 | /** 104 | * @var string|null $linesOfBusiness Define a linha de negócio da empresa. Campo de livre preenchimento 105 | * [0 .. 100 chars] 106 | */ 107 | protected ?string $linesOfBusiness = null; 108 | 109 | /** 110 | * @var string $businessUrl [0 .. 100 chars]. 111 | */ 112 | protected string $businessUrl; 113 | 114 | /** 115 | * @var bool|null $emailOptOut Define se a conta criada receberá ou não quaisquer emails Juno como os enviados nas 116 | * operações de emissão de cobranças, trasnferências, entre outros. Requer permissão avançada. Útil para 117 | * comunicações com seu cliente diretamente pela sua aplicação. 118 | */ 119 | protected ?bool $emailOptOut = null; 120 | 121 | /** 122 | * @var bool|null $autoTransfer Define se as transferências da conta serão feitas automaticamente. Caso haja saldo 123 | * na conta digital em questão, a transferência será feita todos os dias. Requer permissão avançada. 124 | * PF. 125 | */ 126 | protected ?bool $autoTransfer = null; 127 | 128 | /** 129 | * @var bool|null $socialName Define se o atributo name poderá ou não receber o nome social. 130 | * Válido apenas para PF. 131 | */ 132 | protected ?bool $socialName = null; 133 | 134 | /** 135 | * @var float|null $monthlyIncomeOrRevenue Renda mensal ou receita. 136 | * Obrigatório para PF e PJ. 137 | */ 138 | protected ?float $monthlyIncomeOrRevenue = null; 139 | 140 | /** 141 | * @var string|null $cnae Campo destinado ao CNAE(Classificação Nacional de Atividades Econômicas) da empresa. 142 | * Obrigatório para PJ. 143 | * 7 chars. 144 | */ 145 | protected ?string $cnae = null; 146 | 147 | /** 148 | * @var string|null $establishmentDate Data de abertura da empresa. 149 | * Obrigatório para PJ. 150 | */ 151 | protected ?string $establishmentDate = null; 152 | 153 | /** 154 | * @var bool|null $pep Define se o cadastro pertence a uma pessoa politicamente exposta. 155 | */ 156 | protected ?bool $pep = null; 157 | 158 | /** 159 | * @var CompanyMember[]|null $companyMembers Quadro societário da empresa. 160 | * Obrigatório para contas PJ de companyType SA e LTDA. 161 | */ 162 | protected ?array $companyMembers = null; 163 | 164 | /** 165 | * @param string $companyType 166 | * @return AccountDTO 167 | */ 168 | public function setCompanyType(string $companyType): AccountDTO 169 | { 170 | $this->companyType = $companyType; 171 | return $this; 172 | } 173 | 174 | /** 175 | * @param string $name 176 | * @return AccountDTO 177 | */ 178 | public function setName(string $name): AccountDTO 179 | { 180 | $this->name = $name; 181 | return $this; 182 | } 183 | 184 | /** 185 | * @param string $document 186 | * @return AccountDTO 187 | */ 188 | public function setDocument(string $document): AccountDTO 189 | { 190 | $this->document = $document; 191 | return $this; 192 | } 193 | 194 | /** 195 | * @param string $email 196 | * @return AccountDTO 197 | */ 198 | public function setEmail(string $email): AccountDTO 199 | { 200 | $this->email = $email; 201 | return $this; 202 | } 203 | 204 | /** 205 | * @param string $phone 206 | * @return AccountDTO 207 | */ 208 | public function setPhone(string $phone): AccountDTO 209 | { 210 | $this->phone = $phone; 211 | return $this; 212 | } 213 | 214 | /** 215 | * @param int $businessArea 216 | * @return AccountDTO 217 | */ 218 | public function setBusinessArea(int $businessArea): AccountDTO 219 | { 220 | $this->businessArea = $businessArea; 221 | return $this; 222 | } 223 | 224 | /** 225 | * @param string $tradingName 226 | * @return AccountDTO 227 | */ 228 | public function setTradingName(string $tradingName): AccountDTO 229 | { 230 | $this->tradingName = $tradingName; 231 | return $this; 232 | } 233 | 234 | /** 235 | * Obrigatório para contas PF. 236 | * YYYY-MM-DD 237 | * @param string $birthDate 238 | * @return AccountDTO 239 | */ 240 | public function setBirthDate(string $birthDate): AccountDTO 241 | { 242 | $this->birthDate = $birthDate; 243 | return $this; 244 | } 245 | 246 | /** 247 | * @param Address $address 248 | * @return AccountDTO 249 | */ 250 | public function setAddress(Address $address): AccountDTO 251 | { 252 | $this->address = $address; 253 | return $this; 254 | } 255 | 256 | /** 257 | * @param BankAccount $bankAccount 258 | * @return AccountDTO 259 | */ 260 | public function setBankAccount(BankAccount $bankAccount): AccountDTO 261 | { 262 | $this->bankAccount = $bankAccount; 263 | return $this; 264 | } 265 | 266 | /** 267 | * @param LegalRepresentative|null $legalRepresentative 268 | * @return AccountDTO 269 | */ 270 | public function setLegalRepresentative(?LegalRepresentative $legalRepresentative): AccountDTO 271 | { 272 | $this->legalRepresentative = $legalRepresentative; 273 | return $this; 274 | } 275 | 276 | /** 277 | * @param string $type 278 | * @return AccountDTO 279 | */ 280 | public function setType(string $type): AccountDTO 281 | { 282 | $this->type = $type; 283 | return $this; 284 | } 285 | 286 | /** 287 | * @param string|null $linesOfBusiness 288 | * @return AccountDTO 289 | */ 290 | public function setLinesOfBusiness(?string $linesOfBusiness): AccountDTO 291 | { 292 | $this->linesOfBusiness = $linesOfBusiness; 293 | return $this; 294 | } 295 | 296 | /** 297 | * @param string $businessUrl 298 | * @return AccountDTO 299 | */ 300 | public function setBusinessUrl(string $businessUrl): AccountDTO 301 | { 302 | $this->businessUrl = $businessUrl; 303 | return $this; 304 | } 305 | 306 | /** 307 | * @param bool|null $emailOptOut 308 | * @return AccountDTO 309 | */ 310 | public function setEmailOptOut(?bool $emailOptOut): AccountDTO 311 | { 312 | $this->emailOptOut = $emailOptOut; 313 | return $this; 314 | } 315 | 316 | /** 317 | * @param bool|null $autoTransfer 318 | * @return AccountDTO 319 | */ 320 | public function setAutoTransfer(?bool $autoTransfer): AccountDTO 321 | { 322 | $this->autoTransfer = $autoTransfer; 323 | return $this; 324 | } 325 | 326 | /** 327 | * @param bool|null $socialName 328 | * @return AccountDTO 329 | */ 330 | public function setSocialName(?bool $socialName): AccountDTO 331 | { 332 | $this->socialName = $socialName; 333 | return $this; 334 | } 335 | 336 | /** 337 | * @param float|null $monthlyIncomeOrRevenue 338 | * @return AccountDTO 339 | */ 340 | public function setMonthlyIncomeOrRevenue(?float $monthlyIncomeOrRevenue): AccountDTO 341 | { 342 | $this->monthlyIncomeOrRevenue = $monthlyIncomeOrRevenue; 343 | return $this; 344 | } 345 | 346 | /** 347 | * @param string|null $cnae 348 | * @return AccountDTO 349 | */ 350 | public function setCnae(?string $cnae): AccountDTO 351 | { 352 | $this->cnae = $cnae; 353 | return $this; 354 | } 355 | 356 | /** 357 | * @param string|null $establishmentDate 358 | * @return AccountDTO 359 | */ 360 | public function setEstablishmentDate(?string $establishmentDate): AccountDTO 361 | { 362 | $this->establishmentDate = $establishmentDate; 363 | return $this; 364 | } 365 | 366 | /** 367 | * @param bool|null $pep 368 | * @return AccountDTO 369 | */ 370 | public function setPep(?bool $pep): AccountDTO 371 | { 372 | $this->pep = $pep; 373 | return $this; 374 | } 375 | 376 | /** 377 | * @param CompanyMember[]|null $companyMembers 378 | * @return AccountDTO 379 | */ 380 | public function setCompanyMembers(?array $companyMembers): AccountDTO 381 | { 382 | $this->companyMembers = $companyMembers; 383 | return $this; 384 | } 385 | } 386 | -------------------------------------------------------------------------------- /src/Api/Account/AccountUpdateDTO.php: -------------------------------------------------------------------------------- 1 | YYYY-MM-DD */ 21 | protected ?string $birthDate = null; 22 | 23 | /** @var string|null $linesOfBusiness [0 .. 100 chars] free description */ 24 | protected ?string $linesOfBusiness = null; 25 | 26 | /** @var string|null $email [0 .. 80] chars */ 27 | protected ?string $email = null; 28 | 29 | /** @var string|null $phone [10 .. 16] chars */ 30 | protected ?string $phone = null; 31 | 32 | /** @var int|null $businessArea business area id */ 33 | protected ?int $businessArea = null; 34 | 35 | /** @var string|null $tradingName [0 .. 80] chars */ 36 | protected ?string $tradingName = null; 37 | 38 | protected ?Address $address = null; 39 | 40 | protected ?BankAccount $bankAccount = null; 41 | 42 | protected ?LegalRepresentative $legalRepresentative = null; 43 | 44 | /** 45 | * @param string|null $companyType 46 | * @return AccountUpdateDTO 47 | */ 48 | public function setCompanyType(?string $companyType): AccountUpdateDTO 49 | { 50 | $this->companyType = $companyType; 51 | return $this; 52 | } 53 | 54 | /** 55 | * @param string|null $name 56 | * @return AccountUpdateDTO 57 | */ 58 | public function setName(?string $name): AccountUpdateDTO 59 | { 60 | $this->name = $name; 61 | return $this; 62 | } 63 | 64 | /** 65 | * @param string|null $birthDate 66 | * @return AccountUpdateDTO 67 | */ 68 | public function setBirthDate(?string $birthDate): AccountUpdateDTO 69 | { 70 | $this->birthDate = $birthDate; 71 | return $this; 72 | } 73 | 74 | /** 75 | * @param string|null $linesOfBusiness 76 | * @return AccountUpdateDTO 77 | */ 78 | public function setLinesOfBusiness(?string $linesOfBusiness): AccountUpdateDTO 79 | { 80 | $this->linesOfBusiness = $linesOfBusiness; 81 | return $this; 82 | } 83 | 84 | /** 85 | * @param string|null $email 86 | * @return AccountUpdateDTO 87 | */ 88 | public function setEmail(?string $email): AccountUpdateDTO 89 | { 90 | $this->email = $email; 91 | return $this; 92 | } 93 | 94 | /** 95 | * @param string|null $phone 96 | * @return AccountUpdateDTO 97 | */ 98 | public function setPhone(?string $phone): AccountUpdateDTO 99 | { 100 | $this->phone = $phone; 101 | return $this; 102 | } 103 | 104 | /** 105 | * @param int|null $businessArea 106 | * @return AccountUpdateDTO 107 | */ 108 | public function setBusinessArea(?int $businessArea): AccountUpdateDTO 109 | { 110 | $this->businessArea = $businessArea; 111 | return $this; 112 | } 113 | 114 | /** 115 | * @param string|null $tradingName 116 | * @return AccountUpdateDTO 117 | */ 118 | public function setTradingName(?string $tradingName): AccountUpdateDTO 119 | { 120 | $this->tradingName = $tradingName; 121 | return $this; 122 | } 123 | 124 | /** 125 | * @param Address|null $address 126 | * @return AccountUpdateDTO 127 | */ 128 | public function setAddress(?Address $address): AccountUpdateDTO 129 | { 130 | $this->address = $address; 131 | return $this; 132 | } 133 | 134 | /** 135 | * @param BankAccount|null $bankAccount 136 | * @return AccountUpdateDTO 137 | */ 138 | public function setBankAccount(?BankAccount $bankAccount): AccountUpdateDTO 139 | { 140 | $this->bankAccount = $bankAccount; 141 | return $this; 142 | } 143 | 144 | /** 145 | * @param LegalRepresentative|null $legalRepresentative 146 | * @return AccountUpdateDTO 147 | */ 148 | public function setLegalRepresentative(?LegalRepresentative $legalRepresentative): AccountUpdateDTO 149 | { 150 | $this->legalRepresentative = $legalRepresentative; 151 | return $this; 152 | } 153 | 154 | /** 155 | * @return string|null 156 | */ 157 | public function getCompanyType(): ?string 158 | { 159 | return $this->companyType; 160 | } 161 | 162 | /** 163 | * @return string|null 164 | */ 165 | public function getName(): ?string 166 | { 167 | return $this->name; 168 | } 169 | 170 | /** 171 | * @return string|null 172 | */ 173 | public function getBirthDate(): ?string 174 | { 175 | return $this->birthDate; 176 | } 177 | 178 | /** 179 | * @return string|null 180 | */ 181 | public function getLinesOfBusiness(): ?string 182 | { 183 | return $this->linesOfBusiness; 184 | } 185 | 186 | /** 187 | * @return string|null 188 | */ 189 | public function getEmail(): ?string 190 | { 191 | return $this->email; 192 | } 193 | 194 | /** 195 | * @return string|null 196 | */ 197 | public function getPhone(): ?string 198 | { 199 | return $this->phone; 200 | } 201 | 202 | /** 203 | * @return int|null 204 | */ 205 | public function getBusinessArea(): ?int 206 | { 207 | return $this->businessArea; 208 | } 209 | 210 | /** 211 | * @return string|null 212 | */ 213 | public function getTradingName(): ?string 214 | { 215 | return $this->tradingName; 216 | } 217 | 218 | /** 219 | * @return Address|null 220 | */ 221 | public function getAddress(): ?Address 222 | { 223 | return $this->address; 224 | } 225 | 226 | /** 227 | * @return BankAccount|null 228 | */ 229 | public function getBankAccount(): ?BankAccount 230 | { 231 | return $this->bankAccount; 232 | } 233 | 234 | /** 235 | * @return LegalRepresentative|null 236 | */ 237 | public function getLegalRepresentative(): ?LegalRepresentative 238 | { 239 | return $this->legalRepresentative; 240 | } 241 | } 242 | -------------------------------------------------------------------------------- /src/Api/Account/CreateAccountResponse.php: -------------------------------------------------------------------------------- 1 | id; 21 | } 22 | 23 | /** 24 | * @return string 25 | */ 26 | public function getResourceToken(): string 27 | { 28 | return $this->resourceToken; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Api/Account/FindAccountResponse.php: -------------------------------------------------------------------------------- 1 | id; 26 | } 27 | 28 | /** 29 | * @return string 30 | */ 31 | public function getType(): string 32 | { 33 | return $this->type; 34 | } 35 | 36 | /** 37 | * @return string 38 | */ 39 | public function getStatus(): string 40 | { 41 | return $this->status; 42 | } 43 | 44 | /** 45 | * @return string 46 | */ 47 | public function getPersonType(): string 48 | { 49 | return $this->personType; 50 | } 51 | 52 | /** 53 | * @return string 54 | */ 55 | public function getDocument(): string 56 | { 57 | return $this->document; 58 | } 59 | 60 | /** 61 | * @return string 62 | */ 63 | public function getCreatedOn(): string 64 | { 65 | return $this->createdOn; 66 | } 67 | 68 | /** 69 | * @return string 70 | */ 71 | public function getAccountNumber(): string 72 | { 73 | return $this->accountNumber; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/Api/Account/UpdateAccountResponse.php: -------------------------------------------------------------------------------- 1 | id; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Api/AdditionalData/AdditionalDataApi.php: -------------------------------------------------------------------------------- 1 | mappedGet('data/banks', BankListResponse::class); 21 | } 22 | 23 | /** 24 | * Utilize esse método para retornar a lista de tipos de empresas disponíveis na plataforma Juno que podem ser 25 | * utilizadas na criação de uma Conta Digital. 26 | * 27 | * @link https://dev.juno.com.br/api/v2#tag/Contas-Digitais 28 | * @link https://dev.juno.com.br/api/v2#operation/getCompanyTypes 29 | * @return CompanyTypesListResponse 30 | */ 31 | public function companyTypes(): CompanyTypesListResponse 32 | { 33 | return $this->mappedGet('data/company-types', CompanyTypesListResponse::class); 34 | } 35 | 36 | /** 37 | * Traz a lista de áreas de negócios disponíveis na plataforma Juno que podem ser utilizadas na criação de uma Conta 38 | * Digital. 39 | * 40 | * @link https://dev.juno.com.br/api/v2#tag/Contas-Digitais 41 | * @link https://dev.juno.com.br/api/v2#operation/getBusinessAreas 42 | * @return BusinessAreasListResponse 43 | */ 44 | public function businessAreas(): BusinessAreasListResponse 45 | { 46 | return $this->mappedGet('data/business-areas', BusinessAreasListResponse::class); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Api/AdditionalData/BankListResponse.php: -------------------------------------------------------------------------------- 1 | banks ?? []; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Api/AdditionalData/BusinessAreasListResponse.php: -------------------------------------------------------------------------------- 1 | businessAreas ?? []; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Api/AdditionalData/CompanyTypesListResponse.php: -------------------------------------------------------------------------------- 1 | companyTypes ?? []; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Api/AuthorizedRequest.php: -------------------------------------------------------------------------------- 1 | mappedGet('balance', BalanceResponse::class); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Api/Balance/BalanceResponse.php: -------------------------------------------------------------------------------- 1 | balance; 36 | } 37 | 38 | /** 39 | * @return float 40 | */ 41 | public function getWithheldBalance(): float 42 | { 43 | return $this->withheldBalance; 44 | } 45 | 46 | /** 47 | * @return float 48 | */ 49 | public function getTransferableBalance(): float 50 | { 51 | return $this->transferableBalance; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Api/Charge/CancelChargeResponse.php: -------------------------------------------------------------------------------- 1 | getStatusCode() === 204; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Api/Charge/ChargeApi.php: -------------------------------------------------------------------------------- 1 | mappedPost('charges', CreateChargeResponse::class, [ 37 | RequestOptions::JSON => [ 38 | 'charge' => $charge, 39 | 'billing' => $billing, 40 | ], 41 | ]); 42 | } 43 | 44 | /** 45 | * Muito útil na conciliação de recebimentos este método fornece uma listagem por página das cobranças de uma conta 46 | * digital de acordo ao filtros disponíveis. 47 | * 48 | * Para avançar para as próximas páginas ou voltar para a página anterior deve ser utilizado os links previous e 49 | * next devolvidos na resposta da chamada. 50 | * 51 | * Devolve 20 cobranças por páginas, podendo ser estendido até 100 páginas com pageSize=100. 52 | * 53 | * @param ListChargesRequest|null $requestQueryParams 54 | * @return ChargeListResponse 55 | *@link https://dev.juno.com.br/api/v2#operation/listCharge 56 | */ 57 | public function list(?ListChargesRequest $requestQueryParams = null): ChargeListResponse 58 | { 59 | return $this->mappedGet('charges', ChargeListResponse::class, [ 60 | RequestOptions::QUERY => $requestQueryParams?->toArray() 61 | ]); 62 | } 63 | 64 | /** 65 | * Uma cobrança emitida emitida pode ser consultada a qualquer momento para que se obtenha seu estado atual. 66 | * 67 | * Para a consulta, utilize o ID da cobrança devolvido no momento da emissão. 68 | * 69 | * O ID seguirá o padrão de identidade prefixada conforme descrito na referência da API. 70 | * 71 | * @param string $chargeId 72 | * @link https://dev.juno.com.br/junoAPI20Integration.pdf referência da API 73 | * @link https://dev.juno.com.br/api/v2#operation/findById 74 | * @return FindChargeResponse 75 | */ 76 | public function find(string $chargeId): FindChargeResponse 77 | { 78 | return $this->mappedGet("charges/$chargeId", FindChargeResponse::class); 79 | } 80 | 81 | /** 82 | * Uma cobrança emitida emitida pode ser cancelada a qualquer momento desde que não tenha recebido pagamento. 83 | * 84 | * Isso é válido para cobranças de qualquer paymentType que estejam como active, ou seja, em aberto. 85 | * 86 | * Para transações que tenham sido capturadas, seu cancelamento deve ser feito através desse recurso. 87 | * 88 | * O sucesso no cancelamento retornará um 204 de sucesso sem qualquer conteúdo. 89 | * 90 | * @param string $chargeId 91 | * @link https://dev.juno.com.br/api/v2#operation/cancelById 92 | * @return CancelChargeResponse 93 | */ 94 | public function cancel(string $chargeId): CancelChargeResponse 95 | { 96 | return $this->mappedPut("charges/$chargeId/cancelation", CancelChargeResponse::class); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/Api/Charge/ChargeListResponse.php: -------------------------------------------------------------------------------- 1 | charges ?? []; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Api/Charge/CreateChargeResponse.php: -------------------------------------------------------------------------------- 1 | charges ?? []; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Api/Charge/FindChargeResponse.php: -------------------------------------------------------------------------------- 1 | id; 37 | } 38 | 39 | /** 40 | * @return int 41 | */ 42 | public function getCode(): int 43 | { 44 | return $this->code; 45 | } 46 | 47 | /** 48 | * @return string 49 | */ 50 | public function getReference(): string 51 | { 52 | return $this->reference; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getDueDate(): string 59 | { 60 | return $this->dueDate; 61 | } 62 | 63 | /** 64 | * @return string 65 | */ 66 | public function getLink(): string 67 | { 68 | return $this->link; 69 | } 70 | 71 | /** 72 | * @return string 73 | */ 74 | public function getCheckoutUrl(): string 75 | { 76 | return $this->checkoutUrl; 77 | } 78 | 79 | /** 80 | * @return string 81 | */ 82 | public function getInstallmentLink(): string 83 | { 84 | return $this->installmentLink; 85 | } 86 | 87 | /** 88 | * @return string 89 | */ 90 | public function getPayNumber(): string 91 | { 92 | return $this->payNumber; 93 | } 94 | 95 | /** 96 | * @return int 97 | */ 98 | public function getAmount(): int 99 | { 100 | return $this->amount; 101 | } 102 | 103 | /** 104 | * @return BilletDetails|null 105 | */ 106 | public function getBilletDetails(): ?BilletDetails 107 | { 108 | return $this->billetDetails; 109 | } 110 | 111 | /** 112 | * @return Payment[] 113 | */ 114 | public function getPayments(): array 115 | { 116 | return $this->payments ?? []; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/Api/Charge/ListChargesRequest.php: -------------------------------------------------------------------------------- 1 | Define a partir de qual objeto charge será feita a busca */ 75 | protected ?string $firstObjectId = null; 76 | 77 | /** @var string|null $firstValue Define a partir de qual valor será feita a busca */ 78 | protected ?string $firstValue = null; 79 | 80 | /** @var string|null $lastObjectId Define até qual objeto charge será feita a busca */ 81 | protected ?string $lastObjectId = null; 82 | 83 | /** @var string|null $lastValue Define até qual valor será feita a busca */ 84 | protected ?string $lastValue = null; 85 | 86 | /** 87 | * @param string|null $createdOnStart yyyy-MM-dd Busca pela criação da cobrança a partir dessa data 88 | * @return ListChargesRequest 89 | */ 90 | public function setCreatedOnStart(?string $createdOnStart): ListChargesRequest 91 | { 92 | $this->createdOnStart = $createdOnStart; 93 | return $this; 94 | } 95 | 96 | /** 97 | * @param string|null $createdOnEnd yyyy-MM-dd Busca pela criação da cobrança até 98 | * @return ListChargesRequest 99 | */ 100 | public function setCreatedOnEnd(?string $createdOnEnd): ListChargesRequest 101 | { 102 | $this->createdOnEnd = $createdOnEnd; 103 | return $this; 104 | } 105 | 106 | /** 107 | * @param string|null $dueDateStart yyyy-MM-dd Busca por vencimentos a partir dessa data 108 | * @return ListChargesRequest 109 | */ 110 | public function setDueDateStart(?string $dueDateStart): ListChargesRequest 111 | { 112 | $this->dueDateStart = $dueDateStart; 113 | return $this; 114 | } 115 | 116 | /** 117 | * @param string|null $dueDateEnd yyyy-MM-dd Busca por vencimentos a partir até essa data 118 | * @return ListChargesRequest 119 | */ 120 | public function setDueDateEnd(?string $dueDateEnd): ListChargesRequest 121 | { 122 | $this->dueDateEnd = $dueDateEnd; 123 | return $this; 124 | } 125 | 126 | /** 127 | * @param string|null $paymentDateStart yyyy-MM-dd Busca por pagamentos a partir dessa data 128 | * @return ListChargesRequest 129 | */ 130 | public function setPaymentDateStart(?string $paymentDateStart): ListChargesRequest 131 | { 132 | $this->paymentDateStart = $paymentDateStart; 133 | return $this; 134 | } 135 | 136 | /** 137 | * @param string|null $paymentDateEnd yyyy-MM-dd Busca por pagamentos até essa data 138 | * @return ListChargesRequest 139 | */ 140 | public function setPaymentDateEnd(?string $paymentDateEnd): ListChargesRequest 141 | { 142 | $this->paymentDateEnd = $paymentDateEnd; 143 | return $this; 144 | } 145 | 146 | /** 147 | * @param bool|null $showUnarchived Mostra cobranças que não foram ou estão arquivadas 148 | * @return ListChargesRequest 149 | */ 150 | public function setShowUnarchived(?bool $showUnarchived): ListChargesRequest 151 | { 152 | $this->showUnarchived = $showUnarchived; 153 | return $this; 154 | } 155 | 156 | /** 157 | * @param bool|null $showArchived Mostra cobranças que foram ou estão arquivadas 158 | * @return ListChargesRequest 159 | */ 160 | public function setShowArchived(?bool $showArchived): ListChargesRequest 161 | { 162 | $this->showArchived = $showArchived; 163 | return $this; 164 | } 165 | 166 | /** 167 | * @param bool|null $showDue Mostra cobranças vencidas 168 | * @return ListChargesRequest 169 | */ 170 | public function setShowDue(?bool $showDue): ListChargesRequest 171 | { 172 | $this->showDue = $showDue; 173 | return $this; 174 | } 175 | 176 | /** 177 | * @param bool|null $showNotDue Mostra cobranças que não estão vencidas 178 | * @return ListChargesRequest 179 | */ 180 | public function setShowNotDue(?bool $showNotDue): ListChargesRequest 181 | { 182 | $this->showNotDue = $showNotDue; 183 | return $this; 184 | } 185 | 186 | /** 187 | * @param bool|null $showPaid Mostra cobranças pagas 188 | * @return ListChargesRequest 189 | */ 190 | public function setShowPaid(?bool $showPaid): ListChargesRequest 191 | { 192 | $this->showPaid = $showPaid; 193 | return $this; 194 | } 195 | 196 | /** 197 | * @param bool|null $showNotPaid Mostra cobranças que não estão pagas 198 | * @return ListChargesRequest 199 | */ 200 | public function setShowNotPaid(?bool $showNotPaid): ListChargesRequest 201 | { 202 | $this->showNotPaid = $showNotPaid; 203 | return $this; 204 | } 205 | 206 | /** 207 | * @param bool|null $showCancelled Mostra cobranças canceladas 208 | * @return ListChargesRequest 209 | */ 210 | public function setShowCancelled(?bool $showCancelled): ListChargesRequest 211 | { 212 | $this->showCancelled = $showCancelled; 213 | return $this; 214 | } 215 | 216 | /** 217 | * @param bool|null $showNotCancelled Mostra cobranças que não estão canceladas 218 | * @return ListChargesRequest 219 | */ 220 | public function setShowNotCancelled(?bool $showNotCancelled): ListChargesRequest 221 | { 222 | $this->showNotCancelled = $showNotCancelled; 223 | return $this; 224 | } 225 | 226 | /** 227 | * @param bool|null $showManualReconciliation Mostra cobranças que foram baixadas manualmente 228 | * @return ListChargesRequest 229 | */ 230 | public function setShowManualReconciliation(?bool $showManualReconciliation): ListChargesRequest 231 | { 232 | $this->showManualReconciliation = $showManualReconciliation; 233 | return $this; 234 | } 235 | 236 | /** 237 | * @param bool|null $showNotManualReconciliation Mostra cobranças que não foram baixadas manualmente 238 | * @return ListChargesRequest 239 | */ 240 | public function setShowNotManualReconciliation(?bool $showNotManualReconciliation): ListChargesRequest 241 | { 242 | $this->showNotManualReconciliation = $showNotManualReconciliation; 243 | return $this; 244 | } 245 | 246 | /** 247 | * @param bool|null $showNotFailed Mostra cobranças que tiveram falha no pagamento. (Checkout transparente) 248 | * @return ListChargesRequest 249 | */ 250 | public function setShowNotFailed(?bool $showNotFailed): ListChargesRequest 251 | { 252 | $this->showNotFailed = $showNotFailed; 253 | return $this; 254 | } 255 | 256 | /** 257 | * @param string|null $orderBy Enum: "id" "dueDate" "amount" "paymentDate" Ordenação cobranças pelos filtros id, 258 | * dueDate, amount e paymentDate 259 | * @return ListChargesRequest 260 | */ 261 | public function setOrderBy(?string $orderBy): ListChargesRequest 262 | { 263 | $this->orderBy = $orderBy; 264 | return $this; 265 | } 266 | 267 | /** 268 | * @param bool|null $orderAsc Ordenação cobranças ascendente ou descentente 269 | * @return ListChargesRequest 270 | */ 271 | public function setOrderAsc(?bool $orderAsc): ListChargesRequest 272 | { 273 | $this->orderAsc = $orderAsc; 274 | return $this; 275 | } 276 | 277 | /** 278 | * @param int|null $pageSize Quantidade de cobranças por página 279 | * @return ListChargesRequest 280 | */ 281 | public function setPageSize(?int $pageSize): ListChargesRequest 282 | { 283 | $this->pageSize = $pageSize; 284 | return $this; 285 | } 286 | 287 | /** 288 | * @param int|null $page Número identificador da página 289 | * @return ListChargesRequest 290 | */ 291 | public function setPage(?int $page): ListChargesRequest 292 | { 293 | $this->page = $page; 294 | return $this; 295 | } 296 | 297 | /** 298 | * @param string|null $firstObjectId Define a partir de qual objeto charge será feita a busca 299 | * @return ListChargesRequest 300 | */ 301 | public function setFirstObjectId(?string $firstObjectId): ListChargesRequest 302 | { 303 | $this->firstObjectId = $firstObjectId; 304 | return $this; 305 | } 306 | 307 | /** 308 | * @param string|null $firstValue Define a partir de qual valor será feita a busca 309 | * @return ListChargesRequest 310 | */ 311 | public function setFirstValue(?string $firstValue): ListChargesRequest 312 | { 313 | $this->firstValue = $firstValue; 314 | return $this; 315 | } 316 | 317 | /** 318 | * @param string|null $lastObjectId Define até qual objeto charge será feita a busca 319 | * @return ListChargesRequest 320 | */ 321 | public function setLastObjectId(?string $lastObjectId): ListChargesRequest 322 | { 323 | $this->lastObjectId = $lastObjectId; 324 | return $this; 325 | } 326 | 327 | /** 328 | * @param string|null $lastValue Define até qual valor será feita a busca 329 | * @return ListChargesRequest 330 | */ 331 | public function setLastValue(?string $lastValue): ListChargesRequest 332 | { 333 | $this->lastValue = $lastValue; 334 | return $this; 335 | } 336 | } 337 | -------------------------------------------------------------------------------- /src/Api/Credentials/CredentialsApi.php: -------------------------------------------------------------------------------- 1 | request('get', 'credentials/public-key'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Api/Document/DocumentApi.php: -------------------------------------------------------------------------------- 1 | mappedGet('documents', DocumentListResponse::class); 24 | } 25 | 26 | /** 27 | * Contas Digitais passam por uma validação do recebimento dos documentos relacionados ao seu tipo de empresa. 28 | * Através desse endpoint é possível consultar o status atual dos documentos enviados. 29 | * 30 | * @param string $documentId 31 | * @link https://dev.juno.com.br/api/v2#operation/getDocumentsById 32 | * @return FindDocumentResponse 33 | */ 34 | public function find(string $documentId): FindDocumentResponse 35 | { 36 | return $this->mappedGet("documents/$documentId", FindDocumentResponse::class); 37 | } 38 | 39 | 40 | /** 41 | * Realiza o upload de arquivos relacionados ao documento identificado por meio de seu ID específico. 42 | * O upload é realizado através de um 'multipart/form-data'. Um ou mais documentos podem ser enviados nesta 43 | * operação. 44 | * 45 | * Extensões de arquivos aceitas: pdf, doc, docx, jpg, jpeg, png, bpm, tiff. 46 | * 47 | * @param string $documentId 48 | * @param string[] $files 49 | * @return UploadDocumentResponse 50 | * @link https://dev.juno.com.br/api/v2#operation/uploadDocument 51 | */ 52 | public function upload(string $documentId, array $files): UploadDocumentResponse 53 | { 54 | $multipartData = array_map(static fn ($fileContent) => ['name' => 'files', 'contents' => $fileContent], $files); 55 | 56 | return $this->mappedPost("documents/$documentId/files", UploadDocumentResponse::class, [ 57 | RequestOptions::MULTIPART => $multipartData, 58 | ]); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Api/Document/DocumentListResponse.php: -------------------------------------------------------------------------------- 1 | documents ?? []; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Api/Document/FindDocumentResponse.php: -------------------------------------------------------------------------------- 1 | id; 22 | } 23 | 24 | /** 25 | * @return string 26 | */ 27 | public function getType(): string 28 | { 29 | return $this->type; 30 | } 31 | 32 | /** 33 | * @return string 34 | */ 35 | public function getDescription(): string 36 | { 37 | return $this->description; 38 | } 39 | 40 | /** 41 | * @return string 42 | */ 43 | public function getApprovalStatus(): string 44 | { 45 | return $this->approvalStatus; 46 | } 47 | 48 | /** 49 | * @return string|null 50 | */ 51 | public function getRejectionReason(): ?string 52 | { 53 | return $this->rejectionReason; 54 | } 55 | 56 | /** 57 | * @return string|null 58 | */ 59 | public function getDetails(): ?string 60 | { 61 | return $this->details; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Api/Document/UploadDocumentResponse.php: -------------------------------------------------------------------------------- 1 | */ 13 | protected string $id; 14 | protected string $type; 15 | protected string $description; 16 | protected string $approvalStatus; 17 | protected ?string $rejectionReason; 18 | protected ?string $details; 19 | 20 | /** 21 | * @return string 22 | */ 23 | public function getId(): string 24 | { 25 | return $this->id; 26 | } 27 | 28 | /** 29 | * @return string 30 | */ 31 | public function getType(): string 32 | { 33 | return $this->type; 34 | } 35 | 36 | /** 37 | * @return string 38 | */ 39 | public function getDescription(): string 40 | { 41 | return $this->description; 42 | } 43 | 44 | /** 45 | * Possible values: 46 | * - AWAITING 47 | * - VERIFYING 48 | * - APPROVED 49 | * - REJECTED 50 | * @return string 51 | */ 52 | public function getApprovalStatus(): string 53 | { 54 | return $this->approvalStatus; 55 | } 56 | 57 | /** 58 | * @return string|null 59 | */ 60 | public function getRejectionReason(): ?string 61 | { 62 | return $this->rejectionReason; 63 | } 64 | 65 | /** 66 | * @return string|null 67 | */ 68 | public function getDetails(): ?string 69 | { 70 | return $this->details; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Api/EmbeddedResponse.php: -------------------------------------------------------------------------------- 1 | mappedPost('credit-cards/tokenization', TokenizationResponse::class, [ 38 | RequestOptions::JSON => [ 39 | 'creditCardHash' => $creditCardHash 40 | ] 41 | ]); 42 | } 43 | 44 | 45 | /** 46 | * Para cobranças cujo paymentType é CREDIT_CARD podem ser pagas logo em seguida sua criação. 47 | * Através desse endpoint você cria um pagamento para a cobrança emitida identificada a partir de seu chargeId 48 | * retornado no momento de sua geração. 49 | * 50 | * Este recurso permite a captura tardia de pagamento, ou seja, através dele é possível obter e segurar o valor da 51 | * transação no saldo do cartão em questão sem concluír este pagamento efetivamente, muito utilizado na prestação 52 | * de serviços. 53 | * 54 | * Para utilizar o recurso dessa forma é preciso que o parâmetro delayed receba o valor true, resultando em um 55 | * pagamento capturado que recebe o status AUTHORIZED. Caso contrário, o pagamento será efetuado normalmente com 56 | * status CONFIRMED. 57 | * 58 | * IMPORTANTE: caso o pagamento tenha sido recusado, faça uma nova tentativa utilizando o chargeId da cobrança 59 | * já criada. Não é necessário criar uma nova cobrança para este processo. 60 | * 61 | * @link https://dev.juno.com.br/api/v2#operation/createPayment 62 | * 63 | * @param string $chargeId 64 | * @param PaymentBilling $billing 65 | * @param CreditCardDetails $creditCardDetails 66 | * 67 | * @return Response 68 | * @throws Throwable 69 | */ 70 | public function createPayment(string $chargeId, PaymentBilling $billing, CreditCardDetails $creditCardDetails): Response 71 | { 72 | return $this->mappedPost('payments', CreatePaymentResponse::class, [ 73 | RequestOptions::JSON => [ 74 | 'chargeId' => $chargeId, 75 | 'billing' => $billing, 76 | 'creditCardDetails' => $creditCardDetails 77 | ], 78 | ]); 79 | } 80 | 81 | 82 | /** 83 | * Faz o estorno total ou parcial de transações de cartão de crédito. 84 | * 85 | * Afeta todas as cobranças geradas e todos os pagamentos já realizados, até mesmo para os casos em que o pagamento 86 | * tenha sido parcelado. 87 | * 88 | * Para estorno parcial, a quantidade definida em amount deve ser menor que o valor total da transação. Caso não 89 | * seja passado nenhum valor nesse parâmetro, será feito o estorno total da transação. 90 | * 91 | * Se no endpoint não for passado o valor, vai ser estornado o total, se for menor o parcial. 92 | * 93 | * Caso a cobrança indicada tenha sido criada com o split, no momento do estorno deve ser definido novamente no body 94 | * os destinatários do split. 95 | * 96 | * @link https://dev.juno.com.br/api/v2#operation/refundPayment 97 | * 98 | * @param string $id 99 | * @param float $amount 100 | * @param array $split 101 | * 102 | * @return Response 103 | * @throws Throwable 104 | */ 105 | public function refund(string $id, float $amount, array $split): Response 106 | { 107 | return $this->mappedPost("payments/$id/refunds", RefundResponse::class, [ 108 | RequestOptions::JSON => [ 109 | 'amount' => $amount, 110 | 'split' => $split, 111 | ], 112 | ]); 113 | } 114 | 115 | /** 116 | * Faz a captura total ou parcial de transações previamente autorizadas no cartão de crédito. 117 | * 118 | * Afeta todas as cobranças geradas, até mesmo para os casos em que o pagamento tenha sido parcelado. 119 | * 120 | * Para captura parcial, a quantidade definida em amount deve ser menor que o valor total da transação. 121 | * Caso não seja passado nenhum valor nesse parâmetro, será feita a captura total da transação. 122 | * 123 | * Se no endpoint não for passado o valor, vai ser capturado o total, se for menor o parcial. 124 | * 125 | * @param string $id - example pay_413FC8BB8D33C4862AD2EAE31BA72D1E Id do pagamento 126 | * @param string $chargeId 127 | * @param float $amount 128 | * 129 | * @link https://dev.juno.com.br/api/v2#operation/capturePayment 130 | * 131 | * @return Response 132 | * @throws Throwable 133 | */ 134 | public function capture(string $id, string $chargeId, float $amount): Response 135 | { 136 | return $this->mappedPost("payments/$id/capture", CaptureResponse::class, [ 137 | RequestOptions::JSON => [ 138 | 'chargeId' => $chargeId, 139 | 'amount' => $amount, 140 | ], 141 | ]); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/Api/Payment/PaymentResponse.php: -------------------------------------------------------------------------------- 1 | transactionId; 32 | } 33 | 34 | public function getInstallments(): int 35 | { 36 | return $this->installments; 37 | } 38 | 39 | public function getPayments(): array 40 | { 41 | return $this->payments; 42 | } 43 | 44 | public function getLinks(): array 45 | { 46 | return $this->_links; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Api/Payment/RefundResponse.php: -------------------------------------------------------------------------------- 1 | creditCardId; 20 | } 21 | 22 | public function getLast4CardNumber(): string 23 | { 24 | return $this->last4CardNumber; 25 | } 26 | 27 | public function getExpirationMonth(): string 28 | { 29 | return $this->expirationMonth; 30 | } 31 | 32 | public function getExpirationYear(): string 33 | { 34 | return $this->expirationYear; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Api/Pix/CreatePixKeyResponse.php: -------------------------------------------------------------------------------- 1 | key; 22 | } 23 | 24 | /** 25 | * @return string - yyyy-MM-ddTHH:mm:ss.sssZ 26 | */ 27 | public function getCreationDateTime(): string 28 | { 29 | return $this->creationDateTime; 30 | } 31 | 32 | /** 33 | * @return string - yyyy-MM-ddTHH:mm:ss.sssZ 34 | */ 35 | public function getOwnershipDateTime(): string 36 | { 37 | return $this->ownershipDateTime; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Api/Pix/CreatePixStaticQRCodeResponse.php: -------------------------------------------------------------------------------- 1 | id; 22 | } 23 | 24 | /** 25 | * @return string 26 | */ 27 | public function getQrcodeInBase64(): string 28 | { 29 | return $this->qrcodeInBase64; 30 | } 31 | 32 | /** 33 | * @return string|null 34 | */ 35 | public function getImageInBase64(): ?string 36 | { 37 | return $this->imageInBase64; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Api/Pix/PixApi.php: -------------------------------------------------------------------------------- 1 | mappedPost('pix/keys', CreatePixKeyResponse::class, [ 32 | RequestOptions::JSON => [ 33 | 'type' => 'RANDOM_KEY', 34 | ], 35 | RequestOptions::HEADERS => [ 36 | 'X-Idempotency-Key' => $idempotencyKey, 37 | ], 38 | ]); 39 | } 40 | 41 | /** 42 | * @param string $idempotencyKey Simplificadamente, o conceito de idempotência está relacionado àqueles serviços que 43 | * @param bool $includeImage - Indica se a imagem do Qr Code deve ser incluída na resposta. O payload do Qr Code, 44 | * valor codificado na imagem, é sempre retornado. 45 | * @param string $key - Chave aleatória válida associada à Conta Digital do cliente. Formato UUIDv4. 46 | * @param float|null $amount - Valor da transação [ 0.01 .. 1000000 ]. 47 | * @param string|null $reference - Identificador para conciliação do emissor/recebedor. Este valor será devolvido 48 | * juntamente com as informações referente às ocorrências de pagamento do QR Code. 49 | * @param string|null $additionalData - Dados adicionais. São incluidos no próprio QR Code. 50 | * quando chamados sempre retornam um mesmo resultado. Por exemplo, a consulta de um cadastro pela chave de 51 | * identificação do cadastro sempre retorna o mesmo cadastro. Algumas operações são idempotentes enquanto outras 52 | * não: criar um novo cadastro não é idempotente. A cada chamada do serviço, um novo cadastro é criado. 53 | * A chave de idempotência informada é associada ao objeto criado. Durante uma chamada, se a chave ainda não 54 | * existir, um novo objeto é criado e retornado. Mas, se a chave já existir, o objeto associado à chave é retornado. 55 | * Desta forma, várias chamadas com a mesma chave de idempotência sempre retornam o mesmo resultado. 56 | * @link https://dev.juno.com.br/api/v2#operation/createPixQrCodeStatic 57 | */ 58 | public function createStaticQRCode( 59 | string $idempotencyKey, 60 | string $key, 61 | ?float $amount = null, 62 | bool $includeImage = false, 63 | ?string $reference = null, 64 | ?string $additionalData = null 65 | ): CreatePixStaticQRCodeResponse { 66 | return $this->mappedPost('pix/qrcodes/static', CreatePixStaticQRCodeResponse::class, [ 67 | RequestOptions::JSON => [ 68 | 'includeImage' => $includeImage, 69 | 'key' => $key, 70 | 'amount' => $amount, 71 | 'reference' => $reference, 72 | 'additionalData' => $additionalData, 73 | ] 74 | ], [ 75 | 'X-Idempotency-Key' => $idempotencyKey, 76 | ]); 77 | } 78 | 79 | /** 80 | * @param string $txid O campo txid determina o identificador da transação. O objetivo desse campo é ser um elemento 81 | * que possibilite ao PSP do recebedor apresentar ao usuário recebedor a funcionalidade de conciliação de 82 | * pagamentos. 83 | * Na pacs.008, é referenciado como TransactionIdentification ou idConciliacaoRecebedor. 84 | * Em termos de fluxo de funcionamento, o txid é lido pelo aplicativo do PSP do pagador e, depois de confirmado o 85 | * pagamento, é enviado para o SPI via pacs.008. Uma pacs.008 também é enviada ao PSP do recebedor, contendo, além 86 | * de todas as informações usuais do pagamento, o txid. Ao perceber um recebimento dotado de txid, o PSP do 87 | * recebedor está apto a se comunicar com o usuário recebedor, informando que um pagamento específico foi liquidado. 88 | * O txid é criado exclusivamente pelo usuário recebedor e está sob sua responsabilidade. O txid, no contexto de 89 | * representação de uma cobrança, é único por CPF/CNPJ do usuário recebedor. Cabe ao PSP recebedor validar essa 90 | * regra na API Pix. 91 | * @param Calendar $calendar Os campos aninhados sob o identificador calendário organizam informações a respeito de 92 | * controle de tempo da cobrança. 93 | * @param MonetaryValue $value Valores monetários referentes à cobrança. 94 | * @param string $key O campo chave determina a chave Pix registrada no DICT que será utilizada para a cobrança. 95 | * Essa chave será lida pelo aplicativo do PSP do pagador para consulta ao DICT, que retornará a informação que 96 | * identificará o recebedor da cobrança. 97 | * O formato das chaves pode ser encontrado na seção "Formatação das chaves do DICT no BR Code" do Manual de Padrões 98 | * para iniciação do Pix. 99 | * Apenas o tipo de chave EVP/Randômica é aceita no momento. 100 | * @param PhysicalPerson|LegalPerson|null $debtor Os campos aninhados sob o objeto devedor são opcionais e 101 | * identificam o devedor, ou seja, a pessoa ou a instituição a quem a cobrança está endereçada. Não identifica, 102 | * necessariamente, quem irá efetivamente realizar o pagamento. Um CPF pode ser o devedor de uma cobrança, mas pode 103 | * acontecer de outro CPF realizar, efetivamente, o pagamento do documento. Não é permitido que o campo devedor.cpf 104 | * e campo devedor.cnpj estejam preenchidos ao mesmo tempo. Se o campo devedor.cnpj está preenchido, então o campo 105 | * devedor.cpf não pode estar preenchido, e vice-versa. Se o campo devedor.nome está preenchido, então deve existir 106 | * ou um devedor.cpf ou um campo devedor.cnpj preenchido. 107 | * @param string|null $payerRequest O campo solicitacaoPagador, opcional, determina um texto a ser apresentado ao 108 | * pagador para que ele possa digitar uma informação correlata, em formato livre, a ser enviada ao recebedor. Esse 109 | * texto será preenchido, na pacs.008, pelo PSP do pagador, no campo RemittanceInformation . O tamanho do campo na 110 | * pacs.008 está limitado a 140 caracteres. 111 | * @param AdditionalInfo[] $additionalInfo Cada respectiva informação adicional contida na lista (nome e valor) deve 112 | * ser apresentada ao pagador. 113 | */ 114 | public function createImmediateCharge( 115 | string $txid, 116 | Calendar $calendar, 117 | MonetaryValue $value, 118 | string $key, 119 | $debtor = null, 120 | ?string $payerRequest = null, 121 | array $additionalInfo = [] 122 | ) { 123 | return $this->mappedPut("pix-api/v2/cob/$txid", '', [ 124 | RequestOptions::JSON => [ 125 | 'calendario' => $calendar, 126 | 'devedor' => $debtor, 127 | 'valor' => $value, 128 | 'chave' => $key, 129 | 'solicitacaoPagador' => $payerRequest, 130 | 'infoAdicionais' => $additionalInfo, 131 | ], 132 | ]); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/Api/Subscription/CreatePlanResponse.php: -------------------------------------------------------------------------------- 1 | plans ?? []; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Api/Subscription/SubscriptionApi.php: -------------------------------------------------------------------------------- 1 | mappedPost('plans', CreatePlanResponse::class, [ 28 | RequestOptions::JSON => [ 29 | 'name' => $name, 30 | 'amount' => $amount, 31 | ], 32 | ]); 33 | } 34 | 35 | /** 36 | * Retorna uma listagem de todos os planos criados para consulta. 37 | * 38 | * @link https://dev.juno.com.br/api/v2#operation/listPlans 39 | * @return PlanListResponse 40 | */ 41 | public function listPlans(): PlanListResponse 42 | { 43 | return $this->mappedGet('plans', PlanListResponse::class); 44 | } 45 | 46 | /** 47 | * Retorna as informações de um plano existente por meio do ID do plano. 48 | * 49 | * @param string $planId Id do plano 50 | * @return CreatePlanResponse 51 | * @link https://dev.juno.com.br/api/v2#operation/getPlansById 52 | */ 53 | public function findPlan(string $planId): CreatePlanResponse 54 | { 55 | return $this->mappedGet("plans/$planId", CreatePlanResponse::class); 56 | } 57 | 58 | /** 59 | * Desativa um plano com status ACTIVE a partir de seu ID específico. 60 | * 61 | * @param string $planId Id do plano 62 | * @return CreatePlanResponse 63 | * @link https://dev.juno.com.br/api/v2#operation/getPlansById 64 | */ 65 | public function disablePlan(string $planId): CreatePlanResponse 66 | { 67 | return $this->mappedPost("plans/$planId/deactivation", CreatePlanResponse::class); 68 | } 69 | 70 | /** 71 | * Reativa um plano com status INACTIVE a partir de seu ID específico. 72 | * 73 | * @param string $planId Id do plano 74 | * @return CreatePlanResponse 75 | * @link https://dev.juno.com.br/api/v2#operation/activePlanById 76 | */ 77 | public function enablePlan(string $planId): CreatePlanResponse 78 | { 79 | return $this->mappedPost("plans/$planId/activation", CreatePlanResponse::class); 80 | } 81 | 82 | /** 83 | * Para criar uma assinatura, é necessário ter um plano de assinatura primeiro. Caso você ainda não tenha, a 84 | * explicação está na seção “Criar um plano”. 85 | * Com o plano criado, você pode criar uma assinatura no plano por meio do id específico planId. 86 | * 87 | * @param int $dueDay Dia do mês de vencimento da assinatura. 88 | * @param string $planId Identificação do plano de assinatura criado. 89 | * @param string $chargeDescription Nesse campo deverá ser inserido informações referentes a produtos, serviços e 90 | * afins relacionados a essa cobrança. 91 | * @param CreditCardDetails $cardDetails 92 | * @param Billing $billing 93 | * @param Split|null $split Divisão de valores de recebimento. 94 | * @return CreateSubscriptionResponse 95 | */ 96 | public function create( 97 | int $dueDay, 98 | string $planId, 99 | string $chargeDescription, 100 | CreditCardDetails $cardDetails, 101 | Billing $billing, 102 | ?Split $split = null 103 | ): CreateSubscriptionResponse { 104 | return $this->mappedPost('subscriptions', CreateSubscriptionResponse::class, [ 105 | RequestOptions::JSON => [ 106 | 'dueDay' => $dueDay, 107 | 'planId' => $planId, 108 | 'chargeDescription' => $chargeDescription, 109 | 'creditCardDetails' => $cardDetails, 110 | 'billing' => $billing, 111 | 'split' => $split, 112 | ], 113 | ]); 114 | } 115 | 116 | /** 117 | * Retorna uma lista de assinaturas criadas no plano. 118 | * 119 | * @link https://dev.juno.com.br/api/v2#operation/listSubscriptions 120 | * @return SubscriptionListResponse 121 | */ 122 | public function list(): SubscriptionListResponse 123 | { 124 | return $this->mappedGet('subscriptions', SubscriptionListResponse::class); 125 | } 126 | 127 | /** 128 | * Retorna as informações de uma assinatura a partir de seu ID específico. 129 | * 130 | * @param string $subscriptionId 131 | * @link https://dev.juno.com.br/api/v2#operation/getSubscriptionById 132 | * @return CreateSubscriptionResponse 133 | */ 134 | public function find(string $subscriptionId): CreateSubscriptionResponse 135 | { 136 | return $this->mappedGet("subscriptions/$subscriptionId", CreateSubscriptionResponse::class); 137 | } 138 | 139 | /** 140 | * Desativa uma assinatura com status ACTIVE a partir de seu ID de identificação. 141 | * 142 | * @param string $subscriptionId 143 | * @link https://dev.juno.com.br/api/v2#operation/inactiveSubscriptionById 144 | * @return CreateSubscriptionResponse 145 | */ 146 | public function disable(string $subscriptionId): CreateSubscriptionResponse 147 | { 148 | return $this->mappedPost("subscriptions/$subscriptionId/deactivation"); 149 | } 150 | 151 | /** 152 | * Reativa uma assinatura com status INACTIVE a partir de seu ID de identificação. 153 | * 154 | * @param string $subscriptionId 155 | * @link https://dev.juno.com.br/api/v2#operation/activeSubscriptionById 156 | * @return CreateSubscriptionResponse 157 | */ 158 | public function enable(string $subscriptionId): CreateSubscriptionResponse 159 | { 160 | return $this->mappedPost("subscriptions/$subscriptionId/activation"); 161 | } 162 | 163 | /** 164 | * Faz o cancelamento definitivo de uma assinatura a partir de seu ID específico. Esta ação não pode ser desfeita. 165 | * Caso queira desativar momentaneamente, para depois reativar, considere desativar a assinatura. 166 | * 167 | * @param string $subscriptionId 168 | * @link https://dev.juno.com.br/api/v2#operation/cancelSubscriptionById 169 | * @return CreateSubscriptionResponse 170 | */ 171 | public function cancel(string $subscriptionId): CreateSubscriptionResponse 172 | { 173 | return $this->mappedPost("subscriptions/$subscriptionId/cancelation"); 174 | } 175 | 176 | /** 177 | * Completa ou finaliza uma assinatura a partir de seu ID específico. 178 | * 179 | * @param string $subscriptionId 180 | * @link https://dev.juno.com.br/api/v2#operation/completeSubscriptionById 181 | * @return CreateSubscriptionResponse 182 | */ 183 | public function end(string $subscriptionId): CreateSubscriptionResponse 184 | { 185 | return $this->mappedPost("subscriptions/$subscriptionId/completion"); 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /src/Api/Subscription/SubscriptionListResponse.php: -------------------------------------------------------------------------------- 1 | subscriptions ?? []; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Api/Transference/TransferenceApi.php: -------------------------------------------------------------------------------- 1 | mappedPost('transfers', TransferenceResponse::class, [ 40 | RequestOptions::JSON => [ 41 | 'type' => $type, 42 | 'name' => $name, 43 | 'document' => $document, 44 | 'amount' => $amount, 45 | 'bankAccount' => $bankAccount, 46 | ], 47 | ]); 48 | } 49 | 50 | /** 51 | * @param float $amount 52 | * @link https://dev.juno.com.br/api/v2#operation/requestTransfer 53 | * @return TransferenceResponse 54 | */ 55 | public function defaultBankAccount(float $amount): TransferenceResponse 56 | { 57 | return $this->mappedPost('transfers', TransferenceResponse::class, [ 58 | RequestOptions::JSON => [ 59 | 'type' => self::DEFAULT_BANK_ACCOUNT_TRANSFER_REQUEST, 60 | 'amount' => $amount, 61 | ], 62 | ]); 63 | } 64 | 65 | /** 66 | * @param string $name 67 | * @param string $document 68 | * @param float $amount 69 | * @param BankAccount $bankAccount 70 | * @link https://dev.juno.com.br/api/v2#operation/requestTransfer 71 | * @return TransferenceResponse 72 | */ 73 | public function bankAccount( 74 | string $name, 75 | string $document, 76 | float $amount, 77 | BankAccount $bankAccount 78 | ): TransferenceResponse { 79 | return $this->transfer( 80 | self::BANK_ACCOUNT_TRANSFER_REQUEST, 81 | $name, 82 | $document, 83 | $amount, 84 | $bankAccount 85 | ); 86 | } 87 | 88 | /** 89 | * @param string $name 90 | * @param string $document 91 | * @param float $amount 92 | * @param PixBankAccount $bankAccount 93 | * @link https://dev.juno.com.br/api/v2#operation/requestTransfer 94 | * @return TransferenceResponse 95 | */ 96 | public function pix( 97 | string $name, 98 | string $document, 99 | float $amount, 100 | PixBankAccount $bankAccount 101 | ): TransferenceResponse { 102 | return $this->transfer( 103 | self::PIX_TRANSFER_REQUEST, 104 | $name, 105 | $document, 106 | $amount, 107 | $bankAccount 108 | ); 109 | } 110 | 111 | /** 112 | * @param string $name 113 | * @param string $document 114 | * @param float $amount 115 | * @param string $accountNumber 116 | * @link https://dev.juno.com.br/api/v2#operation/requestTransfer 117 | * @return TransferenceResponse 118 | */ 119 | public function p2p( 120 | string $name, 121 | string $document, 122 | float $amount, 123 | string $accountNumber 124 | ): TransferenceResponse { 125 | return $this->mappedPost('transfers', TransferenceResponse::class, [ 126 | RequestOptions::JSON => [ 127 | 'type' => self::P2P_TRANSFER_REQUEST, 128 | 'name' => $name, 129 | 'document' => $document, 130 | 'amount' => $amount, 131 | 'bankAccount' => [ 132 | 'accountNumber' => $accountNumber, 133 | ], 134 | ], 135 | ]); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/Api/Transference/TransferenceResponse.php: -------------------------------------------------------------------------------- 1 | id; 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getDigitalAccountId(): string 35 | { 36 | return $this->digitalAccountId; 37 | } 38 | 39 | /** 40 | * @return string 41 | */ 42 | public function getCreationDate(): string 43 | { 44 | return $this->creationDate; 45 | } 46 | 47 | /** 48 | * @return string|null 49 | */ 50 | public function getTransferDate(): ?string 51 | { 52 | return $this->transferDate; 53 | } 54 | 55 | /** 56 | * @return float 57 | */ 58 | public function getAmount(): float 59 | { 60 | return $this->amount; 61 | } 62 | 63 | /** 64 | * @return string 65 | */ 66 | public function getStatus(): string 67 | { 68 | return $this->status; 69 | } 70 | 71 | /** 72 | * @return Recipient|null 73 | */ 74 | public function getRecipient(): ?Recipient 75 | { 76 | return $this->recipient; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Api/Webhook/FindWebhookResponse.php: -------------------------------------------------------------------------------- 1 | data ?? []; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Api/Webhook/Notification/NotificationBase.php: -------------------------------------------------------------------------------- 1 | eventId; 19 | } 20 | 21 | /** 22 | * Pode ser um de: 23 | * - BANK_PAID_BACK 24 | * - CONFIRMED 25 | * - PARTIALLY_REFUNDED 26 | * - CUSTOMER_PAID_BACK 27 | * - DECLINED 28 | * - FAILED NOT_AUTHORIZED 29 | * @return string 30 | */ 31 | public function getEventType(): string 32 | { 33 | return $this->eventType; 34 | } 35 | 36 | /** 37 | * @return array 38 | */ 39 | public function getData(): array 40 | { 41 | return $this->data ?? []; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Api/Webhook/Notification/PaymentNotification.php: -------------------------------------------------------------------------------- 1 | data ?? []; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Api/Webhook/Notification/TransferNotification.php: -------------------------------------------------------------------------------- 1 | data ?? []; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Api/Webhook/WebhookApi.php: -------------------------------------------------------------------------------- 1 | mappedGet('notifications/event-types', WebhookTypeListResponse::class); 39 | } 40 | 41 | /** 42 | * Cadastre um ou mais webhooks para receber os tipos de notificação subescritos nos eventos disponíveis. 43 | * Os webhooks e inscrição a um evento precisa ser única por recurso, o que significa que cada conta digital DEVE 44 | * ter seu próprio webhook registrado. Não há webhook global. Você pode usar o endpoint para todos os registros de 45 | * webhook, com ou sem parametros de cadeia de consulta. 46 | * 47 | * Atenção: O webhook deve usar HTTP sobre SSL encriptado e começar com https://. 48 | * 49 | * Não é possível se inscrever em um evento que já tenha esteja com uma inscrição ativa. Este deve ser desativado 50 | * para que uma nova inscrição seja feita. 51 | * 52 | * Explicando o processo de assinatura: 53 | * 54 | * Em resposta a esta solicitação, devolvemos os dados básicos do cadastro, a identificação do webhook e uma chave 55 | * (secret) exclusiva para o webhook cadastrado. A chave é utilizada para assinar os eventos que serão enviados para 56 | * o webhook e também para validar a assinatura dos eventos recebidos pelo webhook. Portanto, é muito importante que 57 | * a chave seja armazenada de forma apropriada para que a assinatura dos eventos recebidos possa ser verificada 58 | * adequadamente. 59 | * 60 | * O processo de assinatura do evento é o seguinte: 61 | * 62 | * O evento é assinado utilizando-se o algoritmo HMAC (SHA-256), que recebe como entrada o conteúdo do evento 63 | * (payload) e a chave do webhook. 64 | * O algoritmo nos devolve um hash (assinatura) que é enviado no header do request HTTP (campo X-Signature). 65 | * Esquematicamente: x_signature = hmac(secret, event_content). 66 | * 67 | * Como deve ser o processo de verificação da assinatura, do lado do webhook, durante a recepção de uma mensagem: 68 | * 69 | * O cliente deve assinar o conteúdo do evento da mesma forma descrita acima e assim gerar um hash (assinatuda) do 70 | * payload do evento. O conteúdo da mensagem HTTP deve ser assinada antes de qualquer formatação. 71 | * O hash gerado deve ser comparado com o hash enviado no header do request HTTP, campo X-Signature. 72 | * Os valores devem ser iguais. 73 | * Esquematicamente: verification = hmac(secret, event_content). O que deve implicar que: 74 | * verification == http_header[X-Signature]. 75 | * 76 | * O que isso significa? 77 | * 78 | * Quando os valores das assinaturas são idênticos, significa que o conteúdo do evento que saiu dos nossos 79 | * servidores chegou exatamente igual no servidor do cliente. 80 | * Caso os valores não sejam iguais, pode significar que o conteúdo do evento foi adulterado durante o trajeto e 81 | * portanto deve ser ignorado. 82 | * Também pode significar que alguma outra fonte pode estar enviando mensagens indevidas para a url de notificação 83 | * do cliente, e portanto, estas mensagens não são de fonte confiável e devem ser ignoradas. 84 | * Outros pontos importantes que podem não estar claros: 85 | * O cadastro de webhooks é por conta digital. X-Resource-Token deve ser informado para indicar a conta onde o 86 | * webhook será cadastrado. 87 | * 88 | * Não é permitido que dois webhooks da mesma conta digital assinem os mesmo eventos. 89 | * 90 | * @param string $url 91 | * @param string[] $eventTypes 92 | * @link https://dev.juno.com.br/api/v2#operation/getEventTypes eventos disponíveis 93 | * @link https://dev.juno.com.br/api/v2#operation/createWebhook 94 | * @see WebhookEventType para os tipos de eventos válidos 95 | * @return FindWebhookResponse 96 | */ 97 | public function create(string $url, array $eventTypes): FindWebhookResponse 98 | { 99 | return $this->mappedPost('notifications/webhooks', FindWebhookResponse::class, [ 100 | RequestOptions::JSON => [ 101 | 'url' => $url, 102 | 'eventTypes' => $eventTypes, 103 | ], 104 | ]); 105 | } 106 | 107 | /** 108 | * Retorna uma lista completa dos webhooks cadastrados para a conta digital e suas respectivas inscrições. 109 | * 110 | * @link https://dev.juno.com.br/api/v2#operation/getWebhooks 111 | * @return WebhookListResponse 112 | */ 113 | public function list(): WebhookListResponse 114 | { 115 | return $this->mappedGet('notifications/webhooks', WebhookListResponse::class); 116 | } 117 | 118 | /** 119 | * Retorna o webhook específicado. 120 | * A partir do id específico retornado no momento da criação deste webhook, faça a consulta deste e verifique o 121 | * estado atual e o evento para o qual foi inscrito. 122 | * Caso o estado e/ou o tipo de evento esteja diferente do esperado, atualize o webhook. 123 | * 124 | * @param string $webhookId 125 | * @link https://dev.juno.com.br/api/v2#operation/findWebhook 126 | * @return FindWebhookResponse 127 | */ 128 | public function find(string $webhookId): FindWebhookResponse 129 | { 130 | return $this->mappedGet("notifications/webhooks/$webhookId", FindWebhookResponse::class); 131 | } 132 | 133 | /** 134 | * Atualize os campos status e eventTypes dos webhooks cadastradados. 135 | * Ao menos um dos campos precisa ser mudado, não sendo necessário a mudança de ambos ao mesmo tempo. Entretanto, 136 | * envie ambos os campos mesmo que apenas um destes venha a ser modificado. 137 | * A url do Webhook não pode ser modificada. 138 | * 139 | * @param string $webhookId 140 | * @param string $status - Enum: "ACTIVE" ou "INACTIVE" 141 | * @param string[] $eventTypes 142 | * @link https://dev.juno.com.br/api/v2#operation/updateWebhook 143 | * @see WebhookEventType para os tipos de eventos válidos 144 | * @return FindWebhookResponse 145 | */ 146 | public function update(string $webhookId, string $status, array $eventTypes): FindWebhookResponse 147 | { 148 | return $this->mappedPatch("notifications/webhooks/$webhookId", FindWebhookResponse::class, [ 149 | RequestOptions::JSON => [ 150 | 'status' => $status, 151 | 'eventTypes' => $eventTypes, 152 | ], 153 | ]); 154 | } 155 | 156 | /** 157 | * Deleta um webhook. 158 | * Esta operação não deleta os eventos que já foram despachados para os webhooks listados. 159 | * 160 | * @param string $webhookId 161 | * @link https://dev.juno.com.br/api/v2#operation/deleteWebhook 162 | * @return Response 163 | */ 164 | public function delete(string $webhookId): Response 165 | { 166 | return $this->request('delete', "notifications/webhooks/$webhookId"); 167 | } 168 | 169 | /** 170 | * @param PaymentNotification|TransferNotification $notification 171 | * @param array $requestHeaders 172 | * @param string $secret 173 | * @return bool 174 | * @throws \JsonException 175 | */ 176 | public function checkNotificationSignature($notification, array $requestHeaders, string $secret): bool 177 | { 178 | $signature = $requestHeaders['X-Signature'] ?? null; 179 | $data = $notification->getHydrationData()['data'] ?? null; 180 | 181 | if (is_null($signature)) { 182 | throw new InvalidArgumentException('Header de assinatura ausente'); 183 | } 184 | 185 | if (is_null($data)) { 186 | throw new InvalidArgumentException('Falha ao obter os dados do webhook. Campo \'data\' ausente'); 187 | } 188 | 189 | $hash = hash_hmac('sha256', json_encode($data, JSON_THROW_ON_ERROR), $secret); 190 | 191 | return hash_equals($signature, $hash); 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /src/Api/Webhook/WebhookBase.php: -------------------------------------------------------------------------------- 1 | id; 28 | } 29 | 30 | /** 31 | * @return string 32 | */ 33 | public function getUrl(): string 34 | { 35 | return $this->url; 36 | } 37 | 38 | /** 39 | * @return string 40 | */ 41 | public function getSecret(): string 42 | { 43 | return $this->secret; 44 | } 45 | 46 | /** 47 | * @return string 48 | */ 49 | public function getStatus(): string 50 | { 51 | return $this->status; 52 | } 53 | 54 | /** 55 | * @return WebhookEventType[] 56 | */ 57 | public function getEventTypes(): array 58 | { 59 | return $this->eventTypes ?? []; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Api/Webhook/WebhookListResponse.php: -------------------------------------------------------------------------------- 1 | webhooks ?? []; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Api/Webhook/WebhookTypeListResponse.php: -------------------------------------------------------------------------------- 1 | eventTypes ?? []; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Console/InstallJunoPackage.php: -------------------------------------------------------------------------------- 1 | confirm('O arquivo de configuração já existe, deseja sobrescrever?', false)) { 19 | $this->publish(true); 20 | $this->info('Arquivo de configuração sobrescrito'); 21 | } 22 | 23 | return; 24 | } 25 | 26 | $this->publish(); 27 | $this->info('Arquivo de configuração copiado para ./config/juno.php'); 28 | } 29 | 30 | private function publish($force = false): void 31 | { 32 | $params = [ 33 | '--provider' => JunoServiceProvider::class, 34 | '--tag' => 'config' 35 | ]; 36 | 37 | if ($force) { 38 | $params['--force'] = ''; 39 | } 40 | 41 | $this->call('vendor:publish', $params); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Entity/AccountHolder.php: -------------------------------------------------------------------------------- 1 | name; 23 | } 24 | 25 | /** 26 | * @return string 27 | */ 28 | public function getDocument(): string 29 | { 30 | return $this->document; 31 | } 32 | 33 | /** 34 | * @param string $name Nome do titular da conta bancária. 35 | * @return AccountHolder 36 | */ 37 | public function setName(string $name): AccountHolder 38 | { 39 | $this->name = $name; 40 | return $this; 41 | } 42 | 43 | /** 44 | * @param string $document CPF do titular da conta bancária. Envie sem ponto ou traço. 45 | * @return AccountHolder 46 | */ 47 | public function setDocument(string $document): AccountHolder 48 | { 49 | $this->document = $document; 50 | return $this; 51 | } 52 | 53 | public static function new(string $name, string $document): self 54 | { 55 | return (new static()) 56 | ->setName($name) 57 | ->setDocument($document); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Entity/Address.php: -------------------------------------------------------------------------------- 1 | street; 39 | } 40 | 41 | /** 42 | * @return string|null 43 | */ 44 | public function getNumber(): ?string 45 | { 46 | return $this->number; 47 | } 48 | 49 | /** 50 | * @return string|null 51 | */ 52 | public function getComplement(): ?string 53 | { 54 | return $this->complement; 55 | } 56 | 57 | /** 58 | * @return string|null 59 | */ 60 | public function getNeighborhood(): ?string 61 | { 62 | return $this->neighborhood; 63 | } 64 | 65 | /** 66 | * @return string|null 67 | */ 68 | public function getCity(): ?string 69 | { 70 | return $this->city; 71 | } 72 | 73 | /** 74 | * @return string|null 75 | */ 76 | public function getState(): ?string 77 | { 78 | return $this->state; 79 | } 80 | 81 | /** 82 | * @return string|null 83 | */ 84 | public function getPostCode(): ?string 85 | { 86 | return $this->postCode; 87 | } 88 | 89 | /** 90 | * @param string $street Rua. 91 | * @return Address 92 | */ 93 | public function setStreet(string $street): Address 94 | { 95 | $this->street = $street; 96 | return $this; 97 | } 98 | 99 | /** 100 | * @param string $number Número. Se não houver, envie N/A. 101 | * @return Address 102 | */ 103 | public function setNumber(string $number): Address 104 | { 105 | $this->number = $number; 106 | return $this; 107 | } 108 | 109 | /** 110 | * @param string|null $complement Complemento. 111 | * @return Address 112 | */ 113 | public function setComplement(?string $complement): Address 114 | { 115 | $this->complement = $complement; 116 | return $this; 117 | } 118 | 119 | /** 120 | * @param string|null $neighborhood Bairro. 121 | * @return Address 122 | */ 123 | public function setNeighborhood(?string $neighborhood): Address 124 | { 125 | $this->neighborhood = $neighborhood; 126 | return $this; 127 | } 128 | 129 | /** 130 | * @param string $city Cidade. 131 | * @return Address 132 | */ 133 | public function setCity(string $city): Address 134 | { 135 | $this->city = $city; 136 | return $this; 137 | } 138 | 139 | /** 140 | * @param string $state Estado em sigla de Unidade Federativa (UF). 141 | * @return Address 142 | */ 143 | public function setState(string $state): Address 144 | { 145 | if (strlen($state) !== 2) { 146 | throw new InvalidArgumentException('Estados devem ser fornecidos em formato de sigla (2 chars)'); 147 | } 148 | 149 | $this->state = $state; 150 | return $this; 151 | } 152 | 153 | /** 154 | * @param string $postCode Código de Endereçamento Postal no Brasil (CEP). SEM hífen. 155 | * @return Address 156 | */ 157 | public function setPostalCode(string $postCode): Address 158 | { 159 | $postCode = preg_replace('/\D/', '', $postCode); 160 | $this->postCode = $postCode; 161 | return $this; 162 | } 163 | 164 | /** 165 | * Configura o número do endereço como 'N/A'. 166 | * @return Address 167 | */ 168 | public function setWithoutNumber(): Address 169 | { 170 | $this->number = 'N/A'; 171 | return $this; 172 | } 173 | 174 | public static function new(string $street, string $number, string $city, string $state, string $postalCode): self 175 | { 176 | return (new static()) 177 | ->setStreet($street) 178 | ->setNumber($number) 179 | ->setCity($city) 180 | ->setState($state) 181 | ->setPostalCode($postalCode); 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /src/Entity/BankAccount.php: -------------------------------------------------------------------------------- 1 | bankNumber; 48 | } 49 | 50 | /** 51 | * @return string 52 | */ 53 | public function getAgencyNumber(): string 54 | { 55 | return $this->agencyNumber; 56 | } 57 | 58 | /** 59 | * @return string 60 | */ 61 | public function getAccountNumber(): string 62 | { 63 | return $this->accountNumber; 64 | } 65 | 66 | /** 67 | * @return string|null 68 | */ 69 | public function getAccountComplementNumber(): ?string 70 | { 71 | return $this->accountComplementNumber; 72 | } 73 | 74 | /** 75 | * @return string 76 | */ 77 | public function getAccountType(): string 78 | { 79 | return $this->accountType; 80 | } 81 | 82 | /** 83 | * @return AccountHolder 84 | */ 85 | public function getAccountHolder(): AccountHolder 86 | { 87 | return $this->accountHolder; 88 | } 89 | 90 | /** 91 | * @param string|null $bankNumber Código de compensação do bancos do Brasil. Espera 3 digitos. 92 | * @return BankAccount 93 | */ 94 | public function setBankNumber(?string $bankNumber): BankAccount 95 | { 96 | if (!is_null($bankNumber) && strlen($bankNumber) !== 3) { 97 | throw new InvalidArgumentException('O código do banco deve conter 3 dígitos.'); 98 | } 99 | 100 | $this->bankNumber = $bankNumber; 101 | return $this; 102 | } 103 | 104 | /** 105 | * @param string $agencyNumber Número da agência. Deve respeitar o padrão de cada banco. 106 | * @return BankAccount 107 | */ 108 | public function setAgencyNumber(string $agencyNumber): BankAccount 109 | { 110 | $this->agencyNumber = $agencyNumber; 111 | return $this; 112 | } 113 | 114 | /** 115 | * @param string $accountNumber Número da conta. Deve respeitar o padrão de cada banco. 116 | * @return BankAccount 117 | */ 118 | public function setAccountNumber(string $accountNumber): BankAccount 119 | { 120 | $this->accountNumber = $accountNumber; 121 | return $this; 122 | } 123 | 124 | /** 125 | * @param string|null $accountComplementNumber Complemento da conta a ser criada. 126 | * Enum: "001" "002" "003" "006" "007" "013" "022" "023" "028" "043" "031". 127 | * Exclusivo e obrigatório apenas para contas Caixa. 128 | * @return BankAccount 129 | */ 130 | public function setAccountComplementNumber(?string $accountComplementNumber): BankAccount 131 | { 132 | $this->accountComplementNumber = $accountComplementNumber; 133 | return $this; 134 | } 135 | 136 | /** 137 | * @param string $accountType Tipo da conta. Envie CHECKING para Conta Corrente e SAVINGS para Poupança. 138 | * @return BankAccount 139 | */ 140 | public function setAccountType(string $accountType): BankAccount 141 | { 142 | $this->accountType = $accountType; 143 | return $this; 144 | } 145 | 146 | /** 147 | * @param AccountHolder|null $accountHolder Titular da conta. 148 | * @return BankAccount 149 | */ 150 | public function setAccountHolder(?AccountHolder $accountHolder): BankAccount 151 | { 152 | $this->accountHolder = $accountHolder; 153 | return $this; 154 | } 155 | 156 | public static function new( 157 | string $accountNumber, 158 | string $agencyNumber, 159 | string $accountType, 160 | ?string $bankNumber = null, 161 | ?AccountHolder $accountHolder = null 162 | ): self { 163 | return (new static()) 164 | ->setAccountNumber($accountNumber) 165 | ->setAgencyNumber($agencyNumber) 166 | ->setAccountType($accountType) 167 | ->setBankNumber($bankNumber) 168 | ->setAccountHolder($accountHolder); 169 | } 170 | 171 | public static function checking( 172 | string $accountNumber, 173 | string $agencyNumber, 174 | ?string $bankNumber = null, 175 | ?AccountHolder $accountHolder = null 176 | ): self { 177 | return self::new($accountNumber, $agencyNumber, self::CHECKING_ACCOUNT_TYPE, $bankNumber, $accountHolder); 178 | } 179 | 180 | public static function savings( 181 | string $accountNumber, 182 | string $agencyNumber, 183 | ?string $bankNumber = null, 184 | ?AccountHolder $accountHolder = null 185 | ): self { 186 | return self::new($accountNumber, $agencyNumber, self::SAVINGS_ACCOUNT_TYPE, $bankNumber, $accountHolder); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /src/Entity/BankResource.php: -------------------------------------------------------------------------------- 1 | number; 20 | } 21 | 22 | /** 23 | * @return string 24 | */ 25 | public function getName(): string 26 | { 27 | return $this->name; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Entity/BilletDetails.php: -------------------------------------------------------------------------------- 1 | bankAccount; 29 | } 30 | 31 | /** 32 | * @return string Nosso número 33 | */ 34 | public function getOurNumber(): string 35 | { 36 | return $this->ourNumber; 37 | } 38 | 39 | /** 40 | * @return string Código de barras 41 | */ 42 | public function getBarcodeNumber(): string 43 | { 44 | return $this->barcodeNumber; 45 | } 46 | 47 | /** 48 | * @return string Carteira bancária 49 | */ 50 | public function getPortfolio(): string 51 | { 52 | return $this->portfolio; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Entity/Billing.php: -------------------------------------------------------------------------------- 1 | Data de nascimento do comprador. */ 30 | protected ?string $birthDate = null; 31 | 32 | /** @var bool $notify - Define se o compador receberá emails de notificação diretamente da Juno. */ 33 | protected bool $notify = false; 34 | 35 | /** 36 | * @return string 37 | */ 38 | public function getName(): string 39 | { 40 | return $this->name; 41 | } 42 | 43 | /** 44 | * @return string 45 | */ 46 | public function getDocument(): string 47 | { 48 | return $this->document; 49 | } 50 | 51 | /** 52 | * @return string 53 | */ 54 | public function getEmail(): string 55 | { 56 | return $this->email; 57 | } 58 | 59 | /** 60 | * @return Address 61 | */ 62 | public function getAddress(): Address 63 | { 64 | return $this->address; 65 | } 66 | 67 | /** 68 | * @return string|null 69 | */ 70 | public function getSecondaryEmail(): ?string 71 | { 72 | return $this->secondaryEmail; 73 | } 74 | 75 | /** 76 | * @return string|null 77 | */ 78 | public function getPhone(): ?string 79 | { 80 | return $this->phone; 81 | } 82 | 83 | /** 84 | * @return string|null 85 | */ 86 | public function getBirthDate(): ?string 87 | { 88 | return $this->birthDate; 89 | } 90 | 91 | /** 92 | * @return bool 93 | */ 94 | public function isNotify(): bool 95 | { 96 | return $this->notify; 97 | } 98 | 99 | /** 100 | * @param string $name 101 | * @return Billing 102 | */ 103 | public function setName(string $name): Billing 104 | { 105 | $this->name = $name; 106 | return $this; 107 | } 108 | 109 | /** 110 | * @param string $document 111 | * @return Billing 112 | */ 113 | public function setDocument(string $document): Billing 114 | { 115 | $this->document = $document; 116 | return $this; 117 | } 118 | 119 | /** 120 | * @param string $email 121 | * @return Billing 122 | */ 123 | public function setEmail(string $email): Billing 124 | { 125 | $this->email = $email; 126 | return $this; 127 | } 128 | 129 | /** 130 | * @param Address $address 131 | * @return Billing 132 | */ 133 | public function setAddress(Address $address): Billing 134 | { 135 | $this->address = $address; 136 | return $this; 137 | } 138 | 139 | /** 140 | * @param string|null $secondaryEmail 141 | * @return Billing 142 | */ 143 | public function setSecondaryEmail(?string $secondaryEmail): Billing 144 | { 145 | $this->secondaryEmail = $secondaryEmail; 146 | return $this; 147 | } 148 | 149 | /** 150 | * @param string|null $phone 151 | * @return Billing 152 | */ 153 | public function setPhone(?string $phone): Billing 154 | { 155 | $this->phone = $phone; 156 | return $this; 157 | } 158 | 159 | /** 160 | * @param string|null $birthDate 161 | * @return Billing 162 | */ 163 | public function setBirthDate(?string $birthDate): Billing 164 | { 165 | $this->birthDate = $birthDate; 166 | return $this; 167 | } 168 | 169 | /** 170 | * @param bool $notify 171 | * @return Billing 172 | */ 173 | public function setNotify(bool $notify): Billing 174 | { 175 | $this->notify = $notify; 176 | return $this; 177 | } 178 | 179 | public static function new(string $name, string $document, string $email, Address $address): self 180 | { 181 | return (new static()) 182 | ->setName($name) 183 | ->setDocument($document) 184 | ->setEmail($email) 185 | ->setAddress($address); 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /src/Entity/BusinessAreaResource.php: -------------------------------------------------------------------------------- 1 | code; 21 | } 22 | 23 | /** 24 | * @return string 25 | */ 26 | public function getActivity(): string 27 | { 28 | return $this->activity; 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getCategory(): string 35 | { 36 | return $this->category; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Entity/ChargeResource.php: -------------------------------------------------------------------------------- 1 | */ 12 | protected string $id; 13 | 14 | /** @var int $code */ 15 | protected int $code; 16 | 17 | protected string $reference; 18 | 19 | /** @var string $dueDate */ 20 | protected string $dueDate; 21 | 22 | protected string $link; 23 | 24 | protected string $checkoutUrl; 25 | 26 | protected string $installmentLink; 27 | 28 | protected string $payNumber; 29 | 30 | protected float $amount; 31 | 32 | /** @var string $status Enum: "ACTIVE", "CANCELLED", "MANUAL_RECONCILIATION", "FAILED" or "PAID" 33 | */ 34 | protected string $status; 35 | 36 | protected BilletDetails $billetDetails; 37 | 38 | /** @var Payment[] $payments */ 39 | protected array $payments; 40 | 41 | protected Pix $pix; 42 | 43 | public function paymentsItemType(): string 44 | { 45 | return Payment::class; 46 | } 47 | 48 | /** 49 | * @return string 50 | */ 51 | public function getId(): string 52 | { 53 | return $this->id; 54 | } 55 | 56 | /** 57 | * @return int 58 | */ 59 | public function getCode(): int 60 | { 61 | return $this->code; 62 | } 63 | 64 | /** 65 | * @return string 66 | */ 67 | public function getReference(): string 68 | { 69 | return $this->reference; 70 | } 71 | 72 | /** 73 | * @return string 74 | */ 75 | public function getDueDate(): string 76 | { 77 | return $this->dueDate; 78 | } 79 | 80 | /** 81 | * @return string 82 | */ 83 | public function getLink(): string 84 | { 85 | return $this->link; 86 | } 87 | 88 | /** 89 | * @return string 90 | */ 91 | public function getCheckoutUrl(): string 92 | { 93 | return $this->checkoutUrl; 94 | } 95 | 96 | /** 97 | * @return string 98 | */ 99 | public function getInstallmentLink(): string 100 | { 101 | return $this->installmentLink; 102 | } 103 | 104 | /** 105 | * @return string 106 | */ 107 | public function getPayNumber(): string 108 | { 109 | return $this->payNumber; 110 | } 111 | 112 | /** 113 | * @return float 114 | */ 115 | public function getAmount(): float 116 | { 117 | return $this->amount; 118 | } 119 | 120 | /** 121 | * @return string 122 | */ 123 | public function getStatus(): string 124 | { 125 | return $this->status; 126 | } 127 | 128 | /** 129 | * @return BilletDetails 130 | */ 131 | public function getBilletDetails(): BilletDetails 132 | { 133 | return $this->billetDetails; 134 | } 135 | 136 | /** 137 | * @return Payment[] 138 | */ 139 | public function getPayments(): array 140 | { 141 | return $this->payments ?? []; 142 | } 143 | 144 | /** 145 | * @return Pix 146 | */ 147 | public function getPix(): Pix 148 | { 149 | return $this->pix; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/Entity/CompanyMember.php: -------------------------------------------------------------------------------- 1 | Data de nascimento do membro. */ 18 | protected string $birthDate; 19 | 20 | /** 21 | * @return string 22 | */ 23 | public function getName(): string 24 | { 25 | return $this->name; 26 | } 27 | 28 | /** 29 | * @return string 30 | */ 31 | public function getDocument(): string 32 | { 33 | return $this->document; 34 | } 35 | 36 | /** 37 | * @return string 38 | */ 39 | public function getBirthDate(): string 40 | { 41 | return $this->birthDate; 42 | } 43 | 44 | /** 45 | * @param string $name Nome do membro. 46 | * @return CompanyMember 47 | */ 48 | public function setName(string $name): CompanyMember 49 | { 50 | $this->name = $name; 51 | return $this; 52 | } 53 | 54 | /** 55 | * @param string $document CPF ou CNPJ do membro. 56 | * @return CompanyMember 57 | */ 58 | public function setDocument(string $document): CompanyMember 59 | { 60 | $this->document = $document; 61 | return $this; 62 | } 63 | 64 | /** 65 | * @param string $birthDate Data de nascimento do membro. 66 | * @return CompanyMember 67 | */ 68 | public function setBirthDate(string $birthDate): CompanyMember 69 | { 70 | $this->birthDate = $birthDate; 71 | return $this; 72 | } 73 | 74 | public static function new(string $name, string $document, string $birthdate): self 75 | { 76 | return (new static()) 77 | ->setName($name) 78 | ->setDocument($document) 79 | ->setBirthDate($birthdate); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Entity/CreatePlansResource.php: -------------------------------------------------------------------------------- 1 | creditCardId; 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getCreditCardHash(): string 35 | { 36 | return $this->creditCardHash; 37 | } 38 | 39 | /** 40 | * @param string $creditCardId Id do cartão de crédito gerado a partir da Tokenização. Caso seja utilizado esse 41 | * parâmetro, não deve ser enviado o creditCardHash. 42 | * @return CreditCardDetails 43 | */ 44 | public function setCreditCardId(string $creditCardId): CreditCardDetails 45 | { 46 | $this->creditCardId = $creditCardId; 47 | return $this; 48 | } 49 | 50 | /** 51 | * @param string $creditCardHash Hash do cartão de crédito gerado a partir da comunicação da Biblioteca de 52 | * Criptografia. Caso seja utilizado esse parâmetro, não deve ser enviado o creditCardId. 53 | * @return CreditCardDetails 54 | */ 55 | public function setCreditCardHash(string $creditCardHash): CreditCardDetails 56 | { 57 | $this->creditCardHash = $creditCardHash; 58 | return $this; 59 | } 60 | 61 | public static function new(string $creditCardId, string $creditCardHash): self 62 | { 63 | return (new static()) 64 | ->setCreditCardId($creditCardId) 65 | ->setCreditCardHash($creditCardHash); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Entity/DocumentResource.php: -------------------------------------------------------------------------------- 1 | */ 12 | protected string $id; 13 | 14 | protected string $type; 15 | 16 | protected string $description; 17 | 18 | protected string $approvalStatus; 19 | 20 | protected ?string $rejectionReason = null; 21 | 22 | protected ?string $details = null; 23 | 24 | /** 25 | * @return string 26 | */ 27 | public function getId(): string 28 | { 29 | return $this->id; 30 | } 31 | 32 | /** 33 | * @return string 34 | */ 35 | public function getType(): string 36 | { 37 | return $this->type; 38 | } 39 | 40 | /** 41 | * @return string 42 | */ 43 | public function getDescription(): string 44 | { 45 | return $this->description; 46 | } 47 | 48 | /** 49 | * @return string 50 | */ 51 | public function getApprovalStatus(): string 52 | { 53 | return $this->approvalStatus; 54 | } 55 | 56 | /** 57 | * @return string|null 58 | */ 59 | public function getRejectionReason(): ?string 60 | { 61 | return $this->rejectionReason; 62 | } 63 | 64 | /** 65 | * @return string|null 66 | */ 67 | public function getDetails(): ?string 68 | { 69 | return $this->details; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Entity/ErrorDetail.php: -------------------------------------------------------------------------------- 1 | message; 21 | } 22 | 23 | /** 24 | * @return string 25 | */ 26 | public function getErrorCode(): string 27 | { 28 | return $this->errorCode; 29 | } 30 | 31 | /** 32 | * @return string|null 33 | */ 34 | public function getField(): ?string 35 | { 36 | return $this->field; 37 | } 38 | 39 | /** 40 | * @return string 41 | */ 42 | public function __toString() 43 | { 44 | $ss = sprintf('[ERROR_CODE %s]: %s', $this->errorCode, $this->message); 45 | 46 | if (!is_null($this->field)) { 47 | $ss .= sprintf('\n[FIELD]: %s', $this->field); 48 | } 49 | 50 | return $ss; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Entity/LegalRepresentative.php: -------------------------------------------------------------------------------- 1 | YYYY-MM-DD */ 17 | protected string $birthDate; 18 | 19 | /** 20 | * @param string $name 21 | * @return LegalRepresentative 22 | */ 23 | public function setName(string $name): LegalRepresentative 24 | { 25 | $this->name = $name; 26 | return $this; 27 | } 28 | 29 | /** 30 | * @param string $document CPF (11 chars) || CNPJ (14 chars). 31 | * @return LegalRepresentative 32 | */ 33 | public function setDocument(string $document): LegalRepresentative 34 | { 35 | $this->document = $document; 36 | return $this; 37 | } 38 | 39 | /** 40 | * @param string $birthDate YYYY-MM-DD. 41 | * @return LegalRepresentative 42 | */ 43 | public function setBirthDate(string $birthDate): LegalRepresentative 44 | { 45 | $this->birthDate = $birthDate; 46 | return $this; 47 | } 48 | 49 | public static function new(string $name, string $document, string $birthdate): self 50 | { 51 | return (new static()) 52 | ->setName($name) 53 | ->setDocument($document) 54 | ->setBirthDate($birthdate); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Entity/Link.php: -------------------------------------------------------------------------------- 1 | self; 23 | } 24 | 25 | /** 26 | * @param object $self 27 | */ 28 | public function setSelf(object $self): void 29 | { 30 | $this->self = $self; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Entity/Notification/BankAccount.php: -------------------------------------------------------------------------------- 1 | bankNumber; 26 | } 27 | 28 | /** 29 | * @return string 30 | */ 31 | public function getAgencyNumber(): string 32 | { 33 | return $this->agencyNumber; 34 | } 35 | 36 | /** 37 | * @return string 38 | */ 39 | public function getAccountNumber(): string 40 | { 41 | return $this->accountNumber; 42 | } 43 | 44 | /** 45 | * @return string 46 | */ 47 | public function getAccountType(): string 48 | { 49 | return $this->accountType; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Entity/Notification/Charge.php: -------------------------------------------------------------------------------- 1 | id; 30 | } 31 | 32 | /** 33 | * @return string 34 | */ 35 | public function getCode(): string 36 | { 37 | return $this->code; 38 | } 39 | 40 | /** 41 | * @return string 42 | */ 43 | public function getDueDate(): string 44 | { 45 | return $this->dueDate; 46 | } 47 | 48 | /** 49 | * @return string 50 | */ 51 | public function getAmount(): string 52 | { 53 | return $this->amount; 54 | } 55 | 56 | /** 57 | * @return string 58 | */ 59 | public function getStatus(): string 60 | { 61 | return $this->status; 62 | } 63 | 64 | /** 65 | * @return Payer 66 | */ 67 | public function getPayer(): Payer 68 | { 69 | return $this->payer; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Entity/Notification/ChargeAttributes.php: -------------------------------------------------------------------------------- 1 | amount; 27 | } 28 | 29 | /** 30 | * @return string 31 | */ 32 | public function getCode(): string 33 | { 34 | return $this->code; 35 | } 36 | 37 | /** 38 | * @return string 39 | */ 40 | public function getDigitalAccountId(): string 41 | { 42 | return $this->digitalAccountId; 43 | } 44 | 45 | /** 46 | * @return string 47 | */ 48 | public function getDueData(): string 49 | { 50 | return $this->dueData; 51 | } 52 | 53 | /** 54 | * @return string 55 | */ 56 | public function getReference(): string 57 | { 58 | return $this->reference; 59 | } 60 | 61 | /** 62 | * @return string 63 | */ 64 | public function getStatus(): string 65 | { 66 | return $this->status; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/Entity/Notification/ChargeData.php: -------------------------------------------------------------------------------- 1 | attributes; 18 | } 19 | 20 | public function getTimestamp(): string 21 | { 22 | return $this->timestamp; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Entity/Notification/EntityBaseTrait.php: -------------------------------------------------------------------------------- 1 | entityId; 16 | } 17 | 18 | /** 19 | * @return string 20 | */ 21 | public function getEntityType(): string 22 | { 23 | return $this->entityType; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Entity/Notification/Payer.php: -------------------------------------------------------------------------------- 1 | id; 22 | } 23 | 24 | /** 25 | * @return string|null 26 | */ 27 | public function getName(): ?string 28 | { 29 | return $this->name; 30 | } 31 | 32 | /** 33 | * @return Address|null 34 | */ 35 | public function getAddress(): ?Address 36 | { 37 | return $this->address; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Entity/Notification/PaymentAttributes.php: -------------------------------------------------------------------------------- 1 | digitalAccountId; 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getCreatedOn(): string 35 | { 36 | return $this->createdOn; 37 | } 38 | 39 | /** 40 | * @return string 41 | */ 42 | public function getDate(): string 43 | { 44 | return $this->date; 45 | } 46 | 47 | /** 48 | * @return string 49 | */ 50 | public function getReleaseDate(): string 51 | { 52 | return $this->releaseDate; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getAmount(): string 59 | { 60 | return $this->amount; 61 | } 62 | 63 | /** 64 | * @return string 65 | */ 66 | public function getFee(): string 67 | { 68 | return $this->fee; 69 | } 70 | 71 | /** 72 | * @return string 73 | */ 74 | public function getStatus(): string 75 | { 76 | return $this->status; 77 | } 78 | 79 | /** 80 | * @return string 81 | */ 82 | public function getType(): string 83 | { 84 | return $this->type; 85 | } 86 | 87 | /** 88 | * @return string 89 | */ 90 | public function getPaybackDate(): string 91 | { 92 | return $this->paybackDate; 93 | } 94 | 95 | /** 96 | * @return string 97 | */ 98 | public function getPaybackAmount(): string 99 | { 100 | return $this->paybackAmount; 101 | } 102 | 103 | /** 104 | * @return Charge 105 | */ 106 | public function getCharge(): Charge 107 | { 108 | return $this->charge; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/Entity/Notification/PaymentData.php: -------------------------------------------------------------------------------- 1 | attributes; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Entity/Notification/Recipient.php: -------------------------------------------------------------------------------- 1 | name; 21 | } 22 | 23 | /** 24 | * @return string 25 | */ 26 | public function getDocument(): string 27 | { 28 | return $this->document; 29 | } 30 | 31 | /** 32 | * @return BankAccount 33 | */ 34 | public function getBankAccount(): BankAccount 35 | { 36 | return $this->bankAccount; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Entity/Notification/TransferAttributes.php: -------------------------------------------------------------------------------- 1 | digitalAccountId; 24 | } 25 | 26 | /** 27 | * @return string 28 | */ 29 | public function getCreationDate(): string 30 | { 31 | return $this->creationDate; 32 | } 33 | 34 | /** 35 | * @return string|null 36 | */ 37 | public function getTransferDate(): ?string 38 | { 39 | return $this->transferDate; 40 | } 41 | 42 | /** 43 | * @return string 44 | */ 45 | public function getAmount(): string 46 | { 47 | return $this->amount; 48 | } 49 | 50 | /** 51 | * @return string 52 | */ 53 | public function getStatus(): string 54 | { 55 | return $this->status; 56 | } 57 | 58 | /** 59 | * @return Recipient 60 | */ 61 | public function getRecipient(): Recipient 62 | { 63 | return $this->recipient; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Entity/Notification/TransferData.php: -------------------------------------------------------------------------------- 1 | attributes; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Entity/Payment.php: -------------------------------------------------------------------------------- 1 | id; 37 | } 38 | 39 | /** 40 | * @return string 41 | */ 42 | public function getChargeId(): string 43 | { 44 | return $this->chargeId; 45 | } 46 | 47 | /** 48 | * @return string 49 | */ 50 | public function getDate(): string 51 | { 52 | return $this->date; 53 | } 54 | 55 | /** 56 | * @return string|null 57 | */ 58 | public function getReleaseDate(): ?string 59 | { 60 | return $this->releaseDate; 61 | } 62 | 63 | /** 64 | * @return float 65 | */ 66 | public function getAmount(): float 67 | { 68 | return $this->amount; 69 | } 70 | 71 | /** 72 | * @return float 73 | */ 74 | public function getFee(): float 75 | { 76 | return $this->fee; 77 | } 78 | 79 | /** 80 | * @return string 81 | */ 82 | public function getType(): string 83 | { 84 | return $this->type; 85 | } 86 | 87 | /** 88 | * @return string 89 | */ 90 | public function getStatus(): string 91 | { 92 | return $this->status; 93 | } 94 | 95 | /** 96 | * @return string|null 97 | */ 98 | public function getTransactionId(): ?string 99 | { 100 | return $this->transactionId; 101 | } 102 | 103 | /** 104 | * @return string|null 105 | */ 106 | public function getCreditCardId(): ?string 107 | { 108 | return $this->creditCardId; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/Entity/PaymentBilling.php: -------------------------------------------------------------------------------- 1 | delayed; 21 | } 22 | 23 | /** 24 | * @param bool $delayed 25 | * 26 | * @return Billing 27 | */ 28 | public function setDelayed(bool $delayed): Billing 29 | { 30 | $this->delayed = $delayed; 31 | return $this; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Entity/Pix.php: -------------------------------------------------------------------------------- 1 | */ 12 | protected string $id; 13 | 14 | /** @var string $payloadInBase64 */ 15 | protected string $payloadInBase64; 16 | 17 | /** @var string $imageInBase64 */ 18 | protected string $imageInBase64; 19 | 20 | /** 21 | * @return string 22 | */ 23 | public function getId(): string 24 | { 25 | return $this->id; 26 | } 27 | 28 | /** 29 | * @return string 30 | */ 31 | public function getPayloadInBase64(): string 32 | { 33 | return $this->payloadInBase64; 34 | } 35 | 36 | /** 37 | * @return string 38 | */ 39 | public function getImageInBase64(): string 40 | { 41 | return $this->imageInBase64; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Entity/Pix/AdditionalInfo.php: -------------------------------------------------------------------------------- 1 | nome = $nome; 20 | $this->valor = $valor; 21 | } 22 | 23 | /** 24 | * @return string 25 | */ 26 | public function getNome(): string 27 | { 28 | return $this->nome; 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getValor(): string 35 | { 36 | return $this->valor; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Entity/Pix/Calendar.php: -------------------------------------------------------------------------------- 1 | Tempo de vida da cobrança, especificado em segundos a partir da data de criação 13 | * (Calendario.criacao) 14 | */ 15 | protected int $expiracao; 16 | 17 | /** 18 | * @return int 19 | */ 20 | public function getExpiracao(): int 21 | { 22 | return $this->expiracao; 23 | } 24 | 25 | /** 26 | * @param int $expiracao Tempo de vida da cobrança, especificado em segundos a partir da data de criação 27 | * (Calendario.criacao) 28 | * @return Calendar 29 | */ 30 | public function setExpiracao(int $expiracao): Calendar 31 | { 32 | $this->expiracao = $expiracao; 33 | return $this; 34 | } 35 | 36 | /** 37 | * @param int $expiracao Tempo de vida da cobrança, especificado em segundos a partir da data de criação 38 | * (Calendario.criacao) 39 | * @return static 40 | */ 41 | public static function new(int $expiracao = 8600): self 42 | { 43 | return (new static()) 44 | ->setExpiracao($expiracao); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Entity/Pix/LegalPerson.php: -------------------------------------------------------------------------------- 1 | nome; 19 | } 20 | 21 | /** 22 | * @return string 23 | */ 24 | public function getCnpj(): string 25 | { 26 | return $this->cnpj; 27 | } 28 | 29 | /** 30 | * @param string $nome Nome do usuário. 31 | * @return LegalPerson 32 | */ 33 | public function setNome(string $nome): LegalPerson 34 | { 35 | $this->nome = $nome; 36 | return $this; 37 | } 38 | 39 | /** 40 | * @param string $cnpj CNPJ do usuário. /^\d{14}$/ (14 dígitos) 41 | * @return LegalPerson 42 | */ 43 | public function setCnpj(string $cnpj): LegalPerson 44 | { 45 | $this->cnpj = $cnpj; 46 | return $this; 47 | } 48 | 49 | public static function new(string $name, string $document): self 50 | { 51 | return (new static()) 52 | ->setNome($name) 53 | ->setCnpj($document); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Entity/Pix/MonetaryValue.php: -------------------------------------------------------------------------------- 1 | value; 25 | } 26 | 27 | /** 28 | * @param string $value Valor original da cobrança. 29 | * \d{1,10}\.\d{2} 30 | * Isso é: de 1 a 10 dígitos seguidos de um "." seguido por dois dígitos. 31 | * Valores de 0.01 até 9999999999.99 32 | * @return MonetaryValue 33 | */ 34 | public function setValue(string $value): MonetaryValue 35 | { 36 | $this->value = $value; 37 | return $this; 38 | } 39 | 40 | public static function new(string $value): self 41 | { 42 | return (new static()) 43 | ->setValue($value); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Entity/Pix/PhysicalPerson.php: -------------------------------------------------------------------------------- 1 | nome; 19 | } 20 | 21 | /** 22 | * @return string 23 | */ 24 | public function getCpf(): string 25 | { 26 | return $this->cpf; 27 | } 28 | 29 | /** 30 | * @param string $nome Nome do usuário. 31 | * @return PhysicalPerson 32 | */ 33 | public function setNome(string $nome): PhysicalPerson 34 | { 35 | $this->nome = $nome; 36 | return $this; 37 | } 38 | 39 | /** 40 | * @param string $cpf CPF do usuário. /^\d{11}$/ (11 dígitos) 41 | * @return PhysicalPerson 42 | */ 43 | public function setCpf(string $cpf): PhysicalPerson 44 | { 45 | $this->cpf = $cpf; 46 | return $this; 47 | } 48 | 49 | public static function new(string $name, string $document): self 50 | { 51 | return (new static()) 52 | ->setNome($name) 53 | ->setCpf($document); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Entity/PixBankAccount.php: -------------------------------------------------------------------------------- 1 | ispb; 20 | } 21 | 22 | /** 23 | * @param string|null $ispb Código ISPB da Instituição destino. 24 | * IMPORTANTE: 25 | * Se a Instituição destino não possuir código COMP (bankNumber), o código ISPB (ispb) deve ser informado. 26 | * @return PixBankAccount 27 | */ 28 | public function setIspb(?string $ispb): PixBankAccount 29 | { 30 | $this->ispb = $ispb; 31 | return $this; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Entity/PlanBase.php: -------------------------------------------------------------------------------- 1 | Data de criação do plano. */ 11 | protected string $createdOn; 12 | 13 | /** @var string $name Nome do plano */ 14 | protected string $name; 15 | 16 | /** @var string $frequency Frequência do plano. Frequencia suportada hoje MONTHLY. */ 17 | protected string $frequency; 18 | 19 | /** @var string $status Enum: "ACTIVE", "INACTIVE". Status atual do plano. */ 20 | protected string $status; 21 | 22 | /** @var float $amount */ 23 | protected float $amount; 24 | 25 | /** 26 | * @return string Identificação do plano criado. 27 | */ 28 | public function getId(): string 29 | { 30 | return $this->id; 31 | } 32 | 33 | /** 34 | * @return string Data de criação do plano. 35 | */ 36 | public function getCreatedOn(): string 37 | { 38 | return $this->createdOn; 39 | } 40 | 41 | /** 42 | * @return string Nome do plano 43 | */ 44 | public function getName(): string 45 | { 46 | return $this->name; 47 | } 48 | 49 | /** 50 | * @return string Frequência do plano. Frequencia suportada hoje MONTHLY. 51 | */ 52 | public function getFrequency(): string 53 | { 54 | return $this->frequency; 55 | } 56 | 57 | /** 58 | * @return string Enum: "ACTIVE", "INACTIVE". Status atual do plano. 59 | */ 60 | public function getStatus(): string 61 | { 62 | return $this->status; 63 | } 64 | 65 | /** 66 | * @return float 67 | */ 68 | public function getAmount(): float 69 | { 70 | return $this->amount; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Entity/Recipient.php: -------------------------------------------------------------------------------- 1 | name; 21 | } 22 | 23 | /** 24 | * @return string 25 | */ 26 | public function getDocument(): string 27 | { 28 | return $this->document; 29 | } 30 | 31 | /** 32 | * @return PixBankAccount 33 | */ 34 | public function getBankAccount(): PixBankAccount 35 | { 36 | return $this->bankAccount; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Entity/Split.php: -------------------------------------------------------------------------------- 1 | recipientToken; 48 | } 49 | 50 | /** 51 | * @return float|null 52 | */ 53 | public function getAmount(): ?float 54 | { 55 | return $this->amount; 56 | } 57 | 58 | /** 59 | * @return float|null 60 | */ 61 | public function getPercentage(): ?float 62 | { 63 | return $this->percentage; 64 | } 65 | 66 | /** 67 | * @return bool|null 68 | */ 69 | public function getAmountReminder(): ?bool 70 | { 71 | return $this->amountReminder; 72 | } 73 | 74 | /** 75 | * @return bool|null 76 | */ 77 | public function getChargeFee(): ?bool 78 | { 79 | return $this->chargeFee; 80 | } 81 | 82 | /** 83 | * @param string|null $recipientToken Define os destinatários do split. 84 | * Importante: Caso o emissor da cobrança seja também destinatário na divisão de valores, seu x-resource-token 85 | * também deve ser definido. 86 | * @return Split 87 | */ 88 | public function setRecipientToken(?string $recipientToken): Split 89 | { 90 | $this->recipientToken = $recipientToken; 91 | return $this; 92 | } 93 | 94 | /** 95 | * @param float|null $amount Define o valor fixo que a conta vai receber. Caso seja enviado, não será aceito o 96 | * parâmetro percentage no objeto split. 97 | * @return Split 98 | */ 99 | public function setAmount(?float $amount): Split 100 | { 101 | $this->amount = $amount; 102 | return $this; 103 | } 104 | 105 | /** 106 | * @param float|null $percentage Define o valor percentual que a conta vai receber. Caso seja enviado, não será 107 | * aceito o parâmetro amount no objeto split. 108 | * @return Split 109 | */ 110 | public function setPercentage(?float $percentage): Split 111 | { 112 | $this->percentage = $percentage; 113 | return $this; 114 | } 115 | 116 | /** 117 | * @param bool|null $amountReminder Indica quem recebe o valor restante em caso de uma divisão do valor total da 118 | * transação. 119 | * @return Split 120 | */ 121 | public function setAmountReminder(?bool $amountReminder): Split 122 | { 123 | $this->amountReminder = $amountReminder; 124 | return $this; 125 | } 126 | 127 | /** 128 | * @param bool|null $chargeFee Indica se somente um recebedor será taxado ou se as taxas serão divididas 129 | * proporcionalmente entre todos os recebedores. 130 | * @return Split 131 | */ 132 | public function setChargeFee(?bool $chargeFee): Split 133 | { 134 | $this->chargeFee = $chargeFee; 135 | return $this; 136 | } 137 | 138 | public static function new(): self 139 | { 140 | return new static(); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /src/Entity/SubscriptionBase.php: -------------------------------------------------------------------------------- 1 | Data de criação da assinatura. */ 11 | protected string $createdOn; 12 | 13 | /** @var string $dueDay Data de vencimento da assinatura. */ 14 | protected string $dueDay; 15 | 16 | /** @var string $status Enum: "ACTIVE", "INACTIVE", "CANCELED", "COMPLETED". Status atual da assinatura. */ 17 | protected string $status; 18 | 19 | /** @var string $startsOn Data início da assinatura. */ 20 | protected string $startsOn; 21 | 22 | /** @var string $nextBillingDate Data da próxima cobrança. */ 23 | protected string $nextBillingDate; 24 | 25 | /** 26 | * @return string 27 | */ 28 | public function getId(): string 29 | { 30 | return $this->id; 31 | } 32 | 33 | /** 34 | * @return string 35 | */ 36 | public function getCreatedOn(): string 37 | { 38 | return $this->createdOn; 39 | } 40 | 41 | /** 42 | * @return string 43 | */ 44 | public function getDueDay(): string 45 | { 46 | return $this->dueDay; 47 | } 48 | 49 | /** 50 | * @return string 51 | */ 52 | public function getStatus(): string 53 | { 54 | return $this->status; 55 | } 56 | 57 | /** 58 | * @return string 59 | */ 60 | public function getStartsOn(): string 61 | { 62 | return $this->startsOn; 63 | } 64 | 65 | /** 66 | * @return string 67 | */ 68 | public function getNextBillingDate(): string 69 | { 70 | return $this->nextBillingDate; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Entity/WebhookEventType.php: -------------------------------------------------------------------------------- 1 | id; 34 | } 35 | 36 | /** 37 | * @return string 38 | */ 39 | public function getName(): string 40 | { 41 | return $this->name; 42 | } 43 | 44 | /** 45 | * @return string 46 | */ 47 | public function getLabel(): string 48 | { 49 | return $this->label; 50 | } 51 | 52 | /** 53 | * @return string 54 | */ 55 | public function getStatus(): string 56 | { 57 | return $this->status; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Entity/WebhookResource.php: -------------------------------------------------------------------------------- 1 | status === 'ACTIVE'; 24 | } 25 | 26 | protected function isInactive(): bool 27 | { 28 | return !$this->isActive(); 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getId(): string 35 | { 36 | return $this->id; 37 | } 38 | 39 | /** 40 | * @return string 41 | */ 42 | public function getUrl(): string 43 | { 44 | return $this->url; 45 | } 46 | 47 | /** 48 | * @return string 49 | */ 50 | public function getSecret(): string 51 | { 52 | return $this->secret; 53 | } 54 | 55 | /** 56 | * @return string Enum: "ACTIVE" "INACTIVE" 57 | */ 58 | public function getStatus(): string 59 | { 60 | return $this->status; 61 | } 62 | 63 | /** 64 | * @return WebhookEventType[] 65 | */ 66 | public function getEventTypes(): array 67 | { 68 | return $this->eventTypes ?? []; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/Exception/InvalidArgumentException.php: -------------------------------------------------------------------------------- 1 | timestamp; 33 | } 34 | 35 | /** 36 | * @return int|null 37 | */ 38 | public function getStatus(): ?int 39 | { 40 | return $this->status; 41 | } 42 | 43 | /** 44 | * @return string|null 45 | */ 46 | public function getError(): ?string 47 | { 48 | return $this->error ?? $this->getMessage(); 49 | } 50 | 51 | /** 52 | * @return string|null 53 | */ 54 | public function getPath(): ?string 55 | { 56 | return $this->path; 57 | } 58 | 59 | /** 60 | * @return ErrorDetail[] 61 | */ 62 | public function getDetails(): array 63 | { 64 | return $this->details ?? []; 65 | } 66 | 67 | public function hasDetails(): bool 68 | { 69 | return !is_null($this->details); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Exception/RuntimeException.php: -------------------------------------------------------------------------------- 1 | issueAccessTokenRequest( 22 | $client, 23 | OAuthFlow::CLIENT_CREDENTIALS, 24 | $credentials, 25 | static function (array $requestOptions) use ($client) { 26 | unset($requestOptions[RequestOptions::HEADERS]); 27 | $requestOptions[RequestOptions::FORM_PARAMS]['client_id'] = $client->getClientId(); 28 | $requestOptions[RequestOptions::FORM_PARAMS]['client_secret'] = $client->getClientSecret(); 29 | 30 | return $requestOptions; 31 | } 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Juno.php: -------------------------------------------------------------------------------- 1 | client = new Http($config['http'] ?? []); 37 | $this->config = $config; 38 | } 39 | 40 | /** 41 | * @return Http 42 | */ 43 | public function getHttpInstance(): Http 44 | { 45 | return $this->client; 46 | } 47 | 48 | /** 49 | * @return array 50 | */ 51 | public function getConfig(): array 52 | { 53 | return $this->config ?? []; 54 | } 55 | 56 | /** 57 | * Retorna uma data do tipo ISO 8601, utilizada pela Juno. 58 | * 59 | * @param int|string $year 60 | * @param int|string $month 61 | * @param int|string $day 62 | * @return string 63 | */ 64 | public function dateToString($year, $month, $day): string 65 | { 66 | return sprintf('%s-%02s-%02s', $year, $month, $day); 67 | } 68 | 69 | public function __call(string $name, array $arguments) 70 | { 71 | if (!($apiImpl = $this->config['api_impl'] ?? null) || !array_key_exists($name, $apiImpl)) { 72 | throw new RuntimeException("O endpoint '$name' não foi implementado ou não existe"); 73 | } 74 | 75 | return new $apiImpl[$name]($this); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/JunoServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->runningInConsole()) { 23 | $this->publishes([ 24 | $src => config_path('juno.php') 25 | ], 'config'); 26 | 27 | $this->commands([ 28 | InstallJunoPackage::class, 29 | ]); 30 | } 31 | 32 | $this->mergeConfigFrom($src, 'juno'); 33 | } 34 | 35 | /** 36 | * Register the service provider. 37 | * 38 | * @return void 39 | */ 40 | public function register() 41 | { 42 | $this->app->singleton('jetimob.juno', function (Container $app) { 43 | return new Juno($app['config']['juno'] ?? []); 44 | }); 45 | 46 | $this->app->alias('jetimob.juno', Juno::class); 47 | } 48 | 49 | /** 50 | * Get the services provided by the provider. 51 | * 52 | * @return string[] 53 | */ 54 | public function provides() 55 | { 56 | return [ 57 | 'jetimob.juno', 58 | ]; 59 | } 60 | } 61 | --------------------------------------------------------------------------------