• Модуль: crmmobile
  • Путь к файлу: ~/bitrix/modules/crmmobile/lib/Controller/Action/Terminal/CreatePaymentAction.php
  • Класс: BitrixCrmMobileControllerActionTerminalCreatePaymentAction
  • Вызов: CreatePaymentAction::createContactCompany
private function createContactCompany(?string $phone, ?string $name): SaleResult
{
	$result = new SaleResult();

	$userId = (int)$this->getCurrentUser()->getId();
	$fields = [
		'NAME' => $name ?? '',
		'ASSIGNED_BY_ID' => $userId,
		'TYPE_ID' => 'CLIENT',
		'SOURCE_ID' => 'STORE',
		'FM' => [
			'PHONE' => [
				'n1' => [
					'VALUE_TYPE' => 'MOBILE',
					'VALUE' => $phone ?? '',
				],
			],
		],
	];

	$options = [
		'DISABLE_REQUIRED_USER_FIELD_CHECK' => true,
		'REGISTER_SONET_EVENT' => true,
	];

	$contact = new CCrmContact(false);
	$id = (int)$contact->Add($fields, true, $options);

	if ($id > 0)
	{
		$result->setId($id);
	}
	else
	{
		$result->addError(new MainError($contact->LAST_ERROR));
	}

	return $result;
}