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;
}
    /**
     * Generate a sample form for use in a demo Direct Post implementation.
     *
     * @param string $amount                   Amount of the transaction.
     * @param string $fp_sequence              Sequential number(ie. Invoice #)
     * @param string $relay_response_url       The Relay Response URL
     * @param string $api_login_id             Your API Login ID
     * @param string $transaction_key          Your API Tran Key.
     *
     * @return string
     */
    public static function getCreditCardForm($price, $fp_sequence, $relay_response_url, $api, $key, $nonce)
    {
        $test_mode = get_option('mcs_use_sandbox') == 'true' ? true : false;
        $prefill = $test_mode ? true : false;
        $time = time();
        $fp = self::getFingerprint($api, $key, $price, $fp_sequence, $time);
        $sim = new AuthorizeNetSIM_Form(array('x_amount' => $price, 'x_fp_sequence' => $fp_sequence, 'x_fp_hash' => $fp, 'x_fp_timestamp' => $time, 'x_relay_response' => "TRUE", 'x_relay_url' => $relay_response_url, 'x_login' => $api));
        $hidden_fields = $sim->getHiddenFieldString();
        global $wp;
        $hidden_fields .= "<input type='hidden' name='x_referer_url' value='" . mcs_replace_http(home_url(add_query_arg(array(), $wp->request))) . "' />";
        $post_url = $test_mode ? self::SANDBOX_URL : self::LIVE_URL;
        $button = get_option('mcs_button');
        $quantity = isset($_POST['mcs_quantity']) ? (int) $_POST['mcs_quantity'] : 1;
        if ($quantity == 1) {
            $purchasing = '<p>' . sprintf(__('You\'re purchasing a payment key to submit %1$s event for $%2$s.', 'my-calendar-submissions'), "<strong>{$quantity}</strong>", "<strong>{$price}</strong>") . '</p>';
        } else {
            $purchasing = '	<p>' . sprintf(__('You\'re purchasing a payment key for %1$s events. Total: $%2$s.', 'my-calendar-submissions'), "<strong>{$quantity}</strong>", "<strong>{$price}</strong>") . '</p>';
        }
        $form = $purchasing . '
        <form method="post" action="' . $post_url . '">
				<div>
                ' . $hidden_fields . '
				<input type="hidden" name="x_amount_base" value="' . $price . '" />
				</div>
                <div>
                    <label for="x_card_num">' . __('Credit Card Number', 'my-calendar-submissions') . '</label>
                    <input type="text" required aria-required="true" size="17" id="x_card_num" name="x_card_num" value="' . ($prefill ? '6011000000000012' : '') . '" />
                </div>
                <div>
                    <label for="x_exp_date">' . __('Expiration', 'my-calendar-submissions') . '</label>
                    <input type="text" required aria-required="true" size="4" id="x_exp_date" name="x_exp_date" placeholder="05/' . date('y', strtotime('+ 2 years')) . '" value="' . ($prefill ? '04/17' : '') . '" />
                </div>
                <div>
                    <label for="x_card_code">' . __('Security Code', 'my-calendar-submissions') . '</label>
                    <input type="text" required aria-required="true" size="4" id="x_card_code" name="x_card_code" placeholder="123" value="' . ($prefill ? '782' : '') . '" />
                </div>
                <div>
                    <label for="x_first_name">' . __('First Name', 'my-calendar-submissions') . '</label>
                    <input type="text" required aria-required="true" size="17" id="x_first_name" name="x_first_name" value="' . ($prefill ? 'John' : '') . '" />
                </div>
                <div>
                    <label for="x_last_name">' . __('Last Name', 'my-calendar-submissions') . '</label>
                    <input type="text" required aria-required="true" size="17" id="x_last_name" name="x_last_name" value="' . ($prefill ? 'Doe' : '') . '" />
                </div>
                <div>
                    <label for="x_payer_email">' . __('Email', 'my-calendar-submissions') . '</label>
                    <input type="email" required aria-required="true" size="17" id="x_payer_email" name="x_payer_email" value="' . ($prefill ? '*****@*****.**' : '') . '" />
                </div>				
                <div>
                    <label for="x_address">' . __('Address', 'my-calendar-submissions') . '</label>
                    <input type="text" size="26" id="x_address" name="x_address" value="' . ($prefill ? '123 Main Street' : '') . '" />
                </div>
                <div>
                    <label for="x_city">' . __('City', 'my-calendar-submissions') . '</label>
                    <input type="text" size="17" id="x_city" name="x_city" value="' . ($prefill ? 'Boston' : '') . '" />
                </div>
                <div>
                    <label for="x_state">' . __('State', 'my-calendar-submissions') . '</label>
                    <input type="text" size="4" id="x_state" name="x_state" value="' . ($prefill ? 'MA' : '') . '" />
                </div>
                <div>
                    <label for="x_zip">' . __('Zip Code', 'my-calendar-submissions') . '</label>
                    <input type="text" size="9" id="x_zip" name="x_zip" value="' . ($prefill ? '02142' : '') . '" />
                </div>
                <div>
                    <label for="x_country">' . __('Country', 'my-calendar-submissions') . '</label>
                    <input type="text" size="22" id="x_country" name="x_country" value="' . ($prefill ? 'US' : '') . '" />
                </div>';
        if ($button != '' && mc_is_url($button)) {
            $form .= "<input type='image' src='{$button}' name='submit' class='button' alt='" . __('Buy a payment key', 'my-calendar-submissions') . "' />";
        } else {
            $form .= "<input type='submit' name='submit' class='button' value='" . __('Buy a payment key', 'my-calendar-submissions') . "' />";
        }
        $form .= apply_filters('mcs_authorizenet_form', '', $price);
        $form .= '</form>';
        return $form;
    }