1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
registeryookassawebhookaction.php
См. документацию.
1<?php
2
3namespace Bitrix\Sale\Controller\Action\PaySystem;
4
5use Bitrix\Main;
6use Bitrix\Sale;
7use Bitrix\Seo;
8
16{
17 public function run()
18 {
19 if (!Main\Loader::includeModule('seo'))
20 {
21 $this->addError(new Main\Error('Module seo not installed'));
22 return;
23 }
24
25 $authAdapter = Seo\Checkout\Service::getAuthAdapter(Seo\Checkout\Service::TYPE_YOOKASSA);
26 $hasAuth = $authAdapter->hasAuth();
27 if ($hasAuth)
28 {
29 Main\Config\Option::set('sale', 'YANDEX_CHECKOUT_OAUTH', true);
30
31 $oauthService = Seo\Checkout\Services\Factory::createService($authAdapter->getType());
32 $this->registerWebhooks($oauthService);
33 }
34 else
35 {
36 $this->addError(new Main\Error('Yokassa is not authorized'));
37 }
38 }
39
40 private function registerWebhooks(Seo\Checkout\Services\AccountYookassa $oauthService): void
41 {
42 $registerPaymentSucceededResult = $oauthService->registerPaymentSucceededWebhook();
43 $registerPaymentCanceledWebhookResult = $oauthService->registerPaymentCanceledWebhook();
44 if ($registerPaymentSucceededResult->isSuccess() && $registerPaymentCanceledWebhookResult->isSuccess())
45 {
46 Main\Config\Option::set('sale', 'YANDEX_CHECKOUT_OAUTH_WEBHOOK_REGISTER', true);
47 }
48
49 if (!$registerPaymentSucceededResult->isSuccess())
50 {
51 $this->addErrors($registerPaymentSucceededResult->getErrors());
52 }
53 if (!$registerPaymentCanceledWebhookResult->isSuccess())
54 {
55 $this->addErrors(($registerPaymentCanceledWebhookResult->getErrors()));
56 }
57 }
58}
static set($moduleId, $name, $value="", $siteId="")
Определения option.php:261
addError(Error $error)
Определения action.php:200
addErrors(array $errors)
Определения action.php:213
Определения error.php:15
static getAuthAdapter($type)
Определения service.php:60
static createService(string $type)
Определения factory.php:19