/**
 * Show discount field by default
 * If you want a button, simply add <a class="edd-submit button" href="#">Apply discount</a> after the input field.
 * Because the discount is applied when you click outside the field, it will work in the exact same way
*/
function sumobi_edd_show_discount_field()
{
    if (!isset($_GET['payment-mode']) && count(edd_get_enabled_payment_gateways()) > 1 && !edd_is_ajax_enabled()) {
        return;
    }
    // Only show once a payment method has been selected if ajax is disabled
    if (edd_has_active_discounts() && edd_get_cart_total()) {
        ?>
	<fieldset id="edd_discount_code">
		<p>
			<label class="edd-label" for="edd-discount">
				<?php 
        _e('Discount', 'my-child-theme');
        ?>
				<img src="<?php 
        echo EDD_PLUGIN_URL;
        ?>
assets/images/loading.gif" id="edd-discount-loader" style="display:none;"/>
			</label>
			<span class="edd-description"><?php 
        _e('Enter a coupon code if you have one.', 'my-child-theme');
        ?>
</span>
			<input class="edd-input" type="text" id="edd-discount" name="edd-discount" placeholder="<?php 
        _e('Enter discount', 'my-child-theme');
        ?>
"/>
			
		</p>
	</fieldset>
	<?php 
    }
}
Example #2
0
/**
 * Sets an error on checkout if no gateways are enabled
 *
 * @since 1.3.4
 * @return void
 */
function edd_no_gateway_error()
{
    $gateways = edd_get_enabled_payment_gateways();
    if (empty($gateways)) {
        edd_set_error('no_gateways', __('You must enable a payment gateway to use Easy Digital Downloads', 'edd'));
    } else {
        edd_unset_error('no_gateways');
    }
}
/**
 * Verify credit card numbers live?
 *
 * @since 1.4
 * @return bool $ret True is verify credit cards is live
 */
function edd_is_cc_verify_enabled()
{
    $ret = true;
    /*
     * Enable if use a single gateway other than PayPal or Manual. We have to assume it accepts credit cards
     * Enable if using more than one gateway if they aren't both PayPal and manual, again assuming credit card usage
     */
    $gateways = edd_get_enabled_payment_gateways();
    if (count($gateways) == 1 && !isset($gateways['paypal']) && !isset($gateways['manual'])) {
        $ret = true;
    } else {
        if (count($gateways) == 1) {
            $ret = false;
        } else {
            if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) {
                $ret = false;
            }
        }
    }
    return (bool) apply_filters('edd_verify_credit_cards', $ret);
}
/**
 * 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 EDD Settings, it will be
 * automatically selected.
 *
 * @since 1.2.2
 * @return void
 */
function edd_payment_mode_select()
{
    $gateways = edd_get_enabled_payment_gateways(true);
    $page_URL = edd_get_current_page_url();
    do_action('edd_payment_mode_top');
    ?>
	<?php 
    if (edd_is_ajax_disabled()) {
        ?>
	<form id="edd_payment_mode" action="<?php 
        echo $page_URL;
        ?>
" method="GET">
	<?php 
    }
    ?>
		<fieldset id="edd_payment_mode_select">
			<?php 
    do_action('edd_payment_mode_before_gateways_wrap');
    ?>
			<div id="edd-payment-mode-wrap">
				<span class="edd-payment-mode-label"><?php 
    _e('Select Payment Method', 'edd');
    ?>
</span><br/>
				<?php 
    do_action('edd_payment_mode_before_gateways');
    foreach ($gateways as $gateway_id => $gateway) {
        $checked = checked($gateway_id, edd_get_default_gateway(), false);
        $checked_class = $checked ? ' edd-gateway-option-selected' : '';
        echo '<label for="edd-gateway-' . esc_attr($gateway_id) . '" class="edd-gateway-option' . $checked_class . '" id="edd-gateway-option-' . esc_attr($gateway_id) . '">';
        echo '<input type="radio" name="payment-mode" class="edd-gateway" id="edd-gateway-' . esc_attr($gateway_id) . '" value="' . esc_attr($gateway_id) . '"' . $checked . '>' . esc_html($gateway['checkout_label']);
        echo '</label>';
    }
    do_action('edd_payment_mode_after_gateways');
    ?>
			</div>
			<?php 
    do_action('edd_payment_mode_after_gateways_wrap');
    ?>
		</fieldset>
		<fieldset id="edd_payment_mode_submit" class="edd-no-js">
			<p id="edd-next-submit-wrap">
				<?php 
    echo edd_checkout_button_next();
    ?>
			</p>
		</fieldset>
	<?php 
    if (edd_is_ajax_disabled()) {
        ?>
	</form>
	<?php 
    }
    ?>
	<div id="edd_purchase_form_wrap"></div><!-- the checkout fields are loaded into this-->
	<?php 
    do_action('edd_payment_mode_bottom');
}
 /**
  * Fix chosen gateway
  *
  * @since       1.0.7
  * @param       array $gateway The current chosen gateway
  * @return      array $gateway The fixed chosen gateway
  */
 public function chosen_gateway($gateway)
 {
     if (is_user_logged_in()) {
         // Get the current user
         $user_id = get_current_user_id();
         // Make sure we aren't making a deposit from our wallet
         $fee = EDD()->fees->get_fee('edd-wallet-deposit');
         if ($fee) {
             $gateways = edd_get_enabled_payment_gateways();
             if (count($gateways) == 1) {
                 $gateway = array_keys($gateways);
                 $gateway = $gateway[0];
             }
         }
     }
     return $gateway;
 }
Example #6
0
/**
 * Get system info
 *
 * @since       2.0
 * @access      public
 * @global      object $wpdb Used to query the database using the WordPress Database API
 * @global      array $edd_options Array of all EDD options
 * @return      string $return A string containing the info to output
 */
function edd_tools_sysinfo_get()
{
    global $wpdb, $edd_options;
    if (!class_exists('Browser')) {
        require_once EDD_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 = edd_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('edd_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('edd_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('edd_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' => 'EDD/' . EDD_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 .= '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('edd_sysinfo_after_wordpress_config', $return);
    // EDD configuration
    $return .= "\n" . '-- EDD Configuration' . "\n\n";
    $return .= 'Version:                  ' . EDD_VERSION . "\n";
    $return .= 'Upgraded From:            ' . get_option('edd_version_upgraded_from', 'None') . "\n";
    $return .= 'Test Mode:                ' . (edd_is_test_mode() ? "Enabled\n" : "Disabled\n");
    $return .= 'Ajax:                     ' . (!edd_is_ajax_disabled() ? "Enabled\n" : "Disabled\n");
    $return .= 'Guest Checkout:           ' . (edd_no_guest_checkout() ? "Disabled\n" : "Enabled\n");
    $return .= 'Symlinks:                 ' . (apply_filters('edd_symlink_file_downloads', isset($edd_options['symlink_file_downloads'])) && function_exists('symlink') ? "Enabled\n" : "Disabled\n");
    $return .= 'Download Method:          ' . ucfirst(edd_get_file_download_method()) . "\n";
    $return .= 'Currency Code:            ' . edd_get_currency() . "\n";
    $return .= 'Currency Position:        ' . edd_get_option('currency_position', 'before') . "\n";
    $return .= 'Decimal Separator:        ' . edd_get_option('decimal_separator', '.') . "\n";
    $return .= 'Thousands Separator:      ' . edd_get_option('thousands_separator', ',') . "\n";
    $return = apply_filters('edd_sysinfo_after_edd_config', $return);
    // EDD pages
    $return .= "\n" . '-- EDD Page Configuration' . "\n\n";
    $return .= 'Checkout:                 ' . (!empty($edd_options['purchase_page']) ? "Valid\n" : "Invalid\n");
    $return .= 'Checkout Page:            ' . (!empty($edd_options['purchase_page']) ? get_permalink($edd_options['purchase_page']) . "\n" : "Unset\n");
    $return .= 'Success Page:             ' . (!empty($edd_options['success_page']) ? get_permalink($edd_options['success_page']) . "\n" : "Unset\n");
    $return .= 'Failure Page:             ' . (!empty($edd_options['failure_page']) ? get_permalink($edd_options['failure_page']) . "\n" : "Unset\n");
    $return .= 'Downloads Slug:           ' . (defined('EDD_SLUG') ? '/' . EDD_SLUG . "\n" : "/downloads\n");
    $return = apply_filters('edd_sysinfo_after_edd_pages', $return);
    // EDD gateways
    $return .= "\n" . '-- EDD Gateway Configuration' . "\n\n";
    $active_gateways = edd_get_enabled_payment_gateways();
    if ($active_gateways) {
        $default_gateway_is_active = edd_is_gateway_active(edd_get_default_gateway());
        if ($default_gateway_is_active) {
            $default_gateway = edd_get_default_gateway();
            $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('edd_sysinfo_after_edd_gateways', $return);
    // EDD Taxes
    $return .= "\n" . '-- EDD Tax Configuration' . "\n\n";
    $return .= 'Taxes:                    ' . (edd_use_taxes() ? "Enabled\n" : "Disabled\n");
    $return .= 'Tax Rate:                 ' . edd_get_tax_rate() * 100 . "\n";
    $return .= 'Display On Checkout:      ' . (!empty($edd_options['checkout_include_tax']) ? "Displayed\n" : "Not Displayed\n");
    $return .= 'Prices Include Tax:       ' . (edd_prices_include_tax() ? "Yes\n" : "No\n");
    $rates = edd_get_tax_rates();
    if (!empty($rates)) {
        $return .= 'Country / State Rates:    ' . "\n";
        foreach ($rates as $rate) {
            $return .= '                          Country: ' . $rate['country'] . ', State: ' . $rate['state'] . ', Rate: ' . $rate['rate'] . "\n";
        }
    }
    $return = apply_filters('edd_sysinfo_after_edd_taxes', $return);
    // EDD Templates
    $dir = get_stylesheet_directory() . '/edd_templates/*';
    if (is_dir($dir) && count(glob("{$dir}/*")) !== 0) {
        $return .= "\n" . '-- EDD Template Overrides' . "\n\n";
        foreach (glob($dir) as $file) {
            $return .= 'Filename:                 ' . basename($file) . "\n";
        }
        $return = apply_filters('edd_sysinfo_after_edd_templates', $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('edd_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('edd_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('edd_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('edd_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('edd_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('edd_sysinfo_after_php_ext', $return);
    // Session stuff
    $return .= "\n" . '-- Session Configuration' . "\n\n";
    $return .= 'EDD Use Sessions:         ' . (defined('EDD_USE_PHP_SESSIONS') && EDD_USE_PHP_SESSIONS ? 'Enforced' : (EDD()->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('edd_sysinfo_after_session_config', $return);
    $return .= "\n" . '### End System Info ###';
    return $return;
}
function atcf_is_gatweay_active($gateway)
{
    $active_gateways = edd_get_enabled_payment_gateways();
    return array_key_exists($gateway, $active_gateways);
}
/**
 * Get gateway checkout label
 *
 * Returns the checkout label for the specified gateway.
 *
 * @access      public
 * @since       1.0.8.5
 * @param       string - The ID name of the gateway to retrieve a label for
 * @return      string
*/
function edd_get_gateway_checkout_label($gateway)
{
    $gateways = edd_get_enabled_payment_gateways();
    return isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
}
/**
 * Determines what the currently selected gateway is
 *
 * If the cart amount is zero, no option is shown and the cart uses the manual
 * gateway to emulate a no-gateway-setup for a free download
 *
 * @access public
 * @since 1.3.2
 * @return string $enabled_gateway The slug of the gateway
 */
function edd_get_chosen_gateway()
{
    $gateways = edd_get_enabled_payment_gateways();
    $chosen = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : false;
    if (false !== $chosen) {
        $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
    }
    if (!empty($chosen)) {
        $enabled_gateway = urldecode($chosen);
    } else {
        if (count($gateways) >= 1 && !$chosen) {
            foreach ($gateways as $gateway_id => $gateway) {
                $enabled_gateway = $gateway_id;
                if (edd_get_cart_subtotal() <= 0) {
                    $enabled_gateway = 'manual';
                    // This allows a free download by filling in the info
                }
            }
        } else {
            if (edd_get_cart_subtotal() <= 0) {
                $enabled_gateway = 'manual';
            } else {
                $enabled_gateway = edd_get_default_gateway();
            }
        }
    }
    return apply_filters('edd_chosen_gateway', $enabled_gateway);
}
    /**
     * Redeem Points Markup
     * 
     * Handles to show redeem points markup
     * 
     * @package Easy Digital Downloads - Points and Rewards
     * @since 1.0.0
     **/
    public function edd_points_redeem_point_markup()
    {
        global $current_user, $edd_options;
        if (!isset($_GET['payment-mode']) && count(edd_get_enabled_payment_gateways()) > 1 && !edd_is_ajax_enabled()) {
            return;
        }
        // Only show once a payment method has been selected if ajax is disabled
        //get points plural label
        $plurallabel = isset($edd_options['edd_points_label']['plural']) && !empty($edd_options['edd_points_label']['plural']) ? $edd_options['edd_points_label']['plural'] : 'Point';
        //get discount got by user via points
        $gotdiscount = EDD()->fees->get_fee('points_redeem');
        //get message from settings
        $redemptionmessage = $edd_options['edd_points_reedem_cart_messages'];
        //calculate discount towards points
        $available_discount = $this->model->edd_points_get_discount_for_redeeming_points();
        $button_color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : '';
        if (!empty($available_discount) && !empty($redemptionmessage) && empty($gotdiscount)) {
            //get discounte price from points
            $discountedpoints = $this->model->edd_points_calculate_points($available_discount);
            //get points label to show to user
            $points_label = $this->model->edd_points_get_points_label($discountedpoints);
            //display price to show to user
            $displaydiscprice = edd_currency_filter($available_discount);
            //show message on checkout page
            $points_replace = array("{points}", "{points_label}", "{points_value}");
            $replace_message = array($discountedpoints, $points_label, $displaydiscprice);
            $message = $this->model->edd_points_replace_array($points_replace, $replace_message, $redemptionmessage);
            ?>
 
			<fieldset class="edd-points-redeem-points-wrap">
				<form method="POST" action="" >
					<input type="submit" id="edd_points_apply_discount" name="edd_points_apply_discount" class="button edd-submit <?php 
            _e($button_color);
            ?>
 edd-points-apply-discount-button" value="<?php 
            _e('Apply Discount', 'eddpoints');
            ?>
" />
				</form>
				<div class="edd-points-redeem-message"><?php 
            echo $message;
            ?>
</div><!--.edd-points-checkout-message-->
			</fieldset><!--.edd-points-redeem-points-wrap-->
			<?php 
        }
        //end if cart total not empty
        //if points discount applied then show remove link
        if (!empty($gotdiscount)) {
            $removfeesurl = add_query_arg(array('edd_points_remove_discount' => 'remove'), edd_get_current_page_url());
            ?>
				<fieldset class="edd-points-checkout-message">
					<a href="<?php 
            echo $removfeesurl;
            ?>
" class="button edd-point-remove-discount-link edd-points-float-right"><?php 
            _e('Remove', 'eddpoints');
            ?>
</a>
					<div class="edd-points-remove-disocunt-message"><?php 
            printf(__('Remove %s Discount', 'eddpoints'), $plurallabel);
            ?>
</div><!--.edd-points-checkout-message-->
				</fieldset><!--.edd-points-redeem-points-wrap-->
			<?php 
        }
    }
 /**
  * Get things moving.
  *
  * Defines some class variables and starts the processinging.
  *
  * @since Astoundify Crowdfunding 1.8
  *
  * @return void
  */
 function __construct($campaign_id, $process_failed = false)
 {
     global $edd_options;
     $this->to_process = isset($edd_options['atcf_to_process']) ? $edd_options['atcf_to_process'] : 20;
     $this->process_failed = $process_failed;
     $this->campaign_id = $campaign_id;
     $this->campaign = atcf_get_campaign($this->campaign_id);
     $this->payments = $this->campaign->__get('_payment_ids');
     $this->failed_payments = $this->campaign->__get('_campaign_failed_payments');
     if ($this->process_failed) {
         $this->payments = $this->failed_payments;
     }
     $this->gateways = edd_get_enabled_payment_gateways();
     $this->get_payments();
     $this->sort_payments();
     $this->process();
     $this->log_failed();
     $this->cleanup();
 }
/**
 * The payment mode select form
 *
 * @access      public
 * @since       1.2.2
 * @return      void
*/
function edd_payment_mode_select()
{
    $gateways = edd_get_enabled_payment_gateways();
    $page_URL = edd_get_current_page_url();
    do_action('edd_payment_mode_top');
    ?>
	<form id="edd_payment_mode" action="<?php 
    echo $page_URL;
    ?>
" method="GET">
		<fieldset id="edd_payment_mode_select">
			<?php 
    do_action('edd_payment_mode_before_gateways');
    ?>
			<p id="edd-payment-mode-wrap">
				<?php 
    echo '<select class="edd-select" name="payment-mode" id="edd-gateway">';
    echo '<option value="0">' . __('Select payment method', 'edd') . '</option>';
    foreach ($gateways as $gateway_id => $gateway) {
        echo '<option value="' . $gateway_id . '">' . $gateway['checkout_label'] . '</option>';
    }
    echo '</select>';
    ?>
			</p>
			<?php 
    do_action('edd_payment_mode_after_gateways');
    ?>
		</fieldset>
		<fieldset id="edd_payment_mode_submit" class="edd-no-js">
			<p id="edd-next-submit-wrap">
				<?php 
    echo edd_checkout_button_next();
    ?>
			</p>
		</fieldset>
	</form>
	<div id="edd_purchase_form_wrap"></div><!-- the checkout fields are loaded into this-->
	<?php 
    do_action('edd_payment_mode_bottom');
}
/**
 * Get Checkout Form
 *
 * @access      private
 * @since       1.0 
 * @return      string
*/
function edd_checkout_form()
{
    global $edd_options, $user_ID, $post;
    if (is_singular()) {
        $page_URL = get_permalink($post->ID);
    } else {
        $page_URL = 'http';
        if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
            $pageURL .= "s";
        }
        $page_URL .= "://";
        if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != "80") {
            $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
        } else {
            $page_URL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
        }
    }
    if (is_user_logged_in()) {
        global $user_ID;
        $user_data = get_userdata($user_ID);
    }
    ob_start();
    ?>
		
		<?php 
    if (edd_get_cart_contents()) {
        ?>
				
			<?php 
        do_action('edd_before_checkout_cart');
        edd_checkout_cart();
        do_action('edd_after_checkout_cart');
        ?>
			
			<div id="edd_checkout_form_wrap" class="edd_clearfix">
			
				<?php 
        do_action('edd_checkout_form_top');
        $gateways = edd_get_enabled_payment_gateways();
        $show_gateways = false;
        if (count($gateways) > 1 && !isset($_GET['payment-mode'])) {
            $show_gateways = true;
            if (edd_get_cart_amount() <= 0) {
                $show_gateways = false;
            }
        }
        if ($show_gateways) {
            ?>
					<?php 
            do_action('edd_payment_mode_top');
            ?>
					<form id="edd_payment_mode" action="<?php 
            echo $page_URL;
            ?>
" method="GET">
						<fieldset id="edd_payment_mode_select">
							<?php 
            do_action('edd_payment_mode_before_gateways');
            ?>
							<p id="edd-payment-mode-wrap">
								<?php 
            echo '<select class="edd-select" name="payment-mode" id="edd-gateway">';
            foreach ($gateways as $gateway_id => $gateway) {
                echo '<option value="' . $gateway_id . '">' . $gateway['checkout_label'] . '</option>';
            }
            echo '</select>';
            echo '<label for="edd-gateway">' . __('Choose Your Payment Method', 'edd') . '</label>';
            ?>
							</p>
							<?php 
            do_action('edd_payment_mode_after_gateways');
            ?>
						</fieldset>
						<fieldset id="edd_payment_mode_submit">
							<p id="edd-next-submit-wrap">
								<?php 
            $color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'gray';
            ?>
 
								<span class="edd_button edd_<?php 
            echo $color;
            ?>
">
									<span class="edd_button_outer">
										<span class="edd_button_inner">
											<input type="submit" id="edd_next_button" class="edd_button_text edd-submit" value="<?php 
            _e('Next', 'edd');
            ?>
"/>
										</span>
									</span>
								</span>
							</p>
						</fieldset>
					</form>
					<?php 
            do_action('edd_payment_mode_bottom');
            ?>
			
				<?php 
        } else {
            ?>
		
					<?php 
            if (count($gateways) >= 1 && !isset($_GET['payment-mode'])) {
                foreach ($gateways as $gateway_id => $gateway) {
                    $enabled_gateway = $gateway_id;
                    if (edd_get_cart_amount() <= 0) {
                        $enabled_gateway = 'manual';
                        // this allows a free download by filling in the info
                    }
                }
            } else {
                if (edd_get_cart_amount() <= 0) {
                    $enabled_gateway = 'manual';
                } else {
                    $enabled_gateway = 'none';
                }
            }
            $payment_mode = isset($_GET['payment-mode']) ? urldecode($_GET['payment-mode']) : $enabled_gateway;
            ?>
					
					<?php 
            do_action('edd_before_purchase_form');
            ?>
					<form id="edd_purchase_form" action="<?php 
            echo $page_URL;
            ?>
" method="POST">					
					
						<?php 
            do_action('edd_purchase_form_top');
            ?>
					
						<?php 
            if (isset($edd_options['logged_in_only']) && !isset($edd_options['show_register_form'])) {
                if (is_user_logged_in()) {
                    $can_checkout = true;
                } else {
                    $can_checkout = false;
                }
            } elseif (isset($edd_options['show_register_form']) && isset($edd_options['logged_in_only'])) {
                $can_checkout = true;
            } elseif (!isset($edd_options['logged_in_only'])) {
                $can_checkout = true;
            }
            $can_checkout = true;
            if ($can_checkout) {
                ?>
							
							<?php 
                if (isset($edd_options['show_register_form']) && !is_user_logged_in() && !isset($_GET['login'])) {
                    ?>
								<div id="edd_checkout_login_register"><?php 
                    echo edd_get_register_fields();
                    ?>
</div>
							<?php 
                } elseif (isset($edd_options['show_register_form']) && !is_user_logged_in() && isset($_GET['login'])) {
                    ?>
								<div id="edd_checkout_login_register"><?php 
                    echo edd_get_login_fields();
                    ?>
</div>
							<?php 
                }
                ?>

							<?php 
                if (!isset($_GET['login']) && is_user_logged_in() || !isset($edd_options['show_register_form'])) {
                    ?>
											
							<fieldset id="edd_checkout_user_info">
								<legend><?php 
                    _e('Personal Info', 'edd');
                    ?>
</legend>
								<?php 
                    do_action('edd_purchase_form_before_email');
                    ?>
								<p id="edd-email-wrap">
									<input class="edd-input required" type="email" name="edd_email" placeholder="<?php 
                    _e('Email address', 'edd');
                    ?>
" id="edd-email" value="<?php 
                    echo is_user_logged_in() ? $user_data->user_email : '';
                    ?>
"/>
									<label class="edd-label" for="edd-email"><?php 
                    _e('Email Address', 'edd');
                    ?>
</label>
								</p>
								<?php 
                    do_action('edd_purchase_form_after_email');
                    ?>
								<p id="edd-first-name-wrap">
									<input class="edd-input required" type="text" name="edd_first" placeholder="<?php 
                    _e('First Name', 'edd');
                    ?>
" id="edd-first" value="<?php 
                    echo is_user_logged_in() ? $user_data->first_name : '';
                    ?>
"/>
									<label class="edd-label" for="edd-first"><?php 
                    _e('First Name', 'edd');
                    ?>
</label>
								</p>
								<p id="edd-last-name-wrap">
									<input class="edd-input" type="text" name="edd_last" id="edd-last" placeholder="<?php 
                    _e('Last name', 'edd');
                    ?>
" value="<?php 
                    echo is_user_logged_in() ? $user_data->last_name : '';
                    ?>
"/>
									<label class="edd-label" for="edd-last"><?php 
                    _e('Last Name', 'edd');
                    ?>
</label>
								</p>	
								<?php 
                    do_action('edd_purchase_form_user_info');
                    ?>
							</fieldset>	
							
							<?php 
                    do_action('edd_purchase_form_after_user_info');
                    ?>

							<?php 
                }
                ?>
							
							<?php 
                if (edd_has_active_discounts()) {
                    // only show if we have at least one active discount
                    ?>
								<fieldset id="edd_discount_code">
									<p id="edd-discount-code-wrap">
										<input class="edd-input" type="text" id="edd-discount" name="edd-discount" placeholder="<?php 
                    _e('Enter discount', 'edd');
                    ?>
"/>
										<label class="edd-label" for="edd-discount">
											<?php 
                    _e('Discount', 'edd');
                    ?>
											<?php 
                    if (edd_is_ajax_enabled()) {
                        ?>
												- <a href="#" class="edd-apply-discount"><?php 
                        _e('Apply Discount', 'edd');
                        ?>
</a>
											<?php 
                    }
                    ?>
										</label>
									</p>
								</fieldset>	
							<?php 
                }
                ?>

							<?php 
                // load the credit card form and allow gateways to load their own if they wish
                if (has_action('edd_' . $payment_mode . '_cc_form')) {
                    do_action('edd_' . $payment_mode . '_cc_form');
                } else {
                    do_action('edd_cc_form');
                }
                ?>
			
							
							<?php 
                if (isset($edd_options['show_agree_to_terms'])) {
                    ?>
								<fieldset id="edd_terms_agreement">
									<p>
										<div id="edd_terms" style="display:none;">
											<?php 
                    do_action('edd_before_terms');
                    echo wpautop($edd_options['agree_text']);
                    do_action('edd_after_terms');
                    ?>
										</div>
										<div id="edd_show_terms">
											<a href="#" class="edd_terms_links"><?php 
                    _e('Show Terms', 'edd');
                    ?>
</a>
											<a href="#" class="edd_terms_links" style="display:none;"><?php 
                    _e('Hide Terms', 'edd');
                    ?>
</a>
										</div>
										<input name="edd_agree_to_terms" class="required" type="checkbox" id="edd_agree_to_terms" value="1"/>
										<label for="edd_agree_to_terms"><?php 
                    echo isset($edd_options['agree_label']) ? $edd_options['agree_label'] : __('Agree to Terms?', 'edd');
                    ?>
</label>
									</p>
								</fieldset>
							<?php 
                }
                ?>
	
							<fieldset id="edd_purchase_submit">
								<p>
									<?php 
                do_action('edd_purchase_form_before_submit');
                ?>
									<?php 
                if (is_user_logged_in()) {
                    ?>
									<input type="hidden" name="edd-user-id" value="<?php 
                    echo $user_data->ID;
                    ?>
"/>
									<?php 
                }
                ?>
									<input type="hidden" name="edd_action" value="purchase"/>
									<input type="hidden" name="edd-gateway" value="<?php 
                echo $payment_mode;
                ?>
" />
									<input type="hidden" name="edd-nonce" value="<?php 
                echo wp_create_nonce('edd-purchase-nonce');
                ?>
"/>
									<?php 
                $color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'gray';
                ?>
									<span class="edd_button edd_<?php 
                echo $color;
                ?>
">
										<span class="edd_button_outer">
											<span class="edd_button_inner">
												<?php 
                $complete_purchase = isset($edd_options['checkout_label']) && strlen(trim($edd_options['checkout_label'])) > 0 ? $edd_options['checkout_label'] : __('Purchase', 'edd');
                ?>
												<input type="submit" class="edd_button_text edd-submit" id="edd-purchase-button" name="edd-purchase" value="<?php 
                echo $complete_purchase;
                ?>
"/>
											</span>
										</span>
									</span>
									<?php 
                do_action('edd_purchase_form_after_submit');
                ?>
								</p>
								<?php 
                if (!edd_is_ajax_enabled()) {
                    ?>
									<p class="edd-cancel"><a href="javascript:history.go(-1)"><?php 
                    _e('Go back', 'edd');
                    ?>
</a></p>
								<?php 
                }
                ?>
				
							</fieldset>
						<?php 
            } else {
                ?>
							<p><?php 
                _e('You must be logged in to complete your purchase', 'edd');
                ?>
</p>
						<?php 
            }
            ?>
						<?php 
            do_action('edd_purchase_form_bottom');
            ?>
					</form>
					<?php 
            do_action('edd_after_purchase_form');
            ?>
			<?php 
        }
        ?>
		</div><!--end #edd_checkout_form_wrap-->
		<?php 
    } else {
        do_action('edd_empty_cart');
    }
    return ob_get_clean();
}
echo esc_url(edd_get_current_page_url());
?>
" method="GET">
	<fieldset id="edd_payment_mode_select">
		<div class="row iceberg">
			<div class="island grid">
				<div class="two-seventh">
					<p><?php 
_e('How do you want to pay?', 'yoastcom');
?>
</p>
				</div>
				<div class="three-seventh">
					<fieldset class="iceberg">
						<?php 
$gateways = edd_get_enabled_payment_gateways(true);
?>
						<?php 
foreach ($gateways as $gateway_id => $gateway) {
    ?>
							<label class="edd-gateway-option" for="edd-gateway-<?php 
    echo esc_attr($gateway_id);
    ?>
">
								<input type="radio" name="payment-mode" class="edd-gateway"
									id="edd-gateway-<?php 
    echo esc_attr($gateway_id);
    ?>
"
								    value="<?php 
    echo esc_attr($gateway_id);