- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/cashbox/cashboxrobokassa.php
- Класс: BitrixSaleCashboxCashboxRobokassa
- Вызов: CashboxRobokassa::buildCheckQuery
public function buildCheckQuery(Check $check): array
{
$checkParamsResult = $this->checkParams($check);
if (!$checkParamsResult->isSuccess())
{
return [];
}
$payment = CheckManager::getPaymentByCheck($check);
if (!$payment)
{
return [];
}
$checkData = $check->getDataForCheck();
$request = MainApplication::getInstance()->getContext()->getRequest();
$protocol = $request->isHttps() ? 'https://' : 'http://';
$fields = [
'merchantId' => $this->getPaySystemSetting($payment, 'ROBOXCHANGE_SHOPLOGIN'),
'id' => $checkData['unique_id'],
'originId' => $payment->getId(),
'operation' => SellCheck::getType(),
'sno' => $this->getValueFromSettings('TAX', 'SNO'),
'url' => urlencode($protocol . $request->getHttpHost()),
'total' => (string)SalePriceMaths::roundPrecision($checkData['total_sum']),
'client' => [
'email' => $checkData['client_email'],
'phone' => $checkData['client_phone'],
],
'payments' => [],
'items' => [],
'vats' => [],
];
foreach ($checkData['payments'] as $paymentItem)
{
$fields['payments'][] = [
'type' => self::CHECK_PAYMENT_TYPE,
'sum' => (string)SalePriceMaths::roundPrecision($paymentItem['sum']),
];
}
$checkTypeMap = $this->getCheckTypeMap();
$paymentMethod = $checkTypeMap[$check::getType()];
$paymentObjectMap = $this->getPaymentObjectMap();
foreach ($checkData['items'] as $item)
{
$vat = $this->getValueFromSettings('VAT', $item['vat']);
$tax = $vat ?? $this->getValueFromSettings('VAT', 'NOT_VAT');
$receiptItem = [
'name' => mb_substr($item['name'], 0, self::MAX_NAME_LENGTH),
'quantity' => (string)$item['quantity'],
'sum' => (string)SalePriceMaths::roundPrecision($item['sum']),
'tax' => $tax,
'payment_method' => $paymentMethod,
'payment_object' => $paymentObjectMap[$item['payment_object']],
];
if (!empty($item['marking_code']))
{
$receiptItem['nomenclature_code'] = $item['marking_code'];
}
$fields['items'][] = $receiptItem;
$fields['vats'][] = [
'type' => $tax,
'sum' => (string)SalePriceMaths::roundPrecision($item['vat_sum']),
];
}
return $fields;
}