* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PrestashopCheckout\PayPal\Customer\CommandHandler; use PrestaShop\Module\PrestashopCheckout\PayPal\Customer\Command\SavePayPalCustomerCommand; use PrestaShop\Module\PrestashopCheckout\Repository\PayPalCustomerRepository; class SavePayPalCustomerCommandHandler { /** * @var PayPalCustomerRepository */ private $payPalCustomerRepository; public function __construct(PayPalCustomerRepository $payPalCustomerRepository) { $this->payPalCustomerRepository = $payPalCustomerRepository; } public function handle(SavePayPalCustomerCommand $command) { try { $this->payPalCustomerRepository->findPayPalCustomerIdByCustomerId($command->getCustomerId()); } catch (\Exception $exception) { $this->payPalCustomerRepository->save($command->getCustomerId(), $command->getPayPalCustomerId()); } } }