From: Steve Sutton Date: Wed, 31 Jul 2019 12:08:59 +0000 (-0400) Subject: Fixing bugs for payments X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=0811aed23fb7dc3f92e9e40996f8982f0bd648e7;p=WP-Plugins%2Fglm-member-db-billing.git Fixing bugs for payments Deal with payment errors. --- diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 1ece124..aadad5a 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -575,7 +575,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling case 'mark_paid': $_REQUEST['transaction_time'] = date( 'Y-m-d H:i:s' ); - $invoices = $BillingSupport->getUnPaidInvoicesByAccount( $account['fieldData']['id'] ); + $nvoices = $BillingSupport->getUnPaidInvoicesByAccount( $account['fieldData']['id'] ); // Mark this invoice as paid // Create new payment. $payment_id = $BillingSupport->createPayment( $accountID, $_REQUEST['total_renew_amount'], 'Marked Paid' ); @@ -685,7 +685,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $accountUpdated = true; } if ( $this->ajaxSide ) { - trigger_error( 'Account Ajax Hit', E_USER_NOTICE ); + // trigger_error( 'Account Ajax Hit', E_USER_NOTICE ); header( 'Content-type:application/json;charset=utf-8', true ); echo json_encode( $account, true ); exit; @@ -988,6 +988,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling break; case 'createMemberPayment': + // trigger_error( print_r( $_REQUEST['invoices'], true), E_USER_NOTICE ); $view = 'paymentProcess'; $account_id = filter_var( $_REQUEST['account_id'], FILTER_VALIDATE_INT ); $amount = filter_var( $_REQUEST['amount'], FILTER_VALIDATE_FLOAT ); @@ -995,18 +996,31 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $payment_data = filter_var( $_REQUEST['payment_data'], FILTER_SANITIZE_STRING ); $invoices = filter_var( $_REQUEST['invoices'], FILTER_VALIDATE_INT, array( 'flags' => FILTER_REQUIRE_ARRAY ) ); + // trigger_error( print_r( + // array( + // 'account_id' => $account_id, + // 'amount' => $amount, + // 'payment_method' => $payment_method, + // 'payment_data' => $payment_data, + // 'invoices' => $invoices, + // ), true ), E_USER_NOTICE ); if ( $account_id && $amount && $payment_method && !empty( $invoices ) ) { // Create new payment. $payment_id = $BillingSupport->createPayment( $account_id, $amount, $payment_method, $payment_data ); + // trigger_error( "payment_id: $payment_id", E_USER_NOTICE ); if ( $payment_id ) { + // trigger_error( "before recordPayment", E_USER_NOTICE ); // Record the payment. $BillingSupport->recordPayment( $payment_id, $account_id, $amount, $invoices, $this->config['transaction_numb']['Payment'] ); + // trigger_error( "after recordPayment", E_USER_NOTICE ); } } else { $payment_id = false; } + // trigger_error( print_r( $this->ajaxSide, true), E_USER_NOTICE ); if ( $this->ajaxSide ) { + $invoiceData = $invoices; if ( !empty( $invoices ) ) { $invoiceData = array_map( array( $BillingSupport, 'getInvoiceById' ), $invoices ); } @@ -1014,9 +1028,11 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling 'payment_id' => $payment_id, 'invoices' => $invoiceData ); + // trigger_error( print_r( $return, true), E_USER_NOTICE ); header( 'Content-type:application/json;charset=utf-8', true ); echo json_encode( $return, true ); exit; + // rsp:

Error thrown

Call to a member function remove_role() on boolean

} break; diff --git a/views/admin/billing/makePaymentAdjustmentAjax.html b/views/admin/billing/makePaymentAdjustmentAjax.html index 072215b..e08bf98 100644 --- a/views/admin/billing/makePaymentAdjustmentAjax.html +++ b/views/admin/billing/makePaymentAdjustmentAjax.html @@ -122,19 +122,23 @@ jQuery(document).ready(function($){ if ( rsp ) { var $sucessModal = $('#billingSuccess'); $sucessModal.foundation('open').trigger('resizeme.zp.reveal'); - if ( rsp.invoices.length > 0 ) { + if ( rsp.invoices != undefined && rsp.invoices.length > 0 ) { // Loop over the invoices and update the ones if found on this page. for ( var i in rsp.invoices ) { // Update the balance due $('#balance-' + rsp.invoices[i].id ).html( rsp.invoices[i].balance ); // If the invoices is marked 'Paid' then remove the make payment // or pay invoices links and the send invoices line - if ( rsp.invoices[i].paid ) { + if ( rsp.invoices.length && rsp.invoices[i].paid ) { $('#make-a-payment-' + rsp.invoices[i].id).remove(); $('#pay-invoice-' + rsp.invoices[i].id).remove(); $('#send-invoice-' + rsp.invoices[i].id).remove(); + } else { + //console.log('rsp: ', rsp); } } + } else { + //console.log('rsp: ', rsp); } return true; } else {