From bd1bddc1090fbc79151be8245f6f3e6dc288fd7b Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Tue, 3 Apr 2018 17:07:37 -0400 Subject: [PATCH] Added Payment Processer Classes - Added configuration options Fixed problem with checking status of capabilities in glmPluginSupport.php Added settings for reCAPTCHA and Cluster Margers to Management and Database Added lib/paymentProcessors directory with payment processor classes and test code. Updated Authorize.net payment processor class to new API and added stored payment profiles. --- classes/data/settings/dataSettingsGeneral.php | 41 +++++++++++++++++-- classes/glmPluginSupport.php | 17 +++++--- css/admin.css | 3 ++ index.php | 2 +- .../Authorize.Net/paymentGateway.php | 12 +++++- .../paymentProcessorsTest.php | 29 +++++++------ ...1.1.34.sql => create_database_V1.1.35.sql} | 9 +++- setup/databaseScripts/dbVersions.php | 1 + .../update_database_V1.1.35.sql | 25 +++++++++++ views/admin/management/index.html | 29 +++++++++++++ 10 files changed, 142 insertions(+), 26 deletions(-) rename setup/databaseScripts/{create_database_V1.1.34.sql => create_database_V1.1.35.sql} (97%) create mode 100644 setup/databaseScripts/update_database_V1.1.35.sql diff --git a/classes/data/settings/dataSettingsGeneral.php b/classes/data/settings/dataSettingsGeneral.php index 98aa1b8e..e8211ebf 100644 --- a/classes/data/settings/dataSettingsGeneral.php +++ b/classes/data/settings/dataSettingsGeneral.php @@ -157,14 +157,14 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'type' => 'checkbox', 'use' => 'a' ), - + // Enable File Library Menu 'file_library' => array( 'field' => 'file_library', 'type' => 'checkbox', 'use' => 'a' ), - + // Google Maps API Key 'google_maps_api_key' => array( 'field' => 'google_maps_api_key', @@ -222,7 +222,6 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'use' => 'a' ), - // Default State 'default_state' => array ( 'field' => 'default_state', @@ -255,6 +254,34 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'use' => 'a' ), + // reCAPTCHA Site Key + 'recaptcha_site_key' => array( + 'field' => 'recaptcha_site_key', + 'type' => 'text', + 'use' => 'a' + ), + + // reCAPTCHA Secret Key + 'recaptcha_secret_key' => array( + 'field' => 'recaptcha_secret_key', + 'type' => 'text', + 'use' => 'a' + ), + + // reCAPTCHA Header Code + 'recaptcha_header_code' => array( + 'field' => 'recaptcha_header_code', + 'type' => 'text', + 'use' => 'a' + ), + + // reCAPTCHA Form Code + 'recaptcha_form_code' => array( + 'field' => 'recaptcha_form_code', + 'type' => 'text', + 'use' => 'a' + ), + /* * Member Info edit tab selection */ @@ -625,6 +652,14 @@ class GlmDataSettingsGeneral extends GlmDataAbstract */ + // Google Maps Show Cluster Markers + 'use_cluster_markers' => array( + 'field' => 'use_cluster_markers', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ), + // Google Map Opened 'list_map_show_opened' => array( 'field' => 'list_map_show_opened', diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index 7b473365..cdff7fff 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -445,6 +445,7 @@ function glmMembersInstallErrorsNotice() { * Check if a particular capability exists for the current user and if it's checked * * If $permit is already false, we just return that since we can only withdraw permission with these tests, not add it. + * * @param $cap string Capability to check * @param $permit boolean Used to pass on pre-existing permission value * @@ -452,20 +453,26 @@ function glmMembersInstallErrorsNotice() { */ function glmMembersUserCan( $cap, $permit ) { + // If we're already passed a false, then don't check any further. + if (!$permit) { + return $permit; + } + + // Get the current user information static $glmUser; if ( !$glmUser ) { $glmUser = wp_get_current_user(); } - if (!$permit) { - return false; - } + // Select the capabilities array for this user $glmMembersCaps = $glmUser->allcaps; - if (isset($glmMembersCaps[$cap])) { - return $permit; + // If the capability doesn't exist, then don't permit + if (!isset($glmMembersCaps[$cap])) { + return false; } + // Otherwise let the standard WordPress function check it return current_user_can($cap); } diff --git a/css/admin.css b/css/admin.css index 5a9b271c..3cac1b9f 100644 --- a/css/admin.css +++ b/css/admin.css @@ -173,6 +173,9 @@ .glm-form-text-input-medium-long { width: 50em; } +.glm-form-text-input-long { + width: 70em; +} .glm-form-textarea { width: 60%; } diff --git a/index.php b/index.php index c864a233..382d03ea 100644 --- a/index.php +++ b/index.php @@ -47,7 +47,7 @@ if (!defined('ABSPATH')) { */ define('GLM_MEMBERS_PLUGIN_VERSION', '2.10.27'); -define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.1.34'); +define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.1.35'); // Check if plugin version is not current in WordPress option and if needed updated it if (GLM_MEMBERS_PLUGIN_VERSION != get_option('glmMembersDatabasePluginVersion')) { diff --git a/lib/paymentProcessors/Authorize.Net/paymentGateway.php b/lib/paymentProcessors/Authorize.Net/paymentGateway.php index a458e2ec..ff5179f1 100644 --- a/lib/paymentProcessors/Authorize.Net/paymentGateway.php +++ b/lib/paymentProcessors/Authorize.Net/paymentGateway.php @@ -29,6 +29,14 @@ use net\authorize\api\controller as AnetController; * @license http://www.gaslightmedia.com Gaslightmedia * @release SVN: $Id: AuthorizeNet.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ * @link <> + */ + +/* + * See paymentProcessorsTest.php in paymentProcessors directory for sample and test code. + * + * See following URL for API documentation (hover over "API" at top of page). + * https://developer.authorize.net/api/ + * */ class PaymentGateway @@ -72,8 +80,8 @@ class PaymentGateway * 1 = Local Transaction Approval Test * 2 = Local Transaction Decline Test * 3 = On-Line Transaction Test (SANDBOX) - * conf True if Authorize.net should send confirmation E-Mail to customer - * email Merchant E-Mail address to receive notices from Authorize.net for the transaction + * conf True if Authorize.net should send confirmation E-Mail to customer - Not used by Authroize.net API + * email Merchant E-Mail address to receive notices - Not used by Authorize.net API * * API Access for Authorize.net SANDBOX * API Login ID: 44pvQ8D7d diff --git a/lib/paymentProcessors/paymentProcessorsTest.php b/lib/paymentProcessors/paymentProcessorsTest.php index 02263dc8..d6849a8d 100644 --- a/lib/paymentProcessors/paymentProcessorsTest.php +++ b/lib/paymentProcessors/paymentProcessorsTest.php @@ -31,7 +31,7 @@ $testMode = 3; // Required * 1 = Charge and Save Cust Card Data * 2 = Charge using Saved Cust Card Data */ -$transOption = 0; // Required +$transOption = 1; // Required /** * Account Information @@ -47,10 +47,13 @@ $accountKey = '8rj6ME772K9Pe9pJ'; // Required /** * Confirmation settigngs * + * NOTE: Not used by Authorize.net API. See Authorize.net merchant portal + * Other payment processors may use this data. + * * customerConfirmation True if a confirmation should be sent to customer via E-Mail * vendorConfirmation Merchant E-Mail address to receive transaction notices from payment processor */ -$customerConfirmation = false; // Required +$customerConfirmation = false; // Optional $vendorConfirmationEmail = ''; // Optional /** @@ -62,16 +65,16 @@ $vendorConfirmationEmail = ''; // Optional * invoiceNumb Up to 20 characters * */ -$vendorName = 'Test Vendor'; // Required -$charge = 141.00; // Required +$vendorName = 'Test Vendor'; // Required - May also contain short discription of what's sold +$charge = 143.00; // Required $customerProfileId = ''; // Required for transOption = 2 $paymentProfileId = ''; // Required for transOption = 2 $cardType = ''; // Optional $cardNumber = '6011000000000012'; // Required for transOption = 0 & 1 $nameOnCard = ''; // Optional -$cardExp = '2023-01'; // Required for transOption = 0 & 1 -$cardCode = '123'; // Required for transOption = 0 & 1 -$invoiceNumb = '141'; // Required +$cardExp = '2001-03'; // Required for transOption = 0 & 1 +$cardCode = '234'; // Required for transOption = 0 & 1 +$invoiceNumb = '144'; // Required /** * Customer Contact Information @@ -105,17 +108,17 @@ $account = array( 'login' => $accountLogin, // Required 'key' => $accountKey, // Required 'test' => $testMode, // Required - 'conf' => $customerConfirmation, // Required - 'email' => $vendorConfirmationEmail // Required if "conf" above is true + 'conf' => $customerConfirmation, // Depends on payment processor used - Not used by Authorize.net + 'email' => $vendorConfirmationEmail // Depends on payment processor used - Not used by Authorize.net ); // Create Payment Array - Required $payment = array( - 'transOpt' => $transOption, // Required + 'transOpt' => $transOption, // Required for Authorize.net - Otherwise not required 'name' => $vendorName, // Required 'charge' => $charge, // Required - 'customerProfileId' => $customerProfileId, // Required for transOption = 2 - 'paymentProfileId' => $paymentProfileId, // Required for transOption = 2 + 'customerProfileId' => $customerProfileId, // Required for Authorize.net for transOption = 2 + 'paymentProfileId' => $paymentProfileId, // Required for Authorize.net for transOption = 2 'cctype' => $cardType, // Optional (depends on payment processor) 'ccname' => $nameOnCard, // Not required for Authorize.net 'ccnumb' => $cardNumber, // Required for transOption = 0 & 1 @@ -126,7 +129,7 @@ $payment = array( // Customer Information - Required for transOption = 0 & 1 $customer = array( - 'id' => $custId, // Alphanumeric - Required if creating or using stored customer profile - must be unique to customer + 'id' => $custId, // Alphanumeric - Required if creating or using stored customer profiles with Authorize.net - must be unique to customer // 'type' => $custType, // 'individual' or 'business' - not required 'fname' => $custFname, // Required 'lname' => $custLname, // Required diff --git a/setup/databaseScripts/create_database_V1.1.34.sql b/setup/databaseScripts/create_database_V1.1.35.sql similarity index 97% rename from setup/databaseScripts/create_database_V1.1.34.sql rename to setup/databaseScripts/create_database_V1.1.35.sql index 26daffa5..d42a32ef 100644 --- a/setup/databaseScripts/create_database_V1.1.34.sql +++ b/setup/databaseScripts/create_database_V1.1.35.sql @@ -1,6 +1,6 @@ -- Gaslight Media Members Database -- File Created: 12/29/16 12:06:00 --- Database Version: 1.1.32 +-- Database Version: 1.1.35 -- Database Creation Script -- -- To permit each query below to be executed separately, @@ -431,7 +431,12 @@ CREATE TABLE {prefix}settings_general ( detail_map_show_amenities BOOLEAN DEFAULT '0', members_only_support_email TINYTEXT DEFAULT '', members_only_support_phone TINYTEXT DEFAULT '', - short_desc_char_limit INTEGER DEFAULT '120', -- How many characters the short description is limited to - also used for importing + short_desc_char_limit INTEGER DEFAULT '120', -- How many characters the short description is limited to - also used for importing + use_cluster_markers BOOLEAN DEFAULT '0', -- Flag to say if cluster markers should be use in maps + recaptcha_site_key TINYTEXT DEFAULT '', -- reCAPTCHA site key + recaptcha_secret_key TINYTEXT DEFAULT '', -- reCAPTCHA secret key + recaptcha_header_code TEXT DEFAULT '', -- reCAPTCHA code for page header + recaptcha_form_code TEXT DEFAULT '', -- reCAPTCHA code for captcha form field PRIMARY KEY (id) ); diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index edf1903a..2a1592ef 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -66,6 +66,7 @@ $glmMembersDbVersions = array( '1.1.32' => array('version' => '1.1.32', 'tables' => 20, 'date' => '06/14/17'), '1.1.33' => array('version' => '1.1.33', 'tables' => 22, 'date' => '01/15/18'), '1.1.34' => array('version' => '1.1.34', 'tables' => 22, 'date' => '01/23/18'), + '1.1.35' => array('version' => '1.1.35', 'tables' => 22, 'date' => '04/03/18') ); diff --git a/setup/databaseScripts/update_database_V1.1.35.sql b/setup/databaseScripts/update_database_V1.1.35.sql new file mode 100644 index 00000000..19fbb33a --- /dev/null +++ b/setup/databaseScripts/update_database_V1.1.35.sql @@ -0,0 +1,25 @@ +-- Gaslight Media Members Database +-- File Created: 04/03/18 +-- Database Version: 1.1.35 +-- Database Update From Previous Version Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes. + +ALTER TABLE {prefix}settings_general ADD COLUMN use_cluster_markers BOOLEAN DEFAULT '0'; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN recaptcha_site_key TINYTEXT; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN recaptcha_secret_key TINYTEXT; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN recaptcha_header_code TEXT; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN recaptcha_form_code TEXT; diff --git a/views/admin/management/index.html b/views/admin/management/index.html index dd82dcd7..e7ac627b 100644 --- a/views/admin/management/index.html +++ b/views/admin/management/index.html @@ -129,6 +129,34 @@ + + +

reCAPTCHA Settings

+ + Site Key: + + + + + + Secret Key: + + + + + + Code for Header: + + + + + + Code for Form: + + + + +

Misc. Settings

@@ -290,6 +318,7 @@ + -- 2.17.1

Member List Map Options

Show Map:
Show Map Cluster Markers:
Show Member Name as Link to Detail:
Map Opened by Default: