feat: add fiscalization settings, POST callbacks and fix callback issues

This commit is contained in:
2026-10-26 17:54:23 +03:00
committed by Git Moneta
parent a9bc7f315c
commit b1acb1a1de
13 changed files with 1585 additions and 335 deletions
+162 -9
View File
@@ -22,6 +22,12 @@
</div>
</div>
<div class="container-fluid">
<div id="payanyway-warning-startup" class="alert alert-warning{% if not warning_startup %} d-none{% endif %}">
<i class="fa-solid fa-triangle-exclamation"></i> <span>{{ warning_startup }}</span>
</div>
<div id="payanyway-warning-receipt-email" class="alert alert-warning{% if not warning_receipt_email %} d-none{% endif %}">
<i class="fa-solid fa-triangle-exclamation"></i> <span>{{ warning_receipt_email }}</span>
</div>
<div class="card">
<div class="card-header">
<i class="fa-solid fa-pencil"></i>
@@ -68,8 +74,13 @@
<div class="row mb-3 required">
<label class="col-sm-2 col-form-label" for="input-integrity-code">{{ entry_integrity_code_label }}</label>
<div class="col-sm-10">
<input type="text" name="payment_payanyway_integrity_code" value="{{ payment_payanyway_integrity_code }}"
placeholder="{{ entry_integrity_code_description }}" id="input-integrity-code" class="form-control"/>
<div class="input-group">
<input type="password" name="payment_payanyway_integrity_code" value=""
placeholder="{{ integrity_code_placeholder }}" id="input-integrity-code" class="form-control"
autocomplete="off"/>
<button type="button" class="btn btn-light" id="button-integrity-code-toggle"
data-bs-toggle="tooltip" title="{{ button_integrity_code_toggle }}"><i class="fa-solid fa-eye"></i></button>
</div>
</div>
</div>
@@ -84,15 +95,85 @@
</div>
</div>
{# НДС #}
{# Тестовый режим #}
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="input-vat-rate">{{ entry_vat_rate_label }}</label>
<label class="col-sm-2 col-form-label" for="input-test-mode">
<span>{{ entry_test_mode_label }}</span>
<i class="fa-regular fa-circle-question text-info" data-bs-toggle="tooltip" title="{{ help_test_mode }}"></i>
</label>
<div class="col-sm-10">
<select name="payment_payanyway_vat_rate" id="input-vat-rate" class="form-select">
{% for vat_id, label in payment_payanyway_vat_rates %}
<option value="{{ vat_id }}" {% if vat_id == payment_payanyway_vat_rate %}selected="selected"{% endif %}>{{ label }}</option>
{% endfor %}
</select>
<div class="form-check form-switch form-switch-lg">
<input type="hidden" name="payment_payanyway_test_mode" value="0"/>
<input type="checkbox" name="payment_payanyway_test_mode" value="1" id="input-test-mode"
class="form-check-input" {% if payment_payanyway_test_mode == "1" %} checked{% endif %}>
</div>
</div>
</div>
{# Фискализация чеков #}
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="input-fiscalization">
<span>{{ entry_fiscalization_label }}</span>
<i class="fa-regular fa-circle-question text-info" data-bs-toggle="tooltip" title="{{ help_fiscalization }}"></i>
</label>
<div class="col-sm-10">
<div class="form-check form-switch form-switch-lg">
<input type="hidden" name="payment_payanyway_fiscalization" value="0"/>
<input type="checkbox" name="payment_payanyway_fiscalization" value="1" id="input-fiscalization"
class="form-check-input" {% if payment_payanyway_fiscalization == "1" %} checked{% endif %}>
</div>
</div>
</div>
{# Поля чека — только при фискализации. Скрываются, а не блокируются: заблокированное
поле браузер не отправляет, и значение потерялось бы. #}
<div id="fiscalization-fields">
{# Email для чеков #}
<div class="row mb-3 required">
<label class="col-sm-2 col-form-label" for="input-receipt-email">
<span>{{ entry_receipt_email_label }}</span>
<i class="fa-regular fa-circle-question text-info" data-bs-toggle="tooltip" title="{{ help_receipt_email }}"></i>
</label>
<div class="col-sm-10">
<input type="email" name="payment_payanyway_receipt_email" value="{{ payment_payanyway_receipt_email }}"
placeholder="shop@example.ru" id="input-receipt-email" class="form-control" maxlength="64"/>
</div>
</div>
{# НДС #}
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="input-vat-rate">{{ entry_vat_rate_label }}</label>
<div class="col-sm-10">
<select name="payment_payanyway_vat_rate" id="input-vat-rate" class="form-select">
{% for vat_id, label in payment_payanyway_vat_rates %}
<option value="{{ vat_id }}" {% if vat_id == payment_payanyway_vat_rate %}selected="selected"{% endif %}>{{ label }}</option>
{% endfor %}
</select>
</div>
</div>
{# Признак способа расчёта #}
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="input-payment-method">{{ entry_payment_method_label }}</label>
<div class="col-sm-10">
<select name="payment_payanyway_payment_method" id="input-payment-method" class="form-select">
{% for value, label in payment_payanyway_payment_methods %}
<option value="{{ value }}" {% if value == payment_payanyway_payment_method %}selected="selected"{% endif %}>{{ label }}</option>
{% endfor %}
</select>
</div>
</div>
{# Признак предмета расчёта #}
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="input-payment-object">{{ entry_payment_object_label }}</label>
<div class="col-sm-10">
<select name="payment_payanyway_payment_object" id="input-payment-object" class="form-select">
{% for value, label in payment_payanyway_payment_objects %}
<option value="{{ value }}" {% if value == payment_payanyway_payment_object %}selected="selected"{% endif %}>{{ label }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
@@ -187,6 +268,29 @@
</select>
</div>
</div>
{# canceled #}
<div class="row mb-3">
<label class="col-sm-3 col-form-label">
<span>{{ entry_canceled_order_status_label }}</span>
<i class="fa-regular fa-circle-question text-info"
data-bs-toggle="tooltip"
title="{{ help_canceled_order_status }}"
></i>
</label>
<div class="col-sm-9">
<div class="form-control p-0" style="height: 150px; overflow: auto;">
{% for order_status in order_statuses %}
<div class="form-check m-2">
<input type="checkbox" name="payment_payanyway_canceled_order_status_ids[]"
value="{{ order_status.order_status_id }}" id="input-canceled-{{ order_status.order_status_id }}"
class="form-check-input"{% if order_status.order_status_id in payment_payanyway_canceled_order_status_ids %} checked{% endif %}/>
<label for="input-canceled-{{ order_status.order_status_id }}" class="form-check-label">{{ order_status.name }}</label>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
</div>
@@ -216,6 +320,20 @@
</div>
</div>
{# URL для уведомлений #}
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="input-callback-url">
<span>{{ entry_callback_url_label }}</span>
<i class="fa-regular fa-circle-question text-info" data-bs-toggle="tooltip" title="{{ help_callback_url }}"></i>
</label>
<div class="col-sm-10">
<div class="input-group">
<input type="text" value="{{ callback_url }}" id="input-callback-url" class="form-control" readonly/>
<button type="button" class="btn btn-light" id="button-callback-url-copy">{{ button_copy }}</button>
</div>
</div>
</div>
{# sort-order #}
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="input-sort-order">
@@ -238,4 +356,39 @@
</div>
</div>
</div>
<script>
$(function () {
function toggleFiscalizationFields() {
$('#fiscalization-fields').toggle($('#input-fiscalization').is(':checked'));
}
$('#input-fiscalization').on('change', toggleFiscalizationFields);
toggleFiscalizationFields();
// Форму отправляет common.js OpenCart; после сохранения обновляем предупреждения без перезагрузки.
$(document).on('ajaxSuccess', function (event, xhr, settings) {
var json = xhr.responseJSON;
if (!json || !json['payanyway_warnings'] || (settings.url.indexOf('payanyway.save') === -1)) {
return;
}
$.each({'startup': '#payanyway-warning-startup', 'receipt_email': '#payanyway-warning-receipt-email'}, function (key, selector) {
var text = json['payanyway_warnings'][key] || '';
$(selector).toggleClass('d-none', text === '').find('span').html(text);
});
});
$('#button-integrity-code-toggle').on('click', function () {
var $input = $('#input-integrity-code');
$input.attr('type', $input.attr('type') === 'password' ? 'text' : 'password');
$(this).find('i').toggleClass('fa-eye fa-eye-slash');
});
$('#button-callback-url-copy').on('click', function () {
var $button = $(this);
$('#input-callback-url').trigger('select');
document.execCommand('copy');
$button.text('{{ text_copied }}');
setTimeout(function () { $button.text('{{ button_copy }}'); }, 2000);
});
});
</script>
{{ footer }}