10 public static function exec()
12 if (!Main\Loader::includeModule(
'seo'))
17 if (self::isYandexOauth())
19 self::registerWebhook(Seo\Checkout\Service::TYPE_YANDEX);
21 elseif (self::isYookassaOauth())
23 self::registerWebhook(Seo\Checkout\Service::TYPE_YOOKASSA);
27 private static function isYandexOauth(): bool
29 $authAdapter = Seo\Checkout\Service::getAuthAdapter(Seo\Checkout\Service::TYPE_YANDEX);
30 return $authAdapter->hasAuth();
33 private static function isYookassaOauth(): bool
35 $authAdapter = Seo\Checkout\Service::getAuthAdapter(Seo\Checkout\Service::TYPE_YOOKASSA);
36 return $authAdapter->hasAuth();
39 private static function registerWebhook(
string $type): void
41 $authAdapter = Seo\Checkout\Service::getAuthAdapter($type);
42 $oauthService = Seo\Checkout\Services\Factory::createService($authAdapter->getType());
44 $registerPaymentSucceededResult = $oauthService->registerPaymentSucceededWebhook();
45 $registerPaymentCanceledWebhookResult = $oauthService->registerPaymentCanceledWebhook();
46 if ($registerPaymentSucceededResult->isSuccess() && $registerPaymentCanceledWebhookResult->isSuccess())
48 Main\Config\Option::set(
'sale',
'YANDEX_CHECKOUT_OAUTH_WEBHOOK_REGISTER',
true);