From ad5c8d06c1ae1de8840637d299fbc61682023e78 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 15 May 2018 12:11:40 -0400 Subject: [PATCH] Fix issue with payments in admin when Authorize gives an error. Pass error message through. --- classes/billingSupport.php | 12 ++++++++++-- models/admin/member/billing.php | 7 ++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/classes/billingSupport.php b/classes/billingSupport.php index ce3e2a0..451997e 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -717,6 +717,8 @@ class GlmBillingSupport 'payments' => $payments, ); + // echo '
$templateData: ' . print_r( $templateData, true ) . '
'; + $invoiceHtml = $this->generateInvoiceHtml( $templateData, 'admin/billing/invoiceStore.html' ); return $invoiceHtml; } @@ -1354,6 +1356,11 @@ class GlmBillingSupport 'ccResult' => $ccResult, ); + } else { + $result = array( + 'status' => 0, + 'errors' => $ccResult['description'] + ); } } else { @@ -1465,6 +1472,7 @@ class GlmBillingSupport { $payment_id = implode( '-', $invoices ); $result = $this->processPayment( $account_id, $payment_id, $amount ); + // echo '
$result: ' . print_r( $result, true ) . '
'; if ( $result['status'] === 1 ) { // Need to record the payment. @@ -1477,9 +1485,9 @@ class GlmBillingSupport // Record the payment. $this->recordPayment( $payment_id, $account_id, $amount, $invoices ); - $errors = $result['errors']; + return false; } else { - $errors = $result['errors']; + return $result['errors']; } } diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 3c6ea00..f1b0c15 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -547,8 +547,11 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling // Make the Payment using Billing Support Class $errors = $BillingSupport->makePayment( $account_id, $invoices, $amount ); + // echo '
$errors: ' . print_r( $errors, true ) . '
'; + if ( $errors ) { $paymentError = true; + $messages[] = $errors; // Load DataClass for Management. require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataManagement.php'; $Management = new GlmDataBillingManagement( $this->wpdb, $this->config ); @@ -601,7 +604,9 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling } - $view = 'statements'; + if ( !$errors ) { + $view = 'statements'; + } break; -- 2.17.1