function mcs_payment_form()
{
    $ret = $form = '';
    if (isset($_GET['response_code'])) {
        $mcs = $_GET['response_code'];
        $provider = get_option('mcs_gateway') == 2 ? 'Authorize.net' : 'PayPal';
        switch ($mcs) {
            case 'thanks':
                $ret = "<p class='notice'>" . sprintf(__("Thank you for your purchase! You can view your purchase information at %s. You will receive an email with your payment key once your payment is finalized.", 'my-calendar-submissions'), $provider) . "</p>";
                break;
            case 'cancel':
                $ret = __("Sorry that you decided to cancel your purchase! Contact us if you have any questions!", 'my-calendar-submissions');
                break;
        }
    }
    if (mcs_payment_required()) {
        $price = mcs_get_price(is_user_logged_in());
        $currency = get_option('mcs_currency');
        $quantity = get_option('mcs_quantity');
        $discounts = mcs_check_discount();
        $discount_rate = (int) $discounts['rate'];
        $discount = $discount_rate != 0 ? true : false;
        if (isset($_GET['response_code'])) {
            $message = '';
        } else {
            $message = wpautop(jd_draw_template(array('price' => $price, 'currency' => $currency, 'discount' => $discount_rate, 'begins' => $discounts['begins'], 'ends' => $discounts['ends']), get_option('mcs_payment_message')));
        }
        $form = "<div class='mc-payments-form " . get_option('mcs_gateway') . "'>\n\t\t {$ret}\n\t\t {$message}";
        $nonce = wp_create_nonce('mcs-payments-nonce');
        if (get_option('mcs_gateway') == 'authorizenet') {
            if (get_option('mcs_quantity') != 'true' || (get_option('mcs_quantity') == 'true' && isset($_POST['mcs_quantity']) || isset($_GET['response_code']))) {
                require_once 'gateways/AuthorizeNet.php';
                // The SDK
                $url = mcs_replace_http(add_query_arg('mcsipn', 'true', get_permalink()));
                $rand = time() . rand(100000, 999999);
                $mcs_quantity = isset($_POST['mcs_quantity']) ? (int) $_POST['mcs_quantity'] : 1;
                $price = mcs_calculate_price($mcs_quantity, $price, $discount, $discount_rate);
                $form .= AuthorizeNetDPM::directPost($url, $price, $rand, $nonce);
            } else {
                $form .= mcs_set_quantity_form($price);
            }
        } else {
            $form .= mcs_paypal_form($price, $currency, $discount_rate, $discounts, $discount, $quantity);
        }
        $form .= "</div>";
    }
    return $form;
}
function mcs_get_price($logged_in)
{
    $price = apply_filters('mcs_get_price', get_option('mcs_submission_fee'));
    if ($logged_in) {
        $discounts = mcs_check_discount();
        $discount = $discounts['rate'];
        $discounted = $discount != 0 ? $price - $price * ($discount / 100) : $price;
        $discounted = sprintf("%01.2f", $discounted);
        $price = $discounted;
    }
    return apply_filters('mcs_get_price', $price);
}