}
- $errors = $result['errors'];
+ $errors = array();//$result['errors'];
} else {
$errors = $result['errors'];
* @param int $invoice_id Id of invoice to delete.
*
* @access public
- * @return void
+ * @return int|false The number of invoices updated or false on error.
*/
public function removeInvoiceById( $invoice_id )
{
array( 'invoice' => $invoice_id ),
array( '%d' )
);
- $this->wpdb->delete(
+ $result = $this->wpdb->delete(
GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'invoices',
array( 'id' => $invoice_id ),
array( '%d' )
array( 'type' => $this->config['transaction_numb']['Invoice'], 'type_id' => $invoice_id ),
array( '%d', '%d' )
);
+ return $result;
}
/**
case 'pay_by_credit_card':
// Do the Payment Processing.
$processErrors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] );
+ // echo '<pre>$processErrors: ' . print_r( $processErrors, true ) . '</pre>';
if ( $processErrors ) {
- if ( count( $processErrors ) > 0 ) {
+ if ( isset( $processErrors ) && is_array( $processErrors ) && count( $processErrors ) > 0 ) {
$error = true;
$BillingSupport->removeInvoiceById( $invoice_id );
foreach ( $processErrors as $error ) {
$messages[] = '<span style="color: red;">'.$error.'</span>';
}
$paymentError = true;
+ } else if ( isset( $processErrors ) && $processErrors ) {
+ $error = true;
+ $messages[] = '<span style="color: red;">'.$processErrors.'</span>';
} else {
$paymentSuccess = true;
}
// If there's no error reported then show the invoice
// Now need to show the invoice.
- $view = 'viewInvoice';
+ if ( !$error ) {
+ $view = 'viewInvoice';
- // Get the invoice.
- $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id );
+ // Get the invoice.
+ $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id );
- // If the member_type is changing then update member
- // Get current member type
- $member_id = filter_var( $_REQUEST['member'], FILTER_VALIDATE_INT );
- if ( $member_id ) {
- $current_member_type = $this->wpdb->get_var(
- $this->wpdb->prepare(
- "SELECT member_type
- FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members
- WHERE id = %d",
- $member_id
- )
- );
- $new_type = filter_var( $_REQUEST['member_renewing'], FILTER_VALIDATE_INT );
- $new_member_type = $this->wpdb->get_var(
- $this->wpdb->prepare(
- "SELECT member_type
- FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoice_types
- WHERE id = %d",
- $new_type
- )
- );
- // TODO: Need to reset account invoice_type also
- if ( $current_member_type != $new_member_type ) {
- $this->update(
- GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
- array( 'member_type' => $new_member_type ),
- array( 'id' => $member_id ),
- array( '%d' ),
- array( '%d' )
+ // If the member_type is changing then update member
+ // Get current member type
+ $member_id = filter_var( $_REQUEST['member'], FILTER_VALIDATE_INT );
+ if ( $member_id ) {
+ $current_member_type = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT member_type
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members
+ WHERE id = %d",
+ $member_id
+ )
+ );
+ $new_type = filter_var( $_REQUEST['member_renewing'], FILTER_VALIDATE_INT );
+ $new_member_type = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT member_type
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoice_types
+ WHERE id = %d",
+ $new_type
+ )
);
+ // TODO: Need to reset account invoice_type also
+ if ( $current_member_type != $new_member_type ) {
+ $this->update(
+ GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
+ array( 'member_type' => $new_member_type ),
+ array( 'id' => $member_id ),
+ array( '%d' ),
+ array( '%d' )
+ );
+ }
}
}
+
}
break;
// Do the Payment Processing.
$processErrors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] );
if ( $processErrors ) {
- if ( count( $processErrors ) > 0 ) {
+ if ( isset( $processErrors ) && is_array( $processErrors ) && count( $processErrors ) > 0 ) {
$error = true;
$BillingSupport->removeInvoiceById( $invoice_id );
foreach ( $processErrors as $error ) {
$messages[] = '<span style="color: red;">'.$error.'</span>';
}
+ } else if ( isset( $processErrors ) && $processErrors ) {
+ $error = true;
+ $messages[] = '<span style="color: red;">'.$processErrors.'</span>';
+ } else {
+ $paymentSuccess = true;
}
$view = 'renew';