$paymentSuccess = false;
$paymentError = false;
$payable_types = false;
+ $error = false;
+ $invoiceHtml = '';
// Check to see if a user is logged in
// If they are then they should not see the Become a member form at all.
$error = true;
$messages[] = '<span style="color:red;">An error occurred! invoice_type_data</span>';
}
- echo '<pre>$invoice_type_data: ' . print_r( $invoice_type_data, true ) . '</pre>';
+ // echo '<pre>$invoice_type_data: ' . print_r( $invoice_type_data, true ) . '</pre>';
$member_type = $invoice_type_data['member_type'];
if ( !$member_type ) {
$error = true;
$messages[] = '<span style="color:red;">An error occurred! member_type</span>';
}
- echo '<pre>$member_type: ' . print_r( $member_type, true ) . '</pre>';
+ // echo '<pre>$member_type: ' . print_r( $member_type, true ) . '</pre>';
// Start database transaction
- // $this->wpdb->show_errors();
+ $this->wpdb->show_errors();
$this->wpdb->query('START TRANSACTION');
// $access = $this->config['access_numb']['Full'];
$this->wpdb->insert(
)
);
$member_id = $this->wpdb->insert_id;
- echo '<pre>$member_id: ' . print_r( $member_id, true ) . '</pre>';
+ // echo '<pre>$member_id: ' . print_r( $member_id, true ) . '</pre>';
if ( !$member_id ) {
$error = true;
$messages[] = '<span style="color:red;">An error occurred! member_id</span>';
$member_id
)
);
- echo '<pre>$member: ' . print_r( $member, true ) . '</pre>';
+ // echo '<pre>$member: ' . print_r( $member, true ) . '</pre>';
}
// 2. Setup the member_info
$billing_addr1 = filter_var( $_REQUEST['billing_addr1'] );
$billing_city = filter_var( $_REQUEST['billing_city'] );
$billing_city_id = $this->getCityId( $billing_city );
- echo '<pre>$billing_city_id: ' . print_r( $billing_city_id, true ) . '</pre>';
+ // echo '<pre>$billing_city_id: ' . print_r( $billing_city_id, true ) . '</pre>';
$billing_state = filter_var( $_REQUEST['billing_state'] );
$billing_zip = filter_var( $_REQUEST['billing_zip'] );
$phone = filter_var( $_REQUEST['phone'] );
$member_info_id
)
);
- echo '<pre>$member_info: ' . print_r( $member_info, true ) . '</pre>';
+ // echo '<pre>$member_info: ' . print_r( $member_info, true ) . '</pre>';
}
// 3. Setup the contact (and wpUser)
// Determine the Worpress Role to be used for contact import - Using Entity Manager right now
$newContactID
)
);
- echo '<pre>$new_contact: ' . print_r( $new_contact, true ) . '</pre>';
+ // echo '<pre>$new_contact: ' . print_r( $new_contact, true ) . '</pre>';
} else {
// $this->wpdb->print_error();
$error = true;
// Store the contact ID and active status into user meta data.
update_user_meta($wpUserID, 'glmMembersContactID', $newContactID);
update_user_meta($wpUserID, 'glmMembersContactActive', true);
- echo '<pre>$wpUserID: ' . print_r( $wpUserID, true ) . '</pre>';
+ // echo '<pre>$wpUserID: ' . print_r( $wpUserID, true ) . '</pre>';
} else {
$error = true;
$messages[] = '<span style="color:red;">An error occurred! wpUserID</span>';
$customFieldKey = filter_var( $customFieldKey, FILTER_VALIDATE_INT );
$customFieldValue = filter_var( $customFieldValue );
if ( $customFieldKey && $customFieldValue ) {
+ if ( in_array( $customFieldKey, array( 2, 3 ) ) ) {
+ $customFieldValue = 'Yes';
+ }
$this->wpdb->insert(
GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . 'custom_field_data',
array(
);
$customFieldId = $this->wpdb->insert_id;
if ( $customFieldId ) {
- echo '<pre>$customFieldId: ' . print_r( $customFieldId, true ) . '</pre>';
+ // echo '<pre>$customFieldId: ' . print_r( $customFieldId, true ) . '</pre>';
} else {
$error = true;
$messages[] = '<span style="color:red;">An error occurred! customFieldId</span>';
'anniversary_date' => date( 'Y-m-d' ),
'boss' => false,
'invoice_type' => $invoice_type,
- 'billing_fname' => $billing_fname,
- 'billing_lname' => $billing_lname,
+ 'billing_fname' => $member_fname,
+ 'billing_lname' => $member_lname,
'billing_addr1' => $billing_addr1,
'billing_city' => $billing_city,
'billing_state' => $billing_state,
+ 'billing_zip' => $billing_zip,
'billing_phone' => $billing_phone,
'email' => $memberContactEmail,
),
'%s', // billing_addr1
'%s', // billing_city
'%s', // billing_state
+ '%s', // billing_zip
'%s', // billing_phone
'%s', // email
)
);
+ $accountID = $this->wpdb->insert_id;
+ if ( !$accountID ) {
+ $error = true;
+ $messages[] = '<span style="color:red;">An error occurred! accountID</span>';
+ }
// Save or rollback
if ( $error ) {
$this->wpdb->query('ROLLBACK');
} else {
$this->wpdb->query('COMMIT');
- $view = 'thankyou';
+ // $this->wpdb->query('ROLLBACK');
+
+ // Fetch the invoice type chosen by the member.
+ $member_invoice = $BillingSupport->getInvoiceTypeById( $invoice_type );
+ // Here we'll create the invoice for the member.
+ $invoice_data = array(
+ 'account_id' => $accountID,
+ 'renew_type_id' => $invoice_type,
+ 'amount' => $_REQUEST['total_renew_amount'],
+ 'due_date' => date( 'Y-m-d' ),
+ 'member_invoice' => $member_invoice,
+ 'employee_data' => array(),
+ 'employees' => array(),
+ );
+ $invoice_id = $BillingSupport->createMemberInvoiceWithEmployees( $invoice_data );
+ if ( !$invoice_id ) {
+ $this->wpdb->print_error();
+ $error = true;
+ $messages[] = '<span style="color:red;">An error occurred! invoice_id</span>';
+ }
+ if ( !$error ) {
+
+ // Get payment type and process.
+ $payment_option = filter_var( $_REQUEST['payment_option'], FILTER_SANITIZE_STRING );
+ switch ( $payment_option ) {
+ case 'pay_by_credit_card':
+ // Do the Payment Processing.
+ $processErrors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] );
+ if ( $processErrors ) {
+ if ( count( $processErrors ) > 0 ) {
+ $error = true;
+ $messages[] = '<span style="color:red;">An error occurred! processErrors</span>';
+ }
+ }
+ break;
+ case 'pay_by_check':
+ break;
+ }
+
+ }
+
+ if ( $error ) {
+ } else {
+ $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id );
+ $view = 'thankyou';
+ }
}
break;
'paymentSuccess' => $paymentSuccess,
'paymentError' => $paymentError,
'payable_types' => $payable_types,
- 'states' => $this->config['states']
+ 'states' => $this->config['states'],
+ 'invoiceHtml' => $invoiceHtml,
);
// Return status, any suggested view, and any data to controller.