<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <record id="payment_provider_form" model="ir.ui.view">
        <field name="name">Clover Provider Form</field>
        <field name="model">payment.provider</field>
        <field name="inherit_id" ref="payment.payment_provider_form"/>
        <field name="arch" type="xml">
            <group name="provider_credentials" position="inside">
                <group invisible="code != 'clover'" name="clover_credentials">
                    <separator string="Merchant"/>
                    <field name="clover_merchant_id"
                           required="code == 'clover' and state != 'disabled'"
                           placeholder="e.g. 22701620015"/>
                    <separator string="Ecommerce API Tokens"/>
                    <field name="clover_api_key"
                           required="code == 'clover' and state != 'disabled'"
                           password="True"
                           placeholder="Private token from Ecommerce API Tokens page"/>
                    <field name="clover_public_key"
                           placeholder="Public token from Ecommerce API Tokens page"/>
                    <separator string="REST API / Terminal"/>
                    <field name="clover_rest_api_token"
                           password="True"
                           placeholder="From Clover Dashboard: Setup > API Tokens"/>
                    <separator string="OAuth (Optional)"/>
                    <field name="clover_app_id"
                           placeholder="App ID (for OAuth flow)"/>
                    <label for="clover_app_secret"/>
                    <div class="o_row" col="2">
                        <field name="clover_app_secret" password="True"/>
                    </div>
                </group>
            </group>
            <group name="provider_credentials" position="after">
                <group string="Clover Actions"
                       invisible="code != 'clover'" name="clover_actions"
                       col="4">
                    <button string="Test Connection"
                            type="object"
                            name="action_clover_test_connection"
                            class="btn-primary"
                            invisible="not clover_merchant_id or (not clover_api_key and not clover_rest_api_token)"
                            colspan="2"/>
                </group>
                <group string="Terminal Settings"
                       invisible="code != 'clover'" name="clover_terminal_settings">
                    <field name="clover_default_terminal_id"/>
                </group>
            </group>
        </field>
    </record>

</odoo>
