<?xml version="1.0"?>
<t name="Payment Manage" t-name="payment.manage">
        <!-- Variables description:
            - 'providers' - The payment providers supporting tokenization
            - 'tokens' - The set of payment tokens of the current partner
            - 'default_token_id' - The id of the token that should be pre-selected. Optional
            - 'reference_prefix' - The custom prefix to compute the full transaction reference
            - 'partner_id' - The id of the partner managing the tokens
            - 'access_token' - The access token used to authenticate the partner.
            - 'transaction_route' - The route used to create a validation transaction
            - 'assign_token_route' - The route to call to assign a token to a record. If set, it
                                     enables the token assignation mechanisms: creation of a new
                                     token through a refunded transaction and assignation of an
                                     existing token
            - 'landing_route' - The route the user is redirected to at then end of the flow
            - 'footer_template_id' - The template id for the submit button. Optional
        -->
        <form name="o_payment_manage" class="o_payment_form mt-3 clearfix" t-att-data-reference-prefix="reference_prefix" t-att-data-partner-id="partner_id" t-att-data-access-token="access_token" t-att-data-transaction-route="transaction_route" t-att-data-assign-token-route="assign_token_route" t-att-data-landing-route="landing_route" t-att-data-allow-token-selection="bool(assign_token_route)">
            <t t-set="provider_count" t-value="len(providers) if providers else 0"/>
            <t t-set="token_count" t-value="len(tokens) if tokens else 0"/>
            <t t-set="no_selectable_token" t-value="token_count == 0 or not assign_token_route"/>
            <t t-set="default_payment_option_id" t-value="default_token_id if default_token_id and token_count &gt; 0                         else providers[0].id if provider_count == 1 and no_selectable_token                         else None"/>
            <t t-set="footer_template_id" t-value="footer_template_id or 'payment.footer'"/>
            <div class="card">
                <!-- === Providers === -->
                <t t-foreach="providers" t-as="provider">
                    <div name="o_payment_option_card" class="card-body o_payment_option_card">
                        <label>
                            <!-- === Radio button === -->
                            <!-- Only shown if linked to the only payment option -->
                            <input name="o_payment_radio" type="radio" t-att-checked="provider.id == default_payment_option_id" t-att-class="'' if provider_count + token_count &gt; 1 else 'd-none'" t-att-data-payment-option-id="provider.id" t-att-data-provider="provider.code" data-payment-option-type="provider"/>
                            <!-- === Provider name === -->
                            <span class="payment_option_name">
                                <b t-esc="provider.display_as or provider.name"/>
                            </span>
                            <!-- === "Test Mode" badge === -->
                            <span t-if="provider.state == 'test'" class="badge rounded-pill text-bg-warning" style="margin-left:5px">
                                Test Mode
                            </span>
                            <!-- === "Unpublished" badge === -->
                            <span t-if="not provider.is_published" class="badge rounded-pill text-bg-danger">
                                Unpublished
                            </span>
                        </label>
                        <!-- === Payment icon list === -->
                        <t t-call="payment.icon_list"/>
                        <!-- === Help message === -->
                        <div t-if="not is_html_empty(provider.pre_msg)" t-out="provider.pre_msg" class="text-muted ms-3"/>
                    </div>
                    <!-- === Provider inline form === -->
                    <t t-if="provider.sudo()._should_build_inline_form(is_validation=True)">
                        <div t-attf-id="o_payment_provider_inline_form_{{provider.id}}" name="o_payment_inline_form" class="card-footer d-none">
                            <t t-set="inline_form_xml_id" t-value="provider.sudo().inline_form_view_id.xml_id"/>
                            <!-- === Inline form content (filled by provider) === -->
                            <div t-if="inline_form_xml_id" class="clearfix">
                                <t t-call="{{inline_form_xml_id}}">
                                    <t t-set="provider_id" t-value="provider.id"/>
                                </t>
                            </div>
                        </div>
                    </t>
                </t>
                <!-- === Tokens === -->
                <t t-foreach="tokens" t-as="token">
                    <div name="o_payment_option_card" class="card-body o_payment_option_card">
                        <label>
                            <!-- === Radio button === -->
                            <!-- Only shown if 'assign_token_route' is set -->
                            <input name="o_payment_radio" type="radio" t-att-checked="token.id == default_payment_option_id" t-att-class="'' if bool(assign_token_route) else 'd-none'" t-att-data-payment-option-id="token.id" t-att-data-provider="token.provider_code" data-payment-option-type="token"/>
                            <!-- === Token name === -->
                            <span class="payment_option_name" t-esc="token.display_name"/>
                            <!-- === "V" check mark === -->
                            <t t-call="payment.verified_token_checkmark"/>
                            <!-- === "Unpublished" badge === -->
                            <span t-if="not token.provider_id.is_published and token.env.user._is_internal()" class="badge rounded-pill text-bg-danger ms-1">
                                Unpublished
                            </span>
                        </label>
                        <!-- === "Delete" token button === -->
                        <button name="o_payment_delete_token" class="btn btn-primary btn-sm float-end">
                            <i class="fa fa-trash"/> Delete
                        </button>
                    </div>
                    <!-- === Token inline form === -->
                    <div t-attf-id="o_payment_token_inline_form_{{token.id}}" name="o_payment_inline_form" class="card-footer d-none">
                        <t t-set="token_inline_form_xml_id" t-value="token.sudo().provider_id.token_inline_form_view_id.xml_id"/>
                        <!-- === Inline form content (filled by provider) === -->
                        <div t-if="token_inline_form_xml_id" class="clearfix">
                            <t t-call="{{token_inline_form_xml_id}}">
                                <t t-set="token" t-value="token"/>
                            </t>
                        </div>
                    </div>
                </t>
            </div>
            <!-- === "Save Payment Method" button === -->
            <t t-call="{{footer_template_id}}">
                <t t-set="label">Save Payment Method</t>
                <t t-set="icon_class" t-value="'fa-plus-circle'"/>
            </t>
        </form>
    </t>

    