HEX
Server: LiteSpeed
System: Linux ip-172-31-16-207.ap-south-1.compute.internal 4.18.0-553.89.1.el8_10.x86_64 #1 SMP Mon Dec 8 03:53:08 EST 2025 x86_64
User: borda9888 (5005)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /home/bordallopinheiro.in/public_html/wp-content/plugins/woo-razorpay/includes/utils.php
<?php
/**
 * controls visibility of 1cc buttons
 * checks test mode, metrics collection config
 * NOTE: we add additional check to see if the config field exists as it may cause issues
 * during plugin updates
 */

/**
 * payment plugins are loaded even if they are disabled which triggers the 1cc button flow
 * we need to check if the plugin is disabled
 */
function isRazorpayPluginEnabled()
{
    return (
        empty(get_option('woocommerce_razorpay_settings')['enabled']) === false
        && 'yes' == get_option('woocommerce_razorpay_settings')['enabled']
    );
}

function isTestModeEnabled()
{
    return (
        empty(get_option('woocommerce_razorpay_settings')['enable_1cc_test_mode']) === false
        && 'yes' == get_option('woocommerce_razorpay_settings')['enable_1cc_test_mode']
    );
}

function is1ccEnabled()
{
    return (
        empty(get_option('woocommerce_razorpay_settings')['enable_1cc']) === false
        && 'yes' == get_option('woocommerce_razorpay_settings')['enable_1cc']
    );
}

function isProductSupported()
{

}

function isCartSupported()
{

}

function isDebugModeEnabled()
{
    return (
        empty(get_option('woocommerce_razorpay_settings')['enable_1cc_debug_mode']) === false
        && 'yes' == get_option('woocommerce_razorpay_settings')['enable_1cc_debug_mode']
    );
}

function isPdpCheckoutEnabled()
{
    return (
        empty(get_option('woocommerce_razorpay_settings')['enable_1cc_pdp_checkout']) === false
        && 'yes' == get_option('woocommerce_razorpay_settings')['enable_1cc_pdp_checkout']
    );
}

function isMiniCartCheckoutEnabled()
{
    return (
        empty(get_option('woocommerce_razorpay_settings')['enable_1cc_mini_cart_checkout']) === false
        && 'yes' == get_option('woocommerce_razorpay_settings')['enable_1cc_mini_cart_checkout']
    );
}

function isMandatoryAccCreationEnabled()
{
    return (
        empty(get_option('woocommerce_razorpay_settings')['1cc_account_creation']) === false
        && 'yes' == get_option('woocommerce_razorpay_settings')['1cc_account_creation']
    );
}
function validateInput($route, $param)
{
    $failure_reason = null;

    switch ($route) {
        case 'list':
            if (empty(sanitize_text_field($param['amount'])) === true) {
                $failure_reason = 'Field amount is required.';
            }
            break;

        case 'apply':
            if (empty(sanitize_text_field($param['code'])) === true) {
                $failure_reason = 'Field code is required.';

            } elseif (empty(sanitize_text_field($param['order_id'])) === true) {

                $failure_reason = 'Field order id is required.';

            }
            break;

        case 'shipping':
            if (empty(sanitize_text_field($param['order_id'])) === true) {
                $failure_reason = 'Field order id is required.';

            } elseif (empty($param['addresses']) === true) {

                $failure_reason = 'Field addresses is required.';

            }
            break;

        default:

            break;
    }

    return $failure_reason;
}