Fixed cc expiration date changing when checkout fails
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 10 Sep 2018 20:00:05 +0000 (16:00 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 10 Sep 2018 20:00:05 +0000 (16:00 -0400)
index.php
models/front/registrations/checkoutProcess.php
readme.txt

index 8812809..437738a 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
  * Plugin Name: GLM Associate - Event Registrations Add-On
  * Plugin URI: http://www.gaslightmedia.com/
  * Description: Add-on to integrate registrations into Events add-on.
- * Version: 1.0.15
+ * Version: 1.0.16
  * Author: Gaslight Media
  * Author URI: http://www.gaslightmedia.com/
  * License: GPL2
@@ -17,7 +17,7 @@
  * @package glmMembersRegistrationsAddOn
  * @author Chuck Scott <cscott@gaslightmedia.com>
  * @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.0.15
+ * @version 1.0.16
  */
 
 // Check that we're being called by WordPress.
@@ -41,7 +41,7 @@ if (!defined('ABSPATH')) {
  *  so that we're sure the other add-ons see an up to date
  *  version from this plugin.
  */
-define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION', '1.0.15');
+define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION', '1.0.16');
 define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_VERSION', '1.0.1');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
index 5e21183..9b2a523 100644 (file)
@@ -416,6 +416,8 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
                     'cc_name' => filter_input(INPUT_POST, 'cc_name', FILTER_SANITIZE_STRING),
                     'cc_numb' => filter_input(INPUT_POST, 'cc_numb', FILTER_SANITIZE_NUMBER_INT),
                     'cc_exp'  => filter_input(INPUT_POST, 'cc_exp', FILTER_SANITIZE_STRING),
+                    // Save the Expiration date in case a processor needs it in some other format and we need to return to the form
+                    'cc_exp_orig' => filter_input(INPUT_POST, 'cc_exp', FILTER_SANITIZE_STRING),
                     'cc_cvv'  => filter_input(INPUT_POST, 'cc_cvv', FILTER_SANITIZE_NUMBER_INT)
                 );
 
@@ -794,8 +796,27 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
             // Include the billing info same flag
             $regAccount['billingSame'] = $billingSame;
 
+            // Build failure message text to append to request notes field.
+            $failNotes = "Checkout Failure: ".date('l F j, Y g:i a')."\n";
+            if (is_array($messages) && count($messages > 0)) {
+                foreach ($messages as $mess) {
+                    $failNotes .= '* '.$mess."\n";
+                }
+            }
+            $failNotes .= '\n';
+
+            // Append failure message text to request notes field.
+            $updated = $this->wpdb->query("
+                update ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request
+                set notes = concat(COALESCE(notes,''), '$failNotes')
+                where id = $requestId
+            ");
+
             $view = 'checkout';
 
+            // Restore original card expiration date in case it was changed
+            $cardData['cc_exp'] = $cardData['cc_exp_orig'];
+
             $templateData = array(
                 'request'      => array('page' => 'checkout'),
                 'haveMessages' => count($messages),
index 1b90253..0eb4604 100755 (executable)
@@ -25,6 +25,9 @@ e.g.
 1. Activate the plugin through the 'Plugins' menu in WordPress
 
 == Changelog ==
+= 1.0.16 =
+* Fixed card expiration date changing when user fails at checkout page and checkout is redisplayed
+
 = 1.0.15 =
 * Hotfix to fix confusion with database version number for create and drop scripts