• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/controller/action/entity/initiatepayaction.php
  • Класс: BitrixSaleControllerActionEntityInitiatePayAction
  • Вызов: InitiatePayAction::initiatePay
private function initiatePay(): void
{
	$this->updatePaymentMetadata();

	$request = null;
	if (!empty($this->params['template']))
	{
		$request = BitrixMainContext::getCurrent()->getRequest();
		$request->set(['template' => $this->params['template']]);
	}

	$this->serviceResult = $this->service->initiatePay(
		$this->payment,
		$request,
		SalePaySystemBaseServiceHandler::STRING
	);

	if (!$this->serviceResult->isSuccess())
	{
		$this->addError(new Error(
			'payment service error',
			SaleControllerErrorEnumeration::INITIATE_PAY_ACTION_PAYMENT_SERVICE_INTERNAL_ERROR
		));

		$this->addErrors($this->serviceResult->getErrors());

		foreach ($this->serviceResult->getBuyerErrors() as $buyerError)
		{
			$customData = $buyerError->getCustomData();
			$errorContext = is_array($customData) ? $customData : [];
			$errorContext['is_buyer'] = true;

			$this->addError(new Error(
				$buyerError->getMessage(),
				$buyerError->getCode(),
				$errorContext
			));
		}
	}
}