1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
checkoutwebhookregistrationagent.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Sale\Update;
4
5
use Bitrix\Main;
6
use Bitrix\Seo;
7
8
class
CheckoutWebhookRegistrationAgent
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
{
46
$authAdapter =
Seo\Checkout\Service::getAuthAdapter
(
$type
);
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
$type
Определения
options.php:106
Bitrix\Main\Config\Option\set
static set($moduleId, $name, $value="", $siteId="")
Определения
option.php:261
Bitrix\Sale\Update\CheckoutWebhookRegistrationAgent
Определения
checkoutwebhookregistrationagent.php:9
Bitrix\Sale\Update\CheckoutWebhookRegistrationAgent\exec
static exec()
Определения
checkoutwebhookregistrationagent.php:10
Bitrix\Seo\Checkout\Service\getAuthAdapter
static getAuthAdapter($type)
Определения
service.php:60
Bitrix\Seo\Checkout\Services\Factory\createService
static createService(string $type)
Определения
factory.php:19
Bitrix\Main
Bitrix\Seo\Checkout
Определения
authadapter.php:3
Bitrix\Seo
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
bitrix
modules
sale
lib
update
checkoutwebhookregistrationagent.php
Создано системой
1.14.0