![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-paypal-graph-ql/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\PaypalGraphQl\Model; use Magento\Framework\GraphQl\Exception\GraphQlInputException; use Magento\PaypalGraphQl\Model\Resolver\Store\Url as UrlService; use Magento\Paypal\Model\Config; use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderInterface; /** * Get payment additional data for Paypal HostedPro payment */ class HostedProAdditionalDataProvider implements AdditionalDataProviderInterface { /** * @var UrlService */ private $urlService; /** * @param UrlService $urlService */ public function __construct(UrlService $urlService) { $this->urlService = $urlService; } /** * Returns additional data * * @param array $data * @return array * @throws GraphQlInputException */ public function getData(array $data): array { $additionalData = $data[Config::METHOD_HOSTEDPRO] ?? []; $this->validateUrlPaths($additionalData); return $additionalData; } /** * Validate redirect url paths * * @param array $data * @throws GraphQlInputException */ private function validateUrlPaths(array $data): void { $urlKeys = ['cancel_url', 'return_url']; foreach ($urlKeys as $urlKey) { if (isset($data[$urlKey])) { if (!$this->urlService->isPath($data[$urlKey])) { throw new GraphQlInputException(__('Invalid Url.')); } } } } }