From: Steve Sutton Date: Fri, 5 Apr 2019 11:48:53 +0000 (-0400) Subject: Setting up Square payment processor. X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=a2d1f9a99d9dfdcb8ff8c273df4737a289d4b756;p=WP-Plugins%2Fglm-member-db-billing.git Setting up Square payment processor. Creating new fields for the management of square payment processor. Setting up the billing support class to use square as processor. --- diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 1073969..75f3bf6 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -1221,7 +1221,7 @@ class GlmBillingSupport // Setup the required account information for the selected payment processor switch ( $ccProcessor ) { - case $this->config['proc_method_numb']['Authorize.net']: + case $this->config['billing_proc_method_numb']['Authorize.net']: // Get account data $account = array( @@ -1234,7 +1234,7 @@ class GlmBillingSupport break; - case $this->config['proc_method_numb']['MerchantSolutions']: + case $this->config['billing_proc_method_numb']['MerchantSolutions']: // Get account data $account = array( @@ -1247,15 +1247,30 @@ class GlmBillingSupport break; + case $this->config['billing_proc_method_numb']['Square']: + // Get account data + $account = array( + 'prod_app_id' => $this->config['billing_settings']['square_prod_app_id'], + 'prod_access_token' => $this->config['billing_settings']['square_prod_access_token'], + 'prod_location_id' => $this->config['billing_settings']['square_prod_location_id'], + 'sandbox_app_id' => $this->config['billing_settings']['square_sandbox_app_id'], + 'sandbox_access_token' => $this->config['billing_settings']['square_sandbox_access_token'], + 'sandbox_location_id' => $this->config['billing_settings']['square_sandbox_location_id'], + 'use_prod' => $this->config['billing_settings']['square_use_prod'], + ); + $checkCC = false; + 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']: + case $this->config['billing_proc_method_numb']['Merchant']: + case $this->config['billing_proc_method_numb']['TestAlwaysGood']: + case $this->config['billing_proc_method_numb']['TestByCardNumber']: default: $account = array(); break; } + // Get the credit card input $cardData = filter_var_array( $_REQUEST, @@ -1348,8 +1363,8 @@ class GlmBillingSupport if ( count( $errors ) == 0 ) { // Determine the directory of the payment processor to load and instantiate it. - if ( $ccProcessor && isset( $this->config['proc_dir'][$ccProcessor] ) ) { - require_once GLM_MEMBERS_PLUGIN_LIB_PATH . '/paymentProcessors/' . $this->config['proc_dir'][$ccProcessor] . '/paymentGateway.php'; + if ( $ccProcessor && isset( $this->config['billing_proc_dir'][$ccProcessor] ) ) { + require_once GLM_MEMBERS_PLUGIN_LIB_PATH . '/paymentProcessors/' . $this->config['billing_proc_dir'][$ccProcessor] . '/paymentGateway.php'; $CcProcessor = new PaymentGateway( $account ); } @@ -1370,8 +1385,6 @@ class GlmBillingSupport // Now try to run the card processor $ccResult = $CcProcessor->processPayment( $payment, $billing ); - // echo '
$ccResult: ' . print_r( $ccResult, true ) . '
'; - // If successful submission - say we're complete if ( is_array( $ccResult ) && isset( $ccResult['status'] ) && $ccResult['status'] == 1 ) { diff --git a/classes/data/dataManagement.php b/classes/data/dataManagement.php index d50d3b0..be74e04 100644 --- a/classes/data/dataManagement.php +++ b/classes/data/dataManagement.php @@ -109,35 +109,35 @@ class GlmDataBillingManagement extends GlmDataAbstract $this->fields = array ( 'id' => array ( - 'field' => 'id', - 'type' => 'integer', + 'field' => 'id', + 'type' => 'integer', 'view_only' => true, - 'use' => 'a' + 'use' => 'a' ), // Payment Methods Selected - Bitmap 'payment_methods' => array ( - 'field' => 'payment_methods', - 'type' => 'bitmap', - 'bitmap' => $this->config['payment_method'], - 'default' => 0, // none selected - 'use' => 'a' + 'field' => 'payment_methods', + 'type' => 'bitmap', + 'bitmap' => $this->config['payment_method'], + 'default' => 0, // none selected + 'use' => 'a' ), // Processing Methods Selected - Bitmap 'proc_methods' => array ( 'field' => 'proc_methods', 'type' => 'list', - 'list' => $this->config['proc_method'], - 'default' => $this->config['proc_method_numb']['Merchant'], + 'list' => $this->config['billing_proc_method'], + 'default' => $this->config['billing_proc_method_numb']['Merchant'], 'use' => 'a' ), // Credit Cards Accepted Selected - Bitmap 'cc_accepts' => array ( - 'field' => 'cc_accepts', + 'field' => 'cc_accepts', 'type' => 'bitmap', - 'bitmap' => $this->config['credit_card'], + 'bitmap' => $this->config['credit_card'], 'default' => 0, // none selected 'use' => 'a' ), @@ -145,77 +145,77 @@ class GlmDataBillingManagement extends GlmDataAbstract // Authorize.net Login 'authorize_net_login' => array ( 'field' => 'authorize_net_login', - 'type' => 'text', - 'use' => 'a' + 'type' => 'text', + 'use' => 'a' ), // Authorize.net Key 'authorize_net_key' => array ( 'field' => 'authorize_net_key', - 'type' => 'text', - 'use' => 'a' + 'type' => 'text', + 'use' => 'a' ), // Authorize.net Test Mode 'authorize_net_test' => array ( - 'field' => 'authorize_net_test', - 'type' => 'list', - 'list' => $this->config['proc_test_mode'], + 'field' => 'authorize_net_test', + 'type' => 'list', + 'list' => $this->config['proc_test_mode'], 'default' => $this->config['proc_test_mode_numb']['Local Approval Test'], - 'use' => 'a' + 'use' => 'a' ), // Always Use Full Billing Info 'authorize_net_conf' => array ( - 'field' => 'authorize_net_conf', - 'type' => 'checkbox', - 'use' => 'a', - 'default' => 0, + 'field' => 'authorize_net_conf', + 'type' => 'checkbox', + 'use' => 'a', + 'default' => 0, ), // Authorize.net Merchant Email 'authorize_net_merchant_email' => array ( 'field' => 'authorize_net_merchant_email', - 'type' => 'text', - 'use' => 'a' + 'type' => 'text', + 'use' => 'a' ), // Merchant Solutions Account ID 'merchant_solutions_acctid' => array ( 'field' => 'merchant_solutions_acctid', - 'type' => 'text', - 'use' => 'a' + 'type' => 'text', + 'use' => 'a' ), // Merchant Solutions Merchant PIN 'merchant_solutions_merchantpin' => array ( 'field' => 'merchant_solutions_merchantpin', - 'type' => 'text', - 'use' => 'a' + 'type' => 'text', + 'use' => 'a' ), // Merchant Solutions Test Mode 'merchant_solutions_test' => array ( - 'field' => 'merchant_solutions_test', - 'type' => 'list', - 'list' => $this->config['proc_test_mode'], + 'field' => 'merchant_solutions_test', + 'type' => 'list', + 'list' => $this->config['proc_test_mode'], 'default' => $this->config['proc_test_mode_numb']['Local Approval Test'], - 'use' => 'a' + 'use' => 'a' ), // Always Use Full Billing Info 'merchant_solutions_conf' => array ( - 'field' => 'merchant_solutions_conf', - 'type' => 'checkbox', - 'use' => 'a', - 'default' => 0, + 'field' => 'merchant_solutions_conf', + 'type' => 'checkbox', + 'use' => 'a', + 'default' => 0, ), // Merchant Email 'merchant_solutions_merchant_email' => array ( 'field' => 'merchant_solutions_merchant_email', - 'type' => 'text', - 'use' => 'a' + 'type' => 'text', + 'use' => 'a' ), // Use uptra invoice template @@ -232,10 +232,59 @@ class GlmDataBillingManagement extends GlmDataAbstract 'use' => 'a', ), + // Square + 'square_prod_access_token' => array ( + 'field' => 'square_prod_access_token', + 'type' => 'text', + 'use' => 'a' + ), + + // Square + 'square_prod_app_id' => array ( + 'field' => 'square_prod_app_id', + 'type' => 'text', + 'use' => 'a' + ), + + // Square + 'square_prod_location_id' => array ( + 'field' => 'square_prod_location_id', + 'type' => 'text', + 'use' => 'a' + ), + + // Square + 'square_sandbox_access_token' => array ( + 'field' => 'square_sandbox_access_token', + 'type' => 'text', + 'use' => 'a' + ), + + // Square + 'square_sandbox_app_id' => array ( + 'field' => 'square_sandbox_app_id', + 'type' => 'text', + 'use' => 'a' + ), + + // Square + 'square_sandbox_location_id' => array ( + 'field' => 'square_sandbox_location_id', + 'type' => 'text', + 'use' => 'a' + ), + + + // If true use Production creds + 'square_use_prod' => array ( + 'field' => 'square_use_prod', + 'type' => 'checkbox', + 'use' => 'a', + 'default' => 0, + ), + ); } } - -?> diff --git a/config/plugin.ini b/config/plugin.ini index b3ddf20..e39a6c8 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -85,36 +85,39 @@ credit_card_match[5] = '/^([30|36|38]{2})([0-9]{12})$ ; ; Card Processing Methods - Use as Bitmap Index or List ; -proc_method[1] = 'By Merchant' -proc_method[2] = 'Authorize.net' -proc_method[3] = 'Merchant Solutions' -proc_method[98] = 'Test - Card Always Good' -proc_method[99] = 'Test by Card Number' - -proc_method_numb['Merchant'] = 1 -proc_method_numb['Authorize.net'] = 2 -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' +billing_proc_method[1] = 'By Merchant' +billing_proc_method[2] = 'Authorize.net' +billing_proc_method[3] = 'Merchant Solutions' +billing_proc_method[4] = 'Square' +billing_proc_method[98] = 'Test - Card Always Good' +billing_proc_method[99] = 'Test by Card Number' + +billing_proc_method_numb['Merchant'] = 1 +billing_proc_method_numb['Authorize.net'] = 2 +billing_proc_method_numb['MerchantSolutions'] = 3 +billing_proc_method_numb['Square'] = 4 +billing_proc_method_numb['TestAlwaysGood'] = 98 +billing_proc_method_numb['TestByCardNumber'] = 99 + +billing_proc_dir[1] = 'ByMerchant' +billing_proc_dir[2] = 'Authorize.Net' +billing_proc_dir[3] = 'MerchantSolutions' +billing_proc_dir[4] = 'Square' +billing_proc_dir[98] = 'TestGood' +billing_proc_dir[99] = 'TestByCardNumber' ; ; Card processing test modes ; -proc_test_mode[0] = 'Production Mode' -proc_test_mode[1] = 'Local Transaction Approval Test' -proc_test_mode[2] = 'Local Transaction Decline Test' -proc_test_mode[3] = 'On-Line Transaction Test' - -proc_test_mode_numb['Local Approval Test'] = 1 -proc_test_mode_numb['Local Decline Test'] = 2 -proc_test_mode_numb['On-Line Test'] = 3 -proc_test_mode_numb['Production Mode'] = 0 +billing_proc_test_mode[0] = 'Production Mode' +billing_proc_test_mode[1] = 'Local Transaction Approval Test' +billing_proc_test_mode[2] = 'Local Transaction Decline Test' +billing_proc_test_mode[3] = 'On-Line Transaction Test' + +billing_proc_test_mode_numb['Local Approval Test'] = 1 +billing_proc_test_mode_numb['Local Decline Test'] = 2 +billing_proc_test_mode_numb['On-Line Test'] = 3 +billing_proc_test_mode_numb['Production Mode'] = 0 ; ; Card processor result codes diff --git a/css/sq-payment-form.css b/css/sq-payment-form.css new file mode 100644 index 0000000..3e83a9a --- /dev/null +++ b/css/sq-payment-form.css @@ -0,0 +1,181 @@ +.sq-field-wrapper { + display: flex; + flex-flow: row nowrap; + margin-bottom: 16px; +} + +.sq-field { + margin-bottom: 16px; + width: 100%; +} + +.sq-field:first-child { + margin-left: 0; +} + +.sq-field:last-child { + margin-right: 0; +} + +.sq-field--in-wrapper { + flex-grow: 1; + margin: 0 8px; +} + +.sq-label { + margin-bottom: 8px; + text-transform: uppercase; +} + +.sq-input { + background-color: #fff; + border-style: solid; + border-width: 1px; + overflow: hidden; + transition: border-color 0.25s ease; + width: 100%; +} + +.sq-input--focus { + background-color: #fbfdff; +} + +.sq-input--error { + background-color: #fbfdff; +} + +.sq-button { + color: #fff; + padding: 16px; + width: 100%; +} + +.sq-button:active { + color: #fff; +} +.sq-payment-form { + max-width: 100%; + padding: 20px 20px 5px; + width: 380px; +} + +.sq-label { + color: #000000; + font-size: 14px; + font-family: "Helvetica Neue", "Helvetica", sans-serif; + font-weight: 500; + letter-spacing: 0.5px; +} + +.sq-input { + border-color: #E0E2E3; + border-radius: 4px; +} + +.sq-input--focus { + border-color: #4A90E2; +} + +.sq-input--error { + border-color: #e02e2f; +} + +.sq-button { + background: #4A90E2; + border-radius: 4px; + font-size: 16px; + font-weight: 600; + letter-spacing: 1px; +} + +.sq-button:active { + background: #4A90E2; +} +.sq-wallet-divider { + margin: 24px 0; + position: relative; + text-align: center; + width: 100%; +} + +.sq-wallet-divider:after, .sq-wallet-divider::after, .sq-wallet-divider:before, .sq-wallet-divider::before { + background: #bbb; + content: ''; + display: block; + height: 1px; + left: 0; + position: absolute; + right: 0; + top: 9px; +} + +.sq-wallet-divider:after, .sq-wallet-divider::after { + right: 65%; +} + +.sq-wallet-divider:before, .sq-wallet-divider::before { + left: 65%; +} + +.sq-wallet-divider__text { + color: #bbb; + padding: 10px; + text-transform: uppercase; +} + +/* Indicates how Google Pay button will appear */ +.button-google-pay { + width: 100%; + min-height: 40px; + padding: 11px 24px; + margin-bottom: 18px; + background-color: #000; + background-image: url(data:image/svg+xml,%3Csvg%20width%3D%22103%22%20height%3D%2217%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm5.379.903c-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322-.868%200-1.528-.259-1.981-.777zm9.859.161L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zm12.379-1.337a1%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301%201%201%200%200%201-.735-.301zM39.93%205.86h1.54V13h-1.54V5.86zm5.568%207.098a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21-.317%200-.616-.051-.896-.154zm3.678-9.982h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976zm32.35-.341v4.083h2.518c.6%200%201.096-.202%201.488-.605.403-.402.605-.882.605-1.437%200-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0%205.52v4.736h-1.504V1.198h3.99c1.013%200%201.873.337%202.582%201.012.72.675%201.08%201.497%201.08%202.466%200%20.991-.36%201.819-1.08%202.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668%202.287c0%20.392.166.718.499.98.332.26.722.391%201.168.391.633%200%201.196-.234%201.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61%200-1.12.148-1.528.442-.409.294-.613.657-.613%201.093m1.946-5.815c1.112%200%201.989.297%202.633.89.642.594.964%201.408.964%202.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45%201.372-2.486%201.372-.882%200-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96%200-.828.313-1.486.94-1.976s1.463-.735%202.51-.735c.892%200%201.629.163%202.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132%202.132%200%200%200-1.455-.547c-.84%200-1.504.353-1.995%201.062l-1.324-.834c.73-1.045%201.81-1.568%203.238-1.568m11.853.262l-5.02%2011.53H96.42l1.864-4.034-3.302-7.496h1.635l2.387%205.749h.032l2.322-5.75z%22%20fill%3D%22%23FFF%22%2F%3E%3Cpath%20d%3D%22M75.448%207.134c0-.473-.04-.93-.116-1.366h-6.344v2.588h3.634a3.11%203.11%200%200%201-1.344%202.042v1.68h2.169c1.27-1.17%202.001-2.9%202.001-4.944%22%20fill%3D%22%234285F4%22%2F%3E%3Cpath%20d%3D%22M68.988%2013.7c1.816%200%203.344-.595%204.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754%200-3.244-1.182-3.776-2.774h-2.234v1.731a6.728%206.728%200%200%200%206.01%203.703%22%20fill%3D%22%2334A853%22%2F%3E%3Cpath%20d%3D%22M65.212%208.267a4.034%204.034%200%200%201%200-2.572V3.964h-2.234a6.678%206.678%200%200%200-.717%203.017c0%201.085.26%202.11.717%203.017l2.234-1.731z%22%20fill%3D%22%23FABB05%22%2F%3E%3Cpath%20d%3D%22M68.988%202.921c.992%200%201.88.34%202.58%201.008v.001l1.92-1.918c-1.165-1.084-2.685-1.75-4.5-1.75a6.728%206.728%200%200%200-6.01%203.702l2.234%201.731c.532-1.592%202.022-2.774%203.776-2.774%22%20fill%3D%22%23E94235%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E); + background-origin: content-box; + background-position: center; + background-repeat: no-repeat; + background-size: contain; + border: 0; + border-radius: 4px; + box-shadow: 0 1px 1px 0 rgba(60, 64, 67, 0.30), 0 1px 3px 1px rgba(60, 64, 67, 0.15); + outline: 0; + cursor: pointer; + display: none; +} + + +.sq-apple-pay { + -webkit-appearance: -apple-pay-button; + border: none; + height: 48px; + margin-bottom: 12px; + width: 100%; + display: none; +} +.sq-masterpass { + background-color: #000; + background-image: url(https://masterpass.com/dyn/img/btn/global/mp_chk_btn_384x048px.svg); + background-repeat: no-repeat; + background-size: contain; + background-position: center right; + border-radius: 5px; + height: 42px; + margin-bottom: 16px; + width: 100%; + display: none; +} + +.sq-button:hover { + cursor: pointer; + background-color: #4281CB; +} + +#error { + width: 100%; + margin-top: 16px; + font-size: 14px; + color: red; + font-weight: 500; + text-align: center; + opacity: 0.8; +} diff --git a/index.php b/index.php index 9f53a5e..12cd96a 100644 --- a/index.php +++ b/index.php @@ -38,7 +38,7 @@ * version from this plugin. */ define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '1.0.25'); -define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.35'); +define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.36'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_BILLING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0'); diff --git a/js/sq-payment-form.js b/js/sq-payment-form.js new file mode 100644 index 0000000..9ce7773 --- /dev/null +++ b/js/sq-payment-form.js @@ -0,0 +1,225 @@ +/** + * Define callback function for "sq-button" + * @param {*} event + */ +function onGetCardNonce(event) { + + // Don't submit the form until SqPaymentForm returns with a nonce + event.preventDefault(); + + // Request a nonce from the SqPaymentForm object + paymentForm.requestCardNonce(); +} + +// Initializes the SqPaymentForm object by +// initializing various configuration fields and providing implementation for callback functions. +var paymentForm = new SqPaymentForm({ + // Initialize the payment form elements + applicationId: applicationId, + locationId: locationId, + inputClass: 'sq-input', + + // Customize the CSS for SqPaymentForm iframe elements + inputStyles: [{ + backgroundColor: 'transparent', + color: '#333333', + fontFamily: '"Helvetica Neue", "Helvetica", sans-serif', + fontSize: '16px', + fontWeight: '400', + placeholderColor: '#8594A7', + placeholderFontWeight: '400', + padding: '16px', + _webkitFontSmoothing: 'antialiased', + _mozOsxFontSmoothing: 'grayscale' + }], + + // Initialize Google Pay button ID + googlePay: { + elementId: 'sq-google-pay' + }, + + // Initialize Apple Pay placeholder ID + applePay: { + elementId: 'sq-apple-pay' + }, + + // Initialize Masterpass placeholder ID + masterpass: { + elementId: 'sq-masterpass' + }, + + // Initialize the credit card placeholders + cardNumber: { + elementId: 'sq-card-number', + placeholder: '•••• •••• •••• ••••' + }, + cvv: { + elementId: 'sq-cvv', + placeholder: 'CVV' + }, + expirationDate: { + elementId: 'sq-expiration-date', + placeholder: 'MM/YY' + }, + postalCode: { + elementId: 'sq-postal-code' + }, + + // SqPaymentForm callback functions + callbacks: { + + /* + * callback function: methodsSupported + * Triggered when: the page is loaded. + */ + methodsSupported: function (methods) { + if (!methods.masterpass && !methods.applePay && !methods.googlePay) { + var walletBox = document.getElementById('sq-walletbox'); + walletBox.style.display = 'none'; + } else { + var walletBox = document.getElementById('sq-walletbox'); + walletBox.style.display = 'block'; + } + + // Only show the button if Google Pay is enabled + if (methods.googlePay === true) { + var googlePayBtn = document.getElementById('sq-google-pay'); + googlePayBtn.style.display = 'inline-block'; + } + + // Only show the button if Apple Pay for Web is enabled + if (methods.applePay === true) { + var applePayBtn = document.getElementById('sq-apple-pay'); + applePayBtn.style.display = 'inline-block'; + } + + // Only show the button if Masterpass is enabled + if (methods.masterpass === true) { + var masterpassBtn = document.getElementById('sq-masterpass'); + masterpassBtn.style.display = 'inline-block'; + } + }, + + /* + * callback function: createPaymentRequest + * Triggered when: a digital wallet payment button is clicked. + */ + createPaymentRequest: function () { + + var paymentRequestJson = { + requestShippingAddress: false, + requestBillingInfo: true, + shippingContact: { + familyName: "CUSTOMER LAST NAME", + givenName: "CUSTOMER FIRST NAME", + email: "mycustomer@example.com", + country: "USA", + region: "CA", + city: "San Francisco", + addressLines: [ + "1455 Market St #600" + ], + postalCode: "94103", + phone:"14255551212" + }, + currencyCode: "USD", + countryCode: "US", + total: { + label: "MERCHANT NAME", + amount: "1.00", + pending: false + }, + lineItems: [ + { + label: "Subtotal", + amount: "1.00", + pending: false + } + ] + }; + + return paymentRequestJson; + }, + + /* + * callback function: validateShippingContact + * Triggered when: a shipping address is selected/changed in a digital + * wallet UI that supports address selection. + */ + validateShippingContact: function (contact) { + + var validationErrorObj ; + /* ADD CODE TO SET validationErrorObj IF ERRORS ARE FOUND */ + return validationErrorObj ; + }, + + /* + * callback function: cardNonceResponseReceived + * Triggered when: SqPaymentForm completes a card nonce request + */ + cardNonceResponseReceived: function(errors, nonce, cardData, billingContact, shippingContact) { + if (errors){ + var error_html = ""; + for (var i =0; i < errors.length; i++){ + error_html += "
  • " + errors[i].message + "
  • "; + } + document.getElementById("error").innerHTML = error_html; + document.getElementById('sq-creditcard').disabled = false; + + return; + }else{ + document.getElementById("error").innerHTML = ""; + } + + // Assign the nonce value to the hidden form field + document.getElementById('card-nonce').value = nonce; + + // POST the nonce form to the payment processing page + document.getElementById('nonce-form').submit(); + + }, + + /* + * callback function: unsupportedBrowserDetected + * Triggered when: the page loads and an unsupported browser is detected + */ + unsupportedBrowserDetected: function() { + /* PROVIDE FEEDBACK TO SITE VISITORS */ + }, + + /* + * callback function: inputEventReceived + * Triggered when: visitors interact with SqPaymentForm iframe elements. + */ + inputEventReceived: function(inputEvent) { + switch (inputEvent.eventType) { + case 'focusClassAdded': + /* HANDLE AS DESIRED */ + break; + case 'focusClassRemoved': + /* HANDLE AS DESIRED */ + break; + case 'errorClassAdded': + /* HANDLE AS DESIRED */ + break; + case 'errorClassRemoved': + /* HANDLE AS DESIRED */ + break; + case 'cardBrandChanged': + /* HANDLE AS DESIRED */ + break; + case 'postalCodeChanged': + /* HANDLE AS DESIRED */ + break; + } + }, + + /* + * callback function: paymentFormLoaded + * Triggered when: SqPaymentForm is fully loaded + */ + paymentFormLoaded: function() { + /* HANDLE AS DESIRED */ + } + } +}); diff --git a/models/admin/management/billing.php b/models/admin/management/billing.php index 12164f7..7066bd4 100644 --- a/models/admin/management/billing.php +++ b/models/admin/management/billing.php @@ -118,6 +118,7 @@ class GlmMembersAdmin_management_billing extends GlmDataBillingManagement $totalImports = false; $numberProcessed = false; + // echo '
    Config: ' . print_r( $this->config, true ) . '
    '; // General settings are always stored in a record with ID=1. $id = 1; diff --git a/models/front/billing/paymentForm.php b/models/front/billing/paymentForm.php index ede1f51..cfd8548 100644 --- a/models/front/billing/paymentForm.php +++ b/models/front/billing/paymentForm.php @@ -157,6 +157,7 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling switch ( $option ) { case 'payment': + // TODO: only the renew form if the member is not active if ( $account_status == 'Active' ) { $view = 'nonrenew'; @@ -197,9 +198,9 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling } // Pull member invoice $memberInvoice = $BillingSupport->getInvoiceById( $invoiceId ); - echo '
    $memberInvoice: ' . print_r( $memberInvoice, true ) . '
    '; + // echo '
    $memberInvoice: ' . print_r( $memberInvoice, true ) . '
    '; $memberInvoiceLineItems = $BillingSupport->getLineItemsForInvoice( $invoiceId ); - echo '
    $memberInvoiceLineItems: ' . print_r( $memberInvoiceLineItems, true ) . '
    '; + // echo '
    $memberInvoiceLineItems: ' . print_r( $memberInvoiceLineItems, true ) . '
    '; if ( isset( $memberInvoiceLineItems ) && is_array( $memberInvoiceLineItems ) && !empty( $memberInvoiceLineItems ) ) { foreach ( $memberInvoiceLineItems as $lineItem ) { if ( $lineItem['recurring'] ) { @@ -233,11 +234,14 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling // Look at the payment option given $payment_option = filter_var( $_REQUEST['payment_option'], FILTER_SANITIZE_STRING ); + echo '
    $_REQUEST: ' . print_r( $_REQUEST, true ) . '
    '; + echo '
    $payment_option: ' . print_r( $payment_option, true ) . '
    '; switch ( $payment_option ) { case 'pay_by_credit_card': // Do the Payment Processing. $processErrors = $BillingSupport->processOnlinePayment( $accountId, $invoiceId, $_REQUEST['total_renew_amount'] ); + // echo '
    $processErrors: ' . print_r( $processErrors, true ) . '
    '; if ( $processErrors ) { if ( isset( $processErrors ) && is_array( $processErrors ) && count( $processErrors ) > 0 ) { @@ -280,48 +284,48 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling } // If there's no error reported then show the invoice - if ( !$error ) { - $this->wpdb->query( 'COMMIT' ); - // Now need to show the invoice. - $view = 'viewInvoice'; - - // Get the invoice. - $invoiceHtml = $BillingSupport->viewInvoice( $invoiceId ); - - // If the member_type is changing then update member - // Get current member type - $member_id = filter_var( $_REQUEST['member'], FILTER_VALIDATE_INT ); - if ( $member_id ) { - $current_member_type = $this->wpdb->get_var( - $this->wpdb->prepare( - "SELECT member_type - FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members - WHERE id = %d", - $member_id - ) - ); - $new_type = filter_var( $_REQUEST['member_renewing'], FILTER_VALIDATE_INT ); - $new_member_type = $this->wpdb->get_var( - $this->wpdb->prepare( - "SELECT member_type - FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoice_types - WHERE id = %d", - $new_type - ) - ); - if ( $current_member_type != $new_member_type ) { - $this->wpdb->update( - GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', - array( 'member_type' => $new_member_type ), - array( 'id' => $member_id ), - array( '%d' ), - array( '%d' ) - ); - } - } - } else { - $this->wpdb->query( 'ROLLBACK' ); - } + // if ( !$error ) { + // $this->wpdb->query( 'COMMIT' ); + // // Now need to show the invoice. + // $view = 'viewInvoice'; + // + // // Get the invoice. + // $invoiceHtml = $BillingSupport->viewInvoice( $invoiceId ); + // + // // If the member_type is changing then update member + // // Get current member type + // $member_id = filter_var( $_REQUEST['member'], FILTER_VALIDATE_INT ); + // if ( $member_id ) { + // $current_member_type = $this->wpdb->get_var( + // $this->wpdb->prepare( + // "SELECT member_type + // FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members + // WHERE id = %d", + // $member_id + // ) + // ); + // $new_type = filter_var( $_REQUEST['member_renewing'], FILTER_VALIDATE_INT ); + // $new_member_type = $this->wpdb->get_var( + // $this->wpdb->prepare( + // "SELECT member_type + // FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoice_types + // WHERE id = %d", + // $new_type + // ) + // ); + // if ( $current_member_type != $new_member_type ) { + // $this->wpdb->update( + // GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', + // array( 'member_type' => $new_member_type ), + // array( 'id' => $member_id ), + // array( '%d' ), + // array( '%d' ) + // ); + // } + // } + // } else { + // $this->wpdb->query( 'ROLLBACK' ); + // } break; @@ -370,6 +374,8 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling 'payable_types' => $payable_types, 'account_status' => $account_status, 'lockedToMember' => $lockedToMember, + 'pluginJsUrl' => GLM_MEMBERS_BILLING_PLUGIN_URL . '/js', + 'pluginCssUrl' => GLM_MEMBERS_BILLING_PLUGIN_URL . '/css', ); // Return status, any suggested view, and any data to controller. diff --git a/setup/databaseScripts/create_database_V0.0.32.sql b/setup/databaseScripts/create_database_V0.0.32.sql deleted file mode 100644 index 2012bb6..0000000 --- a/setup/databaseScripts/create_database_V0.0.32.sql +++ /dev/null @@ -1,318 +0,0 @@ --- Gaslight Media Billing Module --- File Created: 11/19/2018 --- Database Version: 0.0.27 --- Database Creation Script --- --- To permit each query below to be executed separately, --- all queries must be separated by a line with four dashes --- --- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES **** --- - --- Billing Accounts -CREATE TABLE {prefix}accounts ( - id INT NOT NULL AUTO_INCREMENT, - archived BOOLEAN DEFAULT '0', -- Marks account as archived - ref_dest INT NOT NULL, -- reference to member id - ref_name TINYTEXT NOT NULL, -- Name of reference member - invoice_type INT NOT NULL DEFAULT '0', -- Ref to Invoice Type id - billing_contact_name TINYTEXT NULL, -- Billing Contact Name - billing_fname TINYTEXT NULL, -- Billing First Name - billing_lname TINYTEXT NULL, -- Billing Last Name - billing_company TINYTEXT NULL, -- Billing Company Name - billing_position TINYTEXT NULL, -- Billing Title/Position - billing_addr1 TINYTEXT NULL, -- Billing Address 1 - billing_addr2 TINYTEXT NULL, -- Billing Address 2 - billing_city TINYTEXT NULL, -- Billing City - billing_county INT NULL, -- Billing County - billing_state TINYTEXT NULL, -- Billing State - billing_zip TINYTEXT NULL, -- Billing Zip - billing_country TINYTEXT NULL, -- Billing Country - billing_phone TINYTEXT NULL, -- Billing Phone - billing_fax TINYTEXT NULL, -- Billing Fax - anniversary_date DATE NULL, -- anniversary date - renewal_date DATE NULL, -- renewal date of account - payment_data TEXT NULL, -- stored payment data - customer_profile_id TINYTEXT NULL, -- Customer Profile Id (Authorize.net) - payment_profile_id TINYTEXT NULL, -- Payment Profile Id (Authorize.net) - payment_profile_card TINYTEXT NULL, -- Payment Profile Card (Authorize.net) - email TINYTEXT NULL, -- billing email - boss BOOLEAN DEFAULT '0', -- Boss flag - account_number TINYTEXT NULL, -- Account Number - email_invoice BOOLEAN DEFAULT '0', -- Invoice by email - usmail_invoice BOOLEAN DEFAULT '0', -- Invoice by US Mail - fax_invoice BOOLEAN DEFAULT '0', -- Invoice by Fax - PRIMARY KEY (id), - INDEX(ref_dest), - INDEX(ref_name(20)), - INDEX(email(20)), - INDEX(invoice_type), - INDEX(renewal_date), - INDEX(billing_county) -); - ----- - --- transactions -CREATE TABLE {prefix}transactions ( - id INT NOT NULL AUTO_INCREMENT, - type INT NOT NULL, -- type of transaction (payment,invoice,etc) - type_id INT NOT NULL, -- reference to type id - account INT NOT NULL, -- reference to account id - transaction_time DATETIME NOT NULL, -- datetime for the transaction - current_invoice_total DECIMAL(8, 2) NOT NULL, -- invoice total - current_payment_total DECIMAL(8, 2) NOT NULL, -- payment total - PRIMARY KEY (id), - INDEX(account), - INDEX(type_id), - INDEX(transaction_time) -); - ----- - --- Invoices -CREATE TABLE {prefix}invoices ( - id INT NOT NULL AUTO_INCREMENT, - old_invoice_id INT NULL, -- old invoice id from uptra - transaction_time DATETIME NOT NULL, -- datetime for the invoice - account INT NOT NULL, -- ref to account id - amount_total DECIMAL(8, 2) NOT NULL, -- total amount for invoice - balance DECIMAL(8, 2) NOT NULL, -- balance for this invoice - due_date DATE NOT NULL, -- Due date for this invoice - paid BOOLEAN DEFAULT '0', -- true/false if invoice is paid - notes TINYTEXT, -- notes for this invoice - renewal BOOLEAN DEFAULT '0', -- true/false if a renewal - recurring BOOLEAN DEFAULT '0', -- true/false if recurring - recurrence INT NULL DEFAULT 0, -- recurrence type - PRIMARY KEY (id), - INDEX(account), - INDEX(transaction_time), - INDEX(due_date) -); - ----- - --- Line Item Types -CREATE TABLE {prefix}invoice_types ( - id INT NOT NULL AUTO_INCREMENT, - name TINYTEXT NOT NULL, -- name - parent INT NOT NULL DEFAULT 0, -- 0 if top level otherwise ref to another line_item_type as it's parent - member_type INT NOT NULL DEFAULT 0, -- Member Type assigned Default 0 - amount DECIMAL(8,2) NOT NULL DEFAULT '0.00', -- amount - recurring BOOLEAN DEFAULT '0', -- true/false if recurring - recurrence INT NULL DEFAULT 0, -- recurrence type - dynamic_amount BOOLEAN DEFAULT '0', -- true/false if amount is dynamic - qcode TINYTEXT NULL, -- qcode for quickbooks - category TINYTEXT NULL, -- quickbooks category - PRIMARY KEY (id) -); - ----- - --- Line Items -CREATE TABLE {prefix}line_items ( - id INT NOT NULL AUTO_INCREMENT, - invoice INT NOT NULL, -- reference to invoice - line_item_type INT NOT NULL, -- reference to line item type - account INT NULL DEFAULT 0, -- ref to account id (renewal or employee) - name TEXT NOT NULL, -- line item name - amount DECIMAL(8,2) DEFAULT '0.00', -- line item amount per item - quantity INT DEFAULT 1, -- quantity - total DECIMAL(8,2) DEFAULT '0.00', -- line item total - recurring BOOLEAN DEFAULT '0', -- true/false if recurring - recurrence INT NULL DEFAULT 0, -- recurrence type - created DATE NULL, -- Date this line item was first created - first_due_date DATE NULL, -- The first due date for this item - next_due_date DATE NULL, -- Next Due Date for this item - PRIMARY KEY (id), - INDEX(account), - INDEX(created), - INDEX(first_due_date), - INDEX(next_due_date) -); - ----- - --- payments -CREATE TABLE {prefix}payments ( - id INT NOT NULL AUTO_INCREMENT, - transaction_time DATETIME NOT NULL, -- datetime of payment - account INT NOT NULL, -- ref to account table - amount DECIMAL(8, 2) NOT NULL, -- payment amount - payment_method TINYTEXT NOT NULL, -- payment method - payment_data TINYTEXT NULL, -- additional payment info - notes TEXT NULL, -- Notes/Comments on the payment - PRIMARY KEY (id) -); - ----- - --- pdfs -CREATE TABLE {prefix}pdfs ( - id INT NOT NULL AUTO_INCREMENT, - ref_type INT NOT NULL, -- reference type - ref_dest INT NOT NULL, -- reference types id - pdf MEDIUMTEXT NOT NULL, -- saved pdf - PRIMARY KEY (id) -); - ----- - --- Notification Types -CREATE TABLE {prefix}notification_types ( - id INT NOT NULL AUTO_INCREMENT, - name TINYTEXT NOT NULL, -- name - to_email TINYTEXT NULL, -- To email - from_header TINYTEXT NOT NULL, -- from headers - replyto TINYTEXT NULL, -- reply-to headers - subject TINYTEXT NOT NULL, -- Subject - message TEXT NOT NULL, -- Message - send_by_date BOOLEAN NULL DEFAULT '0', -- true/false send by date based on due date - send_by_action BOOLEAN NULL DEFAULT '0', -- send notice based on an action - send_action INT NULL DEFAULT 0, -- (create invoice or receive payment) - send_date_number INT NULL DEFAULT 0, -- number to apply to send by date - send_date_period INT NULL DEFAULT 0, -- (days,weeks,months,years) - send_date_when INT NULL DEFAULT 0, -- (before or after) - PRIMARY KEY (id) -); - ----- - --- Notifications -CREATE TABLE {prefix}notifications ( - id INT NOT NULL AUTO_INCREMENT, - notification_type INT NOT NULL, -- ref to notification type - account INT NOT NULL, -- ref to account - from_replyto TINYTEXT NOT NULL, -- from reply-to header - subject TEXT NOT NULL, -- subject - message TEXT NOT NULL, -- message - date_sent DATETIME NOT NULL, -- Date the notice was sent - email_sent TINYTEXT NOT NULL, -- email used - PRIMARY KEY (id) -); - ----- - --- Notification Queue -CREATE TABLE {prefix}notification_queue ( - id INT NOT NULL AUTO_INCREMENT, - notification_type INT NOT NULL, -- ref to notification type - account INT NOT NULL, -- ref to account - queued_time DATETIME NOT NULL, -- Creation time - processed_time DATETIME NULL, -- The time this queue was processed. (sent out) - PRIMARY KEY (id), - INDEX (notification_type), - INDEX (account), - INDEX (queued_time), - INDEX (processed_time) -); - ----- - --- Gateway Settings -CREATE TABLE {prefix}gateway_settings ( - id INT NOT NULL AUTO_INCREMENT, - name TEXT NOT NULL, - login_id TINYTEXT NOT NULL, - transaction_key TINYTEXT NOT NULL, - PRIMARY KEY (id) -); - ----- - --- Invoice Payments -CREATE TABLE {prefix}invoice_payments ( - id INT NOT NULL AUTO_INCREMENT, - invoice INT NOT NULL, -- reference to invoice id - payment INT NOT NULL, -- reference to payment id - amount DECIMAL(8, 2) NOT NULL, -- payment amount - PRIMARY KEY (id), - INDEX(invoice) -); - ----- - --- Settings -CREATE TABLE {prefix}settings ( - id INT NOT NULL AUTO_INCREMENT, - company_logo TINYTEXT NULL, -- Image logo - company_logo_height INT NULL, -- Logo Height (only used if creating pdf) - company_name TINYTEXT NULL, -- Company Name - company_name2 TINYTEXT NULL, -- Company Name 2 - company_addr1 TINYTEXT NULL, -- Company Address 1 - company_addr2 TINYTEXT NULL, -- Company Address 2 - company_city TINYTEXT NULL, -- Company City - company_state TINYTEXT NULL, -- Company State - company_zip TINYTEXT NULL, -- Company Zip - company_phone TINYTEXT NULL, -- Company Phone - company_email TINYTEXT NULL, -- Company Email - company_url TINYTEXT NULL, -- Company URL - payment_terms TEXT NULL, -- Payment Terms - days_before_renewal INT NULL, -- Number of days before renewal date to allow renewals - days_after_expired INT NULL, -- Number of days after renewal date expired - allow_membership_choice BOOLEAN DEFAULT '0', -- If memberships can choose their membership levels when they renew - allow_employees BOOLEAN DEFAULT '0', -- If memberships have employees - member_types_enabled BOOLEAN DEFAULT '1', -- member types determine invoice types - quickbooks_enabled BOOLEAN DEFAULT '0', -- QuickBooks enabled - member_billing_enabled BOOLEAN DEFAULT '1', -- Member have access to billing info tab - billing_fields_required BOOLEAN DEFAULT '1', -- Require Billing Fields - invoice_methods_enabled BOOLEAN DEFAULT '0', -- Enable Uptra invoice methods - renewal_day_static BOOLEAN DEFAULT '0', -- Renewal dates are same day every year - renewal_day INT NULL, -- Day of the month for renewals - renewal_month INT NULL, -- Month of year for renewals - billing_county_enabled BOOLEAN DEFAULT '0', -- Billing uses county field - invoice_pdf_enabled BOOLEAN DEFAULT '0', -- Create PDF invoices - billing_contact_name_enabled BOOLEAN DEFAULT '0', -- Use billing_contact_name instead of fname lname - PRIMARY KEY (id) -); - ----- - --- Set default billing Settings entry -INSERT INTO {prefix}settings - ( id, days_before_renewal ,days_after_expired, member_types_enabled, quickbooks_enabled, member_billing_enabled ) - VALUES - ( 1, 90, 30, true, false, true ); - ----- - --- Management -CREATE TABLE {prefix}management ( - id INT NOT NULL AUTO_INCREMENT, - payment_methods SMALLINT NULL, -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini - proc_methods SMALLINT NULL, -- Credit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini - cc_accepts SMALLINT NULL, -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini - -- Authorize.net Credentials - authorize_net_login TINYTEXT NULL, - authorize_net_key TINYTEXT NULL, - authorize_net_test TINYINT NULL, -- Authorize.net test mode - List - see proc_test_mode in plugin.ini - authorize_net_conf BOOLEAN NULL, -- Flag to send payment confirmation Email from Authorize.net - authorize_net_merchant_email TINYTEXT NULL, -- E-Mail Authorize.net will send copy of confirmation E-Mail - -- Merchant Solutions Credentials - merchant_solutions_acctid TINYTEXT NULL, -- Merchant Solutions credentials - merchant_solutions_merchantpin TINYTEXT NULL, - merchant_solutions_test TINYINT NULL, -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini - merchant_solutions_conf BOOLEAN NULL, -- Flag to send payment confirmation Email - merchant_solutions_merchant_email TINYTEXT NULL, -- Merchant Solutions will send copy of confirmation E-Mail - uptravel_invoice_template BOOLEAN DEFAULT '0', -- Use uptravel template for invoices. - uptravel_payment_form BOOLEAN DEFAULT '0', -- Use uptravel payment form style. - PRIMARY KEY (id) -); - ----- - --- Set default billing Management entry -INSERT INTO {prefix}management - ( id ) - VALUES - ( 1 ); - ----- - --- Employees table -CREATE TABLE {prefix}employees ( - id INT NOT NULL AUTO_INCREMENT, - account INT NOT NULL, -- Account Id - employee INT NOT NULL, -- Employee Account Id - PRIMARY KEY (id) -); diff --git a/setup/databaseScripts/create_database_V0.0.35.sql b/setup/databaseScripts/create_database_V0.0.35.sql deleted file mode 100644 index 2e3c361..0000000 --- a/setup/databaseScripts/create_database_V0.0.35.sql +++ /dev/null @@ -1,375 +0,0 @@ --- Gaslight Media Billing Module --- File Created: 02/19/2019 --- Database Version: 0.0.33 --- Database Creation Script --- --- To permit each query below to be executed separately, --- all queries must be separated by a line with four dashes --- --- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES **** --- - --- Billing Accounts -CREATE TABLE {prefix}accounts ( - id INT NOT NULL AUTO_INCREMENT, - archived BOOLEAN DEFAULT '0', -- Marks account as archived - ref_dest INT NOT NULL, -- reference to member id - ref_name TINYTEXT NOT NULL, -- Name of reference member - invoice_type INT NOT NULL DEFAULT '0', -- Ref to Invoice Type id - billing_contact_name TINYTEXT NULL, -- Billing Contact Name - billing_fname TINYTEXT NULL, -- Billing First Name - billing_lname TINYTEXT NULL, -- Billing Last Name - billing_company TINYTEXT NULL, -- Billing Company Name - billing_position TINYTEXT NULL, -- Billing Title/Position - billing_addr1 TINYTEXT NULL, -- Billing Address 1 - billing_addr2 TINYTEXT NULL, -- Billing Address 2 - billing_city TINYTEXT NULL, -- Billing City - billing_county INT NULL, -- Billing County - billing_state TINYTEXT NULL, -- Billing State - billing_zip TINYTEXT NULL, -- Billing Zip - billing_country TINYTEXT NULL, -- Billing Country - billing_phone TINYTEXT NULL, -- Billing Phone - billing_fax TINYTEXT NULL, -- Billing Fax - anniversary_date DATE NULL, -- anniversary date - renewal_date DATE NULL, -- renewal date of account - payment_data TEXT NULL, -- stored payment data - customer_profile_id TINYTEXT NULL, -- Customer Profile Id (Authorize.net) - payment_profile_id TINYTEXT NULL, -- Payment Profile Id (Authorize.net) - payment_profile_card TINYTEXT NULL, -- Payment Profile Card (Authorize.net) - email TINYTEXT NULL, -- billing email - boss BOOLEAN DEFAULT '0', -- Boss flag - account_number TINYTEXT NULL, -- Account Number - email_invoice BOOLEAN DEFAULT '0', -- Invoice by email - usmail_invoice BOOLEAN DEFAULT '0', -- Invoice by US Mail - fax_invoice BOOLEAN DEFAULT '0', -- Invoice by Fax - PRIMARY KEY (id), - INDEX(ref_dest), - INDEX(ref_name(20)), - INDEX(email(20)), - INDEX(invoice_type), - INDEX(renewal_date), - INDEX(billing_county) -); - ----- - --- transactions -CREATE TABLE {prefix}transactions ( - id INT NOT NULL AUTO_INCREMENT, - type INT NOT NULL, -- type of transaction (payment,invoice,etc) - type_id INT NOT NULL, -- reference to type id - account INT NOT NULL, -- reference to account id - transaction_time DATETIME NOT NULL, -- datetime for the transaction - current_invoice_total DECIMAL(8, 2) NOT NULL, -- invoice total - current_payment_total DECIMAL(8, 2) NOT NULL, -- payment total - PRIMARY KEY (id), - INDEX(account), - INDEX(type_id), - INDEX(transaction_time) -); - ----- - --- Invoices -CREATE TABLE {prefix}invoices ( - id INT NOT NULL AUTO_INCREMENT, - old_invoice_id INT NULL, -- old invoice id from uptra - transaction_time DATETIME NOT NULL, -- datetime for the invoice - account INT NOT NULL, -- ref to account id - amount_total DECIMAL(8, 2) NOT NULL, -- total amount for invoice - balance DECIMAL(8, 2) NOT NULL, -- balance for this invoice - due_date DATE NOT NULL, -- Due date for this invoice - paid BOOLEAN DEFAULT '0', -- true/false if invoice is paid - notes TINYTEXT, -- notes for this invoice - renewal BOOLEAN DEFAULT '0', -- true/false if a renewal - recurring BOOLEAN DEFAULT '0', -- true/false if recurring - recurrence INT NULL DEFAULT 0, -- recurrence type - PRIMARY KEY (id), - INDEX(account), - INDEX(transaction_time), - INDEX(due_date) -); - ----- - --- Line Item Types -CREATE TABLE {prefix}invoice_types ( - id INT NOT NULL AUTO_INCREMENT, - name TINYTEXT NOT NULL, -- name - parent INT NOT NULL DEFAULT 0, -- 0 if top level otherwise ref to another line_item_type as it's parent - member_type INT NOT NULL DEFAULT 0, -- Member Type assigned Default 0 - amount DECIMAL(8,2) NOT NULL DEFAULT '0.00', -- amount - recurring BOOLEAN DEFAULT '0', -- true/false if recurring - recurrence INT NULL DEFAULT 0, -- recurrence type - dynamic_amount BOOLEAN DEFAULT '0', -- true/false if amount is dynamic - qcode TINYTEXT NULL, -- qcode for quickbooks - category TINYTEXT NULL, -- quickbooks category - PRIMARY KEY (id) -); - ----- - --- Line Items -CREATE TABLE {prefix}line_items ( - id INT NOT NULL AUTO_INCREMENT, - invoice INT NOT NULL, -- reference to invoice - line_item_type INT NOT NULL, -- reference to line item type - account INT NULL DEFAULT 0, -- ref to account id (renewal or employee) - name TEXT NOT NULL, -- line item name - amount DECIMAL(8,2) DEFAULT '0.00', -- line item amount per item - quantity INT DEFAULT 1, -- quantity - total DECIMAL(8,2) DEFAULT '0.00', -- line item total - recurring BOOLEAN DEFAULT '0', -- true/false if recurring - recurrence INT NULL DEFAULT 0, -- recurrence type - created DATE NULL, -- Date this line item was first created - first_due_date DATE NULL, -- The first due date for this item - next_due_date DATE NULL, -- Next Due Date for this item - PRIMARY KEY (id), - INDEX(account), - INDEX(created), - INDEX(first_due_date), - INDEX(next_due_date) -); - ----- - --- payments -CREATE TABLE {prefix}payments ( - id INT NOT NULL AUTO_INCREMENT, - transaction_time DATETIME NOT NULL, -- datetime of payment - account INT NOT NULL, -- ref to account table - amount DECIMAL(8, 2) NOT NULL, -- payment amount - payment_method TINYTEXT NOT NULL, -- payment method - payment_data TINYTEXT NULL, -- additional payment info - notes TEXT NULL, -- Notes/Comments on the payment - PRIMARY KEY (id) -); - ----- - --- pdfs -CREATE TABLE {prefix}pdfs ( - id INT NOT NULL AUTO_INCREMENT, - ref_type INT NOT NULL, -- reference type - ref_dest INT NOT NULL, -- reference types id - pdf MEDIUMTEXT NOT NULL, -- saved pdf - PRIMARY KEY (id) -); - ----- - --- Notification Types -CREATE TABLE {prefix}notification_types ( - id INT NOT NULL AUTO_INCREMENT, - name TINYTEXT NOT NULL, -- name - to_email TINYTEXT NULL, -- To email - from_header TINYTEXT NOT NULL, -- from headers - replyto TINYTEXT NULL, -- reply-to headers - subject TINYTEXT NOT NULL, -- Subject - message TEXT NOT NULL, -- Message - send_by_date BOOLEAN NULL DEFAULT '0', -- true/false send by date based on due date - send_by_action BOOLEAN NULL DEFAULT '0', -- send notice based on an action - send_action INT NULL DEFAULT 0, -- (create invoice or receive payment) - send_date_number INT NULL DEFAULT 0, -- number to apply to send by date - send_date_period INT NULL DEFAULT 0, -- (days,weeks,months,years) - send_date_when INT NULL DEFAULT 0, -- (before or after) - PRIMARY KEY (id) -); - ----- - --- Notifications -CREATE TABLE {prefix}notifications ( - id INT NOT NULL AUTO_INCREMENT, - notification_type INT NOT NULL, -- ref to notification type - account INT NOT NULL, -- ref to account - from_replyto TINYTEXT NOT NULL, -- from reply-to header - subject TEXT NOT NULL, -- subject - message TEXT NOT NULL, -- message - date_sent DATETIME NOT NULL, -- Date the notice was sent - email_sent TINYTEXT NOT NULL, -- email used - type INT NULL, -- Invoice Type - type_id INT NULL, -- type id (invoice or payment) - PRIMARY KEY (id) -); - ----- - --- Notification Queue -CREATE TABLE {prefix}notification_queue ( - id INT NOT NULL AUTO_INCREMENT, - notification_type INT NOT NULL, -- ref to notification type - account INT NOT NULL, -- ref to account - queued_time DATETIME NOT NULL, -- Creation time - processed_time DATETIME NULL, -- The time this queue was processed. (sent out) - PRIMARY KEY (id), - INDEX (notification_type), - INDEX (account), - INDEX (queued_time), - INDEX (processed_time) -); - ----- - --- Gateway Settings -CREATE TABLE {prefix}gateway_settings ( - id INT NOT NULL AUTO_INCREMENT, - name TEXT NOT NULL, - login_id TINYTEXT NOT NULL, - transaction_key TINYTEXT NOT NULL, - PRIMARY KEY (id) -); - ----- - --- Invoice Payments -CREATE TABLE {prefix}invoice_payments ( - id INT NOT NULL AUTO_INCREMENT, - invoice INT NOT NULL, -- reference to invoice id - payment INT NOT NULL, -- reference to payment id - amount DECIMAL(8, 2) NOT NULL, -- payment amount - PRIMARY KEY (id), - INDEX(invoice) -); - ----- - --- Settings -CREATE TABLE {prefix}settings ( - id INT NOT NULL AUTO_INCREMENT, - -- Invoice Options - company_logo TINYTEXT NULL, -- Image logo - company_logo_width INT NULL, -- Logo Width (only used if creating pdf) - company_name TINYTEXT NULL, -- Company Name - company_name2 TINYTEXT NULL, -- Company Name 2 - company_addr1 TINYTEXT NULL, -- Company Address 1 - company_addr2 TINYTEXT NULL, -- Company Address 2 - company_city TINYTEXT NULL, -- Company City - company_state TINYTEXT NULL, -- Company State - company_zip TINYTEXT NULL, -- Company Zip - company_phone TINYTEXT NULL, -- Company Phone - company_email TINYTEXT NULL, -- Company Email - company_url TINYTEXT NULL, -- Company URL - payment_terms TEXT NULL, -- Payment Terms - invoice_show_account_number BOOLEAN DEFAULT '0', -- Show Billing Account number on invoices - invoice_show_invoice_number BOOLEAN DEFAULT '1', -- Show Invoice Number on invoices - days_before_renewal INT NULL, -- Number of days before renewal date to allow renewals - days_after_expired INT NULL, -- Number of days after renewal date expired - -- Renewal Options - allow_membership_choice BOOLEAN DEFAULT '0', -- If memberships can choose their membership levels when they renew - allow_employees BOOLEAN DEFAULT '0', -- If memberships have employees - member_types_enabled BOOLEAN DEFAULT '1', -- member types determine invoice types - quickbooks_enabled BOOLEAN DEFAULT '0', -- QuickBooks enabled - member_billing_enabled BOOLEAN DEFAULT '1', -- Member have access to billing info tab - billing_fields_required BOOLEAN DEFAULT '1', -- Require Billing Fields - invoice_methods_enabled BOOLEAN DEFAULT '0', -- Enable Uptra invoice methods - renewal_day_static BOOLEAN DEFAULT '0', -- Renewal dates are same day every year - renewal_day INT NULL, -- Day of the month for renewals - renewal_month INT NULL, -- Month of year for renewals - billing_county_enabled BOOLEAN DEFAULT '0', -- Billing uses county field - invoice_pdf_enabled BOOLEAN DEFAULT '0', -- Create PDF invoices - billing_contact_name_enabled BOOLEAN DEFAULT '0', -- Use billing_contact_name instead of fname lname - member_types_requiring_billing TEXT NULL, -- List of member type id's that require billing - -- Account Number - account_number_enabled BOOLEAN DEFAULT '0', -- Enable Disable account_number - account_number_required BOOLEAN DEFAULT '0', -- Require account_number - account_number_unique BOOLEAN DEFAULT '0', -- account_number must be unique - PRIMARY KEY (id) -); - ----- - --- Set default billing Settings entry -INSERT INTO {prefix}settings - ( id, days_before_renewal ,days_after_expired, member_types_enabled, quickbooks_enabled, member_billing_enabled ) - VALUES - ( 1, 90, 30, true, false, true ); - ----- - --- Management -CREATE TABLE {prefix}management ( - id INT NOT NULL AUTO_INCREMENT, - payment_methods SMALLINT NULL, -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini - proc_methods SMALLINT NULL, -- Credit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini - cc_accepts SMALLINT NULL, -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini - -- Authorize.net Credentials - authorize_net_login TINYTEXT NULL, - authorize_net_key TINYTEXT NULL, - authorize_net_test TINYINT NULL, -- Authorize.net test mode - List - see proc_test_mode in plugin.ini - authorize_net_conf BOOLEAN NULL, -- Flag to send payment confirmation Email from Authorize.net - authorize_net_merchant_email TINYTEXT NULL, -- E-Mail Authorize.net will send copy of confirmation E-Mail - -- Merchant Solutions Credentials - merchant_solutions_acctid TINYTEXT NULL, -- Merchant Solutions credentials - merchant_solutions_merchantpin TINYTEXT NULL, - merchant_solutions_test TINYINT NULL, -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini - merchant_solutions_conf BOOLEAN NULL, -- Flag to send payment confirmation Email - merchant_solutions_merchant_email TINYTEXT NULL, -- Merchant Solutions will send copy of confirmation E-Mail - uptravel_invoice_template BOOLEAN DEFAULT '0', -- Use uptravel template for invoices. - uptravel_payment_form BOOLEAN DEFAULT '0', -- Use uptravel payment form style. - PRIMARY KEY (id) -); - ----- - --- Set default billing Management entry -INSERT INTO {prefix}management - ( id ) - VALUES - ( 1 ); - ----- - --- Employees table -CREATE TABLE {prefix}employees ( - id INT NOT NULL AUTO_INCREMENT, - account INT NOT NULL, -- Account Id - employee INT NOT NULL, -- Employee Account Id - PRIMARY KEY (id) -); - ----- - --- Terms -CREATE TABLE {prefix}settings_terms ( - id INT NOT NULL AUTO_INCREMENT, - invoice_name TINYTEXT NOT NULL, - invoice_name_plur TINYTEXT NOT NULL, - invoice_name_cap TINYTEXT NOT NULL, - invoice_name_plur_cap TINYTEXT NOT NULL, - invoice_type TINYTEXT NOT NULL, - invoice_type_plur TINYTEXT NOT NULL, - invoice_type_cap TINYTEXT NOT NULL, - invoice_type_plur_cap TINYTEXT NOT NULL, - account_number TINYTEXT NOT NULL, - PRIMARY KEY (id) -); - ----- - -INSERT INTO {prefix}settings_terms - ( - id, - invoice_name, - invoice_name_plur, - invoice_name_cap, - invoice_name_plur_cap, - invoice_type, - invoice_type_plur, - invoice_type_cap, - invoice_type_plur_cap, - account_number - ) - VALUES - ( - 1, - 'invoice', - 'invoices', - 'Invoice', - 'Invoices', - 'invoice type', - 'invoice types', - 'Invoice Type', - 'Invoice Types', - 'Account Number' - ); diff --git a/setup/databaseScripts/create_database_V0.0.36.sql b/setup/databaseScripts/create_database_V0.0.36.sql new file mode 100644 index 0000000..63233a6 --- /dev/null +++ b/setup/databaseScripts/create_database_V0.0.36.sql @@ -0,0 +1,384 @@ +-- Gaslight Media Billing Module +-- File Created: 02/19/2019 +-- Database Version: 0.0.36 +-- Database Creation Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes +-- +-- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES **** +-- + +-- Billing Accounts +CREATE TABLE {prefix}accounts ( + id INT NOT NULL AUTO_INCREMENT, + archived BOOLEAN DEFAULT '0', -- Marks account as archived + ref_dest INT NOT NULL, -- reference to member id + ref_name TINYTEXT NOT NULL, -- Name of reference member + invoice_type INT NOT NULL DEFAULT '0', -- Ref to Invoice Type id + billing_contact_name TINYTEXT NULL, -- Billing Contact Name + billing_fname TINYTEXT NULL, -- Billing First Name + billing_lname TINYTEXT NULL, -- Billing Last Name + billing_company TINYTEXT NULL, -- Billing Company Name + billing_position TINYTEXT NULL, -- Billing Title/Position + billing_addr1 TINYTEXT NULL, -- Billing Address 1 + billing_addr2 TINYTEXT NULL, -- Billing Address 2 + billing_city TINYTEXT NULL, -- Billing City + billing_county INT NULL, -- Billing County + billing_state TINYTEXT NULL, -- Billing State + billing_zip TINYTEXT NULL, -- Billing Zip + billing_country TINYTEXT NULL, -- Billing Country + billing_phone TINYTEXT NULL, -- Billing Phone + billing_fax TINYTEXT NULL, -- Billing Fax + anniversary_date DATE NULL, -- anniversary date + renewal_date DATE NULL, -- renewal date of account + payment_data TEXT NULL, -- stored payment data + customer_profile_id TINYTEXT NULL, -- Customer Profile Id (Authorize.net) + payment_profile_id TINYTEXT NULL, -- Payment Profile Id (Authorize.net) + payment_profile_card TINYTEXT NULL, -- Payment Profile Card (Authorize.net) + email TINYTEXT NULL, -- billing email + boss BOOLEAN DEFAULT '0', -- Boss flag + account_number TINYTEXT NULL, -- Account Number + email_invoice BOOLEAN DEFAULT '0', -- Invoice by email + usmail_invoice BOOLEAN DEFAULT '0', -- Invoice by US Mail + fax_invoice BOOLEAN DEFAULT '0', -- Invoice by Fax + PRIMARY KEY (id), + INDEX(ref_dest), + INDEX(ref_name(20)), + INDEX(email(20)), + INDEX(invoice_type), + INDEX(renewal_date), + INDEX(billing_county) +); + +---- + +-- transactions +CREATE TABLE {prefix}transactions ( + id INT NOT NULL AUTO_INCREMENT, + type INT NOT NULL, -- type of transaction (payment,invoice,etc) + type_id INT NOT NULL, -- reference to type id + account INT NOT NULL, -- reference to account id + transaction_time DATETIME NOT NULL, -- datetime for the transaction + current_invoice_total DECIMAL(8, 2) NOT NULL, -- invoice total + current_payment_total DECIMAL(8, 2) NOT NULL, -- payment total + PRIMARY KEY (id), + INDEX(account), + INDEX(type_id), + INDEX(transaction_time) +); + +---- + +-- Invoices +CREATE TABLE {prefix}invoices ( + id INT NOT NULL AUTO_INCREMENT, + old_invoice_id INT NULL, -- old invoice id from uptra + transaction_time DATETIME NOT NULL, -- datetime for the invoice + account INT NOT NULL, -- ref to account id + amount_total DECIMAL(8, 2) NOT NULL, -- total amount for invoice + balance DECIMAL(8, 2) NOT NULL, -- balance for this invoice + due_date DATE NOT NULL, -- Due date for this invoice + paid BOOLEAN DEFAULT '0', -- true/false if invoice is paid + notes TINYTEXT, -- notes for this invoice + renewal BOOLEAN DEFAULT '0', -- true/false if a renewal + recurring BOOLEAN DEFAULT '0', -- true/false if recurring + recurrence INT NULL DEFAULT 0, -- recurrence type + PRIMARY KEY (id), + INDEX(account), + INDEX(transaction_time), + INDEX(due_date) +); + +---- + +-- Line Item Types +CREATE TABLE {prefix}invoice_types ( + id INT NOT NULL AUTO_INCREMENT, + name TINYTEXT NOT NULL, -- name + parent INT NOT NULL DEFAULT 0, -- 0 if top level otherwise ref to another line_item_type as it's parent + member_type INT NOT NULL DEFAULT 0, -- Member Type assigned Default 0 + amount DECIMAL(8,2) NOT NULL DEFAULT '0.00', -- amount + recurring BOOLEAN DEFAULT '0', -- true/false if recurring + recurrence INT NULL DEFAULT 0, -- recurrence type + dynamic_amount BOOLEAN DEFAULT '0', -- true/false if amount is dynamic + qcode TINYTEXT NULL, -- qcode for quickbooks + category TINYTEXT NULL, -- quickbooks category + PRIMARY KEY (id) +); + +---- + +-- Line Items +CREATE TABLE {prefix}line_items ( + id INT NOT NULL AUTO_INCREMENT, + invoice INT NOT NULL, -- reference to invoice + line_item_type INT NOT NULL, -- reference to line item type + account INT NULL DEFAULT 0, -- ref to account id (renewal or employee) + name TEXT NOT NULL, -- line item name + amount DECIMAL(8,2) DEFAULT '0.00', -- line item amount per item + quantity INT DEFAULT 1, -- quantity + total DECIMAL(8,2) DEFAULT '0.00', -- line item total + recurring BOOLEAN DEFAULT '0', -- true/false if recurring + recurrence INT NULL DEFAULT 0, -- recurrence type + created DATE NULL, -- Date this line item was first created + first_due_date DATE NULL, -- The first due date for this item + next_due_date DATE NULL, -- Next Due Date for this item + PRIMARY KEY (id), + INDEX(account), + INDEX(created), + INDEX(first_due_date), + INDEX(next_due_date) +); + +---- + +-- payments +CREATE TABLE {prefix}payments ( + id INT NOT NULL AUTO_INCREMENT, + transaction_time DATETIME NOT NULL, -- datetime of payment + account INT NOT NULL, -- ref to account table + amount DECIMAL(8, 2) NOT NULL, -- payment amount + payment_method TINYTEXT NOT NULL, -- payment method + payment_data TINYTEXT NULL, -- additional payment info + notes TEXT NULL, -- Notes/Comments on the payment + PRIMARY KEY (id) +); + +---- + +-- pdfs +CREATE TABLE {prefix}pdfs ( + id INT NOT NULL AUTO_INCREMENT, + ref_type INT NOT NULL, -- reference type + ref_dest INT NOT NULL, -- reference types id + pdf MEDIUMTEXT NOT NULL, -- saved pdf + PRIMARY KEY (id) +); + +---- + +-- Notification Types +CREATE TABLE {prefix}notification_types ( + id INT NOT NULL AUTO_INCREMENT, + name TINYTEXT NOT NULL, -- name + to_email TINYTEXT NULL, -- To email + from_header TINYTEXT NOT NULL, -- from headers + replyto TINYTEXT NULL, -- reply-to headers + subject TINYTEXT NOT NULL, -- Subject + message TEXT NOT NULL, -- Message + send_by_date BOOLEAN NULL DEFAULT '0', -- true/false send by date based on due date + send_by_action BOOLEAN NULL DEFAULT '0', -- send notice based on an action + send_action INT NULL DEFAULT 0, -- (create invoice or receive payment) + send_date_number INT NULL DEFAULT 0, -- number to apply to send by date + send_date_period INT NULL DEFAULT 0, -- (days,weeks,months,years) + send_date_when INT NULL DEFAULT 0, -- (before or after) + PRIMARY KEY (id) +); + +---- + +-- Notifications +CREATE TABLE {prefix}notifications ( + id INT NOT NULL AUTO_INCREMENT, + notification_type INT NOT NULL, -- ref to notification type + account INT NOT NULL, -- ref to account + from_replyto TINYTEXT NOT NULL, -- from reply-to header + subject TEXT NOT NULL, -- subject + message TEXT NOT NULL, -- message + date_sent DATETIME NOT NULL, -- Date the notice was sent + email_sent TINYTEXT NOT NULL, -- email used + type INT NULL, -- Invoice Type + type_id INT NULL, -- type id (invoice or payment) + PRIMARY KEY (id) +); + +---- + +-- Notification Queue +CREATE TABLE {prefix}notification_queue ( + id INT NOT NULL AUTO_INCREMENT, + notification_type INT NOT NULL, -- ref to notification type + account INT NOT NULL, -- ref to account + queued_time DATETIME NOT NULL, -- Creation time + processed_time DATETIME NULL, -- The time this queue was processed. (sent out) + PRIMARY KEY (id), + INDEX (notification_type), + INDEX (account), + INDEX (queued_time), + INDEX (processed_time) +); + +---- + +-- Gateway Settings +CREATE TABLE {prefix}gateway_settings ( + id INT NOT NULL AUTO_INCREMENT, + name TEXT NOT NULL, + login_id TINYTEXT NOT NULL, + transaction_key TINYTEXT NOT NULL, + PRIMARY KEY (id) +); + +---- + +-- Invoice Payments +CREATE TABLE {prefix}invoice_payments ( + id INT NOT NULL AUTO_INCREMENT, + invoice INT NOT NULL, -- reference to invoice id + payment INT NOT NULL, -- reference to payment id + amount DECIMAL(8, 2) NOT NULL, -- payment amount + PRIMARY KEY (id), + INDEX(invoice) +); + +---- + +-- Settings +CREATE TABLE {prefix}settings ( + id INT NOT NULL AUTO_INCREMENT, + -- Invoice Options + company_logo TINYTEXT NULL, -- Image logo + company_logo_width INT NULL, -- Logo Width (only used if creating pdf) + company_name TINYTEXT NULL, -- Company Name + company_name2 TINYTEXT NULL, -- Company Name 2 + company_addr1 TINYTEXT NULL, -- Company Address 1 + company_addr2 TINYTEXT NULL, -- Company Address 2 + company_city TINYTEXT NULL, -- Company City + company_state TINYTEXT NULL, -- Company State + company_zip TINYTEXT NULL, -- Company Zip + company_phone TINYTEXT NULL, -- Company Phone + company_email TINYTEXT NULL, -- Company Email + company_url TINYTEXT NULL, -- Company URL + payment_terms TEXT NULL, -- Payment Terms + invoice_show_account_number BOOLEAN DEFAULT '0', -- Show Billing Account number on invoices + invoice_show_invoice_number BOOLEAN DEFAULT '1', -- Show Invoice Number on invoices + days_before_renewal INT NULL, -- Number of days before renewal date to allow renewals + days_after_expired INT NULL, -- Number of days after renewal date expired + -- Renewal Options + allow_membership_choice BOOLEAN DEFAULT '0', -- If memberships can choose their membership levels when they renew + allow_employees BOOLEAN DEFAULT '0', -- If memberships have employees + member_types_enabled BOOLEAN DEFAULT '1', -- member types determine invoice types + quickbooks_enabled BOOLEAN DEFAULT '0', -- QuickBooks enabled + member_billing_enabled BOOLEAN DEFAULT '1', -- Member have access to billing info tab + billing_fields_required BOOLEAN DEFAULT '1', -- Require Billing Fields + invoice_methods_enabled BOOLEAN DEFAULT '0', -- Enable Uptra invoice methods + renewal_day_static BOOLEAN DEFAULT '0', -- Renewal dates are same day every year + renewal_day INT NULL, -- Day of the month for renewals + renewal_month INT NULL, -- Month of year for renewals + billing_county_enabled BOOLEAN DEFAULT '0', -- Billing uses county field + invoice_pdf_enabled BOOLEAN DEFAULT '0', -- Create PDF invoices + billing_contact_name_enabled BOOLEAN DEFAULT '0', -- Use billing_contact_name instead of fname lname + member_types_requiring_billing TEXT NULL, -- List of member type id's that require billing + -- Account Number + account_number_enabled BOOLEAN DEFAULT '0', -- Enable Disable account_number + account_number_required BOOLEAN DEFAULT '0', -- Require account_number + account_number_unique BOOLEAN DEFAULT '0', -- account_number must be unique + PRIMARY KEY (id) +); + +---- + +-- Set default billing Settings entry +INSERT INTO {prefix}settings + ( id, days_before_renewal ,days_after_expired, member_types_enabled, quickbooks_enabled, member_billing_enabled ) + VALUES + ( 1, 90, 30, true, false, true ); + +---- + +-- Management +CREATE TABLE {prefix}management ( + id INT NOT NULL AUTO_INCREMENT, + payment_methods SMALLINT NULL, -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini + proc_methods SMALLINT NULL, -- Credit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini + cc_accepts SMALLINT NULL, -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini + -- Authorize.net Credentials + authorize_net_login TINYTEXT NULL, + authorize_net_key TINYTEXT NULL, + authorize_net_test TINYINT NULL, -- Authorize.net test mode - List - see proc_test_mode in plugin.ini + authorize_net_conf BOOLEAN NULL, -- Flag to send payment confirmation Email from Authorize.net + authorize_net_merchant_email TINYTEXT NULL, -- E-Mail Authorize.net will send copy of confirmation E-Mail + -- Merchant Solutions Credentials + merchant_solutions_acctid TINYTEXT NULL, -- Merchant Solutions credentials + merchant_solutions_merchantpin TINYTEXT NULL, + merchant_solutions_test TINYINT NULL, -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini + merchant_solutions_conf BOOLEAN NULL, -- Flag to send payment confirmation Email + merchant_solutions_merchant_email TINYTEXT NULL, -- Merchant Solutions will send copy of confirmation E-Mail + -- Square Credentials + square_prod_access_token TINYTEXT NULL, -- Square production access token + square_prod_app_id TINYTEXT NULL, -- Square production application id + square_prod_location_id TINYTEXT NULL, -- Square production location id + square_sandbox_access_token TINYTEXT NULL, -- Square sandbox access token + square_sandbox_app_id TINYTEXT NULL, -- Square sandbox application id + square_sandbox_location_id TINYTEXT NULL, -- Square sandbox location id + square_use_prod BOOLEAN DEFAULT '0', -- If true use Production creds + -- Uptravel options + uptravel_invoice_template BOOLEAN DEFAULT '0', -- Use uptravel template for invoices. + uptravel_payment_form BOOLEAN DEFAULT '0', -- Use uptravel payment form style. + PRIMARY KEY (id) +); + +---- + +-- Set default billing Management entry +INSERT INTO {prefix}management + ( id ) + VALUES + ( 1 ); + +---- + +-- Employees table +CREATE TABLE {prefix}employees ( + id INT NOT NULL AUTO_INCREMENT, + account INT NOT NULL, -- Account Id + employee INT NOT NULL, -- Employee Account Id + PRIMARY KEY (id) +); + +---- + +-- Terms +CREATE TABLE {prefix}settings_terms ( + id INT NOT NULL AUTO_INCREMENT, + invoice_name TINYTEXT NOT NULL, + invoice_name_plur TINYTEXT NOT NULL, + invoice_name_cap TINYTEXT NOT NULL, + invoice_name_plur_cap TINYTEXT NOT NULL, + invoice_type TINYTEXT NOT NULL, + invoice_type_plur TINYTEXT NOT NULL, + invoice_type_cap TINYTEXT NOT NULL, + invoice_type_plur_cap TINYTEXT NOT NULL, + account_number TINYTEXT NOT NULL, + PRIMARY KEY (id) +); + +---- + +INSERT INTO {prefix}settings_terms + ( + id, + invoice_name, + invoice_name_plur, + invoice_name_cap, + invoice_name_plur_cap, + invoice_type, + invoice_type_plur, + invoice_type_cap, + invoice_type_plur_cap, + account_number + ) + VALUES + ( + 1, + 'invoice', + 'invoices', + 'Invoice', + 'Invoices', + 'invoice type', + 'invoice types', + 'Invoice Type', + 'Invoice Types', + 'Account Number' + ); diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 3c80121..fdff678 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -49,5 +49,6 @@ $glmMembersBillingDbVersions = array( '0.0.33' => array('version' => '0.0.33', 'tables' => 15, 'date' => '02/19/2019'), '0.0.34' => array('version' => '0.0.34', 'tables' => 16, 'date' => '03/19/2019'), '0.0.35' => array('version' => '0.0.35', 'tables' => 16, 'date' => '03/20/2019'), + '0.0.36' => array('version' => '0.0.36', 'tables' => 16, 'date' => '04/02/2019'), ); diff --git a/setup/databaseScripts/update_database_V0.0.36.sql b/setup/databaseScripts/update_database_V0.0.36.sql new file mode 100644 index 0000000..ef5f64d --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.36.sql @@ -0,0 +1,33 @@ +-- Gaslight Media Billing Database +-- File Created: 12/26/2018 +-- Database Version: 0.0.32 +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Update the accounts table +ALTER TABLE {prefix}management ADD square_prod_access_token TINYTEXT NULL; -- Square production access token + +---- + +ALTER TABLE {prefix}management ADD square_prod_app_id TINYTEXT NULL; -- Square production application id + +---- + +ALTER TABLE {prefix}management ADD square_prod_location_id TINYTEXT NULL; -- Square production location id + +---- + +ALTER TABLE {prefix}management ADD square_sandbox_access_token TINYTEXT NULL; -- Square sandbox access token + +---- + +ALTER TABLE {prefix}management ADD square_sandbox_app_id TINYTEXT NULL; -- Square sandbox application id + +---- + +ALTER TABLE {prefix}management ADD square_sandbox_location_id TINYTEXT NULL; -- Square sandbox location id + +---- + +ALTER TABLE {prefix}management ADD square_use_prod BOOLEAN DEFAULT '0'; -- If true use Production creds diff --git a/views/admin/management/billing.html b/views/admin/management/billing.html index a78250d..97fc1de 100644 --- a/views/admin/management/billing.html +++ b/views/admin/management/billing.html @@ -55,6 +55,7 @@ + {* Authorize.net *}

    Authorize.net

    @@ -99,6 +100,7 @@ {if $regSettings.fieldFail.authorize_net_merchant_email}

    {$regSettings.fieldFail.authorize_net_merchant_email}

    {/if} + {* Merchant Solutions *}

    Merchant Solutions

    @@ -143,7 +145,60 @@ {if $regSettings.fieldFail.merchant_solutions_merchant_email}

    {$regSettings.fieldFail.merchant_solutions_merchant_email}

    {/if} - + {* Square *} + + +

    Square

    + + + Mode: + + Use Production Mode + {if $regSettings.fieldFail.square_use_prod}

    {$regSettings.fieldFail.square_use_prod}

    {/if} + + + + Production Access Token: + + + {if $regSettings.fieldFail.square_prod_access_token}

    {$regSettings.fieldFail.square_prod_access_token}

    {/if} + + + + Production App Id: + + + {if $regSettings.fieldFail.square_prod_app_id}

    {$regSettings.fieldFail.square_prod_app_id}

    {/if} + + + + Production Location Id: + + + {if $regSettings.fieldFail.square_prod_location_id}

    {$regSettings.fieldFail.square_prod_location_id}

    {/if} + + + + Sandbox Access Token: + + + {if $regSettings.fieldFail.square_sandbox_access_token}

    {$regSettings.fieldFail.square_sandbox_access_token}

    {/if} + + + + Sandbox App id: + + + {if $regSettings.fieldFail.square_sandbox_app_id}

    {$regSettings.fieldFail.square_sandbox_app_id}

    {/if} + + + + Sandbox Location Id: + + + {if $regSettings.fieldFail.square_sandbox_location_id}

    {$regSettings.fieldFail.square_sandbox_location_id}

    {/if} + +

    Templates

    @@ -176,39 +231,46 @@ - {include file='admin/management/footer.html'} diff --git a/views/common/billing/paymentForm.html b/views/common/billing/paymentForm.html index f1911d4..1d3a60d 100644 --- a/views/common/billing/paymentForm.html +++ b/views/common/billing/paymentForm.html @@ -1,111 +1,114 @@ +
    + Billing Information -
    - Billing Information - - {if $settings.billing_contact_name_enabled} -
    -
    - Billing Contact Name -
    -
    - -
    -
    - {else} -
    -
    - First Name -
    -
    - -
    -
    -
    -
    - Last Name -
    -
    - -
    -
    - {/if} -
    + {if $settings.billing_contact_name_enabled} +
    - Address + Billing Contact Name
    - +
    + {else}
    - City + First Name
    - +
    - State / Province + Last Name
    - +
    -
    -
    - Zip -
    -
    - -
    + {/if} +
    +
    + Address
    -
    -
    - Email Address -
    -
    - -
    +
    + +
    +
    +
    +
    + City +
    +
    + +
    +
    +
    +
    + State / Province
    +
    + +
    +
    +
    +
    + Zip +
    +
    + +
    +
    +
    +
    + Email Address +
    +
    + +
    +
    -
    +
    -
    - Payment Options +
    + Payment Options -
    -
    - Select Payment Option -
    -
    - - - {if !$lockedToMember} - - {/if} -
    +
    +
    + Select Payment Option +
    +
    + + + {if !$lockedToMember} + + {/if}
    +
    - {if isset( $account.fieldData.payment_profile_card ) && $account.fieldData.payment_profile_card} -
    -
    - -
    + {if isset( $account.fieldData.payment_profile_card ) && $account.fieldData.payment_profile_card} +
    +
    +
    - {/if} +
    + {/if} + {* Include the Payment Form template *} + {if $billing_settings.proc_methods == 4} + {include file='common/billing/squarePaymentForm.html'} + {else}
    Name on Card @@ -194,8 +197,9 @@
    {/if} + {/if} -
    +
    + + +{* link to the local SqPaymentForm initialization *} + +{* link to the custom styles for SqPaymentForm *} + + +{* Begin Payment Form *} +
    + {* + * Square's JS will automatically hide these buttons if they are unsupported + * by the current device. + *} +
    + + + +
    + Or +
    +
    +
    + {* + * You should replace the action attribute of the form with the path of + * the URL you want to POST the nonce to (for example, "/process-card"). + + * You need to then make a "Charge" request to Square's transaction API with + * this nonce to securely charge the customer. + + * Learn more about how to setup the server component of the payment form here: + * https://docs.connect.squareup.com/payments/transactions/processing-payment-rest + *} +
    + +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + {* + * After a nonce is generated it will be assigned to this hidden input field. + *} +
    + +
    +
    +{* End Payment Form *} diff --git a/views/front/billing/paymentForm.html b/views/front/billing/paymentForm.html index 36ac87f..9fd0249 100644 --- a/views/front/billing/paymentForm.html +++ b/views/front/billing/paymentForm.html @@ -11,7 +11,7 @@ {/foreach} {/if} -
    + @@ -58,7 +58,7 @@ {* Include the Payment Form template *} {include file='common/billing/paymentForm.html'} - +