From b28ab4938f19fa53a6f9e5e329adad3c4ce06db7 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 6 Nov 2017 16:44:31 -0500 Subject: [PATCH] Fixed lib directory define, completed payment processor integration, updated database Changed some default settings for the registration account data class. Updated database to add new field 2 fields for Merchant Solutions in management Fixed some compatibility issues in the paymnent gateway classes Completed payment processor integration in checkout and texted off-line Some updates and fixes in the checkout view. --- classes/data/dataAccount.php | 15 +- classes/data/dataManagement.php | 15 ++ config/plugin.ini | 36 ++- defines.php | 3 +- index.php | 2 +- .../Authorize.Net/AIM_guide-1.pdf | Bin .../Authorize.Net/paymentGateway.php | 68 +++--- .../MerchantSolutions/paymentGateway.php | 59 +++-- .../paymentGateway.php} | 66 ++--- .../{None => TestGood}/paymentGateway.php | 9 +- models/front/registrations/checkout.php | 63 ++++- .../front/registrations/checkoutProcess.php | 201 ++++++++++++++- ...0.0.16.sql => create_database_V0.0.17.sql} | 10 +- setup/databaseScripts/dbVersions.php | 3 +- ..._V0.0.16.sql => drop_database_V0.0.17.sql} | 0 .../update_database_V0.0.17.sql | 13 + views/admin/management/registrations.html | 83 +++++-- views/front/registrations/checkout.html | 228 +++++++++++++----- 18 files changed, 688 insertions(+), 186 deletions(-) mode change 100755 => 100644 lib/paymentProcessors/Authorize.Net/AIM_guide-1.pdf mode change 100755 => 100644 lib/paymentProcessors/Authorize.Net/paymentGateway.php mode change 100755 => 100644 lib/paymentProcessors/MerchantSolutions/paymentGateway.php rename lib/paymentProcessors/{Test/Test.php => TestByCardNumber/paymentGateway.php} (58%) mode change 100755 => 100644 rename lib/paymentProcessors/{None => TestGood}/paymentGateway.php (86%) mode change 100755 => 100644 rename setup/databaseScripts/{create_database_V0.0.16.sql => create_database_V0.0.17.sql} (98%) rename setup/databaseScripts/{drop_database_V0.0.16.sql => drop_database_V0.0.17.sql} (100%) create mode 100644 setup/databaseScripts/update_database_V0.0.17.sql diff --git a/classes/data/dataAccount.php b/classes/data/dataAccount.php index 77c7518..93e32f5 100644 --- a/classes/data/dataAccount.php +++ b/classes/data/dataAccount.php @@ -157,7 +157,7 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract ), */ - // Account Primary Address + // Member ID if account derived from a member contact 'member_id' => array ( 'field' => 'member_id', 'type' => 'text', @@ -365,7 +365,7 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract 'email' => array ( 'field' => 'email', 'type' => 'text', - 'required' => true, + 'required' => false, 'use' => 'a' ), @@ -395,6 +395,15 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract ), // Pointer to GLM Associate member contact record if account is for a member contact + 'contact_id' => array ( + 'field' => 'contact_id', + 'type' => 'integer', + 'required' => false, + 'use' => 'lgneud' + ), + + // Pointer to GLM Associate member contact record if account is for a member contact +/* 'contact_id' => array ( 'field' => 'contact_id', 'type' => 'pointer', @@ -404,7 +413,7 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract 'required' => true, 'use' => 'lgneud' ), - +*/ // 'contact_fname' => array ( 'field' => 'contact_fname', diff --git a/classes/data/dataManagement.php b/classes/data/dataManagement.php index 839e78e..515c81b 100644 --- a/classes/data/dataManagement.php +++ b/classes/data/dataManagement.php @@ -290,6 +290,21 @@ class GlmDataRegistrationsManagement extends GlmDataAbstract 'use' => 'a' ), + // Always Use Full Billing Info + 'reg_merchant_solutions_conf' => array ( + 'field' => 'reg_merchant_solutions_conf', + 'type' => 'checkbox', + 'use' => 'a', + 'default' => 0, + ), + + // Merchant Email + 'reg_merchant_solutions_merchant_email' => array ( + 'field' => 'reg_merchant_solutions_merchant_email', + 'type' => 'text', + 'use' => 'a' + ), + // Always Use Full Billing Info 'reg_full_billing_info' => array ( 'field' => 'reg_full_billing_info', diff --git a/config/plugin.ini b/config/plugin.ini index ce8c073..a39400d 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -48,6 +48,9 @@ payment_method_numb['CallFromMerchant'] = 5 payment_method_numb['CreditCard'] = 6 payment_method_numb['PayPal'] = 7 +; Default payment method is Credit Card +default_payment_method = 6 + ; ; Payment Code Types - List only ; @@ -91,17 +94,24 @@ reg_ref_type_numb['Registrant'] = 50 ; ; Credit Cards - Use as Bitmap Index or List ; -credit_card[0] = 'Visa' -credit_card[1] = 'MasterCard' -credit_card[2] = 'American Express' -credit_card[3] = 'Discover' -credit_card[4] = 'Diners Club' +credit_card[1] = 'Visa' +credit_card[2] = 'MasterCard' +credit_card[3] = 'American Express' +credit_card[4] = 'Discover' +credit_card[5] = 'Diners Club' + +credit_card_numb['Visa'] = 1 +credit_card_numb['MasterCard'] = 2 +credit_card_numb['American Express'] = 3 +credit_card_numb['Discover'] = 4 +credit_card_numb['Diners Club'] = 5 + +credit_card_match[1] = '/^4[0-9]{12}(?:[0-9]{3})?$/' +credit_card_match[2] = '/^([51|52|53|54|55]{2})([0-9]{14})$/' +credit_card_match[3] = '/^([34|37]{2})([0-9]{13})$/' +credit_card_match[4] = '/^([6011]{4})([0-9]{12})$/' +credit_card_match[5] = '/^([30|36|38]{2})([0-9]{12})$/' -credit_card_numb['Visa'] = 0 -credit_card_numb['MasterCard'] = 1 -credit_card_numb['American Express'] = 2 -credit_card_numb['Discover'] = 3 -credit_card_numb['Diners Club'] = 4 ; ; Card Processing Methods - Use as Bitmap Index or List @@ -118,6 +128,12 @@ proc_method_numb['MerchantSolutions'] = 3 proc_method_numb['TestAlwaysGood'] = 4 proc_method_numb['TestByCardNumber'] = 5 +proc_dir[1] = 'ByMerchant' +proc_dir[2] = 'Authorize.Net' +proc_dir[3] = 'MerchantSolutions' +proc_dir[98] = 'TestGood' +proc_dir[99] = 'TestByCardNumber' + ; ; Card processing test modes ; diff --git a/defines.php b/defines.php index 4edcd47..29b717b 100644 --- a/defines.php +++ b/defines.php @@ -68,7 +68,8 @@ define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_CONFIG_PATH', GLM_MEMBERS_REGISTRATIONS // Parameters related to the Main GLM Member DB plugin - Depending on what's going on these may already defined by the main plugin $pluginsPath = str_replace(GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, '', GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH); define('GLM_MEMBERS_REGISTRATIONS_MAIN_PLUGIN_PATH', $pluginsPath.'/glm-member-db'); -define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_LIB_PATH', GLM_MEMBERS_REGISTRATIONS_MAIN_PLUGIN_PATH.'/lib'); +define('GLM_MEMBERS_REGISTRATIONS_MAIN_PLUGIN_LIB_PATH', GLM_MEMBERS_REGISTRATIONS_MAIN_PLUGIN_PATH.'/lib'); +define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_LIB_PATH', GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH.'/lib'); // Update Server define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_UPDATE_SERVER', 'http://www.gaslightmedia.com/update_server'); \ No newline at end of file diff --git a/index.php b/index.php index 47ca90c..01c8305 100644 --- a/index.php +++ b/index.php @@ -44,7 +44,7 @@ if (!defined('ABSPATH')) { * version from this plugin. */ define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION', '0.0.1'); -define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_VERSION', '0.0.16'); +define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_VERSION', '0.0.17'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.10.10'); diff --git a/lib/paymentProcessors/Authorize.Net/AIM_guide-1.pdf b/lib/paymentProcessors/Authorize.Net/AIM_guide-1.pdf old mode 100755 new mode 100644 diff --git a/lib/paymentProcessors/Authorize.Net/paymentGateway.php b/lib/paymentProcessors/Authorize.Net/paymentGateway.php old mode 100755 new mode 100644 index 0aba97d..37be0cf --- a/lib/paymentProcessors/Authorize.Net/paymentGateway.php +++ b/lib/paymentProcessors/Authorize.Net/paymentGateway.php @@ -132,7 +132,8 @@ class PaymentGateway // Check for required data if (!is_array($payment) || !is_array($payment)) { $resp = array( - 'status' => 2, + 'gateway' => 'Authorize.Net', + 'status' => 2, 'statusText' => 'Bad Data Supplied', 'authCode' => '', 'description' => 'The required payment and contact information was not supplied.' @@ -151,10 +152,11 @@ class PaymentGateway case 1: // Always return a card approval $resp = array( - 'status' => 1, - 'statusText' => 'Card Approved', - 'authCode' => '000000', - 'description' => '(TESTMODE) Local Test - Card Approved' + 'gateway' => 'Authorize.Net', + 'status' => 1, + 'statusText' => 'Card Approved', + 'authCode' => '000000', + 'description' => '(TESTMODE) Local Test - Card Approved' ); return $resp; break; @@ -162,10 +164,11 @@ class PaymentGateway // Fail Test case 2: $resp = array( - 'status' => 7, - 'statusText' => 'Card Declined', - 'authCode' => '', - 'description' => '(TESTMODE) Local Test - Card Declined' + 'gateway' => 'Authorize.Net', + 'status' => 7, + 'statusText' => 'Card Declined', + 'authCode' => '', + 'description' => '(TESTMODE) Local Test - Card Declined' ); return $resp; break; @@ -225,46 +228,51 @@ class PaymentGateway switch ($response->response_code) { case 1: $resp = array( - 'status' => 1, - 'statusText' => 'Card Approved', - 'authCode' => $response->authorization_code, - 'description' => $response->response_reason_text + 'gateway' => 'Authorize.Net', + 'status' => 1, + 'statusText' => 'Card Approved', + 'authCode' => $response->authorization_code, + 'description' => $response->response_reason_text ); break; case 2: $resp = array( - 'status' => 7, - 'statusText' => 'Card Declined', - 'authCode' => '', - 'description' => $respDescr + 'gateway' => 'Authorize.Net', + 'status' => 7, + 'statusText' => 'Card Declined', + 'authCode' => '', + 'description' => $respDescr ); break; case 3: $resp = array( - 'status' => 3, - 'statusText' => 'Transaction Error', - 'authCode' => '', - 'description' => $respDescr + 'gateway' => 'Authorize.Net', + 'status' => 3, + 'statusText' => 'Transaction Error', + 'authCode' => '', + 'description' => $respDescr ); break; case 4: $resp = array( - 'status' => 7, - 'statusText' => 'Held for review', - 'authCode' => '', - 'description' => $response->response_reason_text - ); + 'gateway' => 'Authorize.Net', + 'status' => 7, + 'statusText' => 'Held for review', + 'authCode' => '', + 'description' => $response->response_reason_text + ); break; default: $resp = array( - 'status' => 4, - 'statusText' => 'Bad Response', - 'authCode' => '', - 'description' => $respDescr + 'gateway' => 'Authorize.Net', + 'status' => 4, + 'statusText' => 'Bad Response', + 'authCode' => '', + 'description' => $respDescr ); break; diff --git a/lib/paymentProcessors/MerchantSolutions/paymentGateway.php b/lib/paymentProcessors/MerchantSolutions/paymentGateway.php old mode 100755 new mode 100644 index 805e8cd..6968fe8 --- a/lib/paymentProcessors/MerchantSolutions/paymentGateway.php +++ b/lib/paymentProcessors/MerchantSolutions/paymentGateway.php @@ -126,6 +126,11 @@ class PaymentGateway $this->request->acctid = $account['acctid']; $this->request->merchantpin = $account['merchantpin']; + // Test to see if soap support has been installed + if (!extension_loaded('soap')) { + trigger_error('*** PHP SOAP not installed and required by MerchantSolutions payment gateway! ***', E_USER_ERROR); + } + // Setup options related to doing the SOAP calls ini_set('soap.wsdl_cache_enabled', 1); use_soap_error_handler(false); @@ -238,10 +243,11 @@ class PaymentGateway case 1: // Always return a card approval $resp = array( - 'status' => 1, - 'statusText' => 'Card Approved', - 'authCode' => '000000', - 'description' => '(TESTMODE) Local Test - Card Approved' + 'gateway' => 'MerchantSolutions', + 'status' => 1, + 'statusText' => 'Card Approved', + 'authCode' => '000000', + 'description' => '(TESTMODE) Local Test - Card Approved' ); return $resp; break; @@ -249,10 +255,11 @@ class PaymentGateway // Fail Test case 2: $resp = array( - 'status' => 7, - 'statusText' => 'Card Declined', - 'authCode' => '', - 'description' => '(TESTMODE) Local Test - Card Declined' + 'gateway' => 'MerchantSolutions', + 'status' => 7, + 'statusText' => 'Card Declined', + 'authCode' => '', + 'description' => '(TESTMODE) Local Test - Card Declined' ); return $resp; break; @@ -289,10 +296,11 @@ class PaymentGateway if (strtoupper($this->result) == 'APPROVED') { $resp = array( - 'status' => 1, - 'statusText' => 'Card Approved', - 'authCode' => $this->response->authcode, - 'description' => $this->response->status + 'gateway' => 'MerchantSolutions', + 'status' => 1, + 'statusText' => 'Card Approved', + 'authCode' => $this->response->authcode, + 'description' => $this->response->status ); return $resp; @@ -301,10 +309,11 @@ class PaymentGateway $x = explode(":", $this->response->result); $resp = array( - 'status' => 7, - 'statusText' => 'Card Declined', - 'authCode' => '', - 'description' => $x[2] + 'gateway' => 'MerchantSolutions', + 'status' => 7, + 'statusText' => 'Card Declined', + 'authCode' => '', + 'description' => $x[2] ); return $resp; @@ -316,20 +325,22 @@ class PaymentGateway // Return communications failure $resp = array( - 'status' => 3, - 'statusText' => 'Transaction Error', - 'authCode' => '', - 'description' => 'Unable to communicate with credit card processing service.' + 'gateway' => 'MerchantSolutions', + 'status' => 3, + 'statusText' => 'Transaction Error', + 'authCode' => '', + 'description' => 'Unable to communicate with credit card processing service.' ); return $resp; } $resp = array( - 'status' => 4, - 'statusText' => 'Bad Response', - 'authCode' => '', - 'description' => 'Received unknown response from the credit card processing service.' + 'gateway' => 'MerchantSolutions', + 'status' => 4, + 'statusText' => 'Bad Response', + 'authCode' => '', + 'description' => 'Received unknown response from the credit card processing service.' ); return $resp; diff --git a/lib/paymentProcessors/Test/Test.php b/lib/paymentProcessors/TestByCardNumber/paymentGateway.php old mode 100755 new mode 100644 similarity index 58% rename from lib/paymentProcessors/Test/Test.php rename to lib/paymentProcessors/TestByCardNumber/paymentGateway.php index 162594c..9098c5f --- a/lib/paymentProcessors/Test/Test.php +++ b/lib/paymentProcessors/TestByCardNumber/paymentGateway.php @@ -45,7 +45,7 @@ class PaymentGateway { // Nothing to do here for the test processor - return $this->success; + return true; } @@ -64,6 +64,8 @@ class PaymentGateway * 'ccode' => {security code on back of card} * ) * + * @param array $contact Billing contact information (not used in this class) + * * This Test Processor looks at the last digit of the card number * and synthesizes a corresponding response. * @@ -77,7 +79,7 @@ class PaymentGateway * * @return array Returns array of results */ - function processPayment($pmt) + function processPayment($pmt, $contact = false) { // Get last digit of card number that indicates desired response @@ -92,6 +94,7 @@ class PaymentGateway case 1: $resp = array( + 'gateway' => 'Card # Tests', 'status' => 1, 'statusText' => 'Card Approved', 'authCode' => '00110011', @@ -102,8 +105,9 @@ class PaymentGateway case 2: $resp = array( - 'status' => 2, - 'statusText' => 'Bad data supplied', + 'gateway' => 'Card # Tests', + 'status' => 2, + 'statusText' => 'Bad data supplied', 'authCode' => '', 'description' => 'Card number was not recognizable' ); @@ -112,60 +116,66 @@ class PaymentGateway case 3: $resp = array( - 'status' => 3, - 'statusText' => 'Communications failure', - 'authCode' => '', - 'description' => 'We were unable to communicate with the credit card processing service.' + 'gateway' => 'Card # Tests', + 'status' => 3, + 'statusText' => 'Communications failure', + 'authCode' => '', + 'description' => 'We were unable to communicate with the credit card processing service.' ); break; case 4: $resp = array( - 'status' => 4, - 'statusText' => 'Bad Response', - 'authCode' => '', - 'description' => 'We received an unrecognizable response from the credit card processing service.' + 'gateway' => 'Card # Tests', + 'status' => 4, + 'statusText' => 'Bad Response', + 'authCode' => '', + 'description' => 'We received an unrecognizable response from the credit card processing service.' ); break; case 5: $resp = array( - 'status' => 5, - 'statusText' => 'Transaction not valid', - 'authCode' => '', - 'description' => 'We were unable to validate the response from the credit card processor.' + 'gateway' => 'Card # Tests', + 'status' => 5, + 'statusText' => 'Transaction not valid', + 'authCode' => '', + 'description' => 'We were unable to validate the response from the credit card processor.' ); break; case 6: $resp = array( - 'status' => 6, - 'statusText' => 'Merchant account problem', - 'authCode' => '00110011', - 'description' => 'The merchant account for this venue was not recognized by the credit card processor.' + 'gateway' => 'Card # Tests', + 'status' => 6, + 'statusText' => 'Merchant account problem', + 'authCode' => '00110011', + 'description' => 'The merchant account for this venue was not recognized by the credit card processor.' ); break; case 7: $resp = array( - 'status' => 7, - 'statusText' => 'Card Declined', - 'authCode' => '', - 'description' => 'Your credit card purchase was declined.' + 'gateway' => 'Card # Tests', + 'status' => 7, + 'statusText' => 'Card Declined', + 'authCode' => '', + 'description' => 'Your credit card purchase was declined.' ); break; default: // Consider any other last digit as approved $resp = array( - 'status' => 1, - 'statusText' => 'Card Approved', - 'authCode' => '00110011', - 'description' => 'Card Approved' + 'gateway' => 'Card # Tests', + 'status' => 1, + 'statusText' => 'Card Approved', + 'authCode' => '00110011', + 'description' => 'Card Approved' ); break; diff --git a/lib/paymentProcessors/None/paymentGateway.php b/lib/paymentProcessors/TestGood/paymentGateway.php old mode 100755 new mode 100644 similarity index 86% rename from lib/paymentProcessors/None/paymentGateway.php rename to lib/paymentProcessors/TestGood/paymentGateway.php index 7b76de7..2dd38a8 --- a/lib/paymentProcessors/None/paymentGateway.php +++ b/lib/paymentProcessors/TestGood/paymentGateway.php @@ -45,7 +45,7 @@ class PaymentGateway { // Nothing to do here - return $this->success; + return true; } @@ -64,6 +64,8 @@ class PaymentGateway * 'ccode' => {security code on back of card} * ) * + * @param array $contact Billing contact information (not used in this class) + * * This Processor always returns a "Card Approved" status * and synthesizes a corresponding response. * @@ -71,7 +73,7 @@ class PaymentGateway * * @return array Returns array of results */ - function processPayment($pmt) + function processPayment($pmt, $contact = false) { // Get last digit of card number that indicates desired response @@ -81,7 +83,8 @@ class PaymentGateway $approved = false; $resp = array( - 'status' => 1, + 'gateway' => 'Card Good', + 'status' => 1, 'statusText' => 'No Payment', 'authCode' => '000000', 'description' => 'No Payment Required' diff --git a/models/front/registrations/checkout.php b/models/front/registrations/checkout.php index 907812a..f50cf23 100644 --- a/models/front/registrations/checkout.php +++ b/models/front/registrations/checkout.php @@ -55,6 +55,8 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport $regAccountId = false; $regAccount = false; $messages = array(); + $payMethod = false; + $compCode = false; $Account = new GlmDataRegistrationsAccount($this->wpdb, $this->config); @@ -109,6 +111,9 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport } } + // Get any already submitted comp code + /**** NEED TO DO THIS ****/ + $view = 'checkout'; if ($haveCart) { @@ -134,13 +139,13 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport $regAccount = $Account->newEntry(); - require_once GLM_MEMBERS_CONTACTS_PLUGIN_LIB_PATH.'/EasyPassword/EasyPassword.php'; + require_once GLM_MEMBERS_REGISTRATIONS_MAIN_PLUGIN_LIB_PATH.'/EasyPassword/EasyPassword.php'; $EasyPassword = new EasyPassword(); $regAccount['fieldData']['password'] = $EasyPassword->generateEasyPassword($type = 'firstlast'); } - // Setup credit cart input fields - Use dataRegRequest to generate the field data + // Setup credit card input fields - Use dataRegRequest to generate the field data require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php'; $RegRequest = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config); $regReq = $RegRequest->newEntry(); @@ -154,13 +159,62 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport } } - // Add credit card field data to $regAccount['fieldData'] for use on form - $regAccount['fieldData']['cc_type'] = $cc_type; + // If credit card data was submitted, use that + if (isset($actionData['cardData']) && is_array($actionData['cardData'])) { + + // Set selected card type + reset($cc_type['list']); + + foreach ($cc_type['list'] as $k=>$v) { + + $cc_type['list'][$k]['default'] = false; + if ($k == $actionData['cardData']['cc_type']) { + $cc_type['list'][$k]['default'] = true; + } + } + + $regReq['fieldData']['cc_type'] = $cc_type; + $regReq['fieldData']['cc_name'] = $actionData['cardData']['cc_name']; + $regReq['fieldData']['cc_numb'] = $actionData['cardData']['cc_numb']; + $regReq['fieldData']['cc_exp'] = $actionData['cardData']['cc_exp']; + $regReq['fieldData']['cc_cvv'] = $actionData['cardData']['cc_cvv']; + } + + // Set default payment method + $payMethod = $this->config['default_payment_method']; + + // Get any payment method specified or selected on checkout attempt + if (isset($actionData['payMethod'])) { + $payMethod = $actionData['payMethod']; + } + + // Add credit card and other payment field data to $regAccount['fieldData'] for use on form + $regAccount['fieldData']['cc_type'] = $regReq['fieldData']['cc_type']; + $regAccount['fieldRequired']['cc_type'] = true; + $regAccount['fieldFail']['cc_type'] = ''; + $regAccount['fieldData']['cc_name'] = $regReq['fieldData']['cc_name']; + $regAccount['fieldRequired']['cc_name'] = true; + $regAccount['fieldFail']['cc_name'] = ''; + $regAccount['fieldData']['cc_numb'] = $regReq['fieldData']['cc_numb']; + $regAccount['fieldRequired']['cc_numb'] = true; + $regAccount['fieldFail']['cc_numb'] = ''; + $regAccount['fieldData']['cc_exp'] = $regReq['fieldData']['cc_exp']; + $regAccount['fieldRequired']['cc_exp'] = true; + $regAccount['fieldFail']['cc_exp'] = ''; + $regAccount['fieldData']['cc_cvv'] = $regReq['fieldData']['cc_cvv']; + $regAccount['fieldRequired']['cc_cvv'] = true; + $regAccount['fieldFail']['cc_cvv'] = ''; + $regAccount['fieldData']['cc_conf'] = $regReq['fieldData']['cc_conf']; + + $regAccount['fieldData']['comp_code'] = $compCode; + $regAccount['fieldRequired']['comp_code'] = true; + $regAccount['fieldFail']['comp_code'] = ''; + // *** If redirected back, be sure to get the submitted data // Accounts list not needed @@ -187,6 +241,7 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport 'assetUrl' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_ASSETS_URL, 'haveMessages' => count($messages) > 0, 'messages' => $messages, + 'payMethod' => $payMethod, 'payMethods' => $management['reg_payment_methods']['bitmap'], 'payMethodsNumb' => $this->config['payment_method_numb'] ); diff --git a/models/front/registrations/checkoutProcess.php b/models/front/registrations/checkoutProcess.php index d695894..60b0bc6 100644 --- a/models/front/registrations/checkoutProcess.php +++ b/models/front/registrations/checkoutProcess.php @@ -86,6 +86,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport public function modelAction($actionData = false) { + $messages = array(); $haveCheckout = false; $requestId = false; $accountId = false; @@ -93,8 +94,11 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $modelRedirect = false; $view = 'checkout'; $page = "checkout"; - $messages = array(); + $payMethod = false; + $payMethodName = false; $regPayment = false; + $cardData = false; + $cardTypeMatch = false; $Account = new GlmDataRegistrationsAccount($this->wpdb, $this->config); @@ -131,11 +135,18 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $accountId = ($_SESSION['LoginAccount']['id'] - 0); - // Try to update the account information + // Try to update the account information and if that works get the data for editing again if ($accountId > 0) { + $regAccount = $Account->updateEntry($accountId); + + // If there was a problem, indicate that if (!$regAccount) { $messages[] = 'Unable to recall your account information. Please try again later.'; + + // Otherwise get the data again prepaired for editing + } else { + $regAccount = $Account->editEntry($accountId); } } @@ -182,6 +193,179 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport * Process Payment? */ + require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataManagement.php'; + $Management = new GlmDataRegistrationsManagement($this->wpdb, $this->config); + $management = $Management->getEntry(1); + + // Get payment method selected + if (isset($_REQUEST['payMethod'])) { + $payMethod = ($_REQUEST['payMethod'] - 0); + } + + // Make sure that the selected payment method is available + if ($payMethod > 0 && ($management['reg_payment_methods']['bitmap'][$payMethod]['default'])) { + $payMethodName = $management['reg_payment_methods']['bitmap'][$payMethod]['name']; + } else { + $payMethod = false; + } + + // Execute selected payment method + switch ($payMethod) { + + // No Charge + case $this->config['payment_method_numb']['NoCharge']: + break; + + // Comp Code + case $this->config['payment_method_numb']['CompCode']: + break; + + // Cash + case $this->config['payment_method_numb']['Cash']: + break; + + // Check + case $this->config['payment_method_numb']['Check']: + break; + + // Call From Merchant + case $this->config['payment_method_numb']['CallFromMerchant']: + break; + + // Credit Card + case $this->config['payment_method_numb']['CreditCard']: + + // Get the selected credit card processor type + $ccProcessor = $this->config['settings']['reg_proc_methods']; + + // Setup the required account information for the selected payment processor + switch ($ccProcessor) { + + case $this->config['proc_method_numb']['Authorize.net']: + + // Get account data + $account = array( + 'login' => $this->config['settings']['reg_authorize_net_login'], + 'key' => $this->config['settings']['reg_authorize_net_key'], + 'test' => $this->config['settings']['reg_authorize_net_test'], + 'conf' => $this->config['settings']['reg_authorize_net_conf'], + 'email' => $this->config['settings']['reg_authorize_net_merchant_email'] + ); + + break; + + case $this->config['proc_method_numb']['MerchantSolutions']: + + // Get account data + $account = array( + 'acctid' => $this->config['settings']['reg_merchant_solutions_acctid'], + 'merchantpin' => $this->config['settings']['reg_merchant_solutions_merchantpin'], + 'test' => $this->config['settings']['reg_merchant_solutions_test'], + 'conf' => $this->config['settings']['reg_merchant_solutions_conf'], + 'email' => $this->config['settings']['reg_merchant_solutions_merchant_email'] + ); + + break; + + // These don't require account data + case $this->config['proc_method_numb']['Merchant']: + case $this->config['proc_method_numb']['TestAlwaysGood']: + case $this->config['proc_method_numb']['TestByCardNumber']: + default: + $account = array(); + break; + + } + + // Get the credit card input + $cardData = array( + 'cc_type' => filter_input(INPUT_POST, 'cc_type', FILTER_SANITIZE_NUMBER_INT), + '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), + 'cc_cvv' => filter_input(INPUT_POST, 'cc_cvv', FILTER_SANITIZE_NUMBER_INT) + ); + + // Check all credit card input + if ( + $cardData['cc_type'] && $cardData['cc_type'] > 0 && + $cardData['cc_name'] && $cardData['cc_name'] != '' && + $cardData['cc_numb'] && $cardData['cc_numb'] > 0 && + $cardData['cc_exp'] && $cardData['cc_exp'] != '' && + $cardData['cc_cvv'] && $cardData['cc_cvv'] > 0 + ) { + + + if (!isset($this->config['credit_card_match'][$cardData['cc_type']]) || + !preg_match($this->config['credit_card_match'][$cardData['cc_type']], $cardData['cc_numb']) + ) { + $messages[] = 'The credit card number you entered does not match the selected type of credit card.'; + } + + } else { + $messages[] = 'You did not supply all required credit card information.'; + } + + // Get the correct billing data + // Build array of billing information using either the account data or the billing data as requested + $billPrefix = 'bill_'; + if (isset($_REQUEST['billing_same']) && $_REQUEST['billing_same']) { + $billPrefix = ''; + } + + $billing = array( + 'fname' => $regAccount['fieldData'][$billPrefix.'fname'], + 'lname' => $regAccount['fieldData'][$billPrefix.'lname'], + 'addr1' => $regAccount['fieldData'][$billPrefix.'addr1'], + 'addr2' => $regAccount['fieldData'][$billPrefix.'addr2'], + 'city' => $regAccount['fieldData'][$billPrefix.'city'], + 'state' => $regAccount['fieldData'][$billPrefix.'state']['value'], + 'country' => $regAccount['fieldData'][$billPrefix.'country']['value'], + 'zip' => $regAccount['fieldData'][$billPrefix.'zip'], + 'phone' => $regAccount['fieldData'][$billPrefix.'phone'], + 'email' => $regAccount['fieldData']['email'] + ); + + if (count($messages) == 0) { + + // Determine the directory of the payment processor to load and instatiate it. + if ($ccProcessor && isset($this->config['proc_dir'][$ccProcessor])) { + require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_LIB_PATH.'/paymentProcessors/'.$this->config['proc_dir'][$ccProcessor].'/paymentGateway.php'; + $CcProcessor = new PaymentGateway($account); + } + + $payment = array( + 'name' => $this->config['settings']['reg_org_name'], // Name of venue + 'charge' => $this->cart['totalCharges'], // Total charges this venue + 'cctype' => $cardData['cc_type'], // Card Type + 'ccname' => $cardData['cc_name'], // Name on Card + 'ccnumb' => $cardData['cc_numb'], // Card Number + 'ccexp' => $cardData['cc_exp'], // Expriation Date + 'cccode' => $cardData['cc_cvv'], // CCV - security code + 'invoice' => 0101010101 // Invoice # is session ID (or some part thereof) + ); + + // Now try to run the card processor + $ccResult = $CcProcessor->processPayment($payment, $billing); +echo "
".print_r($ccResult,1)."
"; + +/**** NEED TO FIX INVOICE # ABOVE ****/ + } + + break; + + // Pay Pal + case $this->config['payment_method_numb']['PayPal']: + break; + + // Payment Method unknown + default: +// $payMethod = false; + break; + + } + + if (count($messages) == 0) { @@ -203,7 +387,9 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport 'haveMessages' => count($messages), 'messages' => $messages, 'regAccount' => $regAccount, - 'regPayment' => $regPayment + 'regPayment' => $regPayment, + 'payMethod' => $payMethod, + 'cardData' => $cardData ); return array( 'status' => true, @@ -213,12 +399,19 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport 'data' => $templateData ); } + + // Update the cart flags and include updated billing data +/**** NEED TO DO THIS ****/ + echo "

Checkout Done...

"; + // Compile template data $templateData = array( 'page' => $page, 'haveMessages' => count($messages), - 'messages' => $messages + 'messages' => $messages, + 'payMethod' => $payMethod, + 'payMethodName' => $payMethodName ); // Return status, any suggested view, and any data to controller diff --git a/setup/databaseScripts/create_database_V0.0.16.sql b/setup/databaseScripts/create_database_V0.0.17.sql similarity index 98% rename from setup/databaseScripts/create_database_V0.0.16.sql rename to setup/databaseScripts/create_database_V0.0.17.sql index 3ca1fcd..3c203e1 100644 --- a/setup/databaseScripts/create_database_V0.0.16.sql +++ b/setup/databaseScripts/create_database_V0.0.17.sql @@ -63,7 +63,7 @@ -- Only one entry in this table! CREATE TABLE {prefix}management ( id INT NOT NULL AUTO_INCREMENT, - canonical_reg_page TINYTEXT NULL, -- Canonical page slug for registrations + canonical_reg_page TINYTEXT NULL, -- Canonical page slug for registrations -- System Owner Information reg_org_name TINYTEXT NULL, -- Customer Information - Name of Organization reg_org_short TINYTEXT NULL, @@ -75,8 +75,8 @@ CREATE TABLE {prefix}management ( reg_org_toll_free TINYTEXT NULL, reg_org_internal_email TINYTEXT NULL, reg_org_from_email TINYTEXT NULL, - reg_payment_methods SMALLINT NULL, -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini - reg_proc_methods SMALLINT NULL, -- Payment processing methods available - Bitmap - see proc_method in plugin.ini + reg_payment_methods SMALLINT NULL, -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini + reg_proc_methods SMALLINT NULL, -- Creadit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini reg_cc_accepts SMALLINT NULL, -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini -- Authorize.net Credentials reg_authorize_net_login TINYTEXT NULL, @@ -88,9 +88,11 @@ CREATE TABLE {prefix}management ( reg_merchant_solutions_acctid TINYTEXT NULL, -- Merchant Solutions credentials reg_merchant_solutions_merchantpin TINYTEXT NULL, reg_merchant_solutions_test TINYINT NULL, -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini + reg_merchant_solutions_conf BOOLEAN NULL, -- Flag to send payment confirmation Email + reg_merchant_solutions_merchant_email TINYTEXT NULL, -- Merchant Solutions will send copy of confirmation E-Mail -- Billing settings reg_full_billing_info BOOLEAN NULL, -- Always request full billing information in checkout page regardless of the following settings - reg_bill_info_req_no_charge SMALLINT NULL, -- Bitmap of fields to use in checkout for these types of payments - See billing_field in plugin.conf + reg_bill_info_req_no_charge SMALLINT NULL, -- Bitmap of fields to use in checkout for these types of payments - See billing_field in plugin.conf reg_bill_info_req_comp_code SMALLINT NULL, reg_bill_info_req_cash SMALLINT NULL, reg_bill_info_req_check SMALLINT NULL, diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 1c44fac..5af2dd2 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -29,7 +29,8 @@ $glmMembersRegistrationsDbVersions = array( '0.0.13' => array('version' => '0.0.13', 'tables' => 20, 'date' => '10/03/2017'), '0.0.14' => array('version' => '0.0.14', 'tables' => 20, 'date' => '10/13/2017'), '0.0.15' => array('version' => '0.0.15', 'tables' => 15, 'date' => '10/18/2017'), - '0.0.16' => array('version' => '0.0.16', 'tables' => 15, 'date' => '10/24/2017') + '0.0.16' => array('version' => '0.0.16', 'tables' => 15, 'date' => '10/24/2017'), + '0.0.17' => array('version' => '0.0.17', 'tables' => 15, 'date' => '11/3/2017') ); diff --git a/setup/databaseScripts/drop_database_V0.0.16.sql b/setup/databaseScripts/drop_database_V0.0.17.sql similarity index 100% rename from setup/databaseScripts/drop_database_V0.0.16.sql rename to setup/databaseScripts/drop_database_V0.0.17.sql diff --git a/setup/databaseScripts/update_database_V0.0.17.sql b/setup/databaseScripts/update_database_V0.0.17.sql new file mode 100644 index 0000000..881fc7b --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.17.sql @@ -0,0 +1,13 @@ +-- Gaslight Media Members Database - Registratiuons Add-On +-- File Created: 10/03/17 11:00:00 +-- Database Version: 0.0.16 +-- 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}management ADD COLUMN reg_merchant_solutions_conf BOOLEAN; + +---- + +ALTER TABLE {prefix}management ADD COLUMN reg_merchant_solutions_merchant_email TINYTEXT; diff --git a/views/admin/management/registrations.html b/views/admin/management/registrations.html index 94386ad..f809ef7 100644 --- a/views/admin/management/registrations.html +++ b/views/admin/management/registrations.html @@ -136,27 +136,26 @@ - +

Authorize.net

- - - Authorize.net Login: + + Login: {if $regSettings.fieldFail.reg_authorize_net_login}

{$regSettings.fieldFail.reg_authorize_net_login}

{/if} - - Authorize.net Key: + + Key: {if $regSettings.fieldFail.reg_authorize_net_key}

{$regSettings.fieldFail.reg_authorize_net_key}

{/if} - - Authorize.net Test Mode: + + Test Mode: - + Send Confirmation E-Mail - - Authorize.net Merchant Email: + + Merchant Email: {if $regSettings.fieldFail.reg_authorize_net_merchant_email}

{$regSettings.fieldFail.reg_authorize_net_merchant_email}

{/if} - +

Merchant Solutions

- - Merchant Solutions Account ID: + + Account ID: {if $regSettings.fieldFail.reg_merchant_solutions_acctid}

{$regSettings.fieldFail.reg_merchant_solutions_acctid}

{/if} - - Merchant Solutions Merchant PIN: + + Merchant PIN: {if $regSettings.fieldFail.reg_merchant_solutions_merchantpin}

{$regSettings.fieldFail.reg_merchant_solutions_merchantpin}

{/if} - - Merchant Solutions Test Mode: + + Test Mode: + + Send Confirmation E-Mail + + + + + + Merchant Email: + + + {if $regSettings.fieldFail.reg_merchant_solutions_merchant_email}

{$regSettings.fieldFail.reg_merchant_solutions_merchant_email}

{/if} + +

Billing Information Fields

@@ -292,4 +304,39 @@ + + {include file='admin/management/footer.html'} \ No newline at end of file diff --git a/views/front/registrations/checkout.html b/views/front/registrations/checkout.html index 549d72d..2772ed1 100644 --- a/views/front/registrations/checkout.html +++ b/views/front/registrations/checkout.html @@ -11,8 +11,8 @@ {/if} -{if $haveCart} -
+{if $haveCart} + See summary of registration request and charges below @@ -108,7 +108,7 @@

Billing Information

-
 Same as Account Information
+
 Same as Account Information
First Name:
@@ -174,55 +174,96 @@

Payment Information

- {if $payMethods.{$payMethodsNumb.NoCharge}.default} -
{$payMethods.{$payMethodsNumb.NoCharge}.name}
+ {$pm = $payMethodsNumb.NoCharge} + {if $payMethods.{$pm}.default} +
+
+

*** No Charge ****

+
{/if} - {if $payMethods.{$payMethodsNumb.CompCode}.default} -
{$payMethods.{$payMethodsNumb.CompCode}.name}
+ {$pm = $payMethodsNumb.CompCode} + {if $payMethods.{$pm}.default} +
+
+
+
Enter code:
+
+ +
+
+
{/if} - {if $payMethods.{$payMethodsNumb.Cash}.default} -
{$payMethods.{$payMethodsNumb.Cash}.name}
+ {$pm = $payMethodsNumb.Cash} + {if $payMethods.{$pm}.default} +
+
+

*** Cash ****

+
+ {/if} - {if $payMethods.{$payMethodsNumb.Check}.default} -
{$payMethods.{$payMethodsNumb.Check}.name}
+ {$pm = $payMethodsNumb.Check} + {if $payMethods.{$pm}.default} +
+
+

*** No Check ****

+
{/if} - {if $payMethods.{$payMethodsNumb.CallFromMerchant}.default} -
{$payMethods.{$payMethodsNumb.CallFromMerchant}.name}
+ {$pm = $payMethodsNumb.CallFromMerchant} + {if $payMethods.{$pm}.default} +
+
+

*** Call From Merchant ****

+
{/if} - {if $payMethods.{$payMethodsNumb.CreditCard}.default} -
{$payMethods.{$payMethodsNumb.CreditCard}.name}
-
-
Card Type:
-
- + {$pm = $payMethodsNumb.CreditCard} + {if $payMethods.{$pm}.default} +
+
+
+
Name on Card:
+
+ +
+
+
Card Type:
+
+ +
+
+
+
Card Number:
+
+ +
+
+
+
Card Expiration:
+
+ +
+
+
+
CVV:
+
+ +
+
-
-
Name on Card:
-
-
-
-
Card Number:
-
-
-
-
Card Expiration:
-
-
-
-
CVV:
-
-
{/if} - {if $payMethods.{$payMethodsNumb.PayPal}.default} -
{$payMethods.{$payMethodsNumb.PayPal}.name}
+ {$pm = $payMethodsNumb.PayPal} + {if $payMethods.{$pm}.default} +
+
+

*** Pay Pal ****

+
{/if} @@ -240,18 +281,20 @@

Terms and Conditions (*** Added fields for events ***)

- You must check the boxes below to confirm that you agree to the listed Terms and Conditions for each event. + You must check the boxes below to confirm that you agree to the Terms and Conditions for each event.
{foreach $cart.events as $event} + {if $event.event_terms != ''}
 
{$event.event_name}:
- {$event.event_terms} {$event.id}
+
*** Any added fields go here ***
+ {/if} {/foreach}
@@ -262,17 +305,26 @@
(There is no charge for your request.)
{/if} - {if $cart.blockCheckout} -
-
You have not yet submitted your registration. See above for issues!
-
- {else}
- You have one more step to complete your registration! + You have one more step to complete your registration!
- {/if} + + +
Please wait while we process your registration request. If you don't see a new page, your registration request may not have been processed.
+
+

Something may have gone wrong.

+

+ It may be that your registration request was received and processed and you didn't receive our response yet. + If you still don't see a response in a while, try returning to the cart using the button above. + If still don't see any response, please check your E-Mail to see if you have been sent a confirmation. +

+

+ In any case, we will never process your request more than once. If you can return to the cart, it should say if + your request was recieved and processed. If not, you may try the checkout process again or come back later. +

+

Registration Summary

@@ -312,8 +364,8 @@
{$registrant.fname} {$registrant.lname} {$registrant.event_time} - {if $registrant.registrantDiscount > 0} - {$registrant.registrantDiscount|number_format:2} + {if $registrant.registrantDiscounts > 0} + {$registrant.registrantDiscounts|number_format:2} {else}   {/if} @@ -349,3 +401,69 @@ + + \ No newline at end of file -- 2.17.1