Square payment setup
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 10 Apr 2019 15:36:31 +0000 (11:36 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 10 Apr 2019 15:36:31 +0000 (11:36 -0400)
Working with errors from square.

css/sq-payment-form.css
models/admin/ajax/billingAccount.php
models/front/billing/paymentForm.php
views/front/billing/paymentForm.html

index 5ab577e..56f6f61 100644 (file)
   width: 100%;
   margin-top: 16px;
   font-size: 14px;
-  color: red;
   font-weight: bold;
   text-align: left;
   opacity: 0.8;
index 82c7d5c..7829f9d 100644 (file)
@@ -130,20 +130,20 @@ class GlmMembersAdmin_ajax_billingAccount extends GlmDataAccounts
         case 'verifyInvoiceNumber':
             if ( isset( $_REQUEST['invoice_number'] ) && $invoiceNumber = filter_var( $_REQUEST['invoice_number'], FILTER_VALIDATE_INT ) ) {
                 // Get the invoice
-                $Invoices = new GlmDataInvoices( $this->wpdb, $this->config );
+                $Invoices                  = new GlmDataInvoices( $this->wpdb, $this->config );
                 $Invoices->line_items_post = true;
-                $invoice = $Invoices->getEntry( $invoiceNumber );
+                $invoice                   = $Invoices->getEntry( $invoiceNumber );
                 $Invoices->line_items_post = false;
                 // trigger_error( print_r( $invoice, true ), E_USER_NOTICE );
                 if ( !$invoice ) {
-                    $return = array( 'status'  => false, 'message' => 'no invoice' );
+                    $return = array( 'status' => false, 'message' => 'no invoice' );
                 }
                 // trigger_error( print_r( $invoice, true ), E_USER_NOTICE );
 
                 $accountId = $invoice['account']['value'];
                 // trigger_error( print_r( $accountId, true ), E_USER_NOTICE );
                 if ( !$accountId ) {
-                    $return = array( 'status'  => false, 'message' => 'no accountId' );
+                    $return = array( 'status' => false, 'message' => 'no accountId' );
                 }
                 $invoiceTypeId = false;
                 // Get the invoice id for the renewal line item
@@ -164,9 +164,7 @@ class GlmMembersAdmin_ajax_billingAccount extends GlmDataAccounts
                         ),
                         ARRAY_A
                     );
-                    // trigger_error( print_r( $account, true ), E_USER_NOTICE );
                     // Returning the invoice_type of the account
-                    // TODO: This maybe should be the actual invoice type_id
                     if ( $account ) {
                         $return = array(
                             'status'       => true,
index d96b84b..b154eb2 100644 (file)
@@ -238,16 +238,17 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling
                     case 'pay_by_credit_card':
                         // Do the Payment Processing.
                         $processErrors = $BillingSupport->processOnlinePayment( $accountId, $invoiceId, $_REQUEST['total_renew_amount'] );
+                        // echo '<pre>$processErrors: ' . print_r( $processErrors, true ) . '</pre>';
 
                         if ( $processErrors ) {
                             if ( isset( $processErrors ) && is_array( $processErrors ) && count( $processErrors ) > 0 ) {
                                 $error = true;
                                 foreach ( $processErrors as $error ) {
-                                    $messages[] = '<span style="color: red;">'.$error.'</span>';
+                                    $messages[] = $error;
                                 }
                             } else if ( isset( $processErrors ) && $processErrors ) {
                                 $error = true;
-                                $messages[] = '<span style="color: red;">'.$processErrors.'</span>';
+                                $messages[] = $processErrors;
                             } else {
                                 $paymentSuccess = true;
                             }
index 7419daf..d61426f 100644 (file)
@@ -5,11 +5,13 @@
     {if $paymentSuccess}<span class="glm-notice glm-flash-updated">Payment Completed</span>{/if}
     {if $paymentError}<span class="glm-notice glm-flash-updated">Error With Payment</span>{/if}
 
+    <div id="billing-error">
     {if $messages}
         {foreach $messages as $message}
-            <div class="">{$message}</div>
+            <li>{$message}</li>
         {/foreach}
     {/if}
+    </div>
 
     <form action="{$thisUrl}" method="post"{if $billing_settings.proc_methods == 4} id="nonce-form"{/if}>
         <input type="hidden" name="option" value="paymentProcess" />
         <input type="hidden" id="account_id" name="account_id" value="{$accountId}" />
         <input type="hidden" id="total_renew_amount" name="total_renew_amount" value="" />
 
-        <span id="membername"></span>
-
-        <div id="billing-error"></div>
+        <div><p id="billing-msg-center">Start by entering your invoice number. We will look up your account.</p></div>
 
         <div class="glm-billing-field">
             <div class="glm-billing-label glm-required">
                 Invoice #
             </div>
             <div class="glm-billing-input">
-                <input id="invoice_number" name="invoice_number" value="{if isset($invoiceId)}{$invoiceId}{/if}" required />
+                <input id="invoice_number" name="invoice_number" value="" required />
             </div>
         </div>
-        <div class="glm-billing-field">
+        <div id="billing-membership-class" class="glm-billing-field glm-hidden">
             <div class="glm-billing-label glm-required">
                 Membership Class
             </div>
             </div>
         </div>
 
-        <div class="glm-billing-field">
+        <div id="billing-member-name" class="glm-hidden">
+            Found invoice for:
+            <strong id="membername"></strong>
+        </div>
+        <div id="billing-total-due" class="glm-billing-field glm-hidden">
             <div class="glm-billing-label">
                 Total Due
             </div>
@@ -130,7 +134,10 @@ jQuery(document).ready(function($){
                     console.log( 'invoice_type', msg.invoice_type );
                     {if $settings.allow_membership_choice}
                         $('#invoice_type_id_' + msg.invoice_type ).attr('checked', true);
+                        $('#billing-msg-center').hide();
                         $('#membername').html(msg.invoice.member_name);
+                        $('#billing-total-due').show();
+                        $('#billing-member-name').show();
                         getPageTotal();
                     {else}
                         $('#member_renewing').data( 'amount', msg.invoice.amount_total );
@@ -142,6 +149,16 @@ jQuery(document).ready(function($){
         });
     } );
 
+    {if $messages}
+        $('#billing-error').show();
+        $('#billing-msg-center').hide();
+        // $('#billing-total-due').show();
+        // $('#billing-member-name').show();
+        {if $invoiceId}
+            $('#invoice_number').val( {$invoiceId} ).trigger('change');
+        {/if}
+
+    {/if}
 
     // Generate the total for the renewal.
     function getPageTotal(){