• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/payment.php
  • Класс: Bitrix\Sale\Payment
  • Вызов: Payment::save
public function save()
{
	$this->checkCallingContext();

	$result = new Result();

	$id = $this->getId();
	$isNew = $id <= 0;

	$this->callEventOnBeforeEntitySaved();

	if (!$this->isChanged())
	{
		return $result;
	}

	if ($id > 0)
	{
		$r = $this->update();
	}
	else
	{
		$r = $this->add();
		if ($r->getId() > 0)
		{
			$id = $r->getId();
		}
	}

	if (!$r->isSuccess())
	{
		$result->addErrors($r->getErrors());
		return $result;
	}

	if ($id > 0)
	{
		$result->setId($id);
	}

	if ($this->fields->isChanged('PAID'))
	{
		$this->calculateStatistic();
	}

	$this->callEventOnEntitySaved();

	$this->callDelayedEvents();

	$payableItemCollection = $this->getPayableItemCollection();
	$r = $payableItemCollection->save();
	if (!$r->isSuccess())
	{
		return $result->addErrors($r->getErrors());
	}

	$this->onAfterSave($isNew);

	return $result;
}