Example #1
0
/**
 * Load Scripts
 *
 * Enqueues the required scripts.
 *
 * @since 1.0
 * @global $give_options
 * @global $post
 * @return void
 */
function give_load_scripts()
{
    global $give_options;
    $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/';
    $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
    $scripts_footer = give_get_option('scripts_footer') == 'on' ? true : false;
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    //Localize / PHP to AJAX vars
    $localize_give_checkout = apply_filters('give_global_script_vars', array('ajaxurl' => give_get_ajax_url(), 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), 'currency_sign' => give_currency_filter(''), 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', 'thousands_separator' => isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ',', 'decimal_separator' => isset($give_options['decimal_separator']) ? $give_options['decimal_separator'] : '.', 'no_gateway' => __('Please select a payment method', 'give'), 'general_loading' => __('Loading...', 'give'), 'purchase_loading' => __('Please Wait...', 'give'), 'give_version' => GIVE_VERSION));
    $localize_give_ajax = apply_filters('give_global_ajax_vars', array('ajaxurl' => give_get_ajax_url(), 'position_in_cart' => isset($position) ? $position : -1, 'loading' => __('Loading', 'give'), 'floatlabels' => give_get_option('enable_floatlabels') ? '1' : '0', 'select_option' => __('Please select an option', 'give'), 'default_gateway' => give_get_default_gateway(null), 'permalinks' => get_option('permalink_structure') ? '1' : '0', 'number_decimals' => apply_filters('give_format_amount_decimals', 2)));
    //DEBUG is On
    if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
        if (give_is_cc_verify_enabled()) {
            wp_register_script('give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array('jquery'), GIVE_VERSION, $scripts_footer);
            wp_enqueue_script('give-cc-validator');
        }
        if ($localize_give_ajax['floatlabels']) {
            wp_register_script('give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array('jquery'), GIVE_VERSION, $scripts_footer);
            wp_enqueue_script('give-float-labels');
        }
        wp_register_script('give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array('jquery'), GIVE_VERSION, $scripts_footer);
        wp_enqueue_script('give-blockui');
        wp_register_script('give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array('jquery'), GIVE_VERSION, $scripts_footer);
        wp_enqueue_script('give-qtip');
        wp_register_script('give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array('jquery'), GIVE_VERSION, $scripts_footer);
        wp_enqueue_script('give-accounting');
        wp_register_script('give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array('jquery'), GIVE_VERSION, $scripts_footer);
        wp_enqueue_script('give-magnific');
        wp_register_script('give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array('jquery'), GIVE_VERSION, $scripts_footer);
        wp_enqueue_script('give-checkout-global');
        //General scripts
        wp_register_script('give-scripts', $js_dir . 'give' . $suffix . '.js', array('jquery'), GIVE_VERSION, $scripts_footer);
        wp_enqueue_script('give-scripts');
        // Load AJAX scripts, if enabled
        wp_register_script('give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array('jquery'), GIVE_VERSION, $scripts_footer);
        wp_enqueue_script('give-ajax');
        //Localize / Pass AJAX vars from PHP
        wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_checkout);
        wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax);
    } else {
        //DEBUG is OFF (one JS file to rule them all!)
        wp_register_script('give', $js_dir . 'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer);
        wp_enqueue_script('give');
        //Localize / Pass AJAX vars from PHP
        wp_localize_script('give', 'give_global_vars', $localize_give_checkout);
        wp_localize_script('give', 'give_scripts', $localize_give_ajax);
    }
}
Example #2
0
/**
 * Payment Mode Select
 *
 * Renders the payment mode form by getting all the enabled payment gateways and
 * outputting them as radio buttons for the user to choose the payment gateway. If
 * a default payment gateway has been chosen from the Give Settings, it will be
 * automatically selected.
 *
 * @since 1.0
 *
 * @param int $form_id
 *
 * @return void
 */
function give_payment_mode_select($form_id)
{
    $gateways = give_get_enabled_payment_gateways();
    do_action('give_payment_mode_top');
    ?>

	<fieldset id="give-payment-mode-select">
		<?php 
    do_action('give_payment_mode_before_gateways_wrap');
    ?>
		<div id="give-payment-mode-wrap">
			<legend class="give-payment-mode-label"><?php 
    _e('Select Payment Method', 'give');
    ?>
</legend>
			<?php 
    do_action('give_payment_mode_before_gateways');
    ?>

			<ul id="give-gateway-radio-list">
				<?php 
    foreach ($gateways as $gateway_id => $gateway) {
        $checked = checked($gateway_id, give_get_default_gateway($form_id), false);
        $checked_class = $checked ? ' give-gateway-option-selected' : '';
        echo '<li><label for="give-gateway-' . esc_attr($gateway_id) . '-' . $form_id . '" class="give-gateway-option' . $checked_class . '" id="give-gateway-option-' . esc_attr($gateway_id) . '">';
        echo '<input type="radio" name="payment-mode" class="give-gateway" id="give-gateway-' . esc_attr($gateway_id) . '-' . $form_id . '" value="' . esc_attr($gateway_id) . '"' . $checked . '>' . esc_html($gateway['checkout_label']);
        echo '</label></li>';
    }
    ?>
			</ul>
			<?php 
    do_action('give_payment_mode_after_gateways');
    ?>
			<p class="give-loading-text"><span class="give-loading-animation"></span> <?php 
    _e('Loading', 'give');
    ?>
				<span class="elipsis">.</span><span class="elipsis">.</span><span class="elipsis">.</span></p>
		</div>
		<?php 
    do_action('give_payment_mode_after_gateways_wrap');
    ?>
	</fieldset>

	<div id="give_purchase_form_wrap">

		<?php 
    do_action('give_purchase_form', $form_id);
    ?>

	</div><!-- the checkout fields are loaded into this-->

	<?php 
    do_action('give_payment_mode_bottom');
}
Example #3
0
/**
 * Get system info
 *
 * @since       1.0
 * @access      public
 * @global      object $wpdb         Used to query the database using the WordPress Database API
 * @global      array  $give_options Array of all Give options
 * @return      string $return A string containing the info to output
 */
function give_tools_sysinfo_get()
{
    global $wpdb, $give_options;
    if (!class_exists('Browser')) {
        require_once GIVE_PLUGIN_DIR . 'includes/libraries/browser.php';
    }
    $browser = new Browser();
    // Get theme info
    if (get_bloginfo('version') < '3.4') {
        $theme_data = get_theme_data(get_stylesheet_directory() . '/style.css');
        $theme = $theme_data['Name'] . ' ' . $theme_data['Version'];
    } else {
        $theme_data = wp_get_theme();
        $theme = $theme_data->Name . ' ' . $theme_data->Version;
    }
    // Try to identify the hosting provider
    $host = give_get_host();
    $return = '### Begin System Info ###' . "\n\n";
    // Start with the basics...
    $return .= '-- Site Info' . "\n\n";
    $return .= 'Site URL:                 ' . site_url() . "\n";
    $return .= 'Home URL:                 ' . home_url() . "\n";
    $return .= 'Multisite:                ' . (is_multisite() ? 'Yes' : 'No') . "\n";
    $return = apply_filters('give_sysinfo_after_site_info', $return);
    // Can we determine the site's host?
    if ($host) {
        $return .= "\n" . '-- Hosting Provider' . "\n\n";
        $return .= 'Host:                     ' . $host . "\n";
        $return = apply_filters('give_sysinfo_after_host_info', $return);
    }
    // The local users' browser information, handled by the Browser class
    $return .= "\n" . '-- User Browser' . "\n\n";
    $return .= $browser;
    $return = apply_filters('give_sysinfo_after_user_browser', $return);
    // WordPress configuration
    $return .= "\n" . '-- WordPress Configuration' . "\n\n";
    $return .= 'Version:                  ' . get_bloginfo('version') . "\n";
    $return .= 'Language:                 ' . (defined('WPLANG') && WPLANG ? WPLANG : 'en_US') . "\n";
    $return .= 'Permalink Structure:      ' . (get_option('permalink_structure') ? get_option('permalink_structure') : 'Default') . "\n";
    $return .= 'Active Theme:             ' . $theme . "\n";
    $return .= 'Show On Front:            ' . get_option('show_on_front') . "\n";
    // Only show page specs if frontpage is set to 'page'
    if (get_option('show_on_front') == 'page') {
        $front_page_id = get_option('page_on_front');
        $blog_page_id = get_option('page_for_posts');
        $return .= 'Page On Front:            ' . ($front_page_id != 0 ? get_the_title($front_page_id) . ' (#' . $front_page_id . ')' : 'Unset') . "\n";
        $return .= 'Page For Posts:           ' . ($blog_page_id != 0 ? get_the_title($blog_page_id) . ' (#' . $blog_page_id . ')' : 'Unset') . "\n";
    }
    // Make sure wp_remote_post() is working
    $request['cmd'] = '_notify-validate';
    $params = array('sslverify' => false, 'timeout' => 60, 'user-agent' => 'Give/' . GIVE_VERSION, 'body' => $request);
    $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params);
    if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
        $WP_REMOTE_POST = 'wp_remote_post() works';
    } else {
        $WP_REMOTE_POST = 'wp_remote_post() does not work';
    }
    $return .= 'Remote Post:              ' . $WP_REMOTE_POST . "\n";
    $return .= 'Table Prefix:             ' . 'Length: ' . strlen($wpdb->prefix) . '   Status: ' . (strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable') . "\n";
    $return .= 'Admin AJAX:               ' . (give_test_ajax_works() ? 'Accessible' : 'Inaccessible') . "\n";
    $return .= 'WP_DEBUG:                 ' . (defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set') . "\n";
    $return .= 'Memory Limit:             ' . WP_MEMORY_LIMIT . "\n";
    $return .= 'Registered Post Stati:    ' . implode(', ', get_post_stati()) . "\n";
    $return = apply_filters('give_sysinfo_after_wordpress_config', $return);
    // GIVE configuration
    $return .= "\n" . '-- Give Configuration' . "\n\n";
    $return .= 'Version:                  ' . GIVE_VERSION . "\n";
    $return .= 'Upgraded From:            ' . get_option('give_version_upgraded_from', 'None') . "\n";
    $return .= 'Test Mode:                ' . (give_is_test_mode() ? "Enabled\n" : "Disabled\n");
    $return .= 'Currency Code:            ' . give_get_currency() . "\n";
    $return .= 'Currency Position:        ' . give_get_option('currency_position', 'before') . "\n";
    $return .= 'Decimal Separator:        ' . give_get_option('decimal_separator', '.') . "\n";
    $return .= 'Thousands Separator:      ' . give_get_option('thousands_separator', ',') . "\n";
    $return = apply_filters('give_sysinfo_after_give_config', $return);
    // GIVE pages
    $return .= "\n" . '-- Give Page Configuration' . "\n\n";
    $return .= 'Success Page:             ' . (!empty($give_options['success_page']) ? get_permalink($give_options['success_page']) . "\n" : "Unset\n");
    $return .= 'Failure Page:             ' . (!empty($give_options['failure_page']) ? get_permalink($give_options['failure_page']) . "\n" : "Unset\n");
    $return .= 'Give Forms Slug:           ' . (defined('GIVE_SLUG') ? '/' . GIVE_SLUG . "\n" : "/donations\n");
    $return = apply_filters('give_sysinfo_after_give_pages', $return);
    // GIVE gateways
    $return .= "\n" . '-- Give Gateway Configuration' . "\n\n";
    $active_gateways = give_get_enabled_payment_gateways();
    if ($active_gateways) {
        $default_gateway_is_active = give_is_gateway_active(give_get_default_gateway(null));
        if ($default_gateway_is_active) {
            $default_gateway = give_get_default_gateway(null);
            $default_gateway = $active_gateways[$default_gateway]['admin_label'];
        } else {
            $default_gateway = 'Test Payment';
        }
        $gateways = array();
        foreach ($active_gateways as $gateway) {
            $gateways[] = $gateway['admin_label'];
        }
        $return .= 'Enabled Gateways:         ' . implode(', ', $gateways) . "\n";
        $return .= 'Default Gateway:          ' . $default_gateway . "\n";
    } else {
        $return .= 'Enabled Gateways:         None' . "\n";
    }
    $return = apply_filters('give_sysinfo_after_give_gateways', $return);
    // GIVE Templates
    $dir = get_stylesheet_directory() . '/give_templates/*';
    if (is_dir($dir) && count(glob("{$dir}/*")) !== 0) {
        $return .= "\n" . '-- Give Template Overrides' . "\n\n";
        foreach (glob($dir) as $file) {
            $return .= 'Filename:                 ' . basename($file) . "\n";
        }
        $return = apply_filters('give_sysinfo_after_give_templates', $return);
    }
    // Must-use plugins
    $muplugins = get_mu_plugins();
    if (count($muplugins > 0)) {
        $return .= "\n" . '-- Must-Use Plugins' . "\n\n";
        foreach ($muplugins as $plugin => $plugin_data) {
            $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
        }
        $return = apply_filters('give_sysinfo_after_wordpress_mu_plugins', $return);
    }
    // WordPress active plugins
    $return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
    $plugins = get_plugins();
    $active_plugins = get_option('active_plugins', array());
    foreach ($plugins as $plugin_path => $plugin) {
        if (!in_array($plugin_path, $active_plugins)) {
            continue;
        }
        $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
    }
    $return = apply_filters('give_sysinfo_after_wordpress_plugins', $return);
    // WordPress inactive plugins
    $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
    foreach ($plugins as $plugin_path => $plugin) {
        if (in_array($plugin_path, $active_plugins)) {
            continue;
        }
        $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
    }
    $return = apply_filters('give_sysinfo_after_wordpress_plugins_inactive', $return);
    if (is_multisite()) {
        // WordPress Multisite active plugins
        $return .= "\n" . '-- Network Active Plugins' . "\n\n";
        $plugins = wp_get_active_network_plugins();
        $active_plugins = get_site_option('active_sitewide_plugins', array());
        foreach ($plugins as $plugin_path) {
            $plugin_base = plugin_basename($plugin_path);
            if (!array_key_exists($plugin_base, $active_plugins)) {
                continue;
            }
            $plugin = get_plugin_data($plugin_path);
            $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
        }
        $return = apply_filters('give_sysinfo_after_wordpress_ms_plugins', $return);
    }
    // Server configuration (really just versioning)
    $return .= "\n" . '-- Webserver Configuration' . "\n\n";
    $return .= 'PHP Version:              ' . PHP_VERSION . "\n";
    $return .= 'MySQL Version:            ' . $wpdb->db_version() . "\n";
    $return .= 'Webserver Info:           ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
    $return = apply_filters('give_sysinfo_after_webserver_config', $return);
    // PHP configs... now we're getting to the important stuff
    $return .= "\n" . '-- PHP Configuration' . "\n\n";
    $return .= 'Safe Mode:                ' . (ini_get('safe_mode') ? 'Enabled' : 'Disabled' . "\n");
    $return .= 'Memory Limit:             ' . ini_get('memory_limit') . "\n";
    $return .= 'Upload Max Size:          ' . ini_get('upload_max_filesize') . "\n";
    $return .= 'Post Max Size:            ' . ini_get('post_max_size') . "\n";
    $return .= 'Upload Max Filesize:      ' . ini_get('upload_max_filesize') . "\n";
    $return .= 'Time Limit:               ' . ini_get('max_execution_time') . "\n";
    $return .= 'Max Input Vars:           ' . ini_get('max_input_vars') . "\n";
    $return .= 'Display Errors:           ' . (ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A') . "\n";
    $return = apply_filters('give_sysinfo_after_php_config', $return);
    // PHP extensions and such
    $return .= "\n" . '-- PHP Extensions' . "\n\n";
    $return .= 'cURL:                     ' . (function_exists('curl_init') ? 'Supported' : 'Not Supported') . "\n";
    $return .= 'fsockopen:                ' . (function_exists('fsockopen') ? 'Supported' : 'Not Supported') . "\n";
    $return .= 'SOAP Client:              ' . (class_exists('SoapClient') ? 'Installed' : 'Not Installed') . "\n";
    $return .= 'Suhosin:                  ' . (extension_loaded('suhosin') ? 'Installed' : 'Not Installed') . "\n";
    $return = apply_filters('give_sysinfo_after_php_ext', $return);
    // Session stuff
    $return .= "\n" . '-- Session Configuration' . "\n\n";
    $return .= 'Give Use Sessions:         ' . (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS ? 'Enforced' : (Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled')) . "\n";
    $return .= 'Session:                  ' . (isset($_SESSION) ? 'Enabled' : 'Disabled') . "\n";
    // The rest of this is only relevant is session is enabled
    if (isset($_SESSION)) {
        $return .= 'Session Name:             ' . esc_html(ini_get('session.name')) . "\n";
        $return .= 'Cookie Path:              ' . esc_html(ini_get('session.cookie_path')) . "\n";
        $return .= 'Save Path:                ' . esc_html(ini_get('session.save_path')) . "\n";
        $return .= 'Use Cookies:              ' . (ini_get('session.use_cookies') ? 'On' : 'Off') . "\n";
        $return .= 'Use Only Cookies:         ' . (ini_get('session.use_only_cookies') ? 'On' : 'Off') . "\n";
    }
    $return = apply_filters('give_sysinfo_after_session_config', $return);
    $return .= "\n" . '### End System Info ###';
    return $return;
}
Example #4
0
/**
 * Determines what the currently selected gateway is
 *
 * If the amount is zero, no option is shown and the checkout uses the manual
 * gateway to emulate a no-gateway-setup for a free donation
 *
 * @access public
 * @since  1.0
 *
 * @param  int $form_id The ID of the Form
 *
 * @return string $enabled_gateway The slug of the gateway
 */
function give_get_chosen_gateway($form_id)
{
    $gateways = give_get_enabled_payment_gateways();
    $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0;
    if (empty($request_form_id)) {
        $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0;
    }
    $chosen = give_get_default_gateway($form_id);
    $enabled_gateway = '';
    //Take into account request Form ID args
    if (!empty($request_form_id) && $form_id == $request_form_id) {
        $chosen = $_REQUEST['payment-mode'];
    }
    if ($chosen) {
        $enabled_gateway = urldecode($chosen);
    } else {
        if (count($gateways) >= 1 && !$chosen) {
            foreach ($gateways as $gateway_id => $gateway) {
                $enabled_gateway = $gateway_id;
            }
        } else {
            $enabled_gateway = give_get_default_gateway($form_id);
        }
    }
    return apply_filters('give_chosen_gateway', $enabled_gateway);
}
Example #5
0
/**
 * Purchase Form Validate Gateway
 *
 * Validate the gateway and donation amount
 *
 * @access      private
 * @since       1.0
 * @return      string
 */
function give_purchase_form_validate_gateway()
{
    $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
    $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
    $gateway = give_get_default_gateway($form_id);
    // Check if a gateway value is present
    if (!empty($_REQUEST['give-gateway'])) {
        $gateway = sanitize_text_field($_REQUEST['give-gateway']);
        //Is amount being donated in LIVE mode 0.00? If so, error:
        if ($amount == 0 && !give_is_test_mode()) {
            give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give'));
        } elseif (!give_verify_minimum_price()) {
            give_set_error('invalid_donation_minimum', sprintf(esc_html__('This form has a minimum donation amount of %s.', 'give'), give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))));
        } elseif ($amount == 0 && give_is_test_mode()) {
            $gateway = 'manual';
        } elseif (!give_is_gateway_active($gateway)) {
            give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give'));
        }
    }
    return $gateway;
}
Example #6
0
/**
 * Purchase Form Validate Gateway
 *
 * @access      private
 * @since       1.0
 * @return      string
 */
function give_purchase_form_validate_gateway()
{
    $gateway = give_get_default_gateway($_REQUEST['give-form-id']);
    // Check if a gateway value is present
    if (!empty($_REQUEST['give-gateway'])) {
        $gateway = sanitize_text_field($_REQUEST['give-gateway']);
        if ('0.00' == $_REQUEST['give-amount']) {
            $gateway = 'manual';
        } elseif (!give_is_gateway_active($gateway)) {
            give_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'give'));
        }
    }
    return $gateway;
}
Example #7
0
/**
 * Determines what the currently selected gateway is
 *
 * If the amount is zero, no option is shown and the checkout uses the manual
 * gateway to emulate a no-gateway-setup for a free donation
 *
 * @access public
 * @since  1.0
 *
 * @param  int $form_id The ID of the Form
 *
 * @return string $enabled_gateway The slug of the gateway
 */
function give_get_chosen_gateway($form_id)
{
    $gateways = give_get_enabled_payment_gateways();
    $chosen = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : give_get_default_gateway($form_id);
    $enabled_gateway = '';
    if ($chosen) {
        $enabled_gateway = urldecode($chosen);
    } else {
        if (count($gateways) >= 1 && !$chosen) {
            foreach ($gateways as $gateway_id => $gateway) {
                $enabled_gateway = $gateway_id;
            }
        } else {
            $enabled_gateway = give_get_default_gateway($form_id);
        }
    }
    return apply_filters('give_chosen_gateway', $enabled_gateway);
}
Example #8
0
/**
 * Purchase Form Validate Gateway
 *
 * @access      private
 * @since       1.0
 * @return      string
 */
function give_purchase_form_validate_gateway()
{
    $gateway = give_get_default_gateway($_REQUEST['give-form-id']);
    // Check if a gateway value is present
    if (!empty($_REQUEST['give-gateway'])) {
        $gateway = sanitize_text_field($_REQUEST['give-gateway']);
        //Is amount being donated in LIVE mode above 0.00?
        if ('0.00' == $_REQUEST['give-amount'] && !give_is_test_mode()) {
            give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
        } elseif (!give_verify_minimum_price()) {
            $minimum = give_currency_filter(give_format_amount(give_get_form_minimum_price($_REQUEST['give-form-id'])));
            $error_message = __('This form has a minimum donation amount of %s', 'give');
            give_set_error('invalid_donation_minimum', sprintf($error_message, $minimum));
        } elseif ('0.00' == $_REQUEST['give-amount'] && give_is_test_mode()) {
            $gateway = 'manual';
        } elseif (!give_is_gateway_active($gateway)) {
            give_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'give'));
        }
    }
    return $gateway;
}
Example #9
0
/**
 * Purchase Form Validate Gateway
 *
 * @access      private
 * @since       1.0
 * @return      string
 */
function give_purchase_form_validate_gateway()
{
    $gateway = give_get_default_gateway($_REQUEST['give-form-id']);
    // Check if a gateway value is present
    if (!empty($_REQUEST['give-gateway'])) {
        $gateway = sanitize_text_field($_REQUEST['give-gateway']);
        //Is amount being donated in LIVE mode above 0.00?
        if ('0.00' == $_REQUEST['give-amount'] && !give_is_test_mode()) {
            give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
        } elseif ('0.00' == $_REQUEST['give-amount'] && give_is_test_mode()) {
            $gateway = 'manual';
        } elseif (!give_is_gateway_active($gateway)) {
            give_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'give'));
        }
    }
    return $gateway;
}