1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
checkoutwebhookregistrationagent.php
См. документацию.
1<?php
2
3namespace Bitrix\Sale\Update;
4
5use Bitrix\Main;
6use Bitrix\Seo;
7
9{
10 public static function exec()
11 {
12 if (!Main\Loader::includeModule('seo'))
13 {
14 return;
15 }
16
17 if (!Main\Loader::includeModule('socialservices'))
18 {
19 return;
20 }
21
22 if (self::isYandexOauth())
23 {
24 self::registerWebhook(Seo\Checkout\Service::TYPE_YANDEX);
25 }
26 elseif (self::isYookassaOauth())
27 {
28 self::registerWebhook(Seo\Checkout\Service::TYPE_YOOKASSA);
29 }
30 }
31
32 private static function isYandexOauth(): bool
33 {
34 $authAdapter = Seo\Checkout\Service::getAuthAdapter(Seo\Checkout\Service::TYPE_YANDEX);
35 return $authAdapter->hasAuth();
36 }
37
38 private static function isYookassaOauth(): bool
39 {
40 $authAdapter = Seo\Checkout\Service::getAuthAdapter(Seo\Checkout\Service::TYPE_YOOKASSA);
41 return $authAdapter->hasAuth();
42 }
43
44 private static function registerWebhook(string $type): void
45 {
47 $oauthService = Seo\Checkout\Services\Factory::createService($authAdapter->getType());
48
49 $registerPaymentSucceededResult = $oauthService->registerPaymentSucceededWebhook();
50 $registerPaymentCanceledWebhookResult = $oauthService->registerPaymentCanceledWebhook();
51 if ($registerPaymentSucceededResult->isSuccess() && $registerPaymentCanceledWebhookResult->isSuccess())
52 {
53 Main\Config\Option::set('sale', 'YANDEX_CHECKOUT_OAUTH_WEBHOOK_REGISTER', true);
54 }
55 }
56}
$type
Определения options.php:106
static set($moduleId, $name, $value="", $siteId="")
Определения option.php:261
static getAuthAdapter($type)
Определения service.php:60
static createService(string $type)
Определения factory.php:19
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393