{% set oHeidelPaySettings = oHeidelpayViewConfig.getSettings() %}
{% set oHeidelPayment = oHeidelPaySettings.getPayment(paymentmethod) %}
{% set sImageUrl = oViewConf.getModuleUrl('d3unzer', 'out/img/') %}

{% if empty(attribute(d3hpPaymentFormulars, sPaymentID)) %}
    {% set blD3HeidelpayAllowBtoBBillPurchase = false %}
{% endif %}

{% block heidelpay_btobbillpurchase %}
    <div class="well well-sm">
        <dl>
            <dt>
                <input type="radio"
                    {% if blD3HeidelpayAllowBtoBBillPurchase %}
                            id="payment_{{ sPaymentID }}"
                            name="paymentid"
                            value="{{ sPaymentID }}"
                            {% if oView.getCheckedPaymentId() == paymentmethod.oxpayments__oxid.value %}checked{% endif %}
                        {% else %}
                            disabled
                        {% endif %}
                >
                <label for="payment_{{ sPaymentID }}">
                    <b>{{ paymentmethod.oxpayments__oxdesc.value }}</b>
                    <img src="{{ sImageUrl }}unzer_invoice.png" alt="{{ paymentmethod.oxpayments__oxdesc.value }}" style="vertical-align: middle;">
                </label>
                {% if false == blD3HeidelpayAllowBtoBBillPurchase %}
                    <dfn class="d3HeidelayBToBBillpurchaseNotice alert alert-danger desc">{{ translate({ ident: "D3UNZER_PAYMENT_BTOBBILLPURCHASESECURED_NOTICE", args: iD3HeidelpayBtoBBillPurchaseLimits }) }}</dfn>
                {% endif %}
                {% if false == blD3HeidelpayHasSameAdresses %}
                    <dfn class="alert alert-danger d3HeidelaySameAddressNotice">{{ translate({ ident: "D3UNZER_PAYMENT_NOTSAMEADDRESS_NOTICE" }) }}</dfn>
                {% endif %}
            </dt>
            <dd class="payment-option {% if oView.getCheckedPaymentId() == paymentmethod.oxpayments__oxid.value %}activePayment{% endif %}">
                {% set oPaymentPrice = paymentmethod.getPrice() %}
                {% if oPaymentPrice.getPrice() %}
                    {% if oViewConf.isFunctionalityEnabled('blShowVATForPayCharge') %}
                        ({{ format_price(oPaymentPrice.getNettoPrice(), { currency: currency }) }}
                        {% if oPaymentPrice.getVatValue() > 0 %}
                            {{ translate({ ident: "PLUS_VAT" }) }} {{ format_price(oPaymentPrice.getVatValue(), { currency: currency }) }}
                        {% endif %})
                    {% else %}
                        ({{ format_price(oPaymentPrice.getBruttoPrice(), { currency: currency }) }})
                    {% endif %}
                {% endif %}
                {% if blD3HeidelpayAllowBtoBBillPurchase %}
                    {% for d3hpPaymentID, d3hpPaymentFormular in attribute(d3hpPaymentFormulars, sPaymentID) %}
                        {% include "@d3unzer/apex/forms/" ~ d3hpPaymentFormular.type ~ ".html.twig" with {d3hpPaymentFormular: d3hpPaymentFormular, d3HeidelpayB2BParameters: attribute(d3HeidelpayParameters, sPaymentID)} %}
                    {% endfor %}

                    <div class="row">
                        <div class="col-xs-12 col-lg-9 offset-lg-3">
                            <div class="alert alert-info">{{ translate({ ident: "COMPLETE_MARKED_FIELDS" }) }}</div>
                        </div>
                    </div>

                    {% set doNotShow %}
                        <script type="text/javascript">
                            {% set javaScript %}
                                function toggleD3HpB2Bpurchase() {
                                    var currentClass = $("input.d3heidelpayB2BPurchase:checked").val();
                                    $('.registered, .not_registered').hide();
                                    $('.'+currentClass).show();
                                }

                                toggleD3HpB2Bpurchase();
                                $('.d3heidelpayB2BPurchase').click(function(){
                                    toggleD3HpB2Bpurchase();
                                });
                            {% endset %}
                        </script>
                    {% endset %}
                    {{ script({ add: javaScript.__toString(), dynamic: __oxid_include_dynamic }) }}
                {% endif %}
                {% block checkout_payment_longdesc %}
                    {% if paymentmethod.oxpayments__oxlongdesc.value %}
                        <div class="row">
                            <div class="col-xs-12 col-lg-9 offset-lg-3">
                                <div class="alert alert-info desc">
                                    {{ paymentmethod.oxpayments__oxlongdesc.getRawValue() }}
                                </div>
                            </div>
                        </div>
                    {% endif %}
                {% endblock %}
            </dd>
        </dl>
    </div>
{% endblock %}
