logger = $this->createMock(LoggerInterface::class); $this->config = new AxeptaConfig('url', 'm_id', 'key', 'hmac', []); $this->gateway = $this->createMock(AxeptaApiGateway::class); $this->tokenManager = $this->createMock(AxeptaTokenManager::class); $this->verifier = $this->createMock(AxeptaSignatureVerifier::class); } public function test_can_get_payment_status_by_id(): void { // GIVEN $service = new AxeptaPaymentService($this->logger, $this->config, $this->gateway, $this->tokenManager, $this->verifier); $this->tokenManager->method('getToken')->willReturn('fake-token'); $jsonResponse = json_encode(['responseCode' => 'SUCCESS']); $this->gateway->expects($this->once()) ->method('get') ->willReturn(new Response(200, [], $jsonResponse)); // WHEN $status = $service->getPaymentStatusById('PAY_123'); // THEN $this->assertEquals('SUCCESS', $status); } public function test_can_validate_webhook_access(): void { // GIVEN $service = new AxeptaPaymentService($this->logger, $this->config, $this->gateway, $this->tokenManager, $this->verifier); $request = Request::create('/webhook', 'POST', [], [], [], [ 'HTTP_X_PAYGATE_SIGNATURE_VERSION' => 'v1', 'HTTP_X_PAYGATE_SIGNATURE' => 'v1=abc123hex', 'HTTP_X_PAYGATE_TIMESTAMP' => '1600000000', ], '{"payload":true}'); $this->verifier->expects($this->once()) ->method('verify') ->with('v1', 'v1=abc123hex', '1600000000', '{"payload":true}') ->willReturn(true); // WHEN $isValid = $service->isValidWebhookAccess($request); // THEN $this->assertTrue($isValid); } }