Fix form for the payment exp_month
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 3 Apr 2017 21:01:17 +0000 (17:01 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 3 Apr 2017 21:01:17 +0000 (17:01 -0400)
Also remove check for card and number.
Error given here is misleading people rather get the error from
Authorize.net.
Fixing the date when the record is inserted into database.

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

index 0b81b8d..e545419 100755 (executable)
@@ -4,7 +4,7 @@
        Plugin URI: www.gaslightmedia.com\r
        Description: Integration of the payment system using to AuthorizeNet.\r
        Author: Gaslight Media\r
-       Version: 1.0.6\r
+       Version: 1.0.7\r
 */\r
 session_start();\r
 \r
index b98772f..8fb2ebd 100755 (executable)
@@ -9,7 +9,7 @@
 */\r
 global $wpdb;\r
 if(isset($_REQUEST['action']))\r
-{  \r
+{\r
     if($_REQUEST['action']=='submitpayment')\r
     {\r
         // Check the form for reCaptcha\r
@@ -27,14 +27,14 @@ if(isset($_REQUEST['action']))
             ),\r
             'cookies' => array()\r
         ) );\r
-        \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
-            \r
+\r
             get_form_input();\r
             $_SESSION['payment_msg'] = 'Captcha did not verify!';\r
-            \r
+\r
             header("Location:".site_url().$_SERVER['REQUEST_URI']);\r
             exit;\r
         } else {\r
@@ -70,7 +70,7 @@ if(isset($_REQUEST['action']))
 \r
                // Adjust this to point to the Authorize.Net PHP SDK\r
                include dirname(__FILE__) .'/../anet_php_sdk/AuthorizeNet.php';\r
-        \r
+\r
                $METHOD_TO_USE = "AIM";\r
                $mysetting = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."payment_setting" );\r
                define("AUTHORIZENET_API_LOGIN_ID",$mysetting[0]->api_login);    // Add your API LOGIN ID\r
@@ -90,8 +90,9 @@ if(isset($_REQUEST['action']))
                $REQUEST = $_REQUEST;\r
                if(authorizepayment($METHOD_TO_USE,$REQUEST,$address1,$city,$state,$country,$zipcode,$emailaddress,$plan))\r
                {\r
+            date_default_timezone_set('America/Detroit');\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
+                       VALUES ('".$first_name."', '".$last_name."','".$organization."','".$address."','".$city."','".$country."','".$state."','".$zip."','".$phone."','".$email."','".$donation_type."','".$amount."','".$invoice_num."','".$comment."', '1','" . date( 'Y-m-d H:i:s' ) . "');";\r
                        $wpdb->query($sql);\r
 \r
                        $post = get_post($post->ID);\r
@@ -551,18 +552,18 @@ function glm_payment_form() {
                                        </td>\r
                                        <td class="field_cell">\r
                                                <select name="exp_month" class="inputbox exp_month" >\r
-                                                       <option value="1" <?php if(isset($_SESSION['exp_month'] ) && $_SESSION['exp_month'] === "1") echo "selected"; if(date('m')=='01'){?>  selected="selected"<?php }?>>01</option>\r
-                                                       <option value="2" <?php if(isset($_SESSION['exp_month'] ) && $_SESSION['exp_month'] === "2") echo "selected"; if(date('m')=='02'){?>  selected="selected"<?php }?>>02</option>\r
-                                                       <option value="3" <?php if(isset($_SESSION['exp_month'] ) && $_SESSION['exp_month'] === "3") echo "selected"; if(date('m')=='03'){?>  selected="selected"<?php }?>>03</option>\r
-                                                       <option value="4" <?php if(isset($_SESSION['exp_month'] ) && $_SESSION['exp_month'] === "4") echo "selected"; if(date('m')=='04'){?>  selected="selected"<?php }?>>04</option>\r
-                                                       <option value="5" <?php if(isset($_SESSION['exp_month'] ) && $_SESSION['exp_month'] === "5") echo "selected"; if(date('m')=='05'){?>  selected="selected"<?php }?>>05</option>\r
-                                                       <option value="6" <?php if(isset($_SESSION['exp_month'] ) && $_SESSION['exp_month'] === "6") echo "selected"; if(date('m')=='06'){?>  selected="selected"<?php }?>>06</option>\r
-                                                       <option value="7" <?php if(isset($_SESSION['exp_month'] ) && $_SESSION['state'] === "7") echo "selected"; if(date('m')=='07'){?>  selected="selected"<?php }?>>07</option>\r
-                                                       <option value="8" <?php if(isset($_SESSION['exp_month'] ) && $_SESSION['exp_month'] === "8") echo "selected"; if(date('m')=='08'){?>  selected="selected"<?php }?>>08</option>\r
-                                                       <option value="9" <?php if(isset($_SESSION['exp_month'] ) && $_SESSION['exp_month'] === "9") echo "selected"; if(date('m')=='09'){?>  selected="selected"<?php }?>>09</option>\r
-                                                       <option value="10" <?php if(isset($_SESSION['exp_month'] ) && $_SESSION['state'] === "10") echo "selected"; if(date('m')=='10'){?>  selected="selected"<?php }?>>10</option>\r
-                                                       <option value="11" <?php if(isset($_SESSION['state'] ) && $_SESSION['exp_month'] === "11") echo "selected"; if(date('m')=='11'){?>  selected="selected"<?php }?>>11</option>\r
-                                                       <option value="12" <?php if(isset($_SESSION['exp_month'] ) && $_SESSION['exp_month'] === "12") echo "selected"; if(date('m')=='12'){?>  selected="selected"<?php }?>>12</option>\r
+                                                       <option value="1"  <?php echo ($selectedMonth && $selectedMonth == "1")  ? "selected": '';?>>01</option>\r
+                                                       <option value="2"  <?php echo ($selectedMonth && $selectedMonth == "2")  ? "selected": '';?>>02</option>\r
+                                                       <option value="3"  <?php echo ($selectedMonth && $selectedMonth == "3")  ? "selected": '';?>>03</option>\r
+                                                       <option value="4"  <?php echo ($selectedMonth && $selectedMonth == "4")  ? "selected": '';?>>04</option>\r
+                                                       <option value="5"  <?php echo ($selectedMonth && $selectedMonth == "5")  ? "selected": '';?>>05</option>\r
+                                                       <option value="6"  <?php echo ($selectedMonth && $selectedMonth == "6")  ? "selected": '';?>>06</option>\r
+                                                       <option value="7"  <?php echo ($selectedMonth && $selectedMonth == "7")  ? "selected": '';?>>07</option>\r
+                                                       <option value="8"  <?php echo ($selectedMonth && $selectedMonth == "8")  ? "selected": '';?>>08</option>\r
+                                                       <option value="9"  <?php echo ($selectedMonth && $selectedMonth == "9")  ? "selected": '';?>>09</option>\r
+                                                       <option value="10" <?php echo ($selectedMonth && $selectedMonth == "10") ? "selected": '';?>>10</option>\r
+                                                       <option value="11" <?php echo ($selectedMonth && $selectedMonth == "11") ? "selected": '';?>>11</option>\r
+                                                       <option value="12" <?php echo ($selectedMonth && $selectedMonth == "12") ? "selected": '';?>>12</option>\r
                                                </select> /\r
                                                <select id="exp_year" name="exp_year" class="inputbox exp_month" >\r
                                                        <?php $year = date(Y,time()); $num = 1;\r
@@ -1430,7 +1431,7 @@ function glm_payment_form() {
 <?php\r
     $output = apply_filters( 'glm_payment_filter_form', ob_get_contents());\r
     ob_end_clean();\r
-    \r
+\r
     return $output;\r
 }\r
 \r
index 665cac4..e4f92ac 100755 (executable)
@@ -40,7 +40,7 @@ function authorizepayment($METHOD_TO_USE,$REQUEST,$address1='',$city='',$state='
                        }\r
                        else\r
                        {\r
-                               $_SESSION['payment_msg'] = $response->response_reason_text;                             \r
+                               $_SESSION['payment_msg'] = $response->response_reason_text;\r
                        }\r
                }\r
                elseif (count($REQUEST))\r
@@ -54,7 +54,7 @@ function authorizepayment($METHOD_TO_USE,$REQUEST,$address1='',$city='',$state='
                                        // Redirect the user back to your site.\r
                                        //$return_url = $site_root . 'thank_you_page.php?transaction_id=' .$response->transaction_id;\r
                    paymentemail();\r
-                                       \r
+\r
                                        return true;\r
                                }\r
                                else\r
@@ -62,19 +62,19 @@ function authorizepayment($METHOD_TO_USE,$REQUEST,$address1='',$city='',$state='
                                        // There was a problem. Do your logic here.\r
                                        // Redirect the user back to your site.\r
                                        $_SESSION['payment_msg'] = $response->response_reason_text;\r
-       \r
+\r
                                        header("Location:".site_url().$_SERVER['REQUEST_URI']);\r
                                        exit;\r
-               \r
+\r
                                }\r
                                echo AuthorizeNetDPM::getRelayResponseSnippet($return_url);\r
                        }\r
                        else\r
                        {\r
-                               $_SESSION['payment_msg'] =  "MD5 Hash failed. Check to make sure your MD5 Setting matches the one in";                          \r
+                               $_SESSION['payment_msg'] =  "MD5 Hash failed. Check to make sure your MD5 Setting matches the one in";\r
                        }\r
                }\r
-               \r
+\r
        }\r
 }\r
 \r
@@ -87,6 +87,8 @@ function checkInvoice($invoice_num) {
 }\r
 \r
 function checkCreditCard($cardnumber, $cardname, &$errornumber, &$errortext) {\r
+    // Get rid of the credit card check.\r
+    return true;\r
 \r
        // Define the cards we support. You may add additional card types.\r
        //  Name:      As in the selection box of the form - must be same as user's\r
@@ -199,7 +201,7 @@ function checkCreditCard($cardnumber, $cardname, &$errornumber, &$errortext) {
                $errortext = $ccErrors [$errornumber];\r
                return false;\r
        }\r
-        \r
+\r
 \r
        // Now check the modulus 10 check digit - if required\r
        if ($cards[$cardType]['checkdigit']) {\r