Update the payment form to include reCaptcha
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 1 Nov 2016 16:10:48 +0000 (12:10 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 1 Nov 2016 16:10:48 +0000 (12:10 -0400)
Adding reCaptcha from google to the payment form.

glm-payments.php
includes/payment-display.php

index 9ba9fc0..e8da2c6 100755 (executable)
@@ -1,10 +1,10 @@
-<?php \r
-/*     \r
+<?php\r
+/*\r
        Plugin Name: GLM Payments\r
        Plugin URI: www.gaslightmedia.com\r
        Description: Integration of the payment system using to AuthorizeNet.\r
        Author: Gaslight Media\r
-       Version: 0.6\r
+       Version: 1.0.4\r
 */\r
 session_start();\r
 \r
@@ -19,18 +19,18 @@ add_action('wp_print_scripts', 'load_glm_payment_js');
 add_action('admin_print_styles', 'load_glm_payment_admin_css');\r
 add_action('admin_print_scripts', 'load_glm_payment_admin_js');\r
 \r
-function load_glm_payment_js() \r
+function load_glm_payment_js()\r
 {\r
     wp_enqueue_script( 'glm-payments-js', glm_payment_PATH . '/js/paymentmethods.js', array('jquery') );\r
 }\r
 \r
-function load_glm_payment_admin_js() \r
+function load_glm_payment_admin_js()\r
 {\r
     wp_enqueue_script('jquery-ui-core');\r
     wp_enqueue_script('jquery-ui-tabs');\r
 }\r
 \r
-function load_glm_payment_css() \r
+function load_glm_payment_css()\r
 {\r
     $options = get_option('glm_payment_options');\r
     if ( $options['payment_css_switch'] ) {\r
@@ -54,7 +54,7 @@ add_action( 'admin_menu', 'my_add_menu_items' );
 \r
 function my_render_list_page()\r
 {\r
-       \r
+\r
 }\r
 add_shortcode('glmpayment', 'glm_payment_form');\r
 if(isset($_REQUEST['setting']))\r
@@ -106,11 +106,11 @@ $payment_setting_sql = "CREATE TABLE IF NOT EXISTS `$payment_setting` (
 PRIMARY KEY (`id`),\r
 UNIQUE KEY `id` (`id`)\r
 ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2";\r
-  \r
+\r
    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );\r
    dbDelta( $sql );\r
    dbDelta( $payment_setting_sql );\r
\r
+\r
    add_option( "payment_db_version", $payment_db_version );\r
 }\r
 \r
index c882abe..8434b61 100755 (executable)
@@ -7,11 +7,33 @@
  * @since 1.0\r
  *\r
 */\r
-       global $wpdb;\r
-    if(isset($_REQUEST['action']))\r
-    {\r
+global $wpdb;\r
+if(isset($_REQUEST['action']))\r
+{\r
     if($_REQUEST['action']=='submitpayment')\r
-    {          \r
+    {\r
+        // Check the form for reCaptcha\r
+        $response = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(\r
+            'method'  => 'POST',\r
+            'timeout' => 45,\r
+            'redirection' => 5,\r
+            'httpversion' => '1.0',\r
+            'blocking' => true,\r
+            'headers' => array(),\r
+            'body' => array(\r
+                'secret'   => '6LfUdwoUAAAAAPIZJ1_ipx0hK2Bl8XMMsmamlRDq',\r
+                'response' => $_REQUEST['g-recaptcha-response'],\r
+                'remoteip' => $_SERVER['REMOTE_ADDR']\r
+            ),\r
+            'cookies' => array()\r
+        ) );\r
+        $response_code = wp_remote_retrieve_response_code( $response );\r
+        $api_response = json_decode( wp_remote_retrieve_body( $response ), true );\r
+        if ( $api_response['success'] != true ) {\r
+            $_SESSION['payment_msg'] = 'Captcha did not verify!';\r
+            header("Location:".site_url().$_SERVER['REQUEST_URI']);\r
+            exit;\r
+        }\r
                $first_name = $_REQUEST['first_name'];\r
                $last_name = $_REQUEST['last_name'];\r
                $organization = $_REQUEST['organization'];\r
@@ -21,7 +43,7 @@
                $state = $_REQUEST['state'];\r
                $zip = $_REQUEST['zip'];\r
                $phone = $_REQUEST['phone'];\r
-               $email = $_REQUEST['email'];            \r
+               $email = $_REQUEST['email'];\r
                $donation_type = $_REQUEST['donation_type'];\r
                $r_frequency = $_REQUEST['r_frequency'];\r
                $r_times = $_REQUEST['r_times'];\r
@@ -34,7 +56,7 @@
                $x_card_code = $_REQUEST['x_card_code'];\r
                $comment = $_REQUEST['comment'];\r
                $payment_method = $_REQUEST['payment_method'];\r
-               \r
+\r
                // Adjust this to point to the Authorize.Net PHP SDK\r
                include dirname(__FILE__) .'/../anet_php_sdk/AuthorizeNet.php';\r
 \r
                define("AUTHORIZENET_API_LOGIN_ID",$mysetting[0]->api_login);    // Add your API LOGIN ID\r
                define("AUTHORIZENET_TRANSACTION_KEY",$mysetting[0]->key); // Add your API transaction key\r
                if($mysetting[0]->mod==0){\r
-               define("AUTHORIZENET_SANDBOX",true);       // Set to false to test against production\r
-               define("TEST_REQUEST", true);           // You may want to set to true if testing against production\r
+            define("AUTHORIZENET_SANDBOX",true);       // Set to false to test against production\r
+            define("TEST_REQUEST", true);           // You may want to set to true if testing against production\r
                }\r
                else\r
                {\r
                        define("AUTHORIZENET_SANDBOX",false);       // Set to false to test against production\r
-                       define("TEST_REQUEST", false);  \r
+                       define("TEST_REQUEST", false);\r
                }\r
                // You only need to adjust the two variables below if testing DPM\r
                define("AUTHORIZENET_MD5_SETTING","");                // Add your MD5 Setting.\r
                $REQUEST = $_REQUEST;\r
                if(authorizepayment($METHOD_TO_USE,$REQUEST,$address1,$city,$state,$country,$zipcode,$emailaddress,$plan))\r
                {\r
-                       $sql = "INSERT INTO `".$wpdb->prefix."payment` (`first_name`, `last_name`, `organization`, `address`, `city`, `country`, `state`, `zip`, `phone`, `email`, `donation_type`, `amount`, `invoice_num`,`comment`, `status`,`date`) \r
+                       $sql = "INSERT INTO `".$wpdb->prefix."payment` (`first_name`, `last_name`, `organization`, `address`, `city`, `country`, `state`, `zip`, `phone`, `email`, `donation_type`, `amount`, `invoice_num`,`comment`, `status`,`date`)\r
                        VALUES ('".$first_name."', '".$last_name."','".$organization."','".$address."','".$city."','".$country."','".$state."','".$zip."','".$phone."','".$email."','".$donation_type."','".$amount."','".$invoice_num."','".$comment."', '1',now());";\r
                        $wpdb->query($sql);\r
-                       \r
+\r
                        $post = get_post($post->ID);\r
                        $slug = $post->post_name;\r
-                        \r
+\r
                         // verification form submission to billing@gaslightmedia.com //////\r
                         $headers = "From: Gaslight Media <server@gaslightmedia.com>\r\n" .\r
                                    "Reply-To: noreply@gaslightmedia.com\r\n";\r
-                 \r
-                        $clientInfo =  "A payment has been made on the Gaslight Media website. Please review the billing information below\r\n" .         \r
+\r
+                        $clientInfo =  "A payment has been made on the Gaslight Media website. Please review the billing information below\r\n" .\r
                                             "First Name: " . $first_name . "\r\n" .\r
                                             "Last Name: " . $last_name . "\r\n" .\r
                                             "Invoice #: " . $invoice_num . "\r\n" .\r
                                             "Payment Amount: $". $amount . "\r\n" .\r
                                             "Organization: " . $organization;\r
-                        \r
+\r
                         $message = print_r($clientInfo, true);\r
                         mail( 'billing@gaslightmedia.com', 'GLM Payment Form', $message, $headers);\r
 \r
                        header("Location:".site_url().$_SERVER['REQUEST_URI']);\r
                        exit;\r
                }\r
-               \r
-       }\r
+\r
        }\r
+}\r
 \r
 function glm_payment_form() {\r
+    wp_enqueue_script('reCaptcha', 'https://www.google.com/recaptcha/api.js');\r
     ob_start();\r
         global $wpdb;\r
     ?>\r
@@ -102,9 +125,9 @@ function glm_payment_form() {
                                <tr><td style="color:red;" colspan="4"><?php echo $_SESSION['payment_msg']; $_SESSION['payment_msg']='';?></td></tr>\r
                                <tr>\r
                                        <td colspan="2" class="msg">\r
-                                               <p>For your convenience, you can pay your Invoices using our secured \r
-                                                    online credit card processing form.  If you would like to have your \r
-                                                    Invoice automatically paid monthly via credit card, please call \r
+                                               <p>For your convenience, you can pay your Invoices using our secured\r
+                                                    online credit card processing form.  If you would like to have your\r
+                                                    Invoice automatically paid monthly via credit card, please call\r
                                                     the office and we can set that up for you.\r
                                                 </p>\r
                                                 <p>\r
@@ -114,38 +137,38 @@ function glm_payment_form() {
                                </tr>\r
                                <tr>\r
                                        <td colspan="2" class="heading"><b>Billing information</b></td>\r
-                               </tr>                                   \r
-                               <tr>                    \r
+                               </tr>\r
+                               <tr>\r
                                        <td class="title_cell">First name<span class="required">*</span></td>\r
                                        <td class="field_cell">\r
                                                <input type="text" class="inputbox" name="first_name" id="first_name" value="" size="25" />\r
                                        </td>\r
                                </tr>\r
-                               <tr>                    \r
+                               <tr>\r
                                        <td class="title_cell">Last name<span class="required">*</span></td>\r
                                        <td class="field_cell">\r
                                                <input type="text" class="inputbox" name="last_name" value="" size="25" />\r
                                        </td>\r
                                </tr>\r
-                               <tr>                    \r
+                               <tr>\r
                                        <td class="title_cell">Organization</td>\r
                                        <td class="field_cell">\r
                                                <input type="text" class="inputbox" name="organization" value="" size="30" />\r
                                        </td>\r
                                </tr>\r
-                               <tr>                    \r
+                               <tr>\r
                                        <td class="title_cell">Address<span class="required">*</span></td>\r
                                        <td class="field_cell">\r
                                                <input type="text" class="inputbox" name="address" value="" size="50" />\r
                                        </td>\r
-                               </tr>   \r
-                               <tr>                    \r
+                               </tr>\r
+                               <tr>\r
                                        <td class="title_cell">City<span class="required">*</span></td>\r
                                        <td class="field_cell">\r
                                                <input type="text" class="inputbox" name="city" value="" size="15" />\r
                                        </td>\r
-                               </tr>           \r
-                               <tr style="display: none">                      \r
+                               </tr>\r
+                               <tr style="display: none">\r
                                        <td class="title_cell">Country<span class="required">*</span></td>\r
                                        <td class="field_cell">\r
                                                <select id="country" name="country" onchange="updateStateList();" >\r
@@ -397,8 +420,8 @@ function glm_payment_form() {
                                                <option value="Zimbabwe">Zimbabwe</option>\r
                                        </select>\r
                                        </td>\r
-                               </tr>   \r
-                               <tr>                    \r
+                               </tr>\r
+                               <tr>\r
                                        <td class="title_cell">State<span class="required">*</span></td>\r
                                        <td class="field_cell">\r
                                                <select id="state" name="state" class="">\r
@@ -457,45 +480,45 @@ function glm_payment_form() {
                                        </select>\r
                                        </td>\r
                                </tr>\r
-                               <tr>                    \r
+                               <tr>\r
                                        <td class="title_cell">Zip<span class="required">*</span></td>\r
                                        <td class="field_cell">\r
                                                <input type="text" class="inputbox" name="zip" value="" size="15" />\r
                                        </td>\r
                                </tr>\r
-                               <tr>                    \r
+                               <tr>\r
                                        <td class="title_cell">Phone</td>\r
                                        <td class="field_cell">\r
                                                <input type="text" class="inputbox" name="phone" value="" size="15" />\r
                                        </td>\r
-                               </tr>                                                                                                                                                                   \r
-                               <tr>                    \r
+                               </tr>\r
+                               <tr>\r
                                        <td class="title_cell">Email<span class="required">*</span></td>\r
                                        <td class="field_cell">\r
                                                <input type="text" class="inputbox" name="email" value="" size="40" />\r
                                        </td>\r
                                </tr>\r
                                <tr>\r
-                                       <td colspan="2" class="heading"><strong>Payment Information</strong></td>                       \r
+                                       <td colspan="2" class="heading"><strong>Payment Information</strong></td>\r
                                </tr>\r
-                               \r
-                               \r
+\r
+\r
                                <tr>\r
-                                       <td class="title_cell" valign="top">Amount<span class="required">*</span></td>                          \r
+                                       <td class="title_cell" valign="top">Amount<span class="required">*</span></td>\r
                                        <td id="amount_container">\r
-                                               $ <div style="display: inline-block"> \r
+                                               $ <div style="display: inline-block">\r
                                                     <input type="text" class="inputbox" name="amount" value="" onchange="deSelectRadio();" size="10" style="display: inline-block" />\r
                                                     </div>\r
                                        </td>\r
-                               </tr>   \r
-                                                               \r
+                               </tr>\r
+\r
                                <tr id="invoice_num" >\r
                                        <td class="title_cell">Invoice Number</td>\r
                                        <td class="field_cell">\r
                                                <input type="text" name="invoice_num" class="inputbox" value="" size="20" />\r
                                        </td>\r
                                </tr>\r
-                                 \r
+\r
                                <tr id="tr_card_type">\r
                                        <td class="title_cell">Card type<span class="required">*</span></td>\r
                                        <td class="field_cell">\r
@@ -505,7 +528,7 @@ function glm_payment_form() {
                                                        <option value="Discover">Discover</option>\r
                                                </select>\r
                                        </td>\r
-                               </tr>                           \r
+                               </tr>\r
                                <tr id="tr_card_number" >\r
                                        <td class="title_cell">Credit Card Number<span class="required">*</span></td>\r
                                        <td class="field_cell">\r
@@ -515,7 +538,7 @@ function glm_payment_form() {
                                <tr id="tr_exp_date" >\r
                                        <td class="title_cell">Expiration Date<span class="required">*</span>\r
                                        </td>\r
-                                       <td class="field_cell">                                 \r
+                                       <td class="field_cell">\r
                                                <select name="exp_month" class="inputbox exp_month" >\r
                                                        <option value="1" <?php if(date('m')=='01'){?>  selected="selected"<?php }?>>01</option>\r
                                                        <option value="2" <?php if(date('m')=='02'){?>  selected="selected"<?php }?>>02</option>\r
@@ -529,7 +552,7 @@ function glm_payment_form() {
                                                        <option value="10" <?php if(date('m')=='10'){?>  selected="selected"<?php }?>>10</option>\r
                                                        <option value="11" <?php if(date('m')=='11'){?>  selected="selected"<?php }?>>11</option>\r
                                                        <option value="12" <?php if(date('m')=='12'){?>  selected="selected"<?php }?>>12</option>\r
-                                               </select> / \r
+                                               </select> /\r
                                                <select id="exp_year" name="exp_year" class="inputbox exp_month" >\r
                                                        <?php $year = date(Y,time()); $num = 1;\r
                                                                while ( $num <= 7 ) {\r
@@ -545,9 +568,9 @@ function glm_payment_form() {
                                                <input type="text" name="x_card_code" class="inputbox" onKeyUp="checkNumber(this)" value="" size="20" />\r
                                        </td>\r
                                </tr>\r
-                                                               \r
-                               \r
-                               <tr>                    \r
+\r
+\r
+                               <tr>\r
                                        <td class="title_cell">Comment</td>\r
                                        <td class="field_cell">\r
                                                <textarea rows="7" cols="50" name="comment" class="inputbox"></textarea>\r
@@ -555,6 +578,7 @@ function glm_payment_form() {
                                </tr>\r
                                 <tr id="submit-button">\r
                                     <td>\r
+<div class="g-recaptcha" data-sitekey="6LfUdwoUAAAAAIgmh_g4FjYwiD0RbEpSQ34g_V9j"></div>\r
                                     <input type="button" class="button payment_btn_submit" name="btnSubmit" value="Submit" onclick="checkData();">\r
                                     </td>\r
                                </tr>\r
@@ -568,7 +592,7 @@ function glm_payment_form() {
                                recurrings[3] = 1 ;\r
                                recurrings[4] = 1 ;\r
                                recurrings[5] = 1 ;\r
-                               var countryIds = new Array(); \r
+                               var countryIds = new Array();\r
                                countryIds[0] = 1;\r
                                countryIds[1] = 2;\r
                                countryIds[2] = 3;\r
@@ -814,7 +838,7 @@ function glm_payment_form() {
                                countryIds[242] = 243;\r
                                countryIds[243] = 244;\r
                                countryIds[244] = 245;\r
-                               var countryNames = new Array(); \r
+                               var countryNames = new Array();\r
                                countryNames[0]= "Afghanistan"\r
                                countryNames[1]= "Albania"\r
                                countryNames[2]= "Algeria"\r
@@ -1081,47 +1105,47 @@ function glm_payment_form() {
                                methods.Add(method);\r
                                var currentCampaign = 0 ;\r
                                function checkData() {\r
-                                       var form = document.payment_form;                       \r
+                                       var form = document.payment_form;\r
                                        var minimumAmount = 1 ;\r
                                        var maximumAmount = 100000 ;\r
-                                                               \r
+\r
                                        if (form.first_name.value == '') {\r
                                                alert("Please enter your first name");\r
                                                form.first_name.focus();\r
                                                return ;\r
-                                       }                                               \r
+                                       }\r
                                        if (form.last_name.value=="") {\r
                                                alert("Please enter your last name");\r
                                                form.last_name.focus();\r
                                                return;\r
-                                       }                                               \r
+                                       }\r
                                        if (form.address.value=="") {\r
                                                alert("Please enter your address");\r
                                                form.address.focus();\r
-                                               return; \r
-                                       }                                               \r
+                                               return;\r
+                                       }\r
                                        if (form.city.value == "") {\r
                                                alert("Please enter your city");\r
                                                form.city.focus();\r
-                                               return; \r
-                                       }                                               \r
+                                               return;\r
+                                       }\r
                                        if (form.state.length > 1) {\r
                                                if (form.state.value =="") {\r
                                                        alert("Please enter your state");\r
                                                        form.state.focus();\r
-                                                       return; \r
+                                                       return;\r
                                                }\r
-                                       }                                                                                                                       \r
+                                       }\r
                                        if (form.zip.value == "") {\r
                                                alert("Please enter your zip");\r
                                                form.zip.focus();\r
                                                return;\r
-                                       }                                               \r
+                                       }\r
 //                                     if (form.country.value == "") {\r
 //                                             alert("Please enter your country");\r
 //                                             form.country.focus();\r
-//                                             return; \r
-//                                     }       \r
+//                                             return;\r
+//                                     }\r
 //                                        if (form.invoice_num.value == "") {\r
 //                                            alert("Please enter an invoice number");\r
 //                                            form.invoice_num.focus();\r
@@ -1131,22 +1155,22 @@ function glm_payment_form() {
 //                                             alert("Please enter your phone");\r
 //                                             form.phone.focus();\r
 //                                             return;\r
-//                                     }                                               \r
-                                                                               \r
+//                                     }\r
+\r
                                        if (form.email.value == '') {\r
                                                alert("Please enter your email");\r
                                                form.email.focus();\r
                                                return;\r
                                        }\r
-                                       \r
-                                        \r
+\r
+\r
                                        var emailFilter = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i\r
                                        var ret = emailFilter.test(form.email.value);\r
                                        if (!ret) {\r
                                                alert("Please enter a valid email");\r
                                                form.email.focus();\r
                                                return;\r
-                                       }                                                                       \r
+                                       }\r
                                        var amountValid = false ;\r
                                        var amount = 0 ;\r
                                        if (form.rd_amount) {\r
@@ -1155,29 +1179,29 @@ function glm_payment_form() {
                                                                if(form.rd_amount[i].checked == true) {\r
                                                                        amountValid = true ;\r
                                                                        amount = form.rd_amount[i].value ;\r
-                                                               }       \r
-                                                       }       \r
+                                                               }\r
+                                                       }\r
                                                } else if (form.rd_amount.checked == true) {\r
                                                        amountValid = true ;\r
                                                        amount = form.rd_amount.value ;\r
                                                }\r
-                                                                                                                       \r
+\r
                                        }\r
 \r
-                                       if (!amountValid) {                                                     \r
+                                       if (!amountValid) {\r
                                                if (parseFloat(form.amount.value)) {\r
                                                        amountValid = true;\r
-                                                       amount = form.amount.value ;    \r
-                                               }                               \r
-                                       }               \r
-                                                                               \r
-                                                                                                               \r
+                                                       amount = form.amount.value ;\r
+                                               }\r
+                                       }\r
+\r
+\r
                                        if (!amountValid) {\r
                                                var msg;\r
                                                        msg = "Please choose from pre-defined amounts or enter your own amount in the textbox";\r
                                                alert(msg);\r
-                                               return; \r
-                                       }                       \r
+                                               return;\r
+                                       }\r
 \r
 \r
                                        if (parseFloat(amount) < minimumAmount) {\r
@@ -1193,22 +1217,22 @@ function glm_payment_form() {
                                                return ;\r
                                        }\r
 \r
-                                       \r
-                                       \r
-                               \r
-                                                                                                       \r
-                                                                                                       \r
+\r
+\r
+\r
+\r
+\r
                                        var paymentMethod = "";\r
                                        paymentMethod = "os_authnet";\r
-                                                                               \r
-                                       method = methods.Find(paymentMethod);                           \r
+\r
+                                       method = methods.Find(paymentMethod);\r
                                        //Check payment method page\r
                                        if (method.getCreditCard()) {\r
                                                if (form.x_card_num.value == "") {\r
                                                        alert("Please enter creditcard number");\r
                                                        form.x_card_num.focus();\r
-                                                       return;                                 \r
-                                               }                                       \r
+                                                       return;\r
+                                               }\r
                                                if (form.x_card_code.value == "") {\r
                                                        alert("Please enter card code");\r
                                                        form.x_card_code.focus();\r
@@ -1221,51 +1245,51 @@ function glm_payment_form() {
                                                        form.card_holde_name.focus();\r
                                                        return ;\r
                                                }\r
-                                       }                       \r
+                                       }\r
                                        //This check is only used for echeck payment gateway\r
                                        if (paymentMethod == 'os_echeck') {\r
                                                if (form.x_bank_aba_code.value == '') {\r
                                                        alert("Please enter Bank ABA Routing Number");\r
                                                        form.x_bank_aba_code.focus();\r
                                                        return ;\r
-                                               }                               \r
+                                               }\r
                                                if (form.x_bank_acct_num.value == '') {\r
                                                        alert("Please enter Bank Account Number");\r
                                                        form.x_bank_aba_code.focus();\r
                                                        return ;\r
-                                               }                               \r
+                                               }\r
                                                if (form.x_bank_name.value == '') {\r
                                                        alert("Please enter Bank Name");\r
                                                        form.x_bank_name.focus();\r
-                                                       return ;                \r
-                                               }                               \r
+                                                       return ;\r
+                                               }\r
                                                if (form.x_bank_acct_name.value == '') {\r
                                                        alert("Please enter Account Holder Name");\r
                                                        form.x_bank_acct_name.focus();\r
                                                        return ;\r
-                                               }                               \r
-                                       }                               \r
-                                       \r
+                                               }\r
+                                       }\r
+\r
                                                form.submit();\r
-                                                                                                                                                                                                                               \r
-                               }                       \r
-                                                                                       \r
+\r
+                               }\r
+\r
                                function checkNumber(txtName)\r
-                               {                       \r
-                                       var num = txtName.value                 \r
-                                       if(isNaN(num))                  \r
-                                       {                       \r
-                                               alert("Only number is accepted");                       \r
-                                               txtName.value = "";                     \r
-                                               txtName.focus();                        \r
-                                       }                       \r
+                               {\r
+                                       var num = txtName.value\r
+                                       if(isNaN(num))\r
+                                       {\r
+                                               alert("Only number is accepted");\r
+                                               txtName.value = "";\r
+                                               txtName.focus();\r
+                                       }\r
                                }\r
 \r
 \r
                                function changeDonationType() {\r
                                        var form = document.payment_form ;\r
                                        var trFrequecy = document.getElementById('tr_frequency');\r
-                                       var trNumberDonatons = document.getElementById('tr_number_donations');                                                          \r
+                                       var trNumberDonatons = document.getElementById('tr_number_donations');\r
                                        if (form.donation_type[0].checked == true) {\r
                                                trFrequecy.style.display = 'none' ;\r
                                                if (trNumberDonatons)\r
@@ -1274,8 +1298,8 @@ function glm_payment_form() {
                                                trFrequecy.style.display = '' ;\r
                                                if (trNumberDonatons)\r
                                                        trNumberDonatons.style.display = '' ;\r
-                                       }       \r
-                               }       \r
+                                       }\r
+                               }\r
 \r
                                function deSelectRadio() {\r
                                        var form = document.payment_form ;\r
@@ -1288,9 +1312,9 @@ function glm_payment_form() {
                                                        }\r
                                                } else {\r
                                                        form.rd_amount.checked = false ;\r
-                                               }       \r
-                                                                                                               \r
-                                               }       \r
+                                               }\r
+\r
+                                               }\r
                                        } else {\r
                                                form.amount.value = '';\r
                                        }\r
@@ -1299,14 +1323,14 @@ function glm_payment_form() {
                                function clearTextbox() {\r
                                        var form = document.payment_form ;\r
                                        if (form.amount)\r
-                                               form.amount.value = ''; \r
-                               }               \r
-                                               \r
-                               function displayRecurring(show) {       \r
-                                       var form = document.payment_form ;              \r
+                                               form.amount.value = '';\r
+                               }\r
+\r
+                               function displayRecurring(show) {\r
+                                       var form = document.payment_form ;\r
                                        var trDonationType = document.getElementById('donation_type') ;\r
-                                       if (!trDonationType)  \r
-                                               return ;                        \r
+                                       if (!trDonationType)\r
+                                               return ;\r
                                        var trFrequency = document.getElementById('tr_frequency');\r
                                        var trNumberDonations = document.getElementById('tr_number_donations') ;\r
                                        if (show) {\r
@@ -1316,33 +1340,33 @@ function glm_payment_form() {
                                                        if (trNumberDonations) {\r
                                                                trNumberDonations.style.display = '';\r
                                                        }\r
-                                               }                               \r
+                                               }\r
                                        } else {\r
                                                trDonationType.style.display = 'none';\r
                                                trFrequency.style.display = 'none';\r
                                                if (trNumberDonations) {\r
                                                        trNumberDonations.style.display = 'none';\r
                                                }\r
-                                       }                       \r
+                                       }\r
                                }\r
 \r
 \r
-                               function checkCampaignRecurring() {                                     \r
+                               function checkCampaignRecurring() {\r
                                        var form = document.payment_form ;\r
                                        var show = 1 ;\r
                                        var paymentMethod = "";\r
                                         paymentMethod = "os_authnet";\r
-                                                       \r
+\r
                                        method = methods.Find(paymentMethod);\r
                                        if (!method.getEnableRecurring()) {\r
                                                show = 0 ;\r
                                        } else {\r
                                                if (form.campaign_id.value > 0)\r
                                                        show = recurrings [form.campaign_id.value] ;\r
-                                       }                                                       \r
+                                       }\r
                                        displayRecurring(show);\r
                                }\r
-                                                       \r
+\r
                                function updateAmount() {\r
                                        var form = document.payment_form ;\r
                                        var campaignId = form.campaign_id.value ;\r
@@ -1350,9 +1374,9 @@ function glm_payment_form() {
                                        //Check to enable and disable recurring\r
                                        var show = 1 ;\r
                                        if (campaignId)\r
-                                               show = recurrings [campaignId] ;                \r
-                                       displayRecurring(show);                                         \r
-                                                               \r
+                                               show = recurrings [campaignId] ;\r
+                                       displayRecurring(show);\r
+\r
                                }\r
                                function updateStateList() {\r
                                        var form = document.payment_form ;\r
@@ -1366,16 +1390,16 @@ function glm_payment_form() {
                                        list.length = 1 ;\r
                                        var i = 0;\r
                                        //Get the country index\r
-                                       var country = form.country.value ;                      \r
+                                       var country = form.country.value ;\r
                                        if (country != '') {\r
                                                //Find index of the country\r
                                                for (var i = 0 ; i < countryNames.length ; i++) {\r
-                                                       if (countryNames[i] == country) {                                               \r
+                                                       if (countryNames[i] == country) {\r
                                                                break ;\r
                                                        }\r
                                                }\r
                                                //We will find the states\r
-                                               var countryId = countryIds[i] ;                         \r
+                                               var countryId = countryIds[i] ;\r
                                                var stateNames = stateList[countryId]; ;\r
                                                if (stateNames) {\r
                                                        var arrStates = stateNames.split(',');\r
@@ -1391,12 +1415,12 @@ function glm_payment_form() {
                                                                list.options[i++] = opt;\r
                                                        }\r
                                                        list.lenght = i ;\r
-                                               }                                                               \r
-                                       }                                       \r
+                                               }\r
+                                       }\r
                                }\r
 \r
-                               </script>       \r
-                       \r
+                               </script>\r
+\r
 <?php\r
     $output = apply_filters( 'glm_payment_filter_form', ob_get_contents());\r
     ob_end_clean();\r