<?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\CancellationIntervals;
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');
    $defaultLogoUrl = \plugin_dir_url(__DIR__ . '/../../../../../') . 'modules/inpsyde/worldline-payment-gateway/assets/images/worldline-logo.svg';
    $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], '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], 'logo' => ['title' => \__('Generic logo displayed on your payment page', 'worldline-for-woocommerce') . ' <span class="woocommerce-help-tip" data-tip="' . \esc_attr__('You can upload here a new logo (file types accepted for logos are: .png .gif .jpg only). We recommend that you use images with 20px height & 120px length maximum', 'worldline-for-woocommerce') . '"></span>', 'type' => 'content', 'description' => '
                    <div class="wlop-logo-wrapper">
                        <div class="wlop-logo-preview-container">
                            <img class="wlop-logo-preview" data-default-url="' . \esc_url($defaultLogoUrl) . '" src="" alt="Worldline Logo" style="height: 40px; max-width: 120px; aspect-ratio: auto; margin-bottom: 10px;">
                        </div>
                        <div class="wlop-logo-controls">
                            <button type="button" class="button button-secondary wlop-logo-upload-button">
                                ' . \__('Upload', 'worldline-for-woocommerce') . '
                            </button>
                            <button type="button" class="button button-secondary wlop-logo-delete">
                                ' . \__('Delete', 'worldline-for-woocommerce') . '
                            </button>
                        </div>
                    </div>
                '], 'logo_url' => ['title' => '', 'type' => 'hidden', 'description' => '']];
    $surchargeFields = ['surcharge_title' => ['title' => \__('Surcharge Settings (For merchants in Australia)', '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], 'fixed_soft_descriptor' => ['title' => \__('Fixed soft descriptor', 'worldline-for-woocommerce'), 'type' => 'text', 'description' => \__("Minimum 2, maximum 15 characters. You can specify a fixed value that will be sent to the banks handling the payment. \nIf the consumer's bank supports it, this value may appear on the bank statement. \nImportant: this field must be filled in to use the Sofinco payment method.", 'worldline-for-woocommerce'), 'desc_tip' => \true, 'custom_attributes' => ['maxlength' => 15, 'minlength' => 2]], 'automatic_cancellation_hours' => ['title' => \__('Automatic cancellation', 'worldline-for-woocommerce'), 'type' => 'select', 'default' => CancellationIntervals::DISABLED, 'options' => [CancellationIntervals::DISABLED => \__('Disabled', 'worldline-for-woocommerce'), CancellationIntervals::ONE_HOUR => \__('In 1 hour', 'worldline-for-woocommerce'), CancellationIntervals::THREE_HOURS => \__('In 3 hours', 'worldline-for-woocommerce'), CancellationIntervals::SIX_HOURS => \__('In 6 hours', 'worldline-for-woocommerce'), CancellationIntervals::TWELVE_HOURS => \__('In 12 hours', 'worldline-for-woocommerce'), CancellationIntervals::EIGHTEEN_HOURS => \__('In 18 hours', 'worldline-for-woocommerce'), CancellationIntervals::ONE_DAY => \__('In 24 hours', 'worldline-for-woocommerce'), CancellationIntervals::TWO_DAYS => \__('In 2 days', 'worldline-for-woocommerce'), CancellationIntervals::THREE_DAYS => \__('In 3 days', 'worldline-for-woocommerce')], 'description' => \__('Set up automatic cancellation of pending orders. The selected value defines after how many hours orders in Pending payment status will be cancelled. For example, if 3 hours is selected, all pending orders older than 3 hours will be automatically cancelled. This depends on the website activity since it relies on the WordPress cron.', '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::NO_CHALLENGE_REQUESTED,
        'options' => [ExemptionType::NO_CHALLENGE_REQUESTED => \__('Preference: No challenge request', 'worldline-for-woocommerce'), ExemptionType::LOW_VALUE => \__('Exemption: Low-Value', 'worldline-for-woocommerce'), ExemptionType::TRA => \__('Exemption: Transaction-Risk-Analysis (acquirer)', 'worldline-for-woocommerce')],
        /*
         * translators: %1$s - newlines
         */
        'description' => \sprintf(\__('The No-Challenge Preference requests the card issuer (and the customer\'s card) not to apply Strong Customer Authentication (SCA). The issuer will approve or deny this request, and the transaction will proceed accordingly.
%1$s
The Low-Value exemption applies to transactions below the defined threshold (30 EUR), allowing these low-value payments to bypass SCA and speed up checkout.
%1$s
The Transaction Risk Analysis (TRA) exemption enables a dynamic risk assessment; the issuer and your acquirer will evaluate risk factors, allowing transactions up to 100 EUR to qualify for exemption if deemed low risk. Note that TRA typically requires a formal agreement with your acquirer; enable TRA only after such an agreement is in place. Otherwise, all card transactions may be blocked.
%1$s
Choose carefully to balance user experience and security.', 'worldline-for-woocommerce'), '<br/></br>'),
        'desc_tip' => \true,
    ], '3ds_exemption_tra_warning' => ['type' => 'content', 'render_directly' => \true, 'description' => '<div class="wlop-warning-field wlop-tra-warning">' . \__('Please ensure that Transaction Risk Analysis (TRA) is enabled with your acquirer before enabling this option. If not, all card transactions may be blocked.', 'worldline-for-woocommerce') . '</div>'], '3ds_exemption_limit' => [
        'title' => \__('Exemption limit', 'worldline-for-woocommerce'),
        'type' => 'number',
        'default' => 100,
        'custom_attributes' => ['min' => 0, 'max' => 100],
        /*
         * 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], 'sdd_signature_type' => ['title' => \__('SDD signature type', 'worldline-for-woocommerce'), 'type' => 'select', 'default' => 'SMS', 'options' => ['SMS' => 'SMS', 'UNSIGNED' => 'UNSIGNED'], 'description' => \__('Define how you want the SEPA mandate to be signed. SMS will send a message to the phone number your customer has provided, and UNSIGNED will proceed with the payment without signature.', 'worldline-for-woocommerce'), 'desc_tip' => \true], 'instant_payment' => ['title' => \__('Accept instant payment only for Bank Transfers', 'worldline-for-woocommerce'), 'type' => 'checkbox', 'label' => \__('Enable', 'worldline-for-woocommerce'), 'default' => 'yes', 'description' => \__('By enabling this option, you will only accept bank transfers from your customers where the payment is done instantly.', '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);
});
