<?php

namespace Elementor_Pay_Addons\Shared;

use Elementor\Controls_Manager;
use Elementor_Pay_Addons\Stripe\Stripe_Settings;
use Elementor_Pay_Addons\Shared\Utils;
class Controls {
    /**
     * @param array      $array
     * @param int|string $position
     * @param mixed      $insert
     */
    static function array_insert( &$array, $position, $insert ) {
        if ( is_int( $position ) ) {
            array_splice(
                $array,
                $position,
                0,
                $insert
            );
        } else {
            $pos = array_search( $position, array_keys( $array ) );
            $array = array_merge( array_slice( $array, 0, $pos ), $insert, array_slice( $array, $pos ) );
        }
    }

    public static function get_session_checkout_setting_fields( $prefix = '' ) {
        $isPremium = epa_fs()->can_use_premium_code();
        $default_currency = Stripe_Settings::get_setting( 'default_currency' );
        $setting_controls = [
            [$prefix . 'premium', [
                'label'   => esc_html__( 'premium', 'pay-addons-for-elementor' ),
                'type'    => \Elementor\Controls_Manager::HIDDEN,
                'default' => $isPremium,
            ]],
            [$prefix . 'payment_method_types', [
                'label'              => esc_html__( 'Payment Methods', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT2,
                'multiple'           => true,
                'options'            => Utils::get_supported_payment_methods( $default_currency ),
                'default'            => ['card'],
                'frontend_available' => true,
            ]],
            [$prefix . 'mode', [
                'label'              => esc_html__( 'Mode', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'default'            => 'payment',
                'options'            => [
                    'payment'      => esc_html__( 'one-time', 'pay-addons-for-elementor' ),
                    'subscription' => esc_html__( 'subscription', 'pay-addons-for-elementor' ),
                ],
                'frontend_available' => true,
            ]],
            [$prefix . 'submit_type', [
                'label'              => esc_html__( 'Button type', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'default'            => 'auto',
                'options'            => [
                    'auto'   => esc_html__( 'auto', 'pay-addons-for-elementor' ),
                    'pay'    => esc_html__( 'pay', 'pay-addons-for-elementor' ),
                    'book'   => esc_html__( 'book', 'pay-addons-for-elementor' ),
                    'donate' => esc_html__( 'donate', 'pay-addons-for-elementor' ),
                ],
                'condition'          => [
                    $prefix . 'mode' => 'payment',
                ],
                'frontend_available' => true,
            ]],
            [$prefix . 'success_url', [
                'label'              => esc_html__( 'Success redirect url', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'options'            => Utils::get_pages_options(),
                'default'            => Stripe_Settings::get_setting( 'success_url' ),
                'label_block'        => true,
                'frontend_available' => true,
            ]],
            [$prefix . 'cancel_url', [
                'label'              => esc_html__( 'Cancel redirect url', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'options'            => Utils::get_pages_options(),
                'default'            => Stripe_Settings::get_setting( 'cancel_url' ),
                'label_block'        => true,
                'frontend_available' => true,
            ]],
            [$prefix . 'billing_address_collection', [
                'label'              => esc_html__( 'Billing address required', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SWITCHER,
                'return_value'       => 'yes',
                'default'            => 'yes',
                'frontend_available' => true,
            ]],
            [$prefix . 'allow_promotion_codes', [
                'label'              => esc_html__( 'Enable promotion', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SWITCHER,
                'return_value'       => 'yes',
                'default'            => 'yes',
                'frontend_available' => true,
            ]],
            [$prefix . 'automatic_tax', [
                'label'              => esc_html__( 'Enable automatic taxes', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SWITCHER,
                'return_value'       => 'yes',
                'default'            => 'yes',
                'frontend_available' => true,
            ]],
            [$prefix . 'tax_behavior', [
                'label'              => esc_html__( 'Tax Behaviors', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'default'            => 'exclusive',
                'description'        => esc_html__( 'Only be used when automatic tax enabled. This determines whether or not tax is already included in your pricing. For example, an inclusive line item with an amount of $10 totals to $10, whereas an exclusive line item with an amount of $10 totals to $10 + tax', 'pay-addons-for-elementor' ),
                'options'            => [
                    'exclusive' => esc_html__( 'exclusive', 'pay-addons-for-elementor' ),
                    'inclusive' => esc_html__( 'inclusive', 'pay-addons-for-elementor' ),
                ],
                'condition'          => [
                    $prefix . 'automatic_tax' => 'yes',
                ],
                'frontend_available' => true,
            ]],
            [$prefix . 'phone_number_collection', [
                'label'              => esc_html__( 'Phone number required', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SWITCHER,
                'return_value'       => 'yes',
                'frontend_available' => true,
            ]],
            [$prefix . 'terms_of_service', [
                'label'              => esc_html__( 'Enable terms of service', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SWITCHER,
                'return_value'       => 'yes',
                'frontend_available' => true,
            ]],
            [$prefix . 'shipping_address_collection', [
                'label'              => esc_html__( 'Shipping address countries', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT2,
                'multiple'           => true,
                'options'            => Countries::get_countries(),
                'default'            => ['US'],
                'frontend_available' => true,
            ]]
        ];
        return $setting_controls;
    }

    public static function get_session_checkout_line_item( $prefix = '' ) {
        $default_currency = Stripe_Settings::get_setting( 'default_currency' );
        return [
            ['enable_pricing_plan', [
                'label'        => esc_html__( 'Use stripe price', 'pay-addons-for-elementor' ),
                'type'         => \Elementor\Controls_Manager::SWITCHER,
                'description'  => __( 'Need to create the product and its price in Stripe dashboard.<a href="https://dashboard.stripe.com/products" target="_blank">Create price</a>', 'pay-addons-for-elementor' ),
                'return_value' => 'yes',
                'default'      => 'no',
                'condition'    => [
                    'premium' => true,
                ],
            ]],
            ['price', [
                'label'              => esc_html__( 'Price', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT2,
                'dynamic'            => [
                    'active' => true,
                ],
                'condition'          => [
                    'enable_pricing_plan' => 'yes',
                ],
                'label_block'        => true,
                'options'            => [
                    '' => __( 'Select a price...', 'pay-addons-for-elementor' ),
                ],
                'select2options'     => [
                    'ajax'               => [
                        'url'      => admin_url( 'admin-ajax.php' ),
                        'dataType' => 'json',
                        'delay'    => 250,
                        'data'     => [
                            'action' => 'epa_search_stripe_prices',
                            'nonce'  => wp_create_nonce( 'epa_search_stripe_prices_nonce' ),
                        ],
                        'cache'    => true,
                    ],
                    'minimumInputLength' => 0,
                    'placeholder'        => __( 'Select a price...', 'pay-addons-for-elementor' ),
                ],
                'frontend_available' => true,
            ]],
            ['quantity', [
                'label'              => esc_html__( 'Quantity', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::NUMBER,
                'min'                => 1,
                'default'            => 1,
                'dynamic'            => [
                    'active' => true,
                ],
                'frontend_available' => true,
            ]],
            ['show_quantity', [
                'label'              => esc_html__( 'Show Quantity Input', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SWITCHER,
                'description'        => __( 'Allow customers to enter a quantity in Stripe checkout page', 'pay-addons-for-elementor' ),
                'default'            => '',
                'label_on'           => esc_html__( 'Yes', 'pay-addons-for-elementor' ),
                'label_off'          => esc_html__( 'No', 'pay-addons-for-elementor' ),
                'frontend_available' => true,
            ]],
            ['min_quantity', [
                'label'              => esc_html__( 'Minimum Quantity', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::NUMBER,
                'default'            => 1,
                'min'                => 1,
                'condition'          => [
                    'show_quantity' => 'yes',
                ],
                'frontend_available' => true,
            ]],
            ['max_quantity', [
                'label'              => esc_html__( 'Maximum Quantity', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::NUMBER,
                'default'            => 100,
                'min'                => 1,
                'max'                => 999999,
                'condition'          => [
                    'show_quantity' => 'yes',
                ],
                'frontend_available' => true,
            ]],
            ['price_data.currency', [
                'label'              => esc_html__( 'Currency', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'default'            => $default_currency,
                'options'            => Utils::get_currencies_options(),
                'frontend_available' => true,
                'condition'          => [
                    'enable_pricing_plan!' => 'yes',
                ],
            ]],
            ['price_data.unit_amount', [
                'label'              => esc_html__( 'Amount', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::NUMBER,
                'min'                => 1,
                'default'            => '1.00',
                'dynamic'            => [
                    'active' => true,
                ],
                'frontend_available' => true,
                'condition'          => [
                    'enable_pricing_plan!' => 'yes',
                ],
            ]],
            ['enable_recurring', [
                'label'        => esc_html__( 'Recurring', 'pay-addons-for-elementor' ),
                'type'         => \Elementor\Controls_Manager::SWITCHER,
                'description'  => esc_html__( 'set Mode as subscription in General Settings is required.', 'pay-addons-for-elementor' ),
                'return_value' => 'yes',
                'default'      => 'false',
                'condition'    => [
                    'mode'                 => 'subscription',
                    'enable_pricing_plan!' => 'yes',
                ],
            ]],
            ['price_data.recurring.interval_count', [
                'label'              => esc_html__( 'Number of intervals', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::NUMBER,
                'default'            => 1,
                'condition'          => [
                    'enable_pricing_plan!' => 'yes',
                    'enable_recurring'     => 'yes',
                    'mode'                 => 'subscription',
                ],
                'frontend_available' => true,
            ]],
            ['price_data.recurring.interval', [
                'label'              => esc_html__( 'Recurring frequency', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'default'            => 'month',
                'options'            => [
                    'day'   => esc_html__( 'day', 'pay-addons-for-elementor' ),
                    'week'  => esc_html__( 'week', 'pay-addons-for-elementor' ),
                    'month' => esc_html__( 'month', 'pay-addons-for-elementor' ),
                    'year'  => esc_html__( 'year', 'pay-addons-for-elementor' ),
                ],
                'condition'          => [
                    'enable_pricing_plan!' => 'yes',
                    'enable_recurring'     => 'yes',
                    'mode'                 => 'subscription',
                ],
                'frontend_available' => true,
            ]],
            ['price_data.product_data.name', [
                'label'              => esc_html__( 'Product Name', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::TEXT,
                'default'            => esc_html__( 'your product name', 'pay-addons-for-elementor' ),
                'dynamic'            => [
                    'active' => true,
                ],
                'label_block'        => true,
                'frontend_available' => true,
                'condition'          => [
                    'enable_pricing_plan!' => 'yes',
                ],
            ]],
            ['price_data.product_data.description', [
                'label'              => esc_html__( 'Product Description', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::TEXTAREA,
                'dynamic'            => [
                    'active' => true,
                ],
                'frontend_available' => true,
                'condition'          => [
                    'enable_pricing_plan!' => 'yes',
                ],
            ]],
            ['price_data.product_data.images', [
                'label'              => esc_html__( 'Add Product Images(max 8)', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::GALLERY,
                'default'            => [],
                'frontend_available' => true,
                'condition'          => [
                    'enable_pricing_plan!' => 'yes',
                ],
            ]]
        ];
    }

    public static function get_session_checkout_metadata( $prefix = '' ) {
        $repeater = new \Elementor\Repeater();
        $repeater->add_control( 'metadata_key', [
            'label'              => esc_html__( 'Key', 'pay-addons-for-elementor' ),
            'description'        => esc_html__( '40 characters max', 'pay-addons-for-elementor' ),
            'type'               => \Elementor\Controls_Manager::TEXT,
            'frontend_available' => true,
        ] );
        $repeater->add_control( 'metadata_value', [
            'label'              => esc_html__( 'Value', 'pay-addons-for-elementor' ),
            'description'        => esc_html__( '500 characters max', 'pay-addons-for-elementor' ),
            'type'               => \Elementor\Controls_Manager::TEXT,
            'frontend_available' => true,
        ] );
        return [$prefix . 'metadata', [
            'label'              => esc_html__( 'Metadata', 'pay-addons-for-elementor' ),
            'description'        => esc_html__( 'Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.', 'pay-addons-for-elementor' ),
            'type'               => \Elementor\Controls_Manager::REPEATER,
            'fields'             => $repeater->get_controls(),
            'default'            => [],
            'title_field'        => '{{{ metadata_key }}} : {{{ metadata_value }}}',
            'frontend_available' => true,
        ]];
    }

    public static function add_premium_warning_control( $widget ) {
        $widget->add_control( 'epa_premium_wanring', [
            'type'            => Controls_Manager::RAW_HTML,
            'raw'             => sprintf( __( 'This feature is available in the premium version. <a href="%s" rel="noopener noreferrer" target="_blank">Upgrade</a>', 'pay-addons-for-elementor' ), esc_url( epa_fs()->get_upgrade_url() ) ),
            'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
        ] );
    }

    public static function general_controls( $prefix, $without_name = false ) {
        $return = [
            [$prefix . 'email_field', [
                'label'       => esc_html__( 'Customer email field', 'pay-addons-for-elementor' ),
                'type'        => \Elementor\Controls_Manager::TEXT,
                'default'     => '[field id="email"]',
                'placeholder' => __( 'user@example or [field id="email"]', 'pay-addons-for-elementor' ),
                'render_type' => 'none',
            ]],
            [$prefix . 'fullname_field', [
                'label'       => esc_html__( 'Customer name field', 'pay-addons-for-elementor' ),
                'type'        => \Elementor\Controls_Manager::TEXT,
                'default'     => '[field id="name"]',
                'placeholder' => __( 'Cullen Patrick or [field id="name"]', 'pay-addons-for-elementor' ),
                'render_type' => 'none',
            ]],
            [$prefix . 'redirect_url', [
                'label'              => esc_html__( 'Redirect url', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'options'            => Utils::get_pages_options(),
                'default'            => '',
                'description'        => __( 'Redirect customers to this page after payment completion (no redirection if current page). Consider using our confirmation element or receipt shortcode <strong>[epa_receipt]</strong> to create a customized confirmation page.', 'pay-addons-for-elementor' ),
                'frontend_available' => true,
            ]],
            [$prefix . 'redirect_url_custom', [
                'label'              => esc_html__( 'Custom redirect URL', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::TEXT,
                'placeholder'        => 'https://example.com/thank-you/?param=value',
                'description'        => __( 'Enter a custom URL to redirect to after payment. You can include custom query parameters; Stripe will append its own payment parameters automatically.', 'pay-addons-for-elementor' ),
                'label_block'        => true,
                'render_type'        => 'none',
                'condition'          => [
                    $prefix . 'redirect_url' => 'custom',
                ],
                'frontend_available' => true,
            ]],
            [$prefix . 'payment_type', [
                'label'              => esc_html__( 'Payment Type', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'description'        => __( 'One-time, Subscription, or Flex (decided by end-user)' ),
                'label_block'        => false,
                'default'            => 'onetime',
                'options'            => [
                    'onetime'      => esc_html__( 'One-Time', 'pay-addons-for-elementor' ),
                    'subscription' => esc_html__( 'Subscription', 'pay-addons-for-elementor' ),
                    'flex'         => esc_html__( 'Flex', 'pay-addons-for-elementor' ),
                ],
                'frontend_available' => true,
            ]],
            [$prefix . 'payment_type_condition_field', [
                'label'              => esc_html__( 'If subscription field', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::TEXT,
                'placeholder'        => '[field id="enable_recurring"]',
                'description'        => __( 'This field is decide to use subscrition or not.', 'pay-addons-for-elementor' ),
                'condition'          => [
                    $prefix . 'payment_type' => 'flex',
                ],
                'frontend_available' => true,
            ]],
            [$prefix . 'payment_type_condition_operation', [
                'label'              => esc_html__( 'operation', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'default'            => 'nonempty',
                'options'            => [
                    'checked'    => esc_html__( 'Checked', 'pay-addons-for-elementor' ),
                    'equalto'    => esc_html__( 'Equal to', 'pay-addons-for-elementor' ),
                    'empty'      => esc_html__( 'Empty', 'pay-addons-for-elementor' ),
                    'notchecked' => esc_html__( 'Not Checked', 'pay-addons-for-elementor' ),
                    'notempty'   => esc_html__( 'Not Empty', 'pay-addons-for-elementor' ),
                    'notequalto' => esc_html__( 'Not Equal to', 'pay-addons-for-elementor' ),
                ],
                'condition'          => [
                    $prefix . 'payment_type' => 'flex',
                ],
                'frontend_available' => true,
            ]],
            [$prefix . 'payment_type_condition_value', [
                'label'              => esc_html__( 'value', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::TEXT,
                'render_type'        => 'none',
                'condition'          => [
                    $prefix . 'payment_type'                     => 'flex',
                    $prefix . 'payment_type_condition_operation' => ['equalto', 'notequalto'],
                ],
                'frontend_available' => true,
            ]]
        ];
        return array_filter( $return, function ( $v ) use($without_name, $prefix) {
            return ( $without_name ? $v[0] != $prefix . 'fullname_field' : true );
        }, ARRAY_FILTER_USE_BOTH );
    }

    public static function general_controls_end( $prefix ) {
        return [
            [$prefix . 'hr', [
                'type' => \Elementor\Controls_Manager::DIVIDER,
            ]],
            [$prefix . 'reuse_customer', [
                'label'        => esc_html__( 'Reuse existing customers', 'pay-addons-for-elementor' ),
                'type'         => \Elementor\Controls_Manager::SWITCHER,
                'default'      => 'no',
                'return_value' => 'yes',
                'render_type'  => 'none',
                'description'  => __( 'Search for existing customers by <strong>email</strong> before creating new ones. If disabled, creates a new customer for each transaction.', 'pay-addons-for-elementor' ),
            ]],
            [$prefix . 'save_metadata', [
                'label'        => esc_html__( 'Save as metadata', 'pay-addons-for-elementor' ),
                'type'         => \Elementor\Controls_Manager::SWITCHER,
                'default'      => 'yes',
                'return_value' => 'yes',
                'render_type'  => 'none',
                'description'  => __( 'Store form data directly within Stripe metadata, with a limit of up to 50 fields. (key: 40 characters max, value: 500 characters max)', 'pay-addons-for-elementor' ),
            ]],
            [$prefix . 'automatic_tax', [
                'label'              => esc_html__( 'Enable automatic taxes', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SWITCHER,
                'return_value'       => 'yes',
                'default'            => 'no',
                'description'        => __( 'Automatically calculate taxes based on the customer address. Requires Stripe Tax to be enabled in your Stripe account and an <strong>Address field</strong> in the form.', 'pay-addons-for-elementor' ),
                'render_type'        => 'none',
                'frontend_available' => true,
            ]],
            [$prefix . 'tax_behavior', [
                'label'              => esc_html__( 'Tax Behavior', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'default'            => 'exclusive',
                'description'        => esc_html__( 'Exclusive: tax is added on top of the price. Inclusive: tax is already included in the price.', 'pay-addons-for-elementor' ),
                'options'            => [
                    'exclusive' => esc_html__( 'Exclusive', 'pay-addons-for-elementor' ),
                    'inclusive' => esc_html__( 'Inclusive', 'pay-addons-for-elementor' ),
                ],
                'condition'          => [
                    $prefix . 'automatic_tax' => 'yes',
                ],
                'render_type'        => 'none',
                'frontend_available' => true,
            ]],
            [$prefix . 'tax_code', [
                'label'              => esc_html__( 'Product Tax Code', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::TEXT,
                'default'            => '',
                'placeholder'        => 'txcd_99999999',
                'description'        => __( 'Optional. Stripe product tax code to classify this item (e.g. <code>txcd_99999999</code> for General Services). If left blank, Stripe uses the default tax code from your <a href="https://dashboard.stripe.com/settings/tax" target="_blank">Stripe Tax Settings</a>.', 'pay-addons-for-elementor' ),
                'condition'          => [
                    $prefix . 'automatic_tax' => 'yes',
                ],
                'render_type'        => 'none',
                'frontend_available' => true,
            ]]
        ];
    }

    public static function onetime_controls( $prefix, $without_product = false ) {
        $default_currency = Stripe_Settings::get_setting( 'default_currency' );
        $return = [
            [$prefix . 'onetime_currency', [
                'label'              => esc_html__( 'Currency', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SELECT,
                'default'            => $default_currency,
                'options'            => Utils::get_currencies_options(),
                'frontend_available' => true,
            ]],
            [$prefix . 'onetime_amount_field', [
                'label'              => esc_html__( 'Amount field', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::TEXT,
                'default'            => '19.9',
                'placeholder'        => __( '19.9 or [field id="amount"]', 'pay-addons-for-elementor' ),
                'render_type'        => 'none',
                'dynamic'            => [
                    'active' => true,
                ],
                'frontend_available' => true,
            ]],
            [$prefix . 'onetime_quantity_field', [
                'label'              => esc_html__( 'Quantity field', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::TEXT,
                'default'            => '1',
                'placeholder'        => __( '1 or [field id="quantity"]', 'pay-addons-for-elementor' ),
                'render_type'        => 'none',
                'dynamic'            => [
                    'active' => true,
                ],
                'frontend_available' => true,
            ]],
            [$prefix . 'onetime_product_name_field', [
                'label'       => esc_html__( 'Product name field', 'pay-addons-for-elementor' ),
                'type'        => \Elementor\Controls_Manager::TEXT,
                'default'     => 'Basic plan',
                'placeholder' => __( 'Basic plan or [field id="product-name"]', 'pay-addons-for-elementor' ),
                'render_type' => 'none',
                'dynamic'     => [
                    'active' => true,
                ],
            ]],
            [$prefix . 'onetime_product_desc_field', [
                'label'       => esc_html__( 'Product description field', 'pay-addons-for-elementor' ),
                'type'        => \Elementor\Controls_Manager::TEXTAREA,
                'default'     => esc_html__( 'Your plan description here...', 'pay-addons-for-elementor' ),
                'placeholder' => __( 'any description or [field id="product-desc"]', 'pay-addons-for-elementor' ),
                'label_block' => true,
                'render_type' => 'none',
                'dynamic'     => [
                    'active' => true,
                ],
            ]],
            [$prefix . 'onetime_save_card', [
                'label'              => esc_html__( 'Save card details', 'pay-addons-for-elementor' ),
                'type'               => \Elementor\Controls_Manager::SWITCHER,
                'default'            => 'no',
                'return_value'       => 'yes',
                'render_type'        => 'none',
                'frontend_available' => true,
                'description'        => __( 'If you want to charge customer when they’re offline, recommend to add terms to your website or app that state how you plan to save payment method details and allow customers to opt in', 'pay-addons-for-elementor' ),
            ]],
            [$prefix . 'manual_capture', [
                'label'        => esc_html__( 'Manual capture', 'pay-addons-for-elementor' ),
                'type'         => \Elementor\Controls_Manager::SWITCHER,
                'default'      => 'no',
                'return_value' => 'yes',
                'render_type'  => 'none',
                'description'  => __( 'If enabled, you must manually capture the payment in Stripe Dashboard. This is useful for offline payments or when you need to review the payment before capturing it.', 'pay-addons-for-elementor' ),
            ]]
        ];
        return $return;
    }

}
