<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="payment">
            <group id="leanpay" translate="label" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Leanpay</label>
                <field id="active" translate="label comment" sortOrder="1" type="select" showInDefault="1"
                       showInWebsite="1" showInStore="0">
                    <label>Enable</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="title" translate="label comment" sortOrder="1" type="text" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Title</label>
                </field>

                <field id="instructions" translate="label comment" sortOrder="1" type="textarea" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Instructions</label>
                </field>

                <field id="api_endpoint_type"
                       translate="label"
                       sortOrder="1"
                       type="select"
                       showInDefault="1"
                       showInWebsite="1"
                       showInStore="1"
                       canRestore="1">
                    <label>API Endpoint Type</label>
                    <source_model>Leanpay\Payment\Model\Config\Source\ApiEndpointType</source_model>
                </field>

                <field id="ron_only_mode"
                       translate="label comment"
                       sortOrder="1"
                       type="select"
                       showInDefault="1"
                       showInWebsite="1"
                       showInStore="1"
                       canRestore="1">
                    <label>RON-Only Mode</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment>When enabled, the module operates entirely in RON without requiring EUR as an allowed currency or maintaining a RON to EUR currency rate. Applies only to the Romanian (RON) plugin.</comment>
                    <depends>
                        <field id="api_endpoint_type">RON</field>
                    </depends>
                </field>

                <field id="currency"
                       translate="label comment"
                       sortOrder="1"
                       type="select"
                       showInDefault="1"
                       showInWebsite="1"
                       showInStore="1"
                       canRestore="0">
                    <label>Base Currency rate</label>
                    <frontend_model>Leanpay\Payment\Block\Adminhtml\Form\Field\Currency</frontend_model>
                    <tooltip>
                        <![CDATA[
                            You can add currency rate at <b>General -> Currency Setup -> Allowed Currencies</b>
                            <br>You can change currency rate at <b>STORES -> Currency Rates</b>
                        ]]>
                    </tooltip>
                </field>

                <field id="checkout_url" translate="label comment" sortOrder="1" type="text" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Checkout URL to redirect after failure</label>
                    <comment>
                        <![CDATA[
                            Default: "checkout/index/index"
                            Can be in form of Magento path, or full URL
                        ]]>
                    </comment>
                </field>

                <field id="mode" translate="label comment" sortOrder="1" type="select" showInDefault="1"
                       showInWebsite="1" showInStore="0">
                    <label>Environment Mode</label>
                    <source_model>Leanpay\Payment\Model\Config\Source\Modes</source_model>
                </field>

                <field id="api_key"
                       translate="label comment"
                       sortOrder="10"
                       type="obscure"
                       showInDefault="1"
                       showInWebsite="1"
                       showInStore="1">
                    <label>API Key</label>
                    <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
                </field>

                <field id="api_secret"
                       translate="label comment"
                       sortOrder="20"
                       type="obscure"
                       showInDefault="1"
                       showInWebsite="1"
                       showInStore="1">
                    <label>API Secret Word</label>
                    <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
                </field>

                <field id="installment_cron" translate="label comment" sortOrder="110" type="text" showInDefault="1"
                       showInWebsite="1" showInStore="0">
                    <label>Installment Cron</label>
                    <comment>Please follow cron schema * * * * *</comment>
                </field>

                <field id="allowspecific" translate="label" type="allowspecific" sortOrder="30" showInDefault="1"
                       showInWebsite="1" showInStore="0" canRestore="1">
                    <label>Payment from Applicable Countries</label>
                    <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
                </field>

                <field id="specificcountry" translate="label" type="multiselect" sortOrder="40" showInDefault="1"
                       showInWebsite="1" showInStore="0">
                    <label>Payment from Specific Countries</label>
                    <source_model>Magento\Directory\Model\Config\Source\Country</source_model>
                </field>

                <field id="billing_allowspecific" translate="label" type="allowspecific" sortOrder="50"
                       showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
                    <label>Payment from Applicable Billing Countries</label>
                    <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
                </field>

                <field id="billing_specificcountry" translate="label" type="multiselect" sortOrder="60"
                       showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Payment from Specific Billing Countries</label>
                    <source_model>Magento\Directory\Model\Config\Source\Country</source_model>
                </field>

                <field id="min_order_total" translate="label" type="text" sortOrder="70" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Minimum Order Total</label>
                </field>

                <field id="max_order_total" translate="label" type="text" sortOrder="80" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Maximum Order Total</label>
                </field>
                <field id="installment_allowed_views" translate="label" type="multiselect" sortOrder="90"
                       showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
                    <label>Show installment price in following pages</label>
                    <source_model>Leanpay\Payment\Model\Config\Source\ViewBlockConfig</source_model>
                </field>
                <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1"
                       showInWebsite="1">
                    <label>Sort Order</label>
                    <frontend_class>validate-number</frontend_class>
                </field>
            </group>
            <group id="leanpay_installment" translate="label" sortOrder="2" showInDefault="1" showInWebsite="1"
                   showInStore="1">
                <label>Leanpay Installment price</label>
                <field id="color_theme" translate="label" type="select" sortOrder="10" showInDefault="1"
                       showInWebsite="1" showInStore="1" canRestore="1">
                    <label>Color Theme</label>
                    <source_model>Leanpay\Payment\Model\Config\Source\ColorTheme</source_model>
                </field>
                <field id="use_leanpay_font" translate="label comment" type="select" sortOrder="20"
                       showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
                    <label>Use Leanpay Font</label>
                    <comment>Use Leanpay font (Roboto) or inherit the store font.</comment>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
                <field id="more_info" translate="label comment" sortOrder="40" type="text" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>More information</label>
                </field>
                <field id="check_your_limit" translate="label comment" sortOrder="40" type="text" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Check your limit</label>
                </field>
                <field id="group" translate="label comment" sortOrder="50" type="select" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Group</label>
                    <source_model>Leanpay\Payment\Model\Config\Source\GroupOptions</source_model>
                </field>
                <field id="enable_product_rounding" translate="label comment" sortOrder="60" type="select" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Enable Product Rounding</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment>When enabled, product prices will be rounded up to the nearest value divisible by 5 before retrieving installment estimates. This applies only to Romanian (RON) plugin.</comment>
                </field>
                <field id="refresh" translate="label" type="button" sortOrder="100" showInDefault="1" showInWebsite="1"
                       showInStore="1">
                    <label>Refresh</label>
                    <frontend_model>Leanpay\Payment\Block\System\Config\RefreshButton</frontend_model>
                </field>
                <group id="advanced" translate="label comment" sortOrder="200" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Advanced</label>
                    <comment>These settings are for advanced customization. Change only if you know what you're doing.</comment>
                    <fieldset_css>advanced</fieldset_css>
                    <field id="amount_threshold" translate="label comment" sortOrder="10" type="text" showInDefault="1"
                           showInWebsite="1" showInStore="1">
                        <label>Amount Threshold</label>
                        <comment>Amount threshold at which the dynamic behavior changes. For amounts up to and including this value, the default installment count will be used. For amounts above this value, the maximum available installments will be selected. Default: 300</comment>
                        <frontend_class>validate-number</frontend_class>
                    </field>
                    <field id="default_installment_count" translate="label comment" sortOrder="20" type="text" showInDefault="1"
                           showInWebsite="1" showInStore="1">
                        <label>Default Installment Count (≤ Threshold)</label>
                        <comment>Default number of installments for amounts up to and including the threshold. Default: 3</comment>
                        <frontend_class>validate-number</frontend_class>
                    </field>
                    <field id="under_threshold_text" translate="label comment" sortOrder="30" type="text" showInDefault="1"
                           showInWebsite="1" showInStore="1">
                        <label>Under Threshold Text</label>
                        <comment>Text to display when amount is below threshold. Use %1 as placeholder for amount. Example: "%1 EUR"</comment>
                    </field>
                    <field id="quick_information" translate="label comment" sortOrder="60" type="textarea" showInDefault="1"
                           showInWebsite="1" showInStore="1">
                        <label>Installment Quick Information</label>
                        <comment>Shown inside the installment tooltip on PDP.</comment>
                    </field>
                </group>
            </group>
        </section>

        <section id="leanpay_promos"  translate="label" type="text" sortOrder="301" showInDefault="1" showInWebsite="1" showInStore="1">
            <class>separator-top</class>
            <label>Leanpay Promos</label>
            <tab>sales</tab>
            <resource>Leanpay_Payment::config</resource>
            <group id="mfp" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Multiple Financing Products</label>

                <field id="product_name" translate="label" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
                    <label>Financing Product Name</label>
                    <source_model>Leanpay\Payment\Model\Config\Source\VendorProductCode</source_model>
                </field>

                <!-- Date picker field code start-->
                <field id="start_date" translate="label" type="date" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Start Date For Financing Product Value</label>
                    <frontend_model>Leanpay\Payment\Block\Adminhtml\Form\Field\DatePicker</frontend_model>
                </field>

                <field id="end_date" translate="label" type="date" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>End Date For Financing Product Value</label>
                    <frontend_model>Leanpay\Payment\Block\Adminhtml\Form\Field\DatePicker</frontend_model>
                </field>

                <field id="cart_size" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1"
                       showInStore="1">
                    <label>Cart-size Financing Product Value</label>
                </field>
            </group>

            <group id="aropd" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>Automatic Removal Of Promotion Data</label>
                <field id="module_enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Enabled</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="cron_frequency" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Frequency</label>
                    <source_model>Leanpay\Payment\Model\Config\Source\PromotionDataRemovalOptions</source_model>
                    <frontend_model>Leanpay\Payment\Block\System\Config\ReadOnlySelect</frontend_model>
                    <depends>
                        <field id="module_enabled">1</field>
                    </depends>
                </field>

                <field id="cron_start_time" translate="label" type="time" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Start Time</label>
                    <backend_model>Leanpay\Payment\Model\Config\Backend\Cron</backend_model>
                    <depends>
                        <field id="module_enabled">1</field>
                    </depends>
                </field>

            </group>
        </section>
    </system>
</config>
