• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/paysystem/restservice.php
  • Класс: BitrixSalePaySystemRestService
  • Вызов: RestService::getSettingsByInvoice
static function getSettingsByInvoice(array $params, $n, CRestServer $server)
{
	static::checkOrderPermission();

	$params = self::preparePaySystemParams($params, $server);

	self::checkParamsBeforeSettingsByInvoiceGet($params);

	if (isset($params['PAY_SYSTEM_ID']))
	{
		$service = Manager::getObjectById($params['PAY_SYSTEM_ID']);
	}
	else
	{
		$dbRes = Manager::getList(array('filter' => array('=ACTION_FILE' => $params['BX_REST_HANDLER'])));
		$item = $dbRes->fetch();
		if (!$item)
		{
			throw new RestException('Pay system with handler '.$params['BX_REST_HANDLER'].' not found', self::ERROR_PAY_SYSTEM_NOT_FOUND);
		}

		$service = new Service($item);
	}

	$invoice = InvoiceInvoice::load($params['INVOICE_ID']);
	if ($invoice)
	{
		$paymentCollection = $invoice->getPaymentCollection();
		if ($paymentCollection)
		{
			/** @var Payment $payment */
			foreach ($paymentCollection as $payment)
			{
				if (!$payment->isInner())
				{
					return $service->getParamsBusValue($payment);
				}
			}
		}
	}

	throw new RestException('Invoice #'.$params['INVOICE_ID'].' not found', self::ERROR_INTERNAL_INVOICE_NOT_FOUND);
}