{% extends '@CpCreationVitiCore/admin/base.html.twig' %}

{% block title %}Commande {{ cart.token ?: 'sans reference' }} - VitiCore{% endblock %}
{% block section_label %}Commande{% endblock %}
{% block page_title %}{{ cart.token ?: 'Sans reference' }}{% endblock %}

{% block topbar_actions %}
    <a class="admin-button" href="{{ return_to_order_list|default(path('admin_order')) }}">Retour</a>
{% endblock %}

{% block content %}
    {% set pricing = cart.getPricing %}
    {% set cart_checkout = cart.cartCheckout %}
    {% set invoice = cart.invoice %}
    {% set invoice_address = cart.invoiceAddress %}
    {% set delivery_address = cart.deliveryAddress %}
    {% set billing_address = invoice_address ?: delivery_address %}
    {% set use_shipping_address = cart.deliveryMethod is null or cart.deliveryMethod.category is null or not cart.deliveryMethod.category.disabledShippingAddress %}
    {% set checkout_status = cart.checkoutStatus %}
    {% set effective_payment_method = cart.paymentMethod ?: (cart_checkout ? cart_checkout.paymentMethod : null) %}
    {% set payment_failure_code = cart.paymentFailureCode %}
    {% set payment_failure_message = cart.paymentFailureMessage %}
    {% set checkout_status_labels = {
        paid: 'Payee',
        initiated: 'Paiement initie',
        failed: 'Paiement echoue',
        canceled: 'Paiement annule',
        abandoned: 'Panier abandonne',
        ordered: 'En attente',
        pending: 'En cours'
    } %}
    {% set checkout_status_label = checkout_status_labels[checkout_status]|default(checkout_status ?: 'En cours') %}
    {% set payment_response = cart_checkout and cart_checkout.response is iterable ? cart_checkout.response : null %}
    {% set payment_trace_available = payment_response is iterable and payment_response is not empty %}
    {% set payment_event_type = payment_trace_available ? payment_response.event_type|default(payment_response.webhook_event_type|default(payment_response.type|default(null))) : null %}
    {% set payment_event_id = payment_trace_available ? payment_response.event_id|default(payment_response.webhook_event_id|default(payment_response.id|default(null))) : null %}
    {% if payment_trace_available and payment_event_id is empty and payment_response.raw is defined and payment_response.raw.id is defined %}
        {% set payment_event_id = payment_response.raw.id %}
    {% endif %}
    {% set payment_external_id = payment_trace_available ? payment_response.checkout_session_id|default(payment_response.payment_intent|default(payment_response.payment_id|default(payment_response.transaction_id|default(payment_response.vads_trans_id|default(payment_response.TransID|default(payment_response.orderId|default(null))))))) : null %}
    {% if payment_trace_available and payment_external_id is empty and payment_response.payment is defined and payment_response.payment.id is defined %}
        {% set payment_external_id = payment_response.payment.id %}
    {% endif %}
    {% set order_comment = cart.comment|default('')|trim %}
    {% set is_order_paid = cart_checkout and cart_checkout.payedAt %}
    {% set can_send_document_email = is_order_paid and (document_label == 'checkout_design.document_order' or document_label == 'checkout_design.document_invoice') %}
    {% set document_action_name = document_label == 'checkout_design.document_invoice' ? 'facture' : 'bon de commande' %}
    {% set customer_name = (cart.firstname ~ ' ' ~ cart.lastname)|trim %}
    {% set email_type_labels = {
        account_activation: 'Activation de compte',
        password_reset: 'Réinitialisation du mot de passe',
        offline_order_customer: 'Bon de commande client',
        offline_order_admin: 'Bon de commande boutique',
        paid_order_customer: invoice_feature_enabled ? 'Facture client' : 'Bon de commande client',
        paid_order_admin: invoice_feature_enabled ? 'Facture boutique' : 'Bon de commande boutique',
        order_resend_customer: 'Renvoi bon de commande client',
        document_customer: 'Renvoi document client',
        delivery_customer: 'Avis d’expédition',
        credit_customer: 'Avoir client'
    } %}
    {% set email_status_labels = {
        queued: { label: 'En file', class: 'admin-status-info' },
        retrying: { label: 'Nouvelle tentative', class: 'admin-status-warning' },
        sent: { label: 'Envoyé', class: 'admin-status-success' },
        failed: { label: 'Échec', class: 'admin-status-danger' }
    } %}

    <section class="admin-order-detail">
        <div class="admin-order-hero">
            <div>
                <p>Référence</p>
                <h2>{{ cart.token ?: 'Sans référence' }}</h2>
                <span>{{ customer_name ?: cart.getEmail() ?: 'Client non renseigné' }}</span>
            </div>
            <div class="admin-order-status">
                {% if checkout_status == 'paid' %}
                    <span class="admin-status admin-status-success">Payée</span>
                    {% if cart.isDelivery %}
                        <span class="admin-status admin-status-info">Expédiée</span>
                    {% endif %}
                {% elseif checkout_status == 'initiated' %}
                    <span class="admin-status admin-status-info">Paiement initié</span>
                {% elseif checkout_status == 'failed' %}
                    <span class="admin-status admin-status-danger">Paiement échoué</span>
                {% elseif checkout_status == 'canceled' %}
                    <span class="admin-status admin-status-muted">Paiement annulé</span>
                {% elseif checkout_status == 'abandoned' %}
                    <span class="admin-status admin-status-warning">Panier abandonné</span>
                {% elseif checkout_status == 'ordered' %}
                    <span class="admin-status admin-status-warning">En attente</span>
                {% else %}
                    <span class="admin-status admin-status-warning">En cours</span>
                {% endif %}
            </div>
        </div>

        {% if is_order_paid %}
            <section class="admin-detail-panel admin-order-document-panel">
                <div class="admin-detail-panel-heading">
                    <p>Documents</p>
                    <h3>{{ document_action_name|capitalize }}</h3>
                </div>
                <div class="admin-order-document-actions">
                    <a class="admin-button admin-button-primary" href="{{ path('admin_order_purchase_order_pdf', { id: cart.id }) }}" target="_blank">
                        Télécharger {{ document_action_name }}
                    </a>
                    {% if can_send_document_email %}
                        <form
                            class="admin-inline-form"
                            method="post"
                            action="{{ path('admin_order_send_document_email', { id: cart.id }) }}"
                            data-confirm-submit="true"
                            data-confirm-message="Confirmer le renvoi de {{ document_action_name }} au client ?"
                        >
                            <input type="hidden" name="_token" value="{{ csrf_token('send-document-email-' ~ cart.id) }}">
                            <button class="admin-button" type="submit">Renvoyer {{ document_action_name }}</button>
                        </form>
                    {% endif %}
                </div>
            </section>
        {% endif %}

        <div class="admin-detail-grid">
            <div class="admin-detail-main">
                {% if cart.isCheckoutPayed %}
                    <section class="admin-detail-panel">
                        <div class="admin-detail-panel-heading">
                            <p>Livraison</p>
                            <h3>Mise en expédition</h3>
                        </div>
                        <p class="admin-help-text">
                            Renseignez le transporteur et le code de suivi avant de marquer la commande comme expédiée.
                        </p>
                        <form class="admin-form-grid" method="post" action="{{ path('admin_order_delivery', { id: cart.id }) }}">
                            <input type="hidden" name="_token" value="{{ csrf_token('mark-delivery-' ~ cart.id) }}">
                            <label>
                                <span>Transporteur</span>
                                <select name="tracking_carrier">
                                    <option value="">Aucun</option>
                                    {% for carrier_key, carrier in tracking_carriers %}
                                        <option value="{{ carrier_key }}" {% if selected_tracking_carrier == carrier_key %}selected{% endif %}>{{ carrier.label }}</option>
                                    {% endfor %}
                                </select>
                            </label>
                            <label>
                                <span>Code de suivi</span>
                                <input type="text" name="code_carrier" value="{{ cart.codeCarrier }}" placeholder="Ex. 8X01234567890">
                            </label>
                            <div class="admin-form-static">
                                <span>Lien actuel</span>
                                {% if cart.urlDeSuiviCarrier %}
                                    <a href="{{ cart.urlDeSuiviCarrier }}" target="_blank" rel="noopener noreferrer">Ouvrir le suivi</a>
                                {% else %}
                                    <strong>-</strong>
                                {% endif %}
                            </div>
                            <div class="admin-form-actions">
                                <button class="admin-button admin-button-primary" type="submit">
                                    {% if cart.isDelivery %}Mettre à jour{% else %}Marquer expédiée{% endif %}
                                </button>
                            </div>
                        </form>
                    </section>
                {% endif %}

                <section class="admin-detail-panel">
                    <div class="admin-detail-panel-heading">
                        <p>Panier</p>
                        <h3>Lignes de commande</h3>
                    </div>
                    <div class="admin-order-lines">
                        {% if pricing and pricing.lines is not empty %}
                            {% for line in pricing.lines %}
                                {% set line_previous_ttc = line.isPromoGift ? line.totalTTC : (line.degressiveTTC > 0 ? line.netTTC + line.degressiveTTC : null) %}
                                <article class="admin-order-line">
                                    <div class="admin-order-line-media">
                                        {% if line.imagePath %}
                                            <img src="{{ asset(line.imagePath)|imagine_filter('relative_heighten_293_filter') }}" alt="{{ line.productName ?: 'Produit' }}">
                                        {% else %}
                                            <span>Produit</span>
                                        {% endif %}
                                    </div>
                                    <div class="admin-order-line-content">
                                        <strong>{{ line.productName ?: '-' }}</strong>
                                        {% if line.typeName or line.unitLabel %}
                                            <small>{{ line.typeName }}{% if line.unitLabel %} ({{ line.unitLabel }}){% endif %}</small>
                                        {% endif %}
                                        {% if line.optionName %}
                                            <small>{{ 'shop.option_label'|trans }} : {{ line.optionName }}</small>
                                        {% endif %}
                                        {% if line.isPromoGift %}
                                            <span class="admin-status admin-status-warning">Offert</span>
                                        {% endif %}
                                        {% if line.degressiveTTC > 0 %}
                                            <small>Dégressif : -{{ line.degressiveTTC|price_format }} €</small>
                                        {% endif %}
                                    </div>
                                    <div class="admin-order-line-total">
                                        <small>x{{ line.quantity }}</small>
                                        <strong>
                                            {% if line_previous_ttc is not null and line_previous_ttc > line.netTTC %}
                                                <span>{{ line_previous_ttc|price_format }} €</span>
                                            {% endif %}
                                            {% if line.isPromoGift %}Offert{% else %}{{ line.netTTC|price_format }} €{% endif %}
                                        </strong>
                                    </div>
                                </article>
                            {% endfor %}
                        {% else %}
                            <p class="admin-empty-text">Ce panier est vide.</p>
                        {% endif %}
                    </div>
                </section>

                <section class="admin-detail-panel">
                    <div class="admin-detail-panel-heading">
                        <p>Montants</p>
                        <h3>Totaux</h3>
                    </div>
                    <dl class="admin-total-list">
                        {% if pricing and pricing.degressiveTTC > 0 %}
                            <div><dt>{{ pricing.degressiveIsBottleOffered ? 'Bouteille offerte' : 'Dégressif' }}</dt><dd>-{{ pricing.degressiveTTC|price_format }} €</dd></div>
                        {% endif %}
                        <div><dt>Sous-total</dt><dd>{% if pricing %}{{ pricing.subtotalTTC|price_format }} €{% else %}-{% endif %}</dd></div>
                        {% for promo in cart.promos %}
                            {% if promo.discountItemsTTC > 0 %}
                                <div><dt>Remise{% if promo.code %} - {{ promo.code }}{% endif %}</dt><dd>-{{ promo.discountItemsTTC|price_format }} €</dd></div>
                            {% endif %}
                        {% endfor %}
                        <div>
                            <dt>Livraison</dt>
                            <dd>
                                {% if cart.cartShipping is not null %}
                                    {{ cart.cartShipping.amountTTC|price_format }} €
                                    {% if cart.cartShipping.name %}<small>{{ cart.cartShipping.name }}</small>{% endif %}
                                {% else %}
                                    À définir
                                {% endif %}
                            </dd>
                        </div>
                        {% for promo in cart.promos %}
                            {% if promo.discountShippingTTC > 0 %}
                                <div><dt>Remise livraison{% if promo.code %} - {{ promo.code }}{% endif %}</dt><dd>-{{ promo.discountShippingTTC|price_format }} €</dd></div>
                            {% endif %}
                        {% endfor %}
                        <div class="is-total"><dt>{{ 'shop.total_ttc'|trans }}</dt><dd>{% if pricing %}{{ pricing.totalTTC|price_format }} €{% else %}-{% endif %}</dd></div>
                    </dl>
                </section>

                {% if order_comment %}
                    <section class="admin-detail-panel">
                        <div class="admin-detail-panel-heading">
                            <p>Commentaire</p>
                            <h3>Commentaire de commande</h3>
                        </div>
                        <p class="admin-comment-text">{{ order_comment|nl2br }}</p>
                    </section>
                {% endif %}

                <section class="admin-detail-panel">
                    <div class="admin-detail-panel-heading">
                        <p>Paiement</p>
                        <h3>Suivi paiement</h3>
                    </div>
                    <dl class="admin-detail-list">
                        <div><dt>Méthode</dt><dd>{% if effective_payment_method %}{{ effective_payment_method.method|trans }}{% else %}-{% endif %}</dd></div>
                        <div><dt>Checkout</dt><dd>{% if cart_checkout %}Initialisé{% else %}Non initialisé{% endif %}</dd></div>
                        {% if cart_checkout and cart_checkout.initiatedAt %}
                            <div><dt>Initié le</dt><dd>{{ cart_checkout.initiatedAt|date('d/m/Y H:i') }}</dd></div>
                        {% endif %}
                        {% if cart.abandonedAt %}
                            <div><dt>Abandonné le</dt><dd>{{ cart.abandonedAt|date('d/m/Y H:i') }}</dd></div>
                        {% endif %}
                        <div><dt>Document</dt><dd>{{ document_label|trans({}, 'messages', 'fr') }}</dd></div>
                    </dl>

                    {% if checkout_status == 'failed' or checkout_status == 'canceled' %}
                        <div class="admin-inline-alert {{ checkout_status == 'failed' ? 'is-danger' : 'is-warning' }}">
                            <strong>{% if checkout_status == 'failed' %}Paiement échoué{% else %}Paiement annulé{% endif %}</strong>
                            {% if payment_failure_code %}
                                <span>Code erreur : {{ payment_failure_code }}</span>
                            {% elseif payment_failure_message %}
                                <span>{{ payment_failure_message }}</span>
                            {% endif %}
                        </div>
                    {% endif %}

                    {% if not cart.isCheckoutPayed %}
                        <div class="admin-split-forms">
                            {% if invoice_feature_enabled %}
                                <form class="admin-stacked-form admin-stacked-form-compact" method="post" action="{{ path('admin_order_document_type', { id: cart.id }) }}">
                                    <input type="hidden" name="_token" value="{{ csrf_token('document-type-' ~ cart.id) }}">
                                    <label>
                                        <span>Type de document</span>
                                        <select name="document_type">
                                            <option value="order" {% if cart.documentType == 'order' %}selected{% endif %}>{{ 'checkout_design.document_order'|trans({}, 'messages', 'fr') }}</option>
                                            <option value="invoice" {% if cart.documentType == 'invoice' %}selected{% endif %}>{{ 'checkout_design.document_proforma'|trans({}, 'messages', 'fr') }}</option>
                                        </select>
                                    </label>
                                    <button class="admin-button" type="submit">Enregistrer</button>
                                </form>
                            {% endif %}

                            <form class="admin-stacked-form admin-stacked-form-compact" method="post" action="{{ path('admin_order_mark_paid', { id: cart.id }) }}">
                                <input type="hidden" name="_token" value="{{ csrf_token('mark-paid-' ~ cart.id) }}">
                                <label>
                                    <span>Méthode de paiement</span>
                                    <select name="payment_method_id" required>
                                        <option value="">Choisir</option>
                                        {% for payment_method in payment_methods %}
                                            <option value="{{ payment_method.id }}" {% if cart.paymentMethod and cart.paymentMethod.id == payment_method.id %}selected{% endif %}>
                                                {{ payment_method.configuration['name']|default(payment_method.method|trans) }}
                                            </option>
                                        {% endfor %}
                                    </select>
                                </label>
                                <label>
                                    <span>Date de paiement</span>
                                    <input type="datetime-local" name="payed_at" value="{{ (cart_checkout and cart_checkout.payedAt ? cart_checkout.payedAt : date())|date('Y-m-d\\TH:i') }}" required>
                                </label>
                                {% if checkout_completion_issue %}
                                    <div class="admin-inline-alert is-warning">{{ checkout_completion_issue }}</div>
                                {% endif %}
                                <button class="admin-button admin-button-primary" type="submit" {% if checkout_completion_issue %}disabled="disabled"{% endif %}>Passer en payé</button>
                            </form>
                        </div>
                    {% endif %}
                </section>
            </div>

            <aside class="admin-detail-aside">
                <section class="admin-detail-panel">
                    <div class="admin-detail-panel-heading">
                        <p>État</p>
                        <h3>Commande</h3>
                    </div>
                    <dl class="admin-detail-list">
                        <div><dt>Créée le</dt><dd>{{ cart.createdAt|date('d/m/Y H:i') }}</dd></div>
                        {% if cart_checkout and cart_checkout.payedAt %}
                            <div><dt>Payée le</dt><dd>{{ cart_checkout.payedAt|date('d/m/Y H:i') }}</dd></div>
                        {% endif %}
                        <div><dt>Référence</dt><dd>{{ cart.token ?: '-' }}</dd></div>
                        <div><dt>Code groupe</dt><dd>{{ cart.groupCode ?: '-' }}</dd></div>
                        <div><dt>Quantité</dt><dd>{{ cart.quantity }}{% if pricing and pricing.degressiveIsBottleOffered %} + cadeau{% endif %}</dd></div>
                    </dl>
                    {% if not cart.isCheckoutPayed %}
                        <div class="admin-aside-actions">
                            <a class="admin-button" href="{{ path('admin_order_redirect_payment', { id: cart.id }) }}" target="_blank">Page de paiement</a>
                            <a
                                class="admin-button admin-button-danger"
                                href="{{ path('admin_order_delete', { id: cart.id }) }}"
                                data-confirm-link="true"
                                data-confirm-message="Confirmer la suppression de la commande {{ cart.token ?: cart.id }} ?"
                            >
                                Supprimer
                            </a>
                        </div>
                    {% endif %}
                </section>

                <section class="admin-detail-panel">
                    <div class="admin-detail-panel-heading">
                        <p>Client</p>
                        <h3>Coordonnées</h3>
                    </div>
                    <dl class="admin-detail-list">
                        <div><dt>Compte site</dt><dd>{% if siteUser %}<span class="admin-status admin-status-success">Enregistré</span>{% else %}<span class="admin-status admin-status-muted">Non enregistré</span>{% endif %}</dd></div>
                        {% if cart.company %}<div><dt>Société</dt><dd>{{ cart.company }}</dd></div>{% endif %}
                        <div><dt>Nom</dt><dd>{{ customer_name ?: '-' }}</dd></div>
                        <div><dt>Email</dt><dd>{{ cart.email ?: cart.getEmail() ?: '-' }}</dd></div>
                        <div><dt>Téléphone</dt><dd>{{ cart.phone ?: '-' }}</dd></div>
                        {% if invoice_address and invoice_address.vatId %}
                            <div><dt>TVA</dt><dd>{{ invoice_address.vatId }}</dd></div>
                        {% endif %}
                    </dl>
                </section>

                <section class="admin-detail-panel">
                    <div class="admin-detail-panel-heading">
                        <p>Livraison</p>
                        <h3>Destination</h3>
                    </div>
                    <dl class="admin-detail-list">
                        <div><dt>Statut</dt><dd>{% if cart.isDelivery %}<span class="admin-status admin-status-info">Expédiée</span>{% else %}<span class="admin-status admin-status-muted">Non expédiée</span>{% endif %}</dd></div>
                        <div><dt>Méthode</dt><dd>{% if cart.deliveryMethod %}{{ cart.deliveryMethod.name }}{% elseif cart.cartShipping and cart.cartShipping.name %}{{ cart.cartShipping.name }}{% else %}Livraison standard{% endif %}</dd></div>
                        <div><dt>Suivi</dt><dd>{{ cart.codeCarrier ?: '-' }}</dd></div>
                    </dl>
                    {% if use_shipping_address and delivery_address %}
                        <address class="admin-address">
                            {% if delivery_address.company %}<strong>{{ delivery_address.company }}</strong>{% endif %}
                            {{ delivery_address.firstname }} {{ delivery_address.lastname }}<br>
                            {{ delivery_address.email ?: '-' }}<br>
                            {{ delivery_address.phone ?: '-' }}<br>
                            {{ delivery_address.street }}<br>
                            {{ delivery_address.postal }} {{ delivery_address.city }}<br>
                            {{ delivery_address.country|country_name }}
                        </address>
                    {% elseif cart.deliveryMethod and cart.deliveryMethod.description %}
                        <div class="admin-help-text">{{ cart.deliveryMethod.description|raw }}</div>
                    {% else %}
                        <p class="admin-empty-text">Aucune adresse de livraison.</p>
                    {% endif %}
                </section>

                {% if billing_address %}
                    <section class="admin-detail-panel">
                        <div class="admin-detail-panel-heading">
                            <p>Facturation</p>
                            <h3>Adresse</h3>
                        </div>
                        <address class="admin-address">
                            {% if billing_address.company %}<strong>{{ billing_address.company }}</strong>{% endif %}
                            {{ billing_address.street }}<br>
                            {{ billing_address.postal }} {{ billing_address.city }}<br>
                            {{ billing_address.country|country_name }}
                        </address>
                    </section>
                {% endif %}

                <section class="admin-detail-panel">
                    <div class="admin-detail-panel-heading">
                        <p>Emails</p>
                        <h3>Historique</h3>
                    </div>
                    <div class="admin-email-timeline">
                        {% for email_log in email_logs %}
                            {% set email_status = email_status_labels[email_log.status]|default({ label: email_log.status, class: 'admin-status-muted' }) %}
                            <article>
                                <div>
                                    <strong>{{ email_type_labels[email_log.type]|default(email_log.type) }}</strong>
                                    <span class="admin-status {{ email_status.class }}">{{ email_status.label }}</span>
                                </div>
                                <small>{{ email_log.recipientName ? email_log.recipientName ~ ' - ' : '' }}{{ email_log.recipientEmail }}</small>
                                <small>{{ email_log.queuedAt|date('d/m/Y H:i') }} - {{ email_log.transportLabel }}</small>
                                {% if email_log.subject %}<span>{{ email_log.subject }}</span>{% endif %}
                                {% if email_log.error %}<span class="is-danger">{{ email_log.error }}</span>{% endif %}
                            </article>
                        {% else %}
                            <p class="admin-empty-text">Aucun email suivi pour cette commande.</p>
                        {% endfor %}
                    </div>
                </section>

                {% if invoice_feature_enabled and cart.isCheckoutPayed and invoice %}
                    <section class="admin-detail-panel">
                        <div class="admin-detail-panel-heading">
                            <p>Facturation</p>
                            <h3>Avoir</h3>
                        </div>
                        {% if invoice.credit and credit_summary %}
                            <p class="admin-help-text">Un avoir est associé à cette commande.</p>
                            <dl class="admin-detail-list">
                                <div><dt>Type</dt><dd>{{ credit_summary.mode == 'full' ? 'Avoir total' : 'Avoir partiel' }}</dd></div>
                                <div><dt>Total avoir</dt><dd>{{ credit_summary.totals.total_ttc|default(0)|price_format }} €</dd></div>
                            </dl>
                            <a class="admin-button" href="{{ path('admin_order_credit_pdf', { id: cart.id }) }}" target="_blank">Télécharger l'avoir</a>
                        {% else %}
                            <p class="admin-help-text">La création d'avoir sera reprise dans le nouveau design après validation de cette page.</p>
                        {% endif %}
                    </section>
                {% endif %}
            </aside>
        </div>

        {% if effective_payment_method and effective_payment_method.paymentOnline %}
            <section class="admin-detail-panel admin-payment-webhook-panel">
                <div class="admin-detail-panel-heading">
                    <p>Paiement</p>
                    <h3>Suivi complet des retours de paiement</h3>
                </div>

                {% if payment_trace_available %}
                    <div class="admin-payment-webhook-grid">
                        <dl class="admin-detail-list">
                            <div><dt>Prestataire</dt><dd>{{ effective_payment_method.method|trans }}</dd></div>
                            <div><dt>Statut commande</dt><dd>{{ checkout_status_label }}</dd></div>
                            <div><dt>Dernier traitement</dt><dd>{{ cart_checkout.updatedAt|date('d/m/Y H:i:s') }}</dd></div>
                            {% if payment_event_type %}
                                <div><dt>Evenement</dt><dd>{{ payment_event_type }}</dd></div>
                            {% endif %}
                            {% if payment_event_id %}
                                <div><dt>Event ID</dt><dd>{{ payment_event_id }}</dd></div>
                            {% endif %}
                            {% if payment_external_id %}
                                <div><dt>ID paiement</dt><dd>{{ payment_external_id }}</dd></div>
                            {% endif %}
                        </dl>

                        <details class="admin-payload-details admin-payload-details-wide">
                            <summary>Payload complet</summary>
                            <pre>{{ payment_response|json_encode(constant('JSON_PRETTY_PRINT')) }}</pre>
                        </details>
                    </div>
                {% else %}
                    <p class="admin-empty-text">Aucun retour serveur ou webhook n'a encore ete enregistre pour ce paiement online.</p>
                {% endif %}
            </section>
        {% endif %}
    </section>
{% endblock %}
