diff --git a/src/Celcoin.php b/src/Celcoin.php index 7f3e7d4..60cd848 100644 --- a/src/Celcoin.php +++ b/src/Celcoin.php @@ -15,6 +15,7 @@ use WeDevBr\Celcoin\Clients\CelcoinDDAUser; use WeDevBr\Celcoin\Clients\CelcoinDDAWebhooks; use WeDevBr\Celcoin\Clients\CelcoinElectronicTransactions; +use WeDevBr\Celcoin\Clients\CelcoinInternationalTopups; use WeDevBr\Celcoin\Clients\CelcoinKyc; use WeDevBr\Celcoin\Clients\CelcoinPIXCOB; use WeDevBr\Celcoin\Clients\CelcoinPIXCOBV; @@ -169,4 +170,14 @@ public static function clientBAASBillet(): CelcoinBAASBillet { return new CelcoinBAASBillet(); } + + public static function clientBAASWebhook(): CelcoinBAASWebhooks + { + return new CelcoinBAASWebhooks(); + } + + public static function clientInternationalTopup(): CelcoinInternationalTopups + { + return new CelcoinInternationalTopups(); + } } diff --git a/src/Clients/CelcoinBAASBillet.php b/src/Clients/CelcoinBAASBillet.php index 4125dcc..8c393cb 100644 --- a/src/Clients/CelcoinBAASBillet.php +++ b/src/Clients/CelcoinBAASBillet.php @@ -10,7 +10,7 @@ class CelcoinBAASBillet extends CelcoinBaseApi { - public const BILLET_URL = '/api-integration-baas-webservice/v1/charge'; + public const BILLET_URL = '/baas/v2/Charge'; /** * @throws RequestException @@ -42,4 +42,9 @@ public function cancelBillet($transactionId) { return $this->delete(sprintf('%s/%s', self::BILLET_URL, $transactionId)); } + + public function printBillet(string $billetId) + { + return $this->get(sprintf('%s/pdf/%s', self::BILLET_URL, $billetId)); + } } diff --git a/src/Clients/CelcoinBAASPIX.php b/src/Clients/CelcoinBAASPIX.php index de37ba7..2e0f9b1 100644 --- a/src/Clients/CelcoinBAASPIX.php +++ b/src/Clients/CelcoinBAASPIX.php @@ -68,10 +68,10 @@ public function getParticipant(?string $ISPB = null, ?string $name = null) { return $this->get( self::GET_PARTICIPANT_ENDPOINT, - [ + array_filter([ 'ISPB' => $ISPB, 'Name' => $name, - ] + ]) ); } @@ -89,17 +89,17 @@ public function statusPix(?string $id = null, ?string $clientCode = null, ?strin { return $this->get( self::STATUS_PIX_ENDPOINT, - [ + array_filter([ 'id' => $id, 'clientCode' => $clientCode, 'endToEndId' => $endToEndId, - ] + ]) ); } public function registerPixKey(RegisterPixKey $data) { - $body = Validator::validate($data->toArray(), BAASRegisterPixKey::rules()); + $body = Validator::validate(array_filter($data->toArray()), BAASRegisterPixKey::rules()); return $this->post( self::REGISTER_PIX_KEY_ENDPOINT, @@ -138,11 +138,11 @@ public function statusRefundPix(?string $id = null, ?string $clientCode = null, { return $this->get( self::STATUS_REFUND_PIX_ENDPOINT, - [ + array_filter([ 'id' => $id, 'clientCode' => $clientCode, 'returnIdentification' => $returnIdentification, - ] + ]) ); } @@ -193,7 +193,7 @@ public function claimConsult(string $claimId): ?array $validatedClaim = Validator::validate(['claimId' => $claimId], ['claimId' => ['string', 'uuid']]); return $this->get( - self::CLAIM_CANCEL.'/'.$validatedClaim['claimId'] + self::CLAIM_DICT.'/'.$validatedClaim['claimId'] ); } @@ -218,5 +218,4 @@ public function claimList(array $params = []): ?array $validatedParams ); } - } diff --git a/src/Clients/CelcoinPIXCOBV.php b/src/Clients/CelcoinPIXCOBV.php index d9f0c7b..02bd6a5 100644 --- a/src/Clients/CelcoinPIXCOBV.php +++ b/src/Clients/CelcoinPIXCOBV.php @@ -4,6 +4,7 @@ use Illuminate\Http\Client\RequestException; use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Str; use WeDevBr\Celcoin\Common\CelcoinBaseApi; use WeDevBr\Celcoin\Rules\PIX\COBVCreate; use WeDevBr\Celcoin\Rules\PIX\COBVGet; @@ -62,7 +63,10 @@ final public function payloadCOBVPIX(string $url): ?array Validator::validate(compact('url'), COBVPayload::rules()); return $this->get( - sprintf(self::PAYLOAD_COBV_PIX, urlencode($url)) + sprintf( + self::PAYLOAD_COBV_PIX, + urlencode(Str::replace('https://', '', $url)) + ) ); } diff --git a/src/Common/CelcoinBaseApi.php b/src/Common/CelcoinBaseApi.php index 5c461f9..9f8a41e 100644 --- a/src/Common/CelcoinBaseApi.php +++ b/src/Common/CelcoinBaseApi.php @@ -78,10 +78,8 @@ public function get(string $endpoint, array|string|null $query = null, $response { $token = $this->getToken() ?? $this->auth->getToken(); $request = Http::withToken($token) - ->withHeaders([ - 'accept' => 'application/json', - 'content-type' => 'application/json', - ]); + ->asJson() + ->acceptJson(); if ($this->mtlsCert && $this->mtlsKey && $this->mtlsPassphrase) { $request = $this->setRequestMtls($request); @@ -100,10 +98,8 @@ public function post(string $endpoint, array $body = [], ?Attachable $attachment { $token = $this->getToken() ?? $this->auth->getToken(); $request = Http::withToken($token) - ->withHeaders([ - 'accept' => 'application/json', - 'content-type' => 'application/json', - ]); + ->asJson() + ->acceptJson(); if ($this->mtlsCert && $this->mtlsKey && $this->mtlsPassphrase) { $request = $this->setRequestMtls($request); @@ -112,11 +108,18 @@ public function post(string $endpoint, array $body = [], ?Attachable $attachment foreach ($body as $field => $document) { if ($document instanceof File) { $request->attach($field, $document->getContent(), $document->getFileName()); + $request->contentType('multipart/form-data; boundary=*'); } } if ($attachment) { - $request->attach($attachment->getField(), $attachment->getContents(), $attachment->getFileName()); + $request->attach( + $attachment->getField(), + $attachment->getContents(), + $attachment->getFileName(), + $attachment->getHeaders() + ); + $request->contentType('multipart/form-data; boundary=*'); } return $request->post($this->getFinalUrl($endpoint), $body) @@ -133,10 +136,8 @@ public function put( ): mixed { $token = $this->getToken() ?? $this->auth->getToken(); $request = Http::withToken($token) - ->withHeaders([ - 'accept' => 'application/json', - 'content-type' => 'application/json', - ]); + ->asJson() + ->acceptJson(); if ($this->mtlsCert && $this->mtlsKey && $this->mtlsPassphrase) { $request = $this->setRequestMtls($request); @@ -158,11 +159,9 @@ public function patch( $body_format = $asJson ? 'json' : 'form_params'; $token = $this->getToken() ?? $this->auth->getToken(); $request = Http::withToken($token) - ->bodyFormat($body_format) - ->withHeaders([ - 'accept' => 'application/json', - 'content-type' => 'application/json', - ]); + ->asJson() + ->acceptJson() + ->bodyFormat($body_format); if ($this->mtlsCert && $this->mtlsKey && $this->mtlsPassphrase) { $request = $this->setRequestMtls($request); diff --git a/src/Facades/CelcoinFacade.php b/src/Facades/CelcoinFacade.php index cae4eeb..049acda 100644 --- a/src/Facades/CelcoinFacade.php +++ b/src/Facades/CelcoinFacade.php @@ -31,6 +31,10 @@ * @uses Celcoin::clientPIXReverse * @uses Celcoin::clientPixWebhooks * @uses Celcoin::clientKyc + * @uses Celcoin::clientBAASWebhook + * @uses Celcoin::clientInternationalTopup + * @uses Celcoin::clientBAASBillPayment + * @uses Celcoin::clientBAASBillet */ class CelcoinFacade extends Facade { diff --git a/src/Interfaces/Attachable.php b/src/Interfaces/Attachable.php index 2be6cff..caac94e 100644 --- a/src/Interfaces/Attachable.php +++ b/src/Interfaces/Attachable.php @@ -9,4 +9,6 @@ public function getField(): string; public function getContents(); public function getFileName(); + + public function getHeaders(): array; } diff --git a/src/Rules/BAAS/Billet.php b/src/Rules/BAAS/Billet.php index 9a51aee..4391fe3 100644 --- a/src/Rules/BAAS/Billet.php +++ b/src/Rules/BAAS/Billet.php @@ -8,11 +8,9 @@ public static function rules(): array { return [ 'externalId' => ['required'], - 'merchantCategoryCode' => ['sometimes', 'required'], 'expirationAfterPayment' => ['required', 'numeric', 'min:1'], - 'duedate' => ['required', 'date'], + 'dueDate' => ['required', 'date', 'after:yesterday'], 'amount' => ['required', 'decimal:0,2'], - 'key' => ['required'], 'debtor' => ['required', 'array'], 'debtor.name' => ['required', 'string', 'max: 25'], 'debtor.document' => ['required'], @@ -26,10 +24,10 @@ public static function rules(): array 'receiver.document' => ['required'], 'receiver.account' => ['required', 'numeric'], 'instructions' => ['sometimes', 'array', 'nullable'], - 'instructions.discount' => ['required_with:instructions', 'array'], - 'instructions.discount.amount' => ['required_with:discount', 'decimal:0,2'], - 'instructions.discount.modality' => ['required_with:discount'], - 'instructions.discount.limitDate' => ['required_with:discount', 'date'], + 'instructions.discount' => ['sometimes', 'nullable'], + 'instructions.discount.amount' => ['required_with:instructions.discount.limitDate', 'decimal:0,2'], + 'instructions.discount.modality' => ['required_with:discount.modality'], + 'instructions.discount.limitDate' => ['required_with:discount.amount', 'date'], 'instructions.fine' => ['nullable', 'decimal:0,2'], 'instructions.interest' => ['nullable', 'decimal:0,2'], 'split' => ['sometimes', 'array'], diff --git a/src/Rules/BAAS/RegisterPixKey.php b/src/Rules/BAAS/RegisterPixKey.php index 5cecdc4..b548826 100644 --- a/src/Rules/BAAS/RegisterPixKey.php +++ b/src/Rules/BAAS/RegisterPixKey.php @@ -13,7 +13,7 @@ public static function rules() return [ 'account' => ['required', 'string'], 'keyType' => ['required', Rule::enum(PixKeyTypeEnum::class)], - 'key' => ['required_unless:keyType,EVP', 'string'], + 'key' => ['required_unless:keyType,EVP', 'string', 'nullable'], ]; } } diff --git a/src/Rules/BAAS/TEDTransfer.php b/src/Rules/BAAS/TEDTransfer.php index f6a298f..3722216 100644 --- a/src/Rules/BAAS/TEDTransfer.php +++ b/src/Rules/BAAS/TEDTransfer.php @@ -22,7 +22,7 @@ public static function rules() 'creditParty.accountType' => ['required', 'string'], 'creditParty.personType' => ['required', 'string'], 'clientFinality' => ['required', 'string'], - 'description' => ['some', 'required_if:clientFinality,'.ClientFinalityEnum::OTHERS->value, 'string'], + 'description' => ['sometimes', 'required_if:clientFinality,'.ClientFinalityEnum::OTHERS->value, 'string'], ]; } } diff --git a/src/Types/BAAS/Billet.php b/src/Types/BAAS/Billet.php index 8159240..77612f4 100644 --- a/src/Types/BAAS/Billet.php +++ b/src/Types/BAAS/Billet.php @@ -8,16 +8,12 @@ class Billet extends Data { public string $externalId; - public ?string $merchantCategoryCode; - public int $expirationAfterPayment; - public string $duedate; + public string $dueDate; public float $amount; - public ?string $key; - public BilletDebtor $debtor; public BilletReceiver $receiver; diff --git a/src/Types/KYC/KycDocument.php b/src/Types/KYC/KycDocument.php index 8754ad2..de0ca2b 100644 --- a/src/Types/KYC/KycDocument.php +++ b/src/Types/KYC/KycDocument.php @@ -42,4 +42,9 @@ public function getField(): string { return $this->field; } + + public function getHeaders(): array + { + return ['Content-Type' => $this->file->getMimeType()]; + } } diff --git a/tests/Feature/CelcoinClientInstancesTest.php b/tests/Feature/CelcoinClientInstancesTest.php index 64d2025..847b456 100644 --- a/tests/Feature/CelcoinClientInstancesTest.php +++ b/tests/Feature/CelcoinClientInstancesTest.php @@ -160,4 +160,10 @@ public function testSuccessCreateBaasBillPayment() $instance = Celcoin::clientBAASBillPayment(); $this->assertInstanceOf(CelcoinBAASBillPayment::class, $instance); } + + public function testSuccessCreteBaasWebhooks() + { + $instance = Celcoin::clientBAASWebhooks(); + $this->assertInstanceOf(CelcoinBAASWebhooks::class, $instance); + } } diff --git a/tests/Integration/BAAS/CelcoinBASSBilletTest.php b/tests/Integration/BAAS/CelcoinBASSBilletTest.php index b0772a2..b19f165 100644 --- a/tests/Integration/BAAS/CelcoinBASSBilletTest.php +++ b/tests/Integration/BAAS/CelcoinBASSBilletTest.php @@ -47,10 +47,8 @@ public static function billetBodyRequest(): Billet return new Billet([ 'externalId' => 'externalId1', 'expirationAfterPayment' => 1, - 'merchantCatagoryCode' => '0000', - 'duedate' => '2023-12-30T00:00:00.0000000', + 'dueDate' => now()->format('Y-m-d'), 'amount' => 12.5, - 'key' => 'testepix@celcoin.com.br', 'debtor' => new BilletDebtor([ 'name' => 'João teste de teste', 'document' => '12345678910', diff --git a/tests/Integration/BAAS/PixClaim/PixKeyCancelConfirmTest.php b/tests/Integration/BAAS/PixClaim/PixKeyCancelConfirmTest.php index decc012..560d8d1 100644 --- a/tests/Integration/BAAS/PixClaim/PixKeyCancelConfirmTest.php +++ b/tests/Integration/BAAS/PixClaim/PixKeyCancelConfirmTest.php @@ -11,6 +11,7 @@ use WeDevBr\Celcoin\Tests\GlobalStubs; use WeDevBr\Celcoin\Tests\TestCase; use WeDevBr\Celcoin\Types\PIX\ClaimAnswer; + use function PHPUnit\Framework\assertEquals; class PixKeyCancelConfirmTest extends TestCase diff --git a/tests/Integration/BAAS/PixClaim/PixKeyClaimConfirmTest.php b/tests/Integration/BAAS/PixClaim/PixKeyClaimConfirmTest.php index 5f89571..1652bbc 100644 --- a/tests/Integration/BAAS/PixClaim/PixKeyClaimConfirmTest.php +++ b/tests/Integration/BAAS/PixClaim/PixKeyClaimConfirmTest.php @@ -11,14 +11,13 @@ use WeDevBr\Celcoin\Tests\GlobalStubs; use WeDevBr\Celcoin\Tests\TestCase; use WeDevBr\Celcoin\Types\PIX\ClaimAnswer; + use function PHPUnit\Framework\assertEquals; class PixKeyClaimConfirmTest extends TestCase { use WithFaker; - /** - */ public function testClaimPixKey() { Http::fake( diff --git a/tests/Integration/BAAS/PixClaim/PixKeyClaimConsultTest.php b/tests/Integration/BAAS/PixClaim/PixKeyClaimConsultTest.php index 810aa9b..8ab6791 100644 --- a/tests/Integration/BAAS/PixClaim/PixKeyClaimConsultTest.php +++ b/tests/Integration/BAAS/PixClaim/PixKeyClaimConsultTest.php @@ -10,6 +10,7 @@ use WeDevBr\Celcoin\Clients\CelcoinBAASPIX; use WeDevBr\Celcoin\Tests\GlobalStubs; use WeDevBr\Celcoin\Tests\TestCase; + use function PHPUnit\Framework\assertEquals; class PixKeyClaimConsultTest extends TestCase diff --git a/tests/Integration/BAAS/PixClaim/PixKeyClaimListTest.php b/tests/Integration/BAAS/PixClaim/PixKeyClaimListTest.php index c28e290..2ad56a2 100644 --- a/tests/Integration/BAAS/PixClaim/PixKeyClaimListTest.php +++ b/tests/Integration/BAAS/PixClaim/PixKeyClaimListTest.php @@ -11,6 +11,7 @@ use WeDevBr\Celcoin\Enums\ClaimTypeEnum; use WeDevBr\Celcoin\Tests\GlobalStubs; use WeDevBr\Celcoin\Tests\TestCase; + use function PHPUnit\Framework\assertEquals; class PixKeyClaimListTest extends TestCase @@ -41,14 +42,14 @@ public function testClaimPixKeyWithParams() Http::fake( [ config('celcoin.login_url') => GlobalStubs::loginResponse(), - CelcoinBAASPIX::CLAIM_LIST . '*' => self::stubSuccess(), + CelcoinBAASPIX::CLAIM_LIST.'*' => self::stubSuccess(), ], ); $pixDict = new CelcoinBAASPIX(); $result = $pixDict->claimList([ 'Status' => ClaimStatusEnum::CANCELLED, - 'claimType' => ClaimTypeEnum::OWNERSHIP + 'claimType' => ClaimTypeEnum::OWNERSHIP, ]); assertEquals('SUCCESS', $result['status']); } @@ -57,41 +58,41 @@ private static function stubSuccess(): PromiseInterface { return Http::response( [ - "version" => "1.0.0", - "status" => "SUCCESS", - "body" => [ - "claims" => [ + 'version' => '1.0.0', + 'status' => 'SUCCESS', + 'body' => [ + 'claims' => [ [ - "id" => "8bbc0ba5-2aee-44a0-a3c9-b897802a9f66", - "claimType" => "OWNERSHIP", - "key" => "fulanodetal@gmail.com", - "keyType" => "EMAIL", - "claimerAccount" => [ - "participant" => "30306294", - "branch" => "0001", - "account" => "30053913742139", - "accountType" => "TRAN" + 'id' => '8bbc0ba5-2aee-44a0-a3c9-b897802a9f66', + 'claimType' => 'OWNERSHIP', + 'key' => 'fulanodetal@gmail.com', + 'keyType' => 'EMAIL', + 'claimerAccount' => [ + 'participant' => '30306294', + 'branch' => '0001', + 'account' => '30053913742139', + 'accountType' => 'TRAN', + ], + 'claimer' => [ + 'personType' => 'NATURAL_PERSON', + 'taxId' => '34335125070', + 'name' => 'João da Silva Junior', ], - "claimer" => [ - "personType" => "NATURAL_PERSON", - "taxId" => "34335125070", - "name" => "João da Silva Junior" + 'donorParticipant' => '30306294', + 'status' => 'OPEN', + 'createTimestamp' => '2023-05-01T13:05:09', + 'completionPeriodEnd' => '2023-05-01T13:05:09', + 'resolutionPeriodEnd' => '2023-05-01T13:05:09', + 'lastModified' => '2023-05-01T13:05:09', + 'donorAccount' => [ + 'account' => '30053913742139', + 'branch' => '0001', + 'taxId' => '34335125070', + 'name' => 'João da Silva Junior', ], - "donorParticipant" => "30306294", - "status" => "OPEN", - "createTimestamp" => "2023-05-01T13:05:09", - "completionPeriodEnd" => "2023-05-01T13:05:09", - "resolutionPeriodEnd" => "2023-05-01T13:05:09", - "lastModified" => "2023-05-01T13:05:09", - "donorAccount" => [ - "account" => "30053913742139", - "branch" => "0001", - "taxId" => "34335125070", - "name" => "João da Silva Junior" - ] - ] - ] - ] + ], + ], + ], ], Response::HTTP_OK, ); diff --git a/tests/Integration/BAAS/PixClaim/PixKeyClaimTest.php b/tests/Integration/BAAS/PixClaim/PixKeyClaimTest.php index 199f782..6c123d6 100644 --- a/tests/Integration/BAAS/PixClaim/PixKeyClaimTest.php +++ b/tests/Integration/BAAS/PixClaim/PixKeyClaimTest.php @@ -10,6 +10,7 @@ use WeDevBr\Celcoin\Tests\GlobalStubs; use WeDevBr\Celcoin\Tests\TestCase; use WeDevBr\Celcoin\Types\PIX\Claim; + use function PHPUnit\Framework\assertEquals; class PixKeyClaimTest extends TestCase diff --git a/tests/Integration/BAAS/TED/BAASTEDTransferTest.php b/tests/Integration/BAAS/TED/BAASTEDTransferTest.php index fcf986e..5f66b84 100644 --- a/tests/Integration/BAAS/TED/BAASTEDTransferTest.php +++ b/tests/Integration/BAAS/TED/BAASTEDTransferTest.php @@ -43,8 +43,8 @@ final public function testSuccess(): void 'accountType' => 'CC', 'personType' => 'J', ], - 'clientFinality' => ClientFinalityEnum::ACCOUNT_CREDIT, - 'description' => '', + 'clientFinality' => ClientFinalityEnum::OTHERS, + 'description' => 'description string', ]), ); diff --git a/tests/Integration/PIX/COB/COBCreateTest.php b/tests/Integration/PIX/COB/COBCreateTest.php index 42cedf8..ca4e55c 100644 --- a/tests/Integration/PIX/COB/COBCreateTest.php +++ b/tests/Integration/PIX/COB/COBCreateTest.php @@ -143,9 +143,9 @@ private static function stubCOBError(): PromiseInterface { return Http::response( [ - 'message' => 'Can\'t create a new PixImmediateCollection when the location type is COB', - 'errorCode' => 'PBE410', - ], + 'message' => 'Can\'t create a new PixImmediateCollection when the location type is COB', + 'errorCode' => 'PBE410', + ], Response::HTTP_BAD_REQUEST, ); } diff --git a/tests/Integration/PIX/COB/COBDeteleTest.php b/tests/Integration/PIX/COB/COBDeteleTest.php index 83a1d8e..0d44883 100644 --- a/tests/Integration/PIX/COB/COBDeteleTest.php +++ b/tests/Integration/PIX/COB/COBDeteleTest.php @@ -33,10 +33,10 @@ private function stubSuccess(): PromiseInterface { return Http::response( [ - 'transactionId' => 817849688, - 'status' => 200, - 'message' => '200', - ], + 'transactionId' => 817849688, + 'status' => 200, + 'message' => '200', + ], Response::HTTP_OK, ); } @@ -71,9 +71,9 @@ private function stubError(): PromiseInterface { return Http::response( [ - 'statusCode' => 404, - 'message' => 'Resource not found', - ], + 'statusCode' => 404, + 'message' => 'Resource not found', + ], Response::HTTP_NOT_FOUND, ); } diff --git a/tests/Integration/PIX/COB/COBFetchTest.php b/tests/Integration/PIX/COB/COBFetchTest.php index ba3c5bd..1f90a90 100644 --- a/tests/Integration/PIX/COB/COBFetchTest.php +++ b/tests/Integration/PIX/COB/COBFetchTest.php @@ -103,9 +103,9 @@ private static function stubNotFound(): PromiseInterface { return Http::response( [ - 'message' => 'Não foi possível localizar a cobrança associada ao parâmetro informado.', - 'errorCode' => 'VL002', - ], + 'message' => 'Não foi possível localizar a cobrança associada ao parâmetro informado.', + 'errorCode' => 'VL002', + ], Response::HTTP_BAD_REQUEST, ); } diff --git a/tests/Integration/PIX/COB/COBPayloadTest.php b/tests/Integration/PIX/COB/COBPayloadTest.php index 4118db0..b348b5d 100644 --- a/tests/Integration/PIX/COB/COBPayloadTest.php +++ b/tests/Integration/PIX/COB/COBPayloadTest.php @@ -98,9 +98,9 @@ private static function stubNotFound(): PromiseInterface { return Http::response( [ - 'message' => 'Não foi possível localizar a cobrança associada ao parâmetro informado.', - 'errorCode' => 'VL002', - ], + 'message' => 'Não foi possível localizar a cobrança associada ao parâmetro informado.', + 'errorCode' => 'VL002', + ], Response::HTTP_BAD_REQUEST, ); } diff --git a/tests/Integration/PIX/COB/COBUpdateTest.php b/tests/Integration/PIX/COB/COBUpdateTest.php index 949bbea..24e1e28 100644 --- a/tests/Integration/PIX/COB/COBUpdateTest.php +++ b/tests/Integration/PIX/COB/COBUpdateTest.php @@ -144,9 +144,9 @@ private static function stubCOBError(): PromiseInterface { return Http::response( [ - 'message' => 'Can\'t create a new Pix Collection when there is another Pix Collection active with the same location.', - 'errorCode' => 'PBE318', - ], + 'message' => 'Can\'t create a new Pix Collection when there is another Pix Collection active with the same location.', + 'errorCode' => 'PBE318', + ], Response::HTTP_BAD_REQUEST, ); } diff --git a/tests/Integration/PIX/COBV/COBVPayloadTest.php b/tests/Integration/PIX/COBV/COBVPayloadTest.php index 9d97c2e..212724c 100644 --- a/tests/Integration/PIX/COBV/COBVPayloadTest.php +++ b/tests/Integration/PIX/COBV/COBVPayloadTest.php @@ -5,6 +5,7 @@ use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Http\Client\RequestException; use Illuminate\Support\Facades\Http; +use Illuminate\Support\Str; use Illuminate\Validation\ValidationException; use Symfony\Component\HttpFoundation\Response; use WeDevBr\Celcoin\Clients\CelcoinPIXCOBV; @@ -31,7 +32,7 @@ final public function testPayloadCobvSuccess(): void Http::fake( [ config('celcoin.login_url') => GlobalStubs::loginResponse(), - sprintf(CelcoinPIXCOBV::PAYLOAD_COBV_PIX, urlencode($fetchUrl)) => self::stubSuccess(), + config('celcoin.api_url').sprintf(CelcoinPIXCOBV::PAYLOAD_COBV_PIX, urlencode(Str::replace('https://', '', $fetchUrl))) => self::stubSuccess(), ], ); @@ -103,10 +104,14 @@ final public function testPayloadCobvNotFound(): void http_build_query(compact('transactionId')), ), ); + Http::fake( [ config('celcoin.login_url') => GlobalStubs::loginResponse(), - sprintf(CelcoinPIXCOBV::PAYLOAD_COBV_PIX, urlencode($fetchUrl)) => self::stubNotFound(), + config('celcoin.api_url').sprintf( + CelcoinPIXCOBV::PAYLOAD_COBV_PIX, + urlencode(Str::replace('https://', '', $fetchUrl)) + ) => self::stubNotFound(), ], ); @@ -125,9 +130,9 @@ private static function stubNotFound(): PromiseInterface { return Http::response( [ - 'message' => 'The BRCode is expired and can\'t be paid.', - 'errorCode' => '400', - ], + 'message' => 'The BRCode is expired and can\'t be paid.', + 'errorCode' => '400', + ], Response::HTTP_BAD_REQUEST, ); } diff --git a/tests/Integration/PIX/DICT/PixKeyClaimConfirmTest.php b/tests/Integration/PIX/DICT/PixKeyClaimConfirmTest.php index ac39ddd..4b71ff0 100644 --- a/tests/Integration/PIX/DICT/PixKeyClaimConfirmTest.php +++ b/tests/Integration/PIX/DICT/PixKeyClaimConfirmTest.php @@ -18,8 +18,6 @@ class PixKeyClaimConfirmTest extends TestCase { use WithFaker; - /** - */ public function testClaimPixKey() { Http::fake( diff --git a/tests/TestCase.php b/tests/TestCase.php index 32a5f24..e021b23 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,6 +4,7 @@ use Dotenv\Dotenv; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; +use Illuminate\Support\Facades\Http; use Orchestra\Testbench\Concerns\CreatesApplication; use WeDevBr\Celcoin\CelcoinServiceProvider; @@ -14,6 +15,7 @@ abstract class TestCase extends BaseTestCase public function setUp(): void { parent::setUp(); + Http::preventStrayRequests(); } protected function getPackageProviders($app)