Updates for square payments on admin side.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 26 Apr 2019 13:09:08 +0000 (09:09 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 26 Apr 2019 13:09:08 +0000 (09:09 -0400)
square payment now working for admin side.

classes/billingSupport.php
models/admin/member/billing.php
views/admin/billing/makePayment.html

index fd6878b..651e6df 100644 (file)
@@ -1400,6 +1400,7 @@ class GlmBillingSupport
 
             // Now try to run the card processor
             $ccResult = $CcProcessor->processPayment( $payment, $billing );
+            // echo '<pre>$ccResult: ' . print_r( $ccResult, true ) . '</pre>';
 
             // If successful submission - say we're complete
             if ( is_array( $ccResult ) && isset( $ccResult['status'] ) && $ccResult['status'] == 1 ) {
@@ -1636,12 +1637,15 @@ class GlmBillingSupport
         $payment_id = implode( '-', $invoices );
         $result = $this->processPayment( $account_id, $payment_id, $amount );
         // echo '<pre>$result: ' . print_r( $result, true ) . '</pre>';
+
         if ( $result['status'] === 1 ) {
 
             // Need to record the payment.
             // Set transaction_time to current time.
             $_REQUEST['transaction_time'] = date( 'Y-m-d H:i:s' );
 
+            $ccProcessor = $this->config['billing_settings']['proc_methods'];
+
             // Create new payment.
             $payment_id = $this->createPayment( $account_id, $amount, 'Credit Card' );
 
index b54a233..4b4cfda 100644 (file)
@@ -810,7 +810,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling
                 // Make the Payment using Billing Support Class
                 $errors = $BillingSupport->makePayment( $account_id, $invoices, $amount );
 
-                echo '<pre>$errors: ' . print_r( $errors, true ) . '</pre>';
+                // echo '<pre>$errors: ' . print_r( $errors, true ) . '</pre>';
 
                 // Errors will be an array
                 if ( isset( $errors ) && !empty( $errors ) ) {
index eee6ab1..1be2aeb 100644 (file)
@@ -13,7 +13,7 @@
     {/if}
 
 
-    <form id="PaymentForm" action="{$thisUrl}?page={$thisPage}&glm_action=billing&option=makePayment" method="post">
+    <form {if $billing_settings.proc_methods == 4} id="nonce-form"{else} id="PaymentForm"{/if} 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" />
@@ -55,7 +55,7 @@
 {* Only if payments types are setup *}
 {include file='common/billing/paymentForm.html'}
 
-                <input class="button button-primary" type="submit" value="Make Payment">
+                <input class="button button-primary" type="submit" value="Make Payment" {if $billing_settings.proc_methods == 4} onclick="onGetCardNonce(event)"{/if}>
 
             {else}
             You don't have any unpaid invoices!
 </div>
 
 <script>
+{if $billing_settings.proc_methods == 4}
+    var billingFieldsReq = [
+        { fieldName: 'invoice_number', fieldLabel: 'Invoice Number' },
+        {if $settings.billing_contact_name_enabled}
+            { fieldName: 'billing_contact_name', fieldLabel: 'Billing Contact Name' },
+        {else}
+            { fieldName: 'billing_fname', fieldLabel: 'Billing First Name' },
+            { fieldName: 'billing_lname', fieldLabel: 'Billing Last Name' },
+        {/if}
+        { fieldName: 'billing_addr1', fieldLabel: 'Billing Address' },
+        { fieldName: 'billing_city', fieldLabel: 'Billing City' },
+        { fieldName: 'billing_state', fieldLabel: 'Billing State' },
+        { fieldName: 'billing_zip', fieldLabel: 'Billing Zip' },
+        { fieldName: 'email', fieldLabel: 'Email Address' },
+        { fieldName: 'amount', fieldLabel: 'You have to select at least one invoice with an amount due' },
+    ];
+{/if}
 jQuery(document).ready(function($){
 
     $('#billing-invoice-select').change(function(){