{% extends '@SyliusShop/layout.html.twig' %}
{% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
{% block content %}
<div class="ui hidden divider"></div>
<div class="thankyou-ctn">
<div class="center aligned sixteen wide column">
{% set lastPayment = order.payments.last() %}
<h1 class="ui icon header">
<i class="circular rocket icon"></i>
<div class="content waitingPayment" id="sylius-thank-you" {{ sylius_test_html_attribute('thank-you') }}>
{{ 'sylius.ui.wait'|trans }}
</div>
<div class="content successPayment" id="sylius-thank-you" {{ sylius_test_html_attribute('thank-you') }}>
{{ 'sylius.ui.thank_you'|trans }}
<div class="sub header">{{ 'sylius.ui.placed_an_order'|trans }}</div>
</div>
</h1>
{{ sylius_template_event('sylius.shop.order.thank_you.after_message', {'order': order}) }}
{% if lastPayment != false and lastPayment.method.code == 'HIPAY_CARD' and lastPayment.state != 'completed' %}
<div id="sylius-payment-steps" data-url="{{ path('app_order_payment_status', {'id': lastPayment.id}) }}" class="ui segment" {{ sylius_test_html_attribute('payment-method-instructions') }} >
{% if lastPayment.state != 'completed' %}
<div class="lds-roller-ctn">
<div class="lds-roller"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
</div>
<span id="payment-processing">{{ 'app.hipay.payment_pending'|trans }}</span>
{% else %}
<span id="payment-processing" style="color: #2A439B;">{{ 'app.hipay.payment_success' | trans }}</span>
{% endif %}
</div>
{% endif %}
{% if lastPayment != false %}
{% if lastPayment.method.instructions is not null %}
<div id="sylius-payment-method-instructions" class="ui segment errorPayment" {{ sylius_test_html_attribute('payment-method-instructions') }}>
{{ 'sylius.ui.payment_error'|trans }}
<br/><br/><br/>
<a href="{{ path('sylius_shop_order_again', {'tokenValue': order.tokenValue}) }}" id="sylius-show-order-in-account" class="ui large blue button" {{ sylius_test_html_attribute('show-order-in-account') }}>
{{ 'app.front.commande.again'|trans }}
</a>
</div>
<div id="sylius-payment-method-instructions" class="ui segment successPayment" {{ sylius_test_html_attribute('payment-method-instructions') }}>
{#% if lastPayment.method.id == 4 or lastPayment.method.id == 3 %#}
{# {{ 'app.front.commande.num'|trans }} : {{ order.number }} #}
{# <br/> #}
Total: {% set price = money.convertAndFormat(order.total) %}
{{ price }}
{#% endif %#}
<br/><br/>
{{ lastPayment.method.instructions|nl2br }}
<br/>
</div>
{% endif %}
<div class="ui hidden divider"></div>
{% endif %}
{# {{ form_start(form, {'action': path('sylius_shop_order_show', {'tokenValue': order.tokenValue}), 'attr': {'class': 'ui loadable form', 'novalidate': 'novalidate'}}) }}
{{ form_widget(form) }}
{{ form_row(form.orderComment) }}
{{ form_end(form, {'render_rest': false}) }} #}
{# {{ dump(form.vars) }} #}
{% if form.vars.submitted == false %}
<div class="form_app_site_comment_order successPayment">
{{ form_start(form, {'action': path('app_shop_order_thank_you', {'token_value': order.tokenValue}), 'attr': {'class': 'ui loadable form', 'novalidate': 'novalidate'}}) }}
{{ form_widget(form) }}
{# {{ form_row(form._token) }} #}
<div class="ctn-liens">
<button type="submit" class="lien-bleu" id="sylius-pay-link" {{ sylius_test_html_attribute('pay-link') }}>
<i class="check icon"></i> {{ 'app.front.global.valider'|trans }}
</button>
</div>
{{ form_end(form, {'render_rest': false}) }}
</div>
{% endif %}
<div class="ui hidden divider"></div>
{% if order.customer.user is not null %}
{# <a href="{{ path('sylius_shop_account_order_show', {'number': order.number}) }}" id="sylius-show-order-in-account" class="ui large blue button" {{ sylius_test_html_attribute('show-order-in-account') }}>{{ 'sylius.ui.view_order'|trans }}</a> #}
<a href="/account/orders/" id="sylius-show-order-in-account" class="ui large blue button" {{ sylius_test_html_attribute('show-order-in-account') }}>
{{ 'app.front.commande.all'|trans }}
</a>{% else %}
{% if lastPayment.state != 'completed' %}
<a href="{{ path('sylius_shop_order_show', {'tokenValue': order.tokenValue}) }}" id="payment-method-page" class="ui large blue button" {{ sylius_test_html_attribute('payment-method-page') }}>{{ 'sylius.ui.change_payment_method'|trans }}</a>
{% endif %}
<a href="{{ path('sylius_shop_register_after_checkout', {'tokenValue': order.tokenValue}) }}" class="ui large green button" {{ sylius_test_html_attribute('create-an-account') }}>
<i class="signup icon"></i>
{{ 'sylius.ui.create_an_account'|trans }}
</a>
{% endif %}
</div>
</div>
{# {{ dump(order) }} #}
<script type="text/javascript">
$(document).ready(function() {
$('.errorPayment').hide();
$('.waitingPayment').hide();
$('.successPayment').hide();
let paymentStatus = "{{ lastPayment.state }}";
const paymentMethod = "{{ lastPayment.method.code }}";
if(paymentStatus != 'completed' && paymentMethod == 'HIPAY_CARD') {
$('.waitingPayment').show();
let url = $('#sylius-payment-steps').data('url');
let interval = setInterval(function() {
$.ajax({
url: url,
type: 'GET',
success: function(data) {
paymentStatus = data.success;
if(paymentStatus == 'completed') {
$('.successPayment').show();
$('.errorPayment').hide();
$('.waitingPayment').hide();
clearInterval(interval);
$('#payment-processing').html("{{ 'app.hipay.payment_success' | trans }}");
$('#payment-processing').css('color', '#2A439B');
$('.lds-roller-ctn').hide();
}
else if(paymentStatus != 'processing' && paymentStatus != 'authorized') {
$('.errorPayment').show();
clearInterval(interval);
$('#payment-processing').html("{{ 'app.hipay.payment_error' | trans }}");
$('#payment-processing').css('color', '#FF6254');
$('.lds-roller-ctn').hide();
}
}
});
}, 1000);
}
else {
$('.successPayment').show();
}
// Google Tag Manager
if (typeof dataLayer === 'undefined') {
dataLayer = [];
}
dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object.
dataLayer.push({
event: "purchase",
ecommerce: {
transaction_id: {{ order.number }},
value: {{ order.total/100|replace({'€': '',',': '.'}) }},
tax: 20.00,
currency: "EUR",
items: [
{% for item in order.items %}
{
item_id: {{ item.variant.id }},
item_name: "{{ item.variant.name }}",
index: {{ loop.index0 }},
item_brand: "PPMC",
price: {{ item.unitPrice/100|replace({'€': '',',': '.'}) }},
quantity: {{ item.quantity }}
},
{% endfor %}
]
}
});
});
</script>
{% endblock %}