From ae2b7fdd0183acbdf7f731cea10cea310d657fc1 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Thu, 23 Apr 2015 16:51:44 -0400 Subject: [PATCH] First certified version of plugin. --- NOTES.txt | 6 + assets/checkout_tests.html | 63 + assets/index.php | 2 + classes/MesTridentGateway.php | 12 +- classes/glmMesGateway.php | 1039 +++++++++++++---- classes/index.php | 2 + defines.php | 4 + ...ocommerce-merchant-e-solutions-gateway.php | 108 ++ i18n/languages/default.pot | 366 ++++++ i18n/languages/do_xgettext | 2 + ...ocommerce-merchant-e-solutions-gateway.pot | 27 + i18n/languages/index.php | 2 + index.php | 103 +- readme.txt | 67 +- views/paymentForm.php | 84 -- woo-includes/class-wc-dependencies.php | 31 + woo-includes/index.php | 2 + woo-includes/woo-functions.php | 20 + 18 files changed, 1511 insertions(+), 429 deletions(-) create mode 100644 NOTES.txt create mode 100644 assets/checkout_tests.html create mode 100644 assets/index.php create mode 100644 classes/index.php create mode 100644 glm-woocommerce-merchant-e-solutions-gateway.php create mode 100644 i18n/languages/default.pot create mode 100755 i18n/languages/do_xgettext create mode 100644 i18n/languages/glm-woocommerce-merchant-e-solutions-gateway.pot create mode 100644 i18n/languages/index.php delete mode 100644 views/paymentForm.php create mode 100644 woo-includes/class-wc-dependencies.php create mode 100644 woo-includes/index.php create mode 100644 woo-includes/woo-functions.php diff --git a/NOTES.txt b/NOTES.txt new file mode 100644 index 0000000..860210c --- /dev/null +++ b/NOTES.txt @@ -0,0 +1,6 @@ +Development Notes +----------------- + + +* Do I need the following??? + diff --git a/assets/checkout_tests.html b/assets/checkout_tests.html new file mode 100644 index 0000000..dadaa7e --- /dev/null +++ b/assets/checkout_tests.html @@ -0,0 +1,63 @@ + + + + + + +

GLM MES Payment Gateway Test Information

+

+ Any valid credit card number may be used when the "Transaction Mode" is set to "Test Mode". + In test mode, all transactions are simulated and will not impact the cardholder's account. +

+ +

Credit Card Test Numbers

+
+            Cart Type         Card Number
+            ----------------- -----------------
+            Visa 16 digit     4012301230123010
+            Visa 13 digit     4012301230158
+            MasterCard        5123012301230120 
+            American Express  349999999999991
+            Discover          6011011231231235 
+            JCB               3528288605211810
+        
+ +

Address Verification Tests

+

+ The following test data and responses may be helpful for testing this payment gateway + and validating that a particular implementation is functioning properly. +

+
+            Address Verification Tests
+            Street #     ZIP/postal code   Result 
+            ------------ ---------------- --------------------------------------------------------
+            123          55555            Y - street and postal code match
+            123          999991111        Y - street and postal code match (Visa) 
+                                          X - street and postal code match (MasterCard)
+            123          EH8 9ST          D - exact match, international 
+            123          Other Zip        A - address match, zip mismatch 
+            234          Any Zip          U - address unavailable   
+            345          Any Zip          G - verification unavailable due to international 
+                                              issuer non-participation (Visa and MasterCard only)
+            456          Any Zip          R - issuer system unavailable, retry 
+            235          Any Zip          S - AVS not supported 
+            (other)      55555            Z - address mismatch, 5-digit zip match 
+            (other)      EH8 9ST          Z - address mismatch, international zip match  
+        
+ +

Credit Card Security Code Tests

+
+            CCV, CVC, CID Code Tests
+            Code             Result
+            ---------------- ------------------------------
+            123              M - Match
+            234              P - Not Processed
+            345              U - Issuer is not certified
+            (other 3 digit)  N - No Match
+            1234 (AMEX)      M - Match
+            2345 (AMEX)      P - Not Processed
+            (other 4 digit)  N - No Match
+        
+ + + \ No newline at end of file diff --git a/assets/index.php b/assets/index.php new file mode 100644 index 0000000..7e91415 --- /dev/null +++ b/assets/index.php @@ -0,0 +1,2 @@ +id = GLM_MES_ID; - - // Title of gateway and description displayed in WooCommerce Checkout configuration pages - $this->method_title = __( GLM_MES_SHORT_NAME, GLM_MES_ID ); - $this->method_description = __( GLM_MES_DESCRIPTION, GLM_MES_ID ); - - // Icon displayed with gateway in checkout page - $this -> icon = GLM_MES_ICON; + $this->name = GLM_MES_NAME; + $this->text_domain = GLM_MES_DIR; + + $this->respDescr = array( + + '001' => __('Please contact your credit card issuer or try another card.', 'glm-merchant_e_solutions'), + '002' => __('Please contact your credit card issuer or try another card', 'glm-merchant_e_solutions'), + '004' => __('Your card may not be used at this time. Please contact your credit card issuer or try another card.', 'glm-merchant_e_solutions'), + '005' => __('Your purchase using this credit card has been declined. If you have another credit card, you may try that at this time.', 'glm-merchant_e_solutions'), + '007' => __('Please contact your credit card issuer or try another card', 'glm-merchant_e_solutions'), + '014' => __('Your credit card number appears to be incorrect. Please check the card number you entered and try again.', 'glm-merchant_e_solutions'), + '015' => __('Your credit card number appears to be incorrect. Please check the card number you entered and try again.', 'glm-merchant_e_solutions'), + '019' => __('Your card was not successfully processed. Please try again. If you continue to get this response, please call for assistance.', 'glm-merchant_e_solutions'), + '041' => __('Please contact your credit card issuer or try another card.', 'glm-merchant_e_solutions'), + '043' => __('Please contact your credit card issuer or try another card.', 'glm-merchant_e_solutions'), + '051' => __('Your card is not currently able to cover the cost of this purchase. Delete contents from your cart or try again later.', 'glm-merchant_e_solutions'), + '054' => __('Your card appears to be expired. Please check your credit card information below or try another card.', 'glm-merchant_e_solutions'), + '057' => __('This purchase is not permitted with your credit card. Please contact your credit card issuer or try another card.', 'glm-merchant_e_solutions'), + '059' => __('Please contact your credit card issuer or try another card.', 'glm-merchant_e_solutions'), + '084' => __('There was a problem processing your credit cart. If you continue to get this response, please call for assistance.', 'glm-merchant_e_solutions'), + '110' => __('We do not accept this type of credit card. Please try another card or call for assistance.', 'glm-merchant_e_solutions'), + '114' => __('You did not supply all required credit card information. Please check your credit card payment information below.', 'glm-merchant_e_solutions'), + '210' => __('The address you entered did not satisfactorlly match the cardholder\'s address.', 'glm-merchant_e_solutions'), + '211' => __('The card security code (3 or 4 digit code, usually on the back of the card) did not match.', 'glm-merchant_e_solutions') - // Displays checkout fields for "direct" integration - $this->has_fields = true; - - // Supports the default credit card form - $this->supports = array( 'default_credit_card_form' ); + ); - // Setup Fields and Settings - $this->init_form_fields(); - $this->init_settings(); + $this->amountDrivenTests = array( + '' => __('(none)', 'glm-merchant_e_solutions'), + '0.00' => '$0.00'.__('Card OK', 'glm-merchant_e_solutions'), + '0.01' => '$0.01'.__('Call', 'glm-merchant_e_solutions'), + '0.02' => '$0.02'.__('Call - special condition', 'glm-merchant_e_solutions'), + '0.04' => '$0.04'.__('Hold-call - pick up card (no fraud)', 'glm-merchant_e_solutions'), + '0.05' => '$0.05'.__('Decline - do not honor', 'glm-merchant_e_solutions'), + '0.07' => '$0.07'.__('Hold-call - pick up card (fraud)', 'glm-merchant_e_solutions'), + '0.14' => '$0.14'.__('Card # error', 'glm-merchant_e_solutions'), + '0.15' => '$0.15'.__('No such issuer', 'glm-merchant_e_solutions'), + '0.19' => '$0.19'.__('Re-enter transaction', 'glm-merchant_e_solutions'), + '0.41' => '$0.41'.__('Hold-call - pickup card (fraud: lost card)', 'glm-merchant_e_solutions'), + '0.43' => '$0.43'.__('Hold-call - pickup card (fraud: stolen card)', 'glm-merchant_e_solutions'), + '0.51' => '$0.51'.__('Decline - insufficient funds', 'glm-merchant_e_solutions'), + '0.54' => '$0.54'.__('Expired card', 'glm-merchant_e_solutions'), + '0.57' => '$0.57'.__('Transaction not permitted to cardholder', 'glm-merchant_e_solutions'), + '0.59' => '$0.59'.__('Suspected fraud', 'glm-merchant_e_solutions'), + '0.84' => '$0.84'.__('Invalid Auth', 'glm-merchant_e_solutions'), + '0.86' => '$0.86'.__('Unable to validate pin (not used in this plugin)', 'glm-merchant_e_solutions'), + '1.10' => '$1.10'.__('Card type not accepted by merchant', 'glm-merchant_e_solutions') + ); - // Get the title and description for this checkout method to use in checkout page - $this->title = $this->get_option( 'title' ); - $this->description = $this->get_option( 'description' ); + // Add filter for our gateway + add_filter('woocommerce_payment_gateways', + array( + $this, + 'glmMesAddGateway' + )); + + // Add localization + add_action('init', + array( + $this, + 'load_plugin_textdomain' + )); - // Add credit cards available to the description - $this->description .= '

Credit Cards Accepted

' - .($this->settings['visa'] == 'yes' ? '' : '') - .($this->settings['mastercard'] == 'yes' ? '' : '') - .($this->settings['amex'] == 'yes' ? '' : '') - .'

'; + $this->id = GLM_MES_ID; - // Set the transaction mode selected in the WooCommerce Checkout configuration page for this gateway - $this -> transaction_mode = $this->settings['transaction_mode']; + // Is WooCommerce activated? + if (! in_array('woocommerce/woocommerce.php', + apply_filters('active_plugins', get_option('active_plugins')))) { - // Determine if we're in test or production mode - switch ($this -> settings['transaction_mode']) { + if (is_admin()) { + add_action('admin_notices', + array( + $this, + 'woocommerce_missing_notice' + )); + } + return false; + + } elseif (defined('WC_VERSION') && + version_compare(WC_VERSION, GLM_MES_REQUIRED_WOO_VERSION, '>=')) { + + // Title of gateway and description displayed in WooCommerce Checkout configuration pages + $this->method_description = __('A Merchant e-Solutions payment Gateway plug-in for WooCommerce.', 'glm-merchant_e_solutions'); + + // Icon displayed with gateway in checkout page + $this->icon = GLM_MES_ICON; + + // Displays checkout fields for "direct" integration + $this->has_fields = true; + + // Supports the default credit card form + $this->supports = array( + 'default_credit_card_form', + 'refunds' + ); + + // Setup Fields and Settings + $this->init_form_fields(); + $this->init_settings(); + + // Get the title and description for this checkout method to use on + // the checkout page + $this->title = $this->settings['title']; + $this->description = $this->settings['description']; + + $this->settings['address_verification'] == $this->settings['address_verification']; + $this->settings['cvv_required'] = $this->settings['cvv_required']; + + // Add credit cards available to the description + $this->description .= '

Credit Cards Accepted

' . ($this->settings['visa'] == + 'yes' ? '' : '') . ($this->settings['mastercard'] == + 'yes' ? '' : '') . ($this->settings['amex'] == + 'yes' ? '' : '') . ($this->settings['discover'] == + 'yes' ? '' : '') . '

'; + + // Check for SSL + add_action('admin_notices', array( + $this, + 'ssl_check' + )); + + // Set the transaction mode selected in the WooCommerce Checkout + // configuration page for this gateway + $this->transaction_mode = $this->settings['transaction_mode']; + + // Determine if we're in test or production mode + switch ($this->settings['transaction_mode']) { + + case 'test': + $this->profile_id = $this->settings['test_profile_id']; + $this->profile_key = $this->settings['test_profile_key']; + $this->host = $this->settings['test_url']; + $this->amount_driven_test = $this->settings['amount_driven_test']; + break; + + case 'production': + $this->profile_id = $this->settings['prod_profile_id']; + $this->profile_key = $this->settings['prod_profile_key']; + $this->host = $this->settings['prod_url']; + break; + } + + // Set debug defines + if (! defined('GLM_MES_DEBUG')) { + $d = ($this->settings['mes_debug'] == 'yes'); + define('GLM_MES_DEBUG', $d); + $d = ($this->settings['mes_debug_verbose'] == 'yes'); + define('GLM_MES_DEBUG_VERBOSE', $d); + } + + // Process admin options + if (is_admin()) { + add_action( + 'woocommerce_update_options_payment_gateways_' . $this->id, + array( + $this, + 'process_admin_options' + )); + } - case 'test': - $this->profile_id = $this -> settings['test_profile_id']; - $this->profile_key = $this -> settings['test_profile_key']; - $this->host = $this -> settings['test_url']; - break; + } else { - case 'production': - $this->profile_id = $this -> settings['prod_profile_id']; - $this->profile_key = $this -> settings['prod_profile_key']; - $this->host = $this -> settings['prod_url']; - break; + if (is_admin()) { + add_action('admin_notices', + array( + $this, + 'upgrade_notice' + )); + } + return false; } - if (!defined('GLM_MES_DEBUG')) { - $d = ($this -> settings['mes_debug'] == 'yes'); - define('GLM_MES_DEBUG', $d); - $d = ($this -> settings['mes_debug_verbose'] == 'yes'); - define('GLM_MES_DEBUG_VERBOSE', $d); + // Add Checkout Page Messsages + if (!is_admin()) { + add_action('woocommerce_before_checkout_form', + array( + $this, + 'glmMesCheckoutMessages' + )); } - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); - } // Tell WooCommerce that we exist - public function glmMesAddGateway( $methods ) + public function glmMesAddGateway ($methods) { $methods[] = 'GlmMesGateway'; + return $methods; } - /* - * Initialize Form Fields + // Place message at top of checkout page + public function glmMesCheckoutMessages ($methods) + { + static $msg_sent = false; + + if ($this->settings['transaction_mode'] == 'test') { + + if (!$msg_sent) { + wc_add_notice('PAYMENT GATEWAY OPERATING IN TEST MODE
+

+ The credit card payment gateway is operating in test mode. + All transactions are simulated. There will be no impact on cardholder\'s account, + nor will there be any actual funds transfered to the merchant account. + Click below for a list of card numbers, addresses, and card security codes that may be used + for testing. +
+ Show Test Options +
+ Also note that "Amount Driven Tests" may be selected in "WooCommerce" -> "Settings" -> "Checkout" -> "GLM Merchant e-Solutions" +

+ ', 'notice'); + + $msg_sent = true; + } + } + } + + /** + * Check if SSL has been set for checkout + * Warn admin user if not. + * + * @access public + * @return + * + */ + public function ssl_check () + { + // This is used to prevent duplicate messages + static $ssl_check_sent = false; + + if ($this->enabled == "yes" && ! $ssl_check_sent) { + if (get_option('woocommerce_force_ssl_checkout') == "no") { +//**** USE ONLY SINGLE QUOTES + echo "

" . + sprintf( + __( + " + %s is enabled and WooCommerce is not forcing the + SSL certificate on your checkout page.
Please ensure that you have + a valid SSL certificate and that you are forcing + the checkout pages to be secured.", + 'glm-merchant_e_solutions'), + GLM_MES_SHORT_NAME, + admin_url('admin.php?page=wc-settings&tab=checkout')) . + "

"; + $ssl_check_sent = true; + } + } + } + + /** + * WooCommerce Payment Gateway Upgrade Notice. * - * Add form fields to the WooCommerce Checkout page for this gateway + * @access public + * @return string */ + public function upgrade_notice () + { + echo '

' . + sprintf( + __( + '%s depends on version %s and up of WooCommerce! Please upgrade before activating.', + 'glm-merchant_e_solutions'), $this->name, + GLM_MES_REQUIRED_WOO_VERSION) . '

'; + } + /** + * Load Localisation files. + * + * Note: the first-loaded translation file overrides any + * following ones if the same translation is present. + * + * @access public + * @return void + */ + public function load_plugin_textdomain () + { + // Set filter for plugin's languages directory + $lang_dir = dirname(plugin_basename(__FILE__)) . '/languages/'; + $lang_dir = apply_filters( + 'woocommerce_' . GLM_MES_SLUG . '_languages_directory', + GLM_MES_LANGUAGE_PATH); + + // Traditional WordPress plugin locale filter + $locale = apply_filters('plugin_locale', get_locale(), + $this->text_domain); + $mofile = sprintf('%1$s-%2$s.mo', $this->text_domain, $locale); + + // Setup paths to current locale file + $mofile_local = GLM_MES_LANGUAGE_PATH . $mofile; + $mofile_global = WP_LANG_DIR . '/' . $this->text_domain . '/' . $mofile; + if (file_exists($mofile_global)) { + + // Look in global /wp-content/languages/plugin-name/ folder + load_textdomain($this->text_domain, $mofile_global); + } else + if (file_exists($mofile_local)) { + // Look in local /wp-content/plugins/plugin-name/languages/ + // folder + load_textdomain($this->text_domain, $mofile_local); + } else { + // Load the default language files + load_plugin_textdomain($this->text_domain, false, $lang_dir); + } + } - public function init_form_fields() + /* + * Initialize Form Fields + * + * Add form fields to the WooCommerce Checkout page for this gateway + */ + public function init_form_fields () { $this->form_fields = array( // Enable gateway chackbox 'enabled' => array( - 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'title' => __('Enable/Disable', 'glm-merchant_e_solutions'), 'type' => 'checkbox', - 'label' => __( 'Enable Merchant e-Solutions Gateway', 'woocommerce' ), + 'label' => __('Enable Merchant e-Solutions Gateway', + 'glm-merchant_e_solutions'), 'default' => 'yes' ), // Title displayed to user for this payment method 'title' => array( - 'title' => __( 'Title', 'woocommerce' ), + 'title' => __('Title', 'glm-merchant_e_solutions'), 'type' => 'text', - 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), - 'default' => __( 'Credit Card Payment', 'woocommerce' ), - 'desc_tip' => true, + 'description' => __( + 'This controls the title which the user sees during checkout.', + 'glm-merchant_e_solutions'), + 'default' => __('Credit Card Payment', 'glm-merchant_e_solutions'), + 'desc_tip' => true ), // Description to customer at checkout 'description' => array( - 'title' => __( 'Description', 'woocommerce' ), + 'title' => __('Description', 'glm-merchant_e_solutions'), 'type' => 'textarea', 'default' => 'A description of this payment method to the user at checkout. Include cards accepted, etc.' ), 'sep_0' => array( - 'title' => __( 'Credit Cards Accepted', 'woocommerce' ), - 'type' => 'title', - 'description' => '', + 'title' => __('Credit Cards Accepted', 'glm-merchant_e_solutions'), + 'type' => 'title', + 'description' => '' ), // Visa 'visa' => array( - 'title' => __( '', 'woocommerce' ), - 'type' => 'checkbox', - 'label' => __( 'Visa', 'woocommerce' ), - 'desc_tip' => false, + 'title' => '', + 'type' => 'checkbox', + 'label' => __('Visa', 'glm-merchant_e_solutions'), + 'desc_tip' => false, 'default' => 'no' ), // MasterCard 'mastercard' => array( - 'title' => __( '', 'woocommerce' ), - 'type' => 'checkbox', - 'label' => __( 'MasterCard', 'woocommerce' ), - 'desc_tip' => false, + 'title' => '', + 'type' => 'checkbox', + 'label' => __('MasterCard', 'glm-merchant_e_solutions'), + 'desc_tip' => false, 'default' => 'no' ), // Amex 'amex' => array( - 'title' => __( '', 'woocommerce' ), - 'type' => 'checkbox', - 'label' => __( 'American Express', 'woocommerce' ), - 'desc_tip' => false, + 'title' => '', + 'type' => 'checkbox', + 'label' => __('American Express', 'glm-merchant_e_solutions'), + 'desc_tip' => false, + 'default' => 'no' + ), + + // Discover + 'discover' => array( + 'title' => '', + 'type' => 'checkbox', + 'label' => __('Discover', 'glm-merchant_e_solutions'), + 'desc_tip' => false, + 'default' => 'no' + ), + + // Require 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'), + 'default' => 'no' + ), + + // Require Credit Card CCV/CVC/CID + 'cvv_required' => array( + 'title' => __('Require CVV/CVC/CID', 'glm-merchant_e_solutions'), + 'type' => 'checkbox', + 'label' => __('Check to require a valid credit card CVV/CVC/CID when charging card.', 'glm-merchant_e_solutions'), 'default' => 'no' ), 'sep_1' => array( - 'title' => __( 'Test Mode Credentials', 'woocommerce' ), - 'type' => 'title', - 'description' => '', + 'title' => __('Test Mode Credentials', 'glm-merchant_e_solutions'), + 'type' => 'title', + 'description' => '' ), // MeS Gateway Profile ID 'test_profile_id' => array( - 'title' => __( 'Test Profile ID', 'woocommerce' ), + 'title' => __('Test Profile ID', 'glm-merchant_e_solutions'), 'type' => 'text', - 'default' => __( '9410000xxxxx00000001', 'woocommerce' ), - 'desc_tip' => false, + 'desc_tip' => false, + 'placeholder' => '9410000xxxxx00000001' ), // MeS Gateway Profile Key 'test_profile_key' => array( - 'title' => __( 'Test Profile Key', 'woocommerce' ), + 'title' => __('Test Profile Key', 'glm-merchant_e_solutions'), 'type' => 'text', - 'default' => __( 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'woocommerce' ), - 'desc_tip' => false, + 'desc_tip' => false, + 'placeholder' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ), // MeS Gateway Test URL 'test_url' => array( - 'title' => __( 'Test URL', 'woocommerce' ), + 'title' => __('Test URL', 'glm-merchant_e_solutions'), 'type' => 'text', - 'default' => __( 'https://cert.merchante-solutions.com/mes-api/tridentApi', 'woocommerce' ), - 'desc_tip' => false, + 'default' => 'https://cert.merchante-solutions.com/mes-api/tridentApi', + 'desc_tip' => false ), 'sep_2' => array( - 'title' => __( '

 

Production Mode Credentials', 'woocommerce' ), - 'type' => 'title', - 'description' => '', + 'title' => '

 

'.__( + 'Production Mode Credentials', + 'glm-merchant_e_solutions'), + 'type' => 'title', + 'description' => '' ), // MeS Gateway Profile ID 'prod_profile_id' => array( - 'title' => __( 'Production Profile ID', 'woocommerce' ), + 'title' => __('Production Profile ID', 'glm-merchant_e_solutions'), 'type' => 'text', - 'default' => __( '9410000xxxxx00000001', 'woocommerce' ), - 'desc_tip' => false, + 'desc_tip' => false, + 'placeholder' => '9410000xxxxx00000001' ), // MeS Gateway Profile Key 'prod_profile_key' => array( - 'title' => __( 'Production Profile Key', 'woocommerce' ), + 'title' => __('Production Profile Key', 'glm-merchant_e_solutions'), 'type' => 'text', - 'default' => __( 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'woocommerce' ), - 'desc_tip' => false, + 'desc_tip' => false, + 'placeholder' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ), // MeS Gateway Test URL 'prod_url' => array( - 'title' => __( 'Production URL', 'woocommerce' ), + 'title' => __('Production URL', 'glm-merchant_e_solutions'), 'type' => 'text', - 'default' => __( 'https://cert.merchante-solutions.com/mes-api/tridentApi', 'woocommerce' ), - 'desc_tip' => false, + 'default' => 'https://cert.merchante-solutions.com/mes-api/tridentApi', + 'desc_tip' => false ), 'sep_3' => array( - 'title' => __( '

 

Mode Selection', 'woocommerce' ), - 'type' => 'title', - 'description' => '', + 'title' => '

 

'.__('Mode Selection', 'glm-merchant_e_solutions'), + 'type' => 'title', + 'description' => '' ), // Set Transaction Mode 'transaction_mode' => array( - 'title' => __( 'Transaction Mode', 'woocommerce' ), - 'type' => 'select', - 'label' => __( 'Must be in "Production Mode" for live transactions.', 'woocommerce' ), - 'description' => __( 'See MeS Payment Certification Form to apply for required ID and Key below.', 'woocommerce' ), - 'default' => 'test', - 'desc_tip' => false, - 'options' => array( - 'test' => __( 'Test Mode', 'woocommerce' ), - 'production' => __( 'Production Mode', 'woocommerce' ) + 'title' => __('Transaction Mode', 'glm-merchant_e_solutions'), + 'type' => 'select', + 'label' => __( + 'Must be in "Production Mode" for live transactions.', + 'glm-merchant_e_solutions' + ), + 'description' => sprintf( + __('See %s MeS Payment Certification Form to apply for required ID and Key.', + 'glm-merchant_e_solutions'), + '' + ), + 'default' => 'test', + 'desc_tip' => false, + 'options' => array( + 'test' => __('Test Mode', 'glm-merchant_e_solutions'), + 'production' => __('Production Mode', 'glm-merchant_e_solutions') ) ), + // Amount driven Transaction Tests + 'amount_driven_test' => array( + 'title' => __('Amount Driven Tests', 'glm-merchant_e_solutions'), + 'type' => 'select', + 'description' => __('Selecting an amount driven test will set the payment amount for the transaction to the specific value + and will cause the payment gateway to return the associated respose. This may be used to test all + possible response types that might be experienced in production use.', 'glm-merchant_e_solutions') + .'
' + .__('Show Additional Test Options', 'glm-merchant_e_solutions').'', + 'options' => $this->amountDrivenTests, + 'default' => '', + 'desc_tip' => false + ), + // Set Debug Mode 'mes_debug' => array( - 'title' => __( 'Enable Debug Information', 'woocommerce' ), + 'title' => __('Enable Debug Information', 'glm-merchant_e_solutions'), 'type' => 'checkbox', - 'label' => __( '', 'woocommerce' ), + 'label' => __('Check to enable debug output on checkout page.', 'glm-merchant_e_solutions'), 'default' => 'no' ), // Set Debug Verbose Mode 'mes_debug_verbose' => array( - 'title' => __( 'Enable Verbose Debug', 'woocommerce' ), + 'title' => __('Enable Verbose Debug', 'glm-merchant_e_solutions'), 'type' => 'checkbox', - 'label' => __( '', 'woocommerce' ), + 'label' => __('Check to enable verbose output on checkout page.', 'glm-merchant_e_solutions'), 'default' => 'no' ) - ); + } + /* + * Perform any required field validation + * + * No additional validation at this time + */ + public function validate_fields() + { + return true; } -/* - // Set Payment Fields - public function payment_fields() + /* + * Run PreAuth to check address and CSV if set + * + * + * @var string $tans_type 'PreAuth', 'Settle', 'Sale', or 'Refund' + * @var float $amount Override order amount, used for refunds + * + * @access public + * @return void + */ + private function run_transaction($trans_type = false, $refund_amount = false, $transaction_id = false) { - // Set start and end years for card expiration - $this->cc_start_year = date('Y'); - $this->cc_end_year = $this->cc_start_year + GLM_MES_EXPIRE_YEARS; + $response = array( + 'success' => false + ); - if (GLM_MES_DEBUG_VERBOSE) { - wc_add_notice('GLM MeS Gateway: Parameters available to payment form...

'.print_r($this,1).'

', 'success' ); - } + $doDebug = true; + $sendRequestData = false; - require_once (GLM_MES_PATH . '/views/paymentForm.php'); - } + // Create transaction object + require_once (GLM_MES_CLASS_PATH . '/MesTridentGateway.php'); - // Validate Payment Fields - public function validate_fields() - { + // Select transaction object by type requested + switch ($trans_type) { -// $this->$glm_mes_in['account_number'] = -// $this->sanitize_text_field( ) - } -*/ + case 'PreAuth': - /* - * Process order with MES Gateway - */ - public function process_payment( $order_id ) { + if (GLM_MES_DEBUG_VERBOSE) { + wc_add_notice('GLM MeS Gateway: Running Pre-Authorization', 'success'); + } - // Get a copy of our order - global $woocommerce; - $custOrder = new WC_Order( $order_id ); + // Only run pre-auth if address verification or CVV test is selected + if ($this->settings['address_verification'] == 'yes' || + $this->settings['cvv_required'] == 'yes' ) { - // Get our invoice number - $invNumb = str_replace( "#", "", $custOrder->get_order_number() ); + $trans = new TpgPreAuth($this->profile_id, $this->profile_key); - // Clean up the submitted credit card data - $ccNumb = str_replace( array(' ', '-' ), '', $_POST[GLM_MES_ID.'-card-number'] ); - $cc_exp = str_replace( array( '/', ' '), '', $_POST[GLM_MES_ID.'-card-expiry'] ); - $cc_cvc = ( isset( $_POST[GLM_MES_ID.'-card-cvc'] ) ) ? $_POST[GLM_MES_ID.'-card-cvc'] : ''; - - /* Some other things available to us - $custOrder->billing_first_name, - $custOrder->billing_last_name, - $custOrder->billing_address_1, - $custOrder->billing_city, - $custOrder->billing_state, - $custOrder->billing_postcode, - $custOrder->billing_country, - $custOrder->billing_phone, - $custOrder->billing_email, - $custOrder->shipping_first_name, - $custOrder->shipping_last_name, - $custOrder->shipping_company, - $custOrder->shipping_address_1, - $custOrder->shipping_city, - $custOrder->shipping_country, - $custOrder->shipping_state, - $custOrder->shipping_postcode, - $custOrder->user_id, - $_SERVER['REMOTE_ADDR'], - */ + $sendRequestData = true; + + break; + + // otherwise, no pre-auth needs to be run, so say we're OK to go + } else { + + if (GLM_MES_DEBUG_VERBOSE) { + wc_add_notice('GLM MeS Gateway: No Pre-Authorization requested', 'success'); + } + + } + + // break; - If no pre-auth was required, we're just falling through to Sale + + case 'Sale': + + if (GLM_MES_DEBUG_VERBOSE) { + wc_add_notice('GLM MeS Gateway: Running Credit Card', 'success'); + } + + $trans = new TpgSale($this->profile_id, $this->profile_key); + + $sendRequestData = true; + + break; + + case 'Settle': // Requires a prior pre-auth + + if (GLM_MES_DEBUG_VERBOSE) { + wc_add_notice('GLM MeS Gateway: Running Credit Card after Pre-Auth', 'success'); + } + + // If we don't have a transaction ID then can't run Settle + if (!$transaction_id) { + if (GLM_MES_DEBUG_VERBOSE) { + wc_add_notice('GLM MeS Gateway: No transaction ID was provided for a Settle request!', 'success'); + } + return false; + } + + // Send transaction amount or amount driven test value if set + if ($this->amount_driven_test) { + $amount = $this->amount_driven_test; + } else { + $amount = $this->cust_order->order_total; + } + + $trans = new TpgSettle($this->profile_id, $this->profile_key, $transaction_id, $amount); + + $sendRequestData = false; + + break; + + case 'Refund': + + $trans = new TpgRefund($this->profile_id, $this->profile_key, $transaction_id); + $trans->setRequestField('transaction_amount', $refund_amount); + + // Don't let debug data be output during a refund. + $doDebug = false; + + break; + + default: + + // There is no reason to end up here!!! + $response['auth_response_text'] = "Invalid transaction type in run_transaction()!"; + $response['auth_response_desr'] = "WARNING: This is an internal system error in the GLM MES Payment Gateway."; + return $response; + + break; - if (GLM_MES_DEBUG_VERBOSE) { - wc_add_notice('GLM MeS Gateway: process_payment() called', 'success' ); - wc_add_notice('GLM MeS Gateway: Customer Order Data

'.print_r($custOrder,1).'

', 'success' ); } - // Create transaction object - require_once (GLM_MES_CLASS_PATH . '/MesTridentGateway.php'); - $trans = new TpgSale( $this->profile_id, $this->profile_key, $this->settings ); + if ($sendRequestData) { + + // Send transaction amount + if ($this->amount_driven_test) { + $amount = $this->amount_driven_test; + } else { + $amount = $this->cust_order->order_total; + } + + // Send billing information + $trans->setAvsRequest($this->cust_order->billing_address_1, $this->cust_order->billing_postcode); + $trans->setDynamicData( + $this->cust_order->billing_first_name . ' ' . + $this->cust_order->billing_last_name, $this->cust_order->billing_city, + $this->cust_order->billing_state, $this->cust_order->billing_postcode, + $this->cust_order->billing_phone + ); + + // Send shipping infomration + $trans->setRequestField('ship_first_name', $this->cust_order->shipping_first_name); + $trans->setRequestField('ship_last_name', $this->cust_order->shipping_last_name); + $trans->setRequestField('ship_addr1', $this->cust_order->shipping_address_1); + $trans->setRequestField('ship_city', $this->cust_order->shipping_city); + $trans->setRequestField('ship_state', $this->cust_order->shipping_state); + $trans->setRequestField('ship_zip', $this->cust_order->shipping_postcode); + + // Send Card data + $trans->setRequestField('cvv2', $this->cc_cvc); + $trans->setRequestField('invoice_number', $this->invNumb); + $trans->setTransactionData($this->ccNumb, $this->cc_exp, $amount); - // Set transaction data - $trans->setAvsRequest( $custOrder->billing_address_1, $custOrder->billing_postcode ); - $trans->setRequestField('cvv2', $cc_cvc); - $trans->setRequestField('invoice_number', $invNumb); - $trans->setTransactionData( $ccNumb, $cc_exp, $custOrder->order_total ); + } - // Call the MeS Gateway + // Set the gateway host URL $trans->setHost($this->host); - if (GLM_MES_DEBUG_VERBOSE) { - wc_add_notice('GLM MeS Gateway: Transaction Request

'.print_r($trans,1).'

', 'success'); + if ($doDebug && GLM_MES_DEBUG_VERBOSE) { + wc_add_notice( + 'GLM MeS Gateway: Transaction Request

' .
+                    print_r($trans, 1) . '

', 'success'); } + // Execute the transaction $trans->execute(); - if (GLM_MES_DEBUG_VERBOSE) { - wc_add_notice('GLM MeS Gateway: Response Fields

'.print_r($tran2->ResponseFields,1).'

', 'success'); - } + // Get response codes and text + $response = $trans->ResponseFields; - // Check result - if( $trans->isApproved() ) { - $paymentState = 'approved'; - } else { - $paymentState = 'fail'; - $errorMsg = $trans->ResponseFields['auth_response_text']; + if ($doDebug && GLM_MES_DEBUG) { + wc_add_notice( + 'GLM MeS Gateway: Response Fields - Type = '.$trans_type.'

' .
+                    print_r($response, 1) . '

', + 'success'); } - // Take action based on payment state - switch ($paymentState) { + // Check for success based on transaction type + switch ($trans_type) { - case 'complete': + case 'PreAuth': - // Mark order as complete - $order->payment_complete(); + $auth = true; - // Return thank you page redirect - return array( - 'result' => 'success', - 'redirect' => $this->get_return_url( $order ) - ); + // Selectr "Show Additional Test Options" in "GLM Merchant e-Solutions" settings for these response codes. - break; + // If address verification + if ($this->settings['address_verification'] == 'yes') { + if (!in_array($response['avs_result'], array('Y', 'X', 'D', 'S'))) { + $auth = false; + $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.
"; + } + } - case 'call_for_approval': + // If CVV required + if ($this->settings['cvv_required'] == 'yes') { + if (!in_array($response['cvv2_result'], array('M'))) { + $auth = false; + $response['auth_response_descr'] = 'You may not have entered the correct "Card Code" below. + Please check the code on the back of your card and try again.
'; + } + } - // Mark as on-hold (use if payment delayed) - $order->update_status('on-hold', __( 'Awaiting authorization of Credit Card payment. Please call your Credit Card provider.', 'woocommerce' )); - return; + $response['success'] = $auth; break; - case 'fail': + case 'Settle': + case 'Sale': - // Tell the user we had a payment failure - wc_add_notice( __("

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

Reason: ".$errorMsg.'

Please check your credit card information and try again.', 'woothemes') . $error_message, 'error' ); + // Ask MES gateway code if the transaction was approved + $response['success'] = $trans->isApproved(); - if (GLM_MES_DEBUG && !GLM_MES_DEBUG_VERBOSE) { - wc_add_notice('GLM MeS Gateway: Response Fields

'.print_r($trans->ResponseFields,1).'

', 'success'); - } + break; + + case 'Refund': - return; + // Look at error_code to see if refund was successful + $response['success'] = false; + if ($response['error_code'] == '000') { + $response['success'] = true; + } break; - default: + } - // Need to figure this out + // Check for Gateway Error Codes + $lang = 'EN'; // *** TEMPORARY FOR TESTING *** + if (isset($this->respDescr[$response['error_code']])) { + $response['auth_response_descr'] .= $this->respDescr[$response['error_code']]; + } - break; + return $response; + + } + + /* + * Process order with MES Gateway + */ + public function process_payment ($order_id) + { + + // Get a copy of our order + global $woocommerce; + $this->cust_order = new WC_Order($order_id); + + // Get our invoice number + $this->invNumb = str_replace("#", "", $this->cust_order->get_order_number()); + + // Clean up the submitted credit card data + $this->ccNumb = str_replace( + array( + ' ', + '-' + ), '', $_POST[GLM_MES_ID . '-card-number']); + $this->cc_exp = str_replace( + array( + '/', + ' ' + ), '', $_POST[GLM_MES_ID . '-card-expiry']); + $this->cc_cvc = (isset($_POST[GLM_MES_ID . '-card-cvc'])) ? $_POST[GLM_MES_ID . + '-card-cvc'] : ''; + + /* + * Other data available from WooCommerce + * + * $this->cust_order->billing_first_name, + * $this->cust_order->billing_last_name, + * $this->cust_order->billing_address_1, + * $this->cust_order->billing_city, + * $this->cust_order->billing_state, + * $this->cust_order->billing_postcode, + * $this->cust_order->billing_country, + * $this->cust_order->billing_phone, + * $this->cust_order->billing_email, + * + * $this->cust_order->shipping_first_name, + * $this->cust_order->shipping_last_name, + * $this->cust_order->shipping_company, + * $this->cust_order->shipping_address_1, + * $this->cust_order->shipping_city, + * $this->cust_order->shipping_country, + * $this->cust_order->shipping_state, + * $this->cust_order->shipping_postcode, + * + * $this->cust_order->user_id, + * + */ + + if (GLM_MES_DEBUG_VERBOSE) { + wc_add_notice('GLM MeS Gateway: process_payment() called', + 'success'); + wc_add_notice( + 'GLM MeS Gateway: Customer Order Data

' .
+                             print_r($this->cust_order, 1) . '

', 'success'); + } + + // Check if pre-authorization is required + if ($this->settings['address_verification'] == 'yes' || + $this->settings['cvv_required'] == 'yes' ) { + + // Try pre-authorization first + $response = $this->run_transaction('PreAuth'); + + // If pre-auth was not requested or was successful - run sale + if ($response['success']) { + $response = $this->run_transaction('Settle', false, $response['transaction_id']); + } + + // Ohterwise we're just going to run it as a final sale + } else { + + $response = $this->run_transaction('Sale', false, $response['transaction_id']); + + } + + + // Check result + if ($response['success']) { + + // Say the transaction is complete, mark as paid and empty cart + $this->cust_order->add_order_note( __( 'Merchant e-Solutions payment completed.', 'glm-merchant_e_solutions' ) ); + $this->cust_order->payment_complete($response['transaction_id']); + $woocommerce->cart->empty_cart(); + + // Return thank you page redirect + return array( + 'result' => 'success', + 'redirect' => $this->get_return_url($this->cust_order) + ); + + } 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 + wc_add_notice( + __( + "

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

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

'.$response['auth_response_descr'], + 'woothemes'), 'error'); + + // Add a note to the customer order for reference + $this->cust_order->add_order_note( 'Error: '. $response['auth_response_descr'] ); + + if (GLM_MES_DEBUG && ! GLM_MES_DEBUG_VERBOSE) { + wc_add_notice( + 'GLM MeS Gateway: Response Fields

' .
+                                 print_r($trans->ResponseFields, 1) .
+                                 '

', 'success'); + } } } + /* + * Process a refund + */ + + public function process_refund( $order_id, $amount = null, $reason = '' ) + { + // Get the order object + $order = wc_get_order( $order_id ); + + // Get the MES transaction ID stored with the order + $transaction_id = $order->get_transaction_id(); + + // Attempt the refund + $response = $this->run_transaction('Refund', $amount, $transaction_id); + + // If refund was not successful + if (!$response['success']) { + $order->add_order_note( 'Refund not approved ('.$response['error_code'].'): '.$response['auth_response_text'].'
'.print_r($response,1).'
' ); + } + + // Return to WooCommerce with refund result status + return $response['success']; + } } ?> \ No newline at end of file diff --git a/classes/index.php b/classes/index.php new file mode 100644 index 0000000..7e91415 --- /dev/null +++ b/classes/index.php @@ -0,0 +1,2 @@ +https://www.merchante-solutions.com/. + * Version: 1.0 + * Author: Chuck Scott + * Author URI: http://www.gaslightmedia.com/ + * Text Domain: glm-woocommerce-merchant-e-solutions-gateway + * Domain Path: languages + * License: GPL2 + */ + +/** + * Gaslight Media Merchant e-Solutions Gateway + * Index + * + * PHP version 5.5 + * + * @category glmWordPressPlugin + * @package glmMerchantESolutions + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 1.0 + */ + +/* + * Copyright 2014-2015 Charles Scott (email : cscott@gaslightmedia.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +if( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. +require_once('woo-includes/woo-functions.php'); + +// Get standard defined parameters +require_once('defines.php'); + +/** + * ******************************************************************************* + * + * *** Directory and File Structure *** + * + * index.php + * + * Index file for this plugin. All plugin processing starts here. (See + * "Process Flow" below.) + * + * ******************************************************************************** + */ + +/* + * + * Activate, Deactivate, Uninstall hooks + * + */ + +// Activate +function glmMesPluginActivate () +{ + require_once (GLM_MES_PATH . '/activate.php'); + new glmMesPluginActivate(); +} +register_activation_hook(__FILE__, 'glmMesPluginActivate'); + +// Deactivate +function glmMesPluginDeactivate () +{ + require_once (GLM_MES_PATH . '/deactivate.php'); + $x = new glmMesPluginDeactivate(); + return false; +} +register_deactivation_hook(__FILE__, 'glmMesPluginDeactivate'); + + +/* + * + * Load Controller + * + */ + +add_action( 'plugins_loaded', 'initMesGateway' ); + +/** + * Initialize MES Gateway + * + * @return void + * @access public + */ +function initMesGateway() +{ + require_once (GLM_MES_CLASS_PATH . '/glmMesGateway.php'); + new glmMesGateway(); +} + + +?> \ No newline at end of file diff --git a/i18n/languages/default.pot b/i18n/languages/default.pot new file mode 100644 index 0000000..3c208af --- /dev/null +++ b/i18n/languages/default.pot @@ -0,0 +1,366 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-04-22 14:29-0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../.././includes/response_descriptions.php:14 +#: ../.././includes/response_descriptions.php:22 +#: ../.././includes/response_descriptions.php:23 +#: ../.././includes/response_descriptions.php:27 +msgid "Please contact your credit card issuer or try another card." +msgstr "" + +#: ../.././includes/response_descriptions.php:15 +#: ../.././includes/response_descriptions.php:18 +msgid "Please contact your credit card issuer or try another card" +msgstr "" + +#: ../.././includes/response_descriptions.php:16 +msgid "" +"Your card may not be used at this time. Please contact your credit card " +"issuer or try another card." +msgstr "" + +#: ../.././includes/response_descriptions.php:17 +msgid "" +"Your purchase using this credit card has been declined. If you have another " +"credit card, you may try that at this time." +msgstr "" + +#: ../.././includes/response_descriptions.php:19 +#: ../.././includes/response_descriptions.php:20 +msgid "" +"Your credit card number appears to be incorrect. Please check the card " +"number you entered and try again." +msgstr "" + +#: ../.././includes/response_descriptions.php:21 +msgid "" +"Your card was not successfully processed. Please try again. If you continue " +"to get this response, please call for assistance." +msgstr "" + +#: ../.././includes/response_descriptions.php:24 +msgid "" +"Your card is not currently able to cover the cost of this purchase. Delete " +"contents from your cart or try again later." +msgstr "" + +#: ../.././includes/response_descriptions.php:25 +msgid "" +"Your card appears to be expired. Please check your credit card information " +"below or try another card." +msgstr "" + +#: ../.././includes/response_descriptions.php:26 +msgid "" +"This purchase is not permitted with your credit card. Please contact your " +"credit card issuer or try another card." +msgstr "" + +#: ../.././includes/response_descriptions.php:28 +msgid "" +"There was a problem processing your credit cart. If you continue to get this " +"response, please call for assistance." +msgstr "" + +#: ../.././includes/response_descriptions.php:29 +msgid "" +"We do not accept this type of credit card. Please try another card or call " +"for assistance." +msgstr "" + +#: ../.././includes/response_descriptions.php:30 +msgid "" +"You did not supply all required credit card information. Please check your " +"credit card payment information below." +msgstr "" + +#: ../.././includes/response_descriptions.php:31 +msgid "" +"The address you entered did not satisfactorlly match the cardholder's " +"address." +msgstr "" + +#: ../.././includes/response_descriptions.php:32 +msgid "" +"The card security code (3 or 4 digit code, usually on the back of the card) " +"did not match." +msgstr "" + +#: ../.././includes/response_descriptions.php:37 +msgid "(none)" +msgstr "" + +#: ../.././includes/response_descriptions.php:38 +msgid "Card OK" +msgstr "" + +#: ../.././includes/response_descriptions.php:39 +msgid "Call" +msgstr "" + +#: ../.././includes/response_descriptions.php:40 +msgid "Call - special condition" +msgstr "" + +#: ../.././includes/response_descriptions.php:41 +msgid "Hold-call - pick up card (no fraud)" +msgstr "" + +#: ../.././includes/response_descriptions.php:42 +msgid "Decline - do not honor" +msgstr "" + +#: ../.././includes/response_descriptions.php:43 +msgid "Hold-call - pick up card (fraud)" +msgstr "" + +#: ../.././includes/response_descriptions.php:44 +msgid "Card # error" +msgstr "" + +#: ../.././includes/response_descriptions.php:45 +msgid "No such issuer" +msgstr "" + +#: ../.././includes/response_descriptions.php:46 +msgid "Re-enter transaction" +msgstr "" + +#: ../.././includes/response_descriptions.php:47 +msgid "Hold-call - pickup card (fraud: lost card)" +msgstr "" + +#: ../.././includes/response_descriptions.php:48 +msgid "Hold-call - pickup card (fraud: stolen card)" +msgstr "" + +#: ../.././includes/response_descriptions.php:49 +msgid "Decline - insufficient funds" +msgstr "" + +#: ../.././includes/response_descriptions.php:50 +msgid "Expired card" +msgstr "" + +#: ../.././includes/response_descriptions.php:51 +msgid "Transaction not permitted to cardholder" +msgstr "" + +#: ../.././includes/response_descriptions.php:52 +msgid "Suspected fraud" +msgstr "" + +#: ../.././includes/response_descriptions.php:53 +msgid "Invalid Auth" +msgstr "" + +#: ../.././includes/response_descriptions.php:54 +msgid "Unable to validate pin (not used in this plugin)" +msgstr "" + +#: ../.././includes/response_descriptions.php:55 +msgid "Card type not accepted by merchant" +msgstr "" + +#: ../.././classes/glmMesGateway.php:192 +msgid "A Merchant e-Solutions payment Gateway plug-in for WooCommerce." +msgstr "" + +#: ../.././classes/glmMesGateway.php:351 +#, php-format +msgid "" +"\n" +" %s is enabled and WooCommerce is " +"not forcing the\n" +" SSL certificate on your checkout page.
Please " +"ensure that you have\n" +" a valid SSL certificate and that you are forcing\n" +" the checkout pages to be secured." +msgstr "" + +#: ../.././classes/glmMesGateway.php:377 +#, php-format +msgid "" +"%s depends on version %s and up of WooCommerce! Please upgrade before " +"activating." +msgstr "" + +#: ../.././classes/glmMesGateway.php:433 +msgid "Enable/Disable" +msgstr "" + +#: ../.././classes/glmMesGateway.php:435 +msgid "Enable Merchant e-Solutions Gateway" +msgstr "" + +#: ../.././classes/glmMesGateway.php:442 +msgid "Title" +msgstr "" + +#: ../.././classes/glmMesGateway.php:445 +msgid "This controls the title which the user sees during checkout." +msgstr "" + +#: ../.././classes/glmMesGateway.php:447 +msgid "Credit Card Payment" +msgstr "" + +#: ../.././classes/glmMesGateway.php:453 +msgid "Description" +msgstr "" + +#: ../.././classes/glmMesGateway.php:459 +msgid "Credit Cards Accepted" +msgstr "" + +#: ../.././classes/glmMesGateway.php:468 +msgid "Visa" +msgstr "" + +#: ../.././classes/glmMesGateway.php:477 +msgid "MasterCard" +msgstr "" + +#: ../.././classes/glmMesGateway.php:486 +msgid "American Express" +msgstr "" + +#: ../.././classes/glmMesGateway.php:495 +msgid "Discover" +msgstr "" + +#: ../.././classes/glmMesGateway.php:502 +msgid "Require Address Verification" +msgstr "" + +#: ../.././classes/glmMesGateway.php:504 +msgid "" +"Check to require valid address verification before charging credit card." +msgstr "" + +#: ../.././classes/glmMesGateway.php:510 +msgid "Require CVV/CVC/CID" +msgstr "" + +#: ../.././classes/glmMesGateway.php:512 +msgid "Check to require a valid credit card CVV/CVC/CID when charging card." +msgstr "" + +#: ../.././classes/glmMesGateway.php:517 +msgid "Test Mode Credentials" +msgstr "" + +#: ../.././classes/glmMesGateway.php:524 +msgid "Test Profile ID" +msgstr "" + +#: ../.././classes/glmMesGateway.php:532 +msgid "Test Profile Key" +msgstr "" + +#: ../.././classes/glmMesGateway.php:540 +msgid "Test URL" +msgstr "" + +#: ../.././classes/glmMesGateway.php:548 +msgid "Production Mode Credentials" +msgstr "" + +#: ../.././classes/glmMesGateway.php:556 +msgid "Production Profile ID" +msgstr "" + +#: ../.././classes/glmMesGateway.php:564 +msgid "Production Profile Key" +msgstr "" + +#: ../.././classes/glmMesGateway.php:572 +msgid "Production URL" +msgstr "" + +#: ../.././classes/glmMesGateway.php:579 +msgid "Mode Selection" +msgstr "" + +#: ../.././classes/glmMesGateway.php:586 +msgid "Transaction Mode" +msgstr "" + +#: ../.././classes/glmMesGateway.php:589 +msgid "Must be in \"Production Mode\" for live transactions." +msgstr "" + +#: ../.././classes/glmMesGateway.php:593 +#, php-format +msgid "" +"See %s MeS Payment Certification Form to apply for required ID and Key." +msgstr "" + +#: ../.././classes/glmMesGateway.php:600 +msgid "Test Mode" +msgstr "" + +#: ../.././classes/glmMesGateway.php:601 +msgid "Production Mode" +msgstr "" + +#: ../.././classes/glmMesGateway.php:607 +msgid "Amount Driven Tests" +msgstr "" + +#: ../.././classes/glmMesGateway.php:609 +msgid "" +"Selecting an amount driven test will set the payment amount for the " +"transaction to the specific value\n" +" and will cause the payment gateway to return " +"the associated respose. This may be used to test all\n" +" possible response types that might be " +"experienced in production use." +msgstr "" + +#: ../.././classes/glmMesGateway.php:613 +msgid "Show Additional Test Options" +msgstr "" + +#: ../.././classes/glmMesGateway.php:621 +msgid "Enable Debug Information" +msgstr "" + +#: ../.././classes/glmMesGateway.php:623 +msgid "Check to enable debug output on checkout page." +msgstr "" + +#: ../.././classes/glmMesGateway.php:629 +msgid "Enable Verbose Debug" +msgstr "" + +#: ../.././classes/glmMesGateway.php:631 +msgid "Check to enable verbose output on checkout page." +msgstr "" + +#: ../.././classes/glmMesGateway.php:919 +msgid "Merchant e-Solutions payment completed." +msgstr "" + +#: ../.././classes/glmMesGateway.php:935 +msgid "" +"

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

Reason: " +msgstr "" diff --git a/i18n/languages/do_xgettext b/i18n/languages/do_xgettext new file mode 100755 index 0000000..f53bf86 --- /dev/null +++ b/i18n/languages/do_xgettext @@ -0,0 +1,2 @@ +#!/bin/bash +find ../../. -iname "*.php" | xargs xgettext --from-code=UTF-8 -LPHP -k_e -k_x -k__ -o default.pot diff --git a/i18n/languages/glm-woocommerce-merchant-e-solutions-gateway.pot b/i18n/languages/glm-woocommerce-merchant-e-solutions-gateway.pot new file mode 100644 index 0000000..89ae890 --- /dev/null +++ b/i18n/languages/glm-woocommerce-merchant-e-solutions-gateway.pot @@ -0,0 +1,27 @@ +# WordPress Plugin Boilerplate Copyright (c) {2014} +msgid "" +msgstr "" +"Project-Id-Version: WooCommerce Payment Gateway Boilerplate 1.0.0\n" +"Report-Msgid-Bugs-To: issues\n" +"POT-Creation-Date: 2014-09-17 21:23+0100\n" +"PO-Revision-Date: 2014-09-17 21:23+0100\n" +"Last-Translator: \n" +"Language-Team: WP-Translations \n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.6.9\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: _n_noop:1,2;_c;_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n" +"X-Textdomain-Support: yes\n" +"X-Poedit-SearchPath-0: .\n" + +#: includes/admin/views/admin-options.php:1 +#: includes/class-wc-gateway-payment-gateway-boilerplate.php:29 +#: includes/class-wc-gateway-payment-gateway-boilerplate.php:192 +msgid "Gateway Name" +msgstr "Gaslight Media WooCommerce Merchant e-Solutions Payment Gateway" + diff --git a/i18n/languages/index.php b/i18n/languages/index.php new file mode 100644 index 0000000..7e91415 --- /dev/null +++ b/i18n/languages/index.php @@ -0,0 +1,2 @@ + - * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.0 - */ - -/* - * Copyright 2014-2015 Charles Scott (email : cscott@gaslightmedia.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -// Get standard defined parameters -require_once('defines.php'); - -/** - * ******************************************************************************* - * - * *** Directory and File Structure *** - * - * index.php - * - * Index file for this plugin. All plugin processing starts here. (See - * "Process Flow" below.) - * - * ******************************************************************************** - */ - -/* - * - * Activate, Deactivate, Uninstall hooks - * - */ - -// Activate -function glmMesPluginActivate () -{ - require_once (GLM_MES_PATH . '/activate.php'); - new glmMesPluginActivate(); -} -register_activation_hook(__FILE__, 'glmMesPluginActivate'); - -// Deactivate -function glmMesPluginDeactivate () -{ - require_once (GLM_MES_PATH . '/deactivate.php'); - $x = new glmMesPluginDeactivate(); - return false; -} -register_deactivation_hook(__FILE__, 'glmMesPluginDeactivate'); - - -/* - * - * Load Controller - * - */ - -add_action( 'plugins_loaded', 'initMesGateway' ); - -/** - * Initialize MES Gateway - * - * @return void - * @access public - */ -function initMesGateway() -{ - require_once (GLM_MES_CLASS_PATH . '/glmMesGateway.php'); - new glmMesGateway(); -} - - -?> \ No newline at end of file +// Silence is golden. \ No newline at end of file diff --git a/readme.txt b/readme.txt index d7cf95e..dea9547 100644 --- a/readme.txt +++ b/readme.txt @@ -13,10 +13,27 @@ Merchant e-Solutions credit card payment gateway. == Description == -More description goes here. +This is a plug-in for WordPress/WooCommerce to process credit cards via the +"Merchant e-Solutions" payment gateway. + +Features of this plugin are... + +* Only WooCommerce plug-in certified by Merchant e-Solutions +* Highly integrated with WooCommerce +* Processes payments direct throught Merchant e-Solutions - No additional service required +* Admin options to require address and/or card code validation (checks these first with a pre-authorization check) +* Selectable credit card icons for checkout payment form +* Provides for input of both Test mode and Production mode cridentials +* May be easily switched between test and production mode +* Simple or verbose debug information for testing +* Selectable "Ammount Driven Tests" for a variety of return codes +* Accessible reference information for a variety of other tests for address and card code verification +* Subscription includes perpetual use for the designated number of production sites and E-Mail support and updates for one year == Installation == +When requesting production credentials with Merchant e-Solutions, specifiy that the Certified Product Name is "Gaslight Media". + This section describes how to install the plugin and get it working. e.g. @@ -27,6 +44,54 @@ e.g. == Frequently Asked Questions == += What card numbers can I use for testing = + +Any valid credit card number may be used when the "Transaction Mode" is set to "Test Mode". +In test mode, all transactions are simulated and will not impact the cardholder's account. + +The following card numbers may also be used for testing. +Cart Type Card Number +----------------- ----------------- +Visa 16 digit 4012301230123010 +Visa 13 digit 4012301230158 +MasterCard 5123012301230120 +American Express 349999999999991 +Discover 6011011231231235 +JCB 3528288605211810 + += What other testing data would be helpful = + +The following test data and responses may be helpful for testing this payment gateway +and validating that a particular implementation is functioning properly. + +Address Verification Tests +Street # ZIP/postal code Result +------------ ---------------- -------------------------------------------------------- +123 55555 Y – street and postal code match +123 999991111 Y – street and postal code match (Visa) + X – street and postal code match (MasterCard) +123 EH8 9ST D - exact match, international +123 Other Zip A - address match, zip mismatch +234 Any Zip U - address unavailable +345 Any Zip G - verification unavailable due to international + issuer non-participation (Visa and MasterCard only) +456 Any Zip R - issuer system unavailable, retry +235 Any Zip S – AVS not supported +(other) 55555 Z - address mismatch, 5-digit zip match +(other) EH8 9ST Z - address mismatch, international zip match + +CCV, CVC, CID Code Tests +Code Result +---------------- ------------------------------ +123 M - Match +234 P - Not Processed +345 U - Issuer is not certified +(other 3 digit) N - No Match +1234 (AMEX) M - Match +2345 (AMEX) P - Not Processed +(other 4 digit) N - No Match + + == Screenshots == diff --git a/views/paymentForm.php b/views/paymentForm.php deleted file mode 100644 index cd42544..0000000 --- a/views/paymentForm.php +++ /dev/null @@ -1,84 +0,0 @@ - - - -transaction_mode == 'test') { - echo '

Operating in Test Mode
'; - } -?> - -
-

customer_message; ?>

-
-

- -

- visa == 'yes') { echo ''; } - if ($this->mastercard == 'yes') { echo ''; } - if ($this->amex == 'yes') { echo ''; } - ?> -
-

-

 

-

- - -

-

- - -

-

- - - -

-

- - -

-
-
- \ No newline at end of file diff --git a/woo-includes/class-wc-dependencies.php b/woo-includes/class-wc-dependencies.php new file mode 100644 index 0000000..e19fdae --- /dev/null +++ b/woo-includes/class-wc-dependencies.php @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/woo-includes/index.php b/woo-includes/index.php new file mode 100644 index 0000000..7e91415 --- /dev/null +++ b/woo-includes/index.php @@ -0,0 +1,2 @@ + \ No newline at end of file -- 2.17.1