Adding billing payment form
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 2 Mar 2018 21:45:48 +0000 (16:45 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 2 Mar 2018 21:45:48 +0000 (16:45 -0500)
This is for the member to make a payment.

index.php
models/admin/member/billing.php
setup/databaseScripts/create_database_V0.0.9.sql
views/admin/billing/invoiceStore.html
views/admin/billing/makePayment.html [new file with mode: 0644]
views/admin/billing/memberBillingSubHeader.html
views/admin/billing/paymentProcess.html [new file with mode: 0644]
views/admin/billing/statements.html
views/admin/billing/viewInvoice.html

index 52b6a8b..892b8d6 100644 (file)
--- a/index.php
+++ b/index.php
@@ -148,6 +148,9 @@ if (is_file(GLM_MEMBERS_BILLING_PLUGIN_DB_SCRIPTS.'/dbVersions.php')) {
 $glmMembersBillingSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX."settings WHERE id = 1", ARRAY_A );
 unset($glmMembersBillingSettings['id']);
 
+$glmMembersBillingManagement = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A );
+unset($glmMembersBillingManagement['id']);
+
 function glmMembersBillingRegisterAddOn($addOns) {
 
     // Add this add-on to the add-ons array
@@ -158,7 +161,8 @@ function glmMembersBillingRegisterAddOn($addOns) {
         'slug' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
         'actions' => $GLOBALS['glmMembersBillingAddOnValidActions'],
         'config' => array(
-            'settings' => $GLOBALS['glmMembersBillingSettings']
+            'settings'   => $GLOBALS['glmMembersBillingSettings'],
+            'billing_settings' => $GLOBALS['glmMembersBillingManagement'],
         ),
         'shortcodes' => $GLOBALS['glmMembersBillingShortcodes'],
         'shortcodesDescription' => $GLOBALS['glmMembersBillingShortcodesDescription']
index b9fb255..8e20bc8 100644 (file)
@@ -226,22 +226,195 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling
             // Set the file name for the view file.
             $view = 'viewInvoice';
 
+            break;
+        case 'createPayment':
+
+            echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+
+            $view = 'paymentProcess';
+
+            echo '<pre>$this->config: ' . print_r( $this->config, true ) . '</pre>';
+            // Execute selected payment method
+
+            switch ($payMethod) {
+                // 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.';
+                    }
+
+                    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
+                            'cctype'  => $cardData['cc_type'],                       // Card Type
+                            'ccname'  => $cardData['cc_name'],                       // Name on Card
+                            'ccnumb'  => $cardData['cc_numb'],                       // Card Number
+                            'ccexp'   => $cardData['cc_exp'],                        // Expiration Date
+                            'cccode'  => $cardData['cc_cvv'],                        // CCV - security code
+                            'invoice' => 'reg-'.$_SESSION['glm_reg_cart_id']         // Invoice # is "reg-" plus cart ID
+                        );
+
+                        // Now try to run the card processor
+                        $ccResult = $CcProcessor->processPayment($payment, $billing);
+
+                        // If successful submission - say we're complete
+                        if (is_array($ccResult) && isset($ccResult['status']) && $ccResult['status'] == 1) {
+
+                            $cartStatus = $this->config['submission_status_numb']['COMPLETE'];
+
+                            // Store Credit Card information
+                            $cc_numb_store = '....'.substr($payment['ccnumb'], -4);
+                            $reqData = array_merge(
+                                $reqData,
+                                array(
+                                    'cc_type' => $payment['cctype'],
+                                    'cc_name' => $payment['ccname'],
+                                    'cc_numb' => $cc_numb_store,
+                                    'cc_exp'  => $payment['ccexp'],
+                                    'cc_conf' => $ccConfirmation,
+                                )
+                            );
+                            $reqFormat = array_merge(
+                                $reqFormat,
+                                array(
+                                    '%d',
+                                    '%s',
+                                    '%s',
+                                    '%s',
+                                    '%s',
+                                )
+                            );
+
+                        }
+
+                    }
+
+                    break;
+
+                // Pay Pal
+    //            case $this->config['payment_method_numb']['PayPal']:
+    //                break;
+
+                // Payment Method unknown
+                default:
+                    $payMethod = false;
+                    $messages[] = "I'm sorry, we couldn't tell which payment method you wanted to use. Please select one under \"Payment Information\" below.";
+                    break;
+
+            }
+            break;
+        case 'makepayment':
+
+            require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH .  '/data/dataAccounts.php';
+            $Accounts = new GlmDataAccounts( $this->wpdb, $this->config );
+
+            // Need to see if there's an account for this member.
+            $accountID = $this->wpdb->get_var(
+                $this->wpdb->prepare(
+                    "SELECT id
+                       FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
+                      WHERE ref_dest = %d",
+                    $this->memberID
+                )
+            );
+            $account = $Accounts->getEntry( $accountID );
+
+            // Set the file name for the view file.
+            $view = 'makePayment';
+            // echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
+
+            // Set this to CreditCard
+            $payMethod = $this->config['payment_method_numb']['CreditCard'];
+
+
+
             break;
         case 'list':
             $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config);
             $view = 'statements';
             // Get the list of invoices for this member.
-            // echo '<pre>$this->memberID: ' . print_r( $this->memberID, true) . '</pre>';
-            // echo '<pre>$memberData: ' . print_r( $memberData, true) . '</pre>';
             $statements = $BillingSupport->getStatementsByRefDest( $this->memberID );
             if ( $statements ) {
                 $transactions = $statements['transactions'];
                 $account_data = $statements['account_data'];
                 $balance_due  = $statements['balance_due'];
             }
-            // echo '<pre>$statements: ' . print_r( $statements, true ) . '</pre>';
-
-
             break;
         }
         // echo '<pre>$this->config: ' . print_r( $this->config, true ) . '</pre>';
index f9e859e..34b8906 100644 (file)
@@ -212,7 +212,7 @@ INSERT INTO {prefix}settings
 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,                                 -- Creadit Cart payment processing methods available - Bitmap - see proc_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,
index 6a71da0..82081fc 100644 (file)
                             </tr>
                             <tr>
                                 <th align="right">Payment Amount:</th>
-                                <td align="right"><input type="text" size="5"></td>
+                                <td align="right"> ________ </td>
                             </tr>
                             <tr>
                                 <th align="right"> Account #: </th>
diff --git a/views/admin/billing/makePayment.html b/views/admin/billing/makePayment.html
new file mode 100644 (file)
index 0000000..430e2e4
--- /dev/null
@@ -0,0 +1,75 @@
+{include file='admin/member/header.html'}
+{include file='admin/billing/memberBillingSubHeader.html'}
+
+<div id="billing-payment-form">
+    <form action="{$thisUrl}?page={$thisPage}&glm_action=billing&option=makePayment" method="post">
+        <input type="hidden" name="page" value="{$thisPage}">
+        <input type="hidden" name="glm_action" value="billing">
+        <input type="hidden" name="option" value="createPayment">
+        <input type="hidden" name="member" value="{$memberID}">
+
+        <div class="glm-row">
+            <div class="glm-columns glm-small-12 glm-large-8">
+
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-required"> Select Invoice </div>
+                    <div class="glm-columns glm-small-12">
+                        Need to list unpaid invoices here...
+                    </div>
+                </div>
+
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-required"> Amount </div>
+                    <div class="glm-columns glm-small-12">
+                        <input type="number" name="amount" step="0.01" min="0.01" required />
+                    </div>
+                </div>
+
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-required"> Billing Address 1 </div>
+                    <div class="glm-columns glm-small-12">
+                        <input type="text" name="billing_addr1" value="{$account.billing_addr1}" required />
+                    </div>
+                </div>
+
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12"> Billing Address 2 </div>
+                    <div class="glm-columns glm-small-12">
+                        <input type="text" name="billing_addr2" value="{$account.billing_addr2}" />
+                    </div>
+                </div>
+
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-required"> Billing City </div>
+                    <div class="glm-columns glm-small-12">
+                        <input type="text" name="billing_city" value="{$account.billing_city}" required />
+                    </div>
+                </div>
+
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-required"> Billing State </div>
+                    <div class="glm-columns glm-small-12">
+                        <input type="text" name="billing_address" value="{$account.billing_state}" required />
+                    </div>
+                </div>
+
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-required"> Billing Zip </div>
+                    <div class="glm-columns glm-small-12">
+                        <input type="text" name="billing_zip" value="{$account.billing_zip}" required />
+                    </div>
+                </div>
+
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-large-8">
+                        <input class="button button-primary" type="submit" value="Make Payment">
+                    </div>
+                </div>
+
+            </div>
+        </div>
+
+    </form>
+</div>
+
+{include file='admin/footer.html'}
index 851366b..c54db63 100644 (file)
@@ -1,6 +1,5 @@
 <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
-    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}"
-        class="nav-tab{if $option == 'list'} nav-tab-active{/if}">Statements</a>
-    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=account"
-        class="nav-tab{if $option == 'account'} nav-tab-active{/if}">Account Info</a>
+    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}" class="nav-tab{if $option == 'list'} nav-tab-active{/if}">Statements</a>
+    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=account" class="nav-tab{if $option == 'account'} nav-tab-active{/if}">Account Info</a>
+    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=makepayment" class="nav-tab{if $option == 'makepayment'} nav-tab-active{/if}">Make a Payment</a>
 </h2>
diff --git a/views/admin/billing/paymentProcess.html b/views/admin/billing/paymentProcess.html
new file mode 100644 (file)
index 0000000..09ea881
--- /dev/null
@@ -0,0 +1,6 @@
+{include file='admin/member/header.html'}
+{include file='admin/billing/memberBillingSubHeader.html'}
+
+Payment process here !!
+
+{include file='admin/footer.html'}
index 3bec960..390ff70 100644 (file)
@@ -24,7 +24,7 @@
                     <td>{$transaction.transaction_data.due_date|date_format:"%D"}</td>
                     <td>{$transaction_types[$transaction.type]}</td>
                     <td>${$transaction.transaction_data.amount_total}</td>
-                    <td> <a href="{$thisUrl}?page={$thisPage}&glm_action=billing&option=view&member={$memberID}&id={$transaction.type_id}">View / Make Payment</a> </td>
+                    <td> <a href="{$thisUrl}?page={$thisPage}&glm_action=billing&option=view&member={$memberID}&id={$transaction.type_id}">View</a> </td>
                 {elseif $transaction.type == '20'}
                     <td>{$transaction.transaction_data.transaction_time|date_format:"%D"}</td>
                     <td></td>
index e2f76ba..a799c26 100644 (file)
@@ -1,7 +1,6 @@
 {if $fromMemberMenu}
     {include file='admin/member/header.html'}
     {include file='admin/billing/memberBillingSubHeader.html'}
-    <form action="" method="post">
 {else}
     {include file='admin/billing/header.html'}
     {include file='admin/billing/subHeader.html'}
 {$invoiceHtml}
 </div>
 
-{if $fromMemberMenu}
-        <a class="button button-primary" href="#">Make a Payment</a>
-    </form>
-{else}
-{/if}
 <script src="{$jsUrl}/PrintArea/jquery.PrintArea.js" type="text/JavaScript" language="javascript"></script>
 <script>
 jQuery(document).ready(function($) {