Cambios de usos de env vars

This commit is contained in:
Juan Pablo Vial
2025-06-03 12:04:53 -04:00
parent 02665ac6bd
commit fbfc2cb8ae
4 changed files with 52 additions and 27 deletions

View File

@ -2,6 +2,7 @@
namespace Incoviba\Controller\API\Ventas\MediosPago;
use Exception;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
@ -105,9 +106,9 @@ class Toku extends Controller
return $this->withJson($response, $output);
}
public function reset(ServerRequestInterface $request, ResponseInterface $response,
Service\Venta\MediosPago\Toku $tokuService): ResponseInterface
Service\Venta\MediosPago\Toku $tokuService, ContainerInterface $container): ResponseInterface
{
if (!isset($_ENV['TOKU_ENV']) or strtolower($_ENV['TOKU_ENV']) !== 'sandbox') {
if (!$container->has('TOKU_ENV') or strtolower($container->get('TOKU_ENV')) !== 'sandbox') {
return $this->withJson($response);
}
$input = $request->getParsedBody();

View File

@ -16,9 +16,16 @@ class API
protected Service\API $apiService,
protected Service\Login $loginService,
protected string $key,
protected array $permittedPaths,
protected array $simplePaths,
protected array $externalPaths) {}
array $apiUrls)
{
$this->permittedPaths = $apiUrls['permittedPaths'];
$this->simplePaths = $apiUrls['simplePaths'];
$this->externalPaths = $apiUrls['externalPaths'];
}
protected array $permittedPaths;
protected array $simplePaths;
protected array $externalPaths;
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
@ -27,7 +34,10 @@ class API
}
try {
$key = $this->apiService->getKey($request);
} catch (MissingAuthorizationHeader) {
} catch (MissingAuthorizationHeader $exception) {
$this->logger->warning($exception, [
'headers' => $request->getHeaders()
]);
return $this->responseFactory->createResponse(401);
}
if ($this->validateSimpleKey($request, $key)) {