From: Chuck Scott Date: Tue, 29 Mar 2016 17:53:15 +0000 (-0400) Subject: Added option to just check ZIP code and not full address X-Git-Tag: v1.0.5^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=71c01d9e8a79d1d37fdca98e21d3100d19ae05bc;p=WP-Plugins%2Fglm-woocommerce-merchant-e-solutions-gateway.git Added option to just check ZIP code and not full address --- diff --git a/classes/glmMesGateway.php b/classes/glmMesGateway.php index 35cd46f..fe96f08 100644 --- a/classes/glmMesGateway.php +++ b/classes/glmMesGateway.php @@ -555,11 +555,19 @@ class GlmMesGateway extends WC_Payment_Gateway 'default' => 'no' ), - // Require Address Verification + // Require Full Address Verification 'address_verification' => array( 'title' => __('Require Address Verification', 'glm-merchant_e_solutions'), 'type' => 'checkbox', - 'label' => __('Check to require valid address verification before charging credit card.', 'glm-merchant_e_solutions'), + 'label' => __('Check to require valid address and ZIP/Postal code verification before charging credit card.
Overrides ZIP match option below.', 'glm-merchant_e_solutions'), + 'default' => 'no' + ), + + // Require ZIP Match + 'zip_verification' => array( + 'title' => __('Require ZIP Verification', 'glm-merchant_e_solutions'), + 'type' => 'checkbox', + 'label' => __('Check to require valid ZIP/Postal code verification before charging credit card.', 'glm-merchant_e_solutions'), 'default' => 'no' ), @@ -742,17 +750,21 @@ class GlmMesGateway extends WC_Payment_Gateway wc_add_notice('GLM MeS Gateway: Running Address Verification', 'success'); } - // Only run address verification test if selected - if ($this->settings['address_verification'] == 'yes') { + // Only run address and/or ZIP verification test if selected + if ($this->settings['address_verification'] == 'yes' || $this->settings['zip_verification'] == 'yes') { - $trans = new TpgSale($this->profile_id, $this->profile_key); + if (GLM_MES_DEBUG_VERBOSE) { + wc_add_notice('GLM MeS Gateway: Address Verification Requested', 'success'); + } - // Set transaction type to Address Verification Only - $trans->TranType = "A"; + $trans = new TpgSale($this->profile_id, $this->profile_key); - $sendRequestData = true; + // Set transaction type to Address Verification Only + $trans->TranType = "A"; - break; + $sendRequestData = true; + + break; // otherwise, no AVS, so say we're OK to go } else { @@ -910,6 +922,12 @@ class GlmMesGateway extends WC_Payment_Gateway $response['auth_response_descr'] = "The address you entered does not seem to match the address for this credit card. Please check your address and try again.
"; } + } elseif ($this->settings['zip_verification'] == 'yes') { + if ($response['avs_result'] == 'A' || !in_array($response['avs_result'], array('Z', 'Y', 'X'))) { + $auth = false; + $response['auth_response_descr'] = "The ZIP/Postal code you entered does not seem to match this credit card. + Please check your ZIP/Postal code and try again.
"; + } } else { if (GLM_MES_DEBUG_VERBOSE) { @@ -1108,13 +1126,18 @@ class GlmMesGateway extends WC_Payment_Gateway } // Check if Address Verification is required - if ($this->settings['address_verification'] == 'yes') { + if ($this->settings['zip_verification'] == 'yes' || $this->settings['address_verification'] == 'yes') { // Try Address Verification $response = $this->run_transaction('AVS'); // If AVS was successful - run sale if ($response['success']) { + + if (GLM_MES_DEBUG_VERBOSE) { + wc_add_notice('GLM MeS Gateway: Address Verification OK, running sale', 'success'); + } + $response = $this->run_transaction('Sale', false); } @@ -1143,12 +1166,11 @@ class GlmMesGateway extends WC_Payment_Gateway } else { // Tell the user we had a payment failure -// THE VARIABLE DATA NEEDS TO BE APPENDED RATHER THAT INCLUDED. woothemes is not our method title + // THE VARIABLE DATA NEEDS TO BE APPENDED RATHER THAT INCLUDED. woothemes is not our method title wc_add_notice( __( "

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

Reason: " . - $response['auth_response_text'] . - '

'.$response['auth_response_descr'], + $response['auth_response_descr']."

", 'woothemes'), 'error'); // Add a note to the customer order for reference