From: Chuck Scott Date: Fri, 11 Dec 2015 21:40:43 +0000 (-0500) Subject: Added check for missing CC info and blocking submit on "ENTER" key. X-Git-Tag: v1.0.4^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=a5601887d9b43b52f9f21013d0f67743a444bbb9;p=WP-Plugins%2Fglm-woocommerce-merchant-e-solutions-gateway.git Added check for missing CC info and blocking submit on "ENTER" key. --- diff --git a/classes/glmMesGateway.php b/classes/glmMesGateway.php index 585cc0f..35cd46f 100644 --- a/classes/glmMesGateway.php +++ b/classes/glmMesGateway.php @@ -331,6 +331,25 @@ class GlmMesGateway extends WC_Payment_Gateway )); } + + // Add script to checkout page to block + add_action( 'woocommerce_after_checkout_form', array($this, 'glmAddCheckoutPageScript')); + + } + + public function glmAddCheckoutPageScript() { + echo ' + + '; } // Tell WooCommerce that we exist @@ -996,31 +1015,6 @@ class GlmMesGateway extends WC_Payment_Gateway global $woocommerce; $this->cust_order = new WC_Order($order_id); - // Check for a maximum number of attempts - if ($this->check_max_attempts()) { - - wc_add_notice( - __( - '

We\'re sorry, there was a problem with your payment...

Reason:
' . - 'You have exceeded the maximum number of attempts to process your credit card.
- Please contact us for assistance.', - 'woothemes'), 'notice'); - - // Add a note to the customer order for reference - $this->cust_order->add_order_note( 'Error: '. 'Number of credit card processing attempts exceeded.' ); - - if (GLM_MES_DEBUG && ! GLM_MES_DEBUG_VERBOSE) { - wc_add_notice( - 'GLM MeS Gateway: Maximum attempts exceeded!', 'notice'); - } - - return array( - 'result' => 'failure', - 'redirect' => $this->get_return_url($this->cust_order) - ); - - } - // Get our invoice number $this->invNumb = str_replace("#", "", $this->cust_order->get_order_number()); @@ -1038,6 +1032,22 @@ class GlmMesGateway extends WC_Payment_Gateway $this->cc_cvc = (isset($_POST[GLM_MES_ID . '-card-cvc'])) ? $_POST[GLM_MES_ID . '-card-cvc'] : ''; + // Check for required credit card data + if (trim($this->ccNumb) == '' || trim($this->cc_exp) == '' || trim($this->cc_cvc) == '') { + + wc_add_notice( + __( + '

You have not supplied the required Credit Card information!

+ Please complete the credit card number, expiration date, and card code in the form below at the bottom of the page.', + 'woothemes'), 'notice'); + + return array( + 'result' => 'failure', + 'redirect' => $this->get_return_url($this->cust_order) + ); + + } + /* * Other data available from WooCommerce * @@ -1072,6 +1082,31 @@ class GlmMesGateway extends WC_Payment_Gateway print_r($this->cust_order, 1) . '

', 'success'); } + // Check for a maximum number of attempts + if ($this->check_max_attempts()) { + + wc_add_notice( + __( + '

We\'re sorry, there was a problem with your payment...

Reason:
' . + 'You have exceeded the maximum number of attempts to process your credit card.
+ Please contact us for assistance.', + 'woothemes'), 'notice'); + + // Add a note to the customer order for reference + $this->cust_order->add_order_note( 'Error: '. 'Number of credit card processing attempts exceeded.' ); + + if (GLM_MES_DEBUG && ! GLM_MES_DEBUG_VERBOSE) { + wc_add_notice( + 'GLM MeS Gateway: Maximum attempts exceeded!', 'notice'); + } + + return array( + 'result' => 'failure', + 'redirect' => $this->get_return_url($this->cust_order) + ); + + } + // Check if Address Verification is required if ($this->settings['address_verification'] == 'yes') { diff --git a/glm-woocommerce-merchant-e-solutions-gateway.php b/glm-woocommerce-merchant-e-solutions-gateway.php index ab20e26..f0100a5 100644 --- a/glm-woocommerce-merchant-e-solutions-gateway.php +++ b/glm-woocommerce-merchant-e-solutions-gateway.php @@ -3,7 +3,7 @@ * Plugin Name: GLM WooCommerce Merchant e-Solutions Gateway * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Merchant e-Solutions support for WooCommerce. Provides a payment gateway that will process WooCommerce payments and refunds through Merchant e-Solutions. For more information on Merchant e-Solutions see their Website at https://www.merchante-solutions.com/. - * Version: 1.0.3 + * Version: 1.0.4 * Author: Gaslight Media * Author URI: http://www.gaslightmedia.com/ * Text Domain: glm-woocommerce-merchant-e-solutions-gateway @@ -21,7 +21,7 @@ * @package glmMerchantESolutions * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.0.3 + * @version 1.0.4 */ /*