• Модуль: salescenter
  • Путь к файлу: ~/bitrix/modules/salescenter/lib/integration/imopenlinesmanager.php
  • Класс: BitrixSalesCenterIntegrationImOpenLinesManager
  • Вызов: ImOpenLinesManager::sendPaymentPayNotify
public function sendPaymentPayNotify(Payment $payment): Result
{
	$result = new Result();

	$order = $payment->getOrder();
	$responsibleId = $order->getField('RESPONSIBLE_ID');
	$dialogs = $this->getDialogIdsByUserId($order->getUserId());

	$urlInfo = $this->getPublicUrlInfoForPayment($payment);
	if (!$urlInfo)
	{
		$result->addError(new Error('Page not found'));
		return $result;
	}

	foreach ($dialogs as $dialogId)
	{
		$notifyResult = $this->sendPaymentNotify($payment, $dialogId, false);
		if (!$notifyResult->isSuccess())
		{
			$result->addErrors($notifyResult->getErrors());
		}

		$messageId = Im::addMessage([
			'DIALOG_ID' => $dialogId,
			'AUTHOR_ID' => $responsibleId,
			'FROM_USER_ID' => $responsibleId,
			'PARAMS' => $this->getCommonImParams(),
			'MESSAGE' => $this->createImMessageForPaymentStatus($payment),
		]);

		if (!$messageId)
		{
			global $APPLICATION;
			$result->addError(new Error($APPLICATION->LAST_ERROR));
		}

		$messageId = Im::addMessage([
			'DIALOG_ID' => $dialogId,
			'AUTHOR_ID' => $responsibleId,
			'FROM_USER_ID' => $responsibleId,
			'PARAMS' => $this->getCommonImParams(),
			'MESSAGE' => $this->createImMessageForPaymentOrder($urlInfo['url']),
		]);

		if (!$messageId)
		{
			global $APPLICATION;
			$result->addError(new Error($APPLICATION->LAST_ERROR));
		}
	}

	return $result;
}