45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?
|
|
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
|
|
/** @var CBitrixComponent $this */
|
|
/** @var array $arParams */
|
|
/** @var array $arResult */
|
|
/** @var string $componentPath */
|
|
/** @var string $componentName */
|
|
/** @var string $componentTemplate */
|
|
/** @global CDatabase $DB */
|
|
/** @global CUser $USER */
|
|
/** @global CMain $APPLICATION */
|
|
|
|
use Bitrix\Main\Context,
|
|
Bitrix\Main\Type\DateTime,
|
|
Bitrix\Main\Loader,
|
|
Bitrix\Iblock;
|
|
|
|
if($this->StartResultCache(60*60*24, md5(var_export($_POST, true))))
|
|
{
|
|
$payload = json_encode([
|
|
"car_price" => $arParams['car_price'],
|
|
"initial_payment" => $arParams['initial_payment'],
|
|
"lease_period" => $arParams['lease_period'],
|
|
"redemption_payment" => $arParams['redemption_payment'],
|
|
]);
|
|
|
|
$c = curl_init();
|
|
curl_setopt($c, CURLOPT_URL, API_HOST."/calculator/");
|
|
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30);
|
|
curl_setopt($c, CURLOPT_TIMEOUT, 30);
|
|
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
|
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
|
|
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
|
|
curl_setopt($c, CURLOPT_POST, 1);
|
|
curl_setopt($c, CURLOPT_POSTFIELDS, $payload);
|
|
curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
|
|
|
|
$response = curl_exec($c) or die(curl_error($c));
|
|
curl_close($c);
|
|
|
|
$arResult = [];
|
|
$arResult['CALCULATION'] = (array) json_decode($response);
|
|
|
|
$this->IncludeComponentTemplate();
|
|
} |