<?php

declare (strict_types=1);
namespace Syde\Vendor\Worldline;

// phpcs:disable Inpsyde.CodeQuality.LineLength.TooLong
use Syde\Vendor\Worldline\Dhii\Services\Factory;
use Syde\Vendor\Worldline\Inpsyde\WorldlineForWoocommerce\Config\CaptureMode;
use Syde\Vendor\Worldline\Inpsyde\WorldlineForWoocommerce\WorldlinePaymentGateway\ThreeDSecure\ExemptionType;
return new Factory(['webhooks.settings.fields', 'worldline_payment_gateway.api.default_test_endpoint', 'worldline_payment_gateway.api.default_live_endpoint', 'core.live_create_account_url', 'uninstall.db-cleaner-url'], static function (array $webhookFields, string $defaultTestEndpoint, string $defaultLiveEndpoint, string $liveCreateAccountUrl, string $dbCleanerUrl) : array {
    $config = (require __DIR__ . '/../../../../config.php');
    $apiFields = ['pspid' => ['title' => \__('PSPID', 'worldline-for-woocommerce'), 'type' => 'text', 'description' => \__('Enter your Merchant ID or your Worldline Login Name.', 'worldline-for-woocommerce'), 'desc_tip' => \true], 'live_mode' => ['title' => \__('Live mode', 'worldline-for-woocommerce'), 'type' => 'checkbox', 'label' => \__('Use the live environment', 'worldline-for-woocommerce'), 'default' => 'no'], 'live_account_note' => ['type' => 'content', 'description' => \sprintf(
        // translators: %1$s, %2$s - <a> link tags.
        \__('For creating a live account, please %1$scontact the sales team%2$s.', 'worldline-for-woocommerce'),
        '<a id="wlopLiveAccountNote" target="_blank" href="' . \esc_url($liveCreateAccountUrl) . '">',
        '</a>'
    )], 'test_api_key' => ['title' => \__('Test API Key', 'worldline-for-woocommerce'), 'type' => 'text', 'description' => \__('Find/create the API Key in Developer tab > Payment API on your Worldline Merchant Portal Dashboard (Test).', 'worldline-for-woocommerce'), 'desc_tip' => \true, 'custom_attributes' => ['autocomplete' => 'off']], 'test_api_secret' => ['title' => \__('Test API Secret', 'worldline-for-woocommerce'), 'type' => 'password', 'description' => \__('Find/create the API Secret in the Developer tab > Payment API on your Worldline Merchant Portal Dashboard (Test).', 'worldline-for-woocommerce'), 'desc_tip' => \true, 'custom_attributes' => ['autocomplete' => 'off']], 'test_api_endpoint' => ['title' => \__('Test API Endpoint', 'worldline-for-woocommerce'), 'type' => 'text', 'default' => $defaultTestEndpoint, 'description' => \__('Enter Endpoint URL configured on your test account.', 'worldline-for-woocommerce'), 'desc_tip' => \true], 'live_api_key' => ['title' => \__('Live API Key', 'worldline-for-woocommerce'), 'type' => 'text', 'description' => \__('Find/create the API Key in Developer tab > Payment API on your Worldline Merchant Portal Dashboard.', 'worldline-for-woocommerce'), 'desc_tip' => \true, 'custom_attributes' => ['autocomplete' => 'off']], 'live_api_secret' => ['title' => \__('Live API Secret', 'worldline-for-woocommerce'), 'type' => 'password', 'description' => \__('Find/create the API Secret in Developer tab > Payment API on your Worldline Merchant Portal Dashboard.', 'worldline-for-woocommerce'), 'desc_tip' => \true, 'custom_attributes' => ['autocomplete' => 'off']], 'live_api_endpoint' => ['title' => \__('Live API Endpoint', 'worldline-for-woocommerce'), 'type' => 'text', 'default' => $defaultLiveEndpoint, 'description' => \__('Enter Endpoint URL configured on your live account.', 'worldline-for-woocommerce'), 'desc_tip' => \true]];
    $otherFields = ['debug_logging' => ['title' => \__('Advanced logging', 'worldline-for-woocommerce'), 'type' => 'checkbox', 'label' => \__('Enable debug logging', 'worldline-for-woocommerce'), 'default' => 'no', 'desc_tip' => \true, 'description' => \__('Write more details into the logs, such as HTTP requests.', 'worldline-for-woocommerce')]];
    $checkoutFields = ['checkout_behavior_title' => ['title' => \__('Checkout appearance', 'worldline-for-woocommerce'), 'type' => 'title'], 'primary_gateway_title' => ['title' => \__('Primary gateway title', 'worldline-for-woocommerce'), 'type' => 'text', 'description' => \__('Personalize the Worldline payment method title on checkout page.', 'worldline-for-woocommerce'), 'placeholder' => \__($config['GATEWAY_TITLE_DEFAULT'], 'worldline-for-woocommerce'), 'desc_tip' => \true], 'payment_button_title' => ['title' => \__('Payment button title', 'worldline-for-woocommerce'), 'type' => 'text', 'description' => \__('Personalize the Checkout Button text.', 'worldline-for-woocommerce'), 'desc_tip' => \true], 'checkout_type' => ['title' => \__('Checkout type', 'worldline-for-woocommerce'), 'type' => 'select', 'default' => 'hosted', 'options' => ['hosted' => \__('Full redirection to Worldline Payment Page', 'worldline-for-woocommerce')]], 'card_brands_display' => ['title' => \__('Grouped Cards', 'worldline-for-woocommerce'), 'label' => \__('Enable card grouping', 'worldline-for-woocommerce'), 'type' => 'checkbox', 'default' => 'no'], 'stored_card_buttons' => ['title' => \__('Show tokenized cards', 'worldline-for-woocommerce'), 'type' => 'checkbox', 'label' => \__('Enable', 'worldline-for-woocommerce'), 'description' => \__('When a customer has stored cards, additional "Pay with your stored card ..." buttons will be displayed in checkout.', 'worldline-for-woocommerce'), 'desc_tip' => \true, 'default' => 'yes'], 'hosted_checkout_page_template' => ['title' => \__('Hosted checkout page template', 'worldline-for-woocommerce'), 'type' => 'text', 'description' => \__('Leave it empty for the default template.', 'worldline-for-woocommerce'), 'desc_tip' => \true, 'default' => 'SimplifiedCustomPaymentPage'], 'hosted_tokenization_page_template' => ['title' => \__('Hosted tokenization page template', 'worldline-for-woocommerce'), 'type' => 'text', 'description' => \__('Leave it empty for the default template.', 'worldline-for-woocommerce'), 'desc_tip' => \true]];
    $surchargeFields = ['surcharge_title' => ['title' => \__('Surcharge settings', 'worldline-for-woocommerce'), 'type' => 'title'], 'surcharge_enable' => ['title' => \__('Surcharge', 'worldline-for-woocommerce'), 'type' => 'checkbox', 'label' => \__('Enable', 'worldline-for-woocommerce'), 'description' => \__('Instruct the payment platform to calculate and apply a surcharge amount to a transaction, based on the merchant’s surcharge configuration, net amount, and payment product type.', 'worldline-for-woocommerce') . '<br>' . \__('Please make sure that Surcharging is active on your Worldline account. If it is not configured properly, the payments will not be processed.', 'worldline-for-woocommerce')]];
    $advancedFields = ['advanced_title' => ['title' => \__('Advanced settings', 'worldline-for-woocommerce'), 'type' => 'title'], 'authorization_mode' => ['title' => \__('Authorization mode', 'worldline-for-woocommerce'), 'type' => 'select', 'default' => 'authorization', 'options' => ['authorization' => \__('Authorization', 'worldline-for-woocommerce'), 'sale' => \__('Sale', 'worldline-for-woocommerce')], 'description' => \__('Define whether you want to process payments in one step (money captured directly; SALE) or in two steps (authorization followed by a capture; AUTHORIZATION).', 'worldline-for-woocommerce'), 'desc_tip' => \true], 'credit_card_authorization_mode' => ['title' => \__('Authorization mode for credit cards', 'worldline-for-woocommerce'), 'type' => 'select', 'default' => 'final_authorization', 'options' => ['final_authorization' => \__('Final authorization', 'worldline-for-woocommerce'), 'pre_authorization' => \__('Pre-authorization', 'worldline-for-woocommerce')], 'description' => \__("Use authorization to block customer funds for a period of 7 days. These funds cannot be reversed and must be captured for the full amount. Use pre-authorization to block the funds of your customers for a period of 30 days. The amount captured can be lower than the authorized amount. Note that all acquirers and activity sectors do not support preauthorizations.", 'worldline-for-woocommerce'), 'desc_tip' => \true], 'capture_mode' => ['title' => \__('Capture mode', 'worldline-for-woocommerce'), 'type' => 'select', 'default' => 'manual', 'options' => [CaptureMode::MANUAL => \__('Manual', 'worldline-for-woocommerce'), CaptureMode::END_OF_DAY => \__('At the end of the day', 'worldline-for-woocommerce'), CaptureMode::AFTER_1D => \__('After 1 day', 'worldline-for-woocommerce'), CaptureMode::AFTER_2D => \__('After 2 days', 'worldline-for-woocommerce'), CaptureMode::AFTER_3D => \__('After 3 days', 'worldline-for-woocommerce'), CaptureMode::AFTER_4D => \__('After 4 days', 'worldline-for-woocommerce'), CaptureMode::AFTER_5D => \__('After 5 days', 'worldline-for-woocommerce'), CaptureMode::AFTER_6D => \__('After 6 days', 'worldline-for-woocommerce'), CaptureMode::AFTER_7D => \__('After 7 days', 'worldline-for-woocommerce')], 'description' => \__('Allows to automatically capture orders after the specified time, using the Woo Action Scheduler. Depending on the Action Scheduler/WP Cron setup, sometimes captures may be delayed if the site does not receive traffic during that period.', 'worldline-for-woocommerce'), 'desc_tip' => \true], 'enable_3ds' => ['title' => \__('3-D Secure authentication', 'worldline-for-woocommerce'), 'type' => 'checkbox', 'label' => \__('Enable', 'worldline-for-woocommerce'), 'default' => 'yes', 'description' => \__('Enforce 3DS for all transactions.', 'worldline-for-woocommerce'), 'desc_tip' => \true], 'enforce_3dsv2' => ['title' => \__('Enforce 3DS challenge', 'worldline-for-woocommerce'), 'type' => 'checkbox', 'label' => \__('Enable', 'worldline-for-woocommerce'), 'default' => 'no', 'description' => \__('Enforce strong customer authentication for all transactions.', 'worldline-for-woocommerce'), 'desc_tip' => \true], 'request_3ds_exemption' => [
        'title' => \__('Exempt transactions from 3DS', 'worldline-for-woocommerce'),
        'type' => 'checkbox',
        'label' => \__('Enable', 'worldline-for-woocommerce'),
        'default' => 'no',
        /*
         * translators: %1$s - newlines
         */
        'description' => \sprintf(\__('By enabling the 3DS Exemption, you allow the card issuer and your acquirer to evaluate the risk level of transactions up to the Exemption Limit you specify in EUR. If the criteria are met, your customers will be exempt from Strong Customer Authentication (SCA).
%1$s
If your acquirer rejects the exemption and requires SCA, this is referred to as a soft decline. In such cases, we will attempt to prompt the customer for SCA and reinitiate the transaction if the customer successfully authenticates.', 'worldline-for-woocommerce'), '<br/></br>'),
        'desc_tip' => \true,
    ], '3ds_exemption_warning' => ['type' => 'content', 'render_directly' => \true, 'description' => '<div class="wlop-warning-field">' . \__('Please be aware that if fraud occurs on a transaction that has been granted an exemption, the liability falls on the merchant!', 'worldline-for-woocommerce') . '</div>'], '3ds_exemption_type' => [
        'title' => \__('Exemption type', 'worldline-for-woocommerce'),
        'type' => 'select',
        'default' => ExemptionType::LOW_VALUE,
        'options' => [ExemptionType::LOW_VALUE => \__('Low-Value', 'worldline-for-woocommerce'), ExemptionType::TRA => \__('Transaction-Risk-Analysis', 'worldline-for-woocommerce')],
        /*
         * translators: %1$s - newlines
         */
        'description' => \sprintf(\__('The Low-Value exemption is suitable for transactions below the specified monetary threshold of 30 EUR, allowing these low-value transactions to bypass Strong Customer Authentication (SCA) and streamline the checkout process.
%1$s
On the other hand, the Transaction-Risk-Analysis exemption enables a dynamic risk assessment for your transactions. The card issuer will evaluate the transaction based on various risk factors, allowing transactions up to a limit of 100 EUR to qualify for exemption if they are deemed low risk.
%1$s
Make your selection carefully to optimize the balance between customer experience and security for your transactions.', 'worldline-for-woocommerce'), '<br/></br>'),
        'desc_tip' => \true,
    ], '3ds_exemption_limit' => [
        'title' => \__('Exemption limit', 'worldline-for-woocommerce'),
        'type' => 'number',
        'default' => 30,
        'custom_attributes' => ['min' => 0, 'max' => 30],
        /*
         * translators: %1$s - newlines
         */
        'description' => \sprintf(\__('The exemption limit is specified in EUR. Therefore, if the checkout currency is not in EUR, the conversion will depend on the exchange rate to EUR. It is essential to have EUR configured in your environment, and to ensure accurate conversions, please keep your exchange rates updated.
%1$s
If EUR is not configured, the 3DS exemption will not be applied, and the transaction will not have the exemption requested.
%1$s
Additional Note: PSD2 designates the EUR as the base currency for determining exemption limits for other currencies in the EEA. However, each region can decide to adapt these limits, and regions outside the EEA may also support exemption requests. Due to these complexities, we cannot guarantee that the exemption request will be considered by the issuer or your acquirer.', 'worldline-for-woocommerce'), '<br/></br>'),
        'desc_tip' => \true,
    ], 'send_shopping_cart' => ['title' => \__('Send shopping cart', 'worldline-for-woocommerce'), 'type' => 'checkbox', 'label' => \__('Enable cart data submission.', 'worldline-for-woocommerce'), 'default' => 'yes', 'description' => \__('When enabled, the shopping cart details will be included in the API request.', 'worldline-for-woocommerce'), 'desc_tip' => \true], 'clear_data_on_uninstall' => ['title' => \__('Clear data on uninstall', 'worldline-for-woocommerce'), 'type' => 'checkbox', 'label' => \sprintf(
        /* translators: %s is a link for "Clear now" */
        \__('Delete plugin data from the database upon uninstallation. %s', 'worldline-for-woocommerce'),
        \sprintf('<a href="%s">%s</a>', \esc_url($dbCleanerUrl), \__('(Click here to reset the data now)', 'worldline-for-woocommerce'))
    ), 'default' => 'no']];
    return \array_merge(['enabled' => ['title' => \__('Enable/Disable', 'worldline-for-woocommerce'), 'type' => 'checkbox', 'label' => \__('Enable Worldline Global Online Pay for WooCommerce', 'worldline-for-woocommerce'), 'default' => 'no']], $apiFields, $webhookFields, $otherFields, $checkoutFields, $surchargeFields, $advancedFields);
});
